This commit is contained in:
Kevin Sawicki 2016-06-14 10:05:25 -07:00
parent bf791c110f
commit 4e89656538

View file

@ -191,35 +191,28 @@ template<>
struct Converter<atom::api::WebContents::Type> { struct Converter<atom::api::WebContents::Type> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
atom::api::WebContents::Type val) { atom::api::WebContents::Type val) {
using Type = atom::api::WebContents::Type;
std::string type = ""; std::string type = "";
switch (val) { switch (val) {
case atom::api::WebContents::Type::BACKGROUND_PAGE: case Type::BACKGROUND_PAGE: type = "backgroundPage"; break;
type = "backgroundPage"; case Type::BROWSER_WINDOW: type = "window"; break;
break; case Type::REMOTE: type = "remote"; break;
case atom::api::WebContents::Type::BROWSER_WINDOW: case Type::WEB_VIEW: type = "webview"; break;
type = "window"; default: break;
break;
case atom::api::WebContents::Type::REMOTE:
type = "remote";
break;
case atom::api::WebContents::Type::WEB_VIEW:
type = "webview";
break;
default:
break;
} }
return mate::ConvertToV8(isolate, type); return mate::ConvertToV8(isolate, type);
} }
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val, static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
atom::api::WebContents::Type* out) { atom::api::WebContents::Type* out) {
using Type = atom::api::WebContents::Type;
std::string type; std::string type;
if (!ConvertFromV8(isolate, val, &type)) if (!ConvertFromV8(isolate, val, &type))
return false; return false;
if (type == "webview") { if (type == "webview") {
*out = atom::api::WebContents::Type::WEB_VIEW; *out = Type::WEB_VIEW;
} else if (type == "backgroundPage") { } else if (type == "backgroundPage") {
*out = atom::api::WebContents::Type::BACKGROUND_PAGE; *out = Type::BACKGROUND_PAGE;
} else { } else {
return false; return false;
} }