Specify type instead of isGuest

This commit is contained in:
Kevin Sawicki 2016-06-14 09:23:03 -07:00
parent c7b2545b1b
commit ee0bab6389
2 changed files with 18 additions and 8 deletions

View file

@ -200,8 +200,20 @@ struct Converter<atom::api::WebContents::Type> {
} }
return mate::ConvertToV8(isolate, type); return mate::ConvertToV8(isolate, type);
} }
};
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
atom::api::WebContents::Type* out) {
std::string type;
if (!ConvertFromV8(isolate, val, &type))
return false;
if (type == "webview") {
*out = atom::api::WebContents::Type::WEB_VIEW;
} else {
return false;
}
return true;
}
};
} // namespace mate } // namespace mate
@ -254,10 +266,8 @@ WebContents::WebContents(v8::Isolate* isolate,
// Read options. // Read options.
options.Get("backgroundThrottling", &background_throttling_); options.Get("backgroundThrottling", &background_throttling_);
// Whether it is a guest WebContents. type_ = BROWSER_WINDOW;
bool is_guest = false; options.Get("type", &type_);
options.Get("isGuest", &is_guest);
type_ = is_guest ? WEB_VIEW : BROWSER_WINDOW;
// Obtain the session. // Obtain the session.
std::string partition; std::string partition;
@ -277,7 +287,7 @@ WebContents::WebContents(v8::Isolate* isolate,
session_.Reset(isolate, session.ToV8()); session_.Reset(isolate, session.ToV8());
content::WebContents* web_contents; content::WebContents* web_contents;
if (is_guest) { if (IsGuest()) {
scoped_refptr<content::SiteInstance> site_instance = scoped_refptr<content::SiteInstance> site_instance =
content::SiteInstance::CreateForURL( content::SiteInstance::CreateForURL(
session->browser_context(), GURL("chrome-guest://fake-host")); session->browser_context(), GURL("chrome-guest://fake-host"));
@ -306,7 +316,7 @@ WebContents::WebContents(v8::Isolate* isolate,
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent()); web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
if (is_guest) { if (IsGuest()) {
guest_delegate_->Initialize(this); guest_delegate_->Initialize(this);
NativeWindow* owner_window = nullptr; NativeWindow* owner_window = nullptr;

View file

@ -63,7 +63,7 @@ const createGuest = function (embedder, params) {
const id = getNextInstanceId(embedder) const id = getNextInstanceId(embedder)
const guest = webContents.create({ const guest = webContents.create({
isGuest: true, type: 'webview',
partition: params.partition, partition: params.partition,
embedder: embedder embedder: embedder
}) })