]> khamidou — GitHub mirrors - electron.git/commitdiff
use embedders' browser context when partition is not specified
authorRobo <hop2deep@gmail.com>
Fri, 28 Aug 2015 07:30:50 +0000 (13:00 +0530)
committerRobo <hop2deep@gmail.com>
Thu, 3 Sep 2015 15:19:29 +0000 (20:49 +0530)
atom/browser/api/atom_api_web_contents.cc
atom/browser/lib/guest-view-manager.coffee
docs/api/web-view-tag.md

index da33451c1e7ce0aca82c0e78379af17ed12dedf1..7cefe8e45e3d35406ae8178611b7459730d5b23a 100644 (file)
@@ -159,12 +159,17 @@ WebContents::WebContents(const mate::Dictionary& options) {
 
   type_ = is_guest ? WEB_VIEW : BROWSER_WINDOW;
 
+  content::BrowserContext* browser_context =
+      AtomBrowserMainParts::Get()->browser_context();
   content::WebContents* web_contents;
   if (is_guest) {
     GURL guest_site;
     options.Get("partition", &guest_site);
-    auto browser_context =
-        AtomBrowserMainParts::Get()->GetBrowserContextForPartition(guest_site);
+    // use hosts' browser_context when no partition is specified.
+    if (!guest_site.query().empty()) {
+      browser_context = AtomBrowserMainParts::Get()
+          ->GetBrowserContextForPartition(guest_site);
+    }
     auto site_instance =
         content::SiteInstance::CreateForURL(browser_context, guest_site);
     content::WebContents::CreateParams params(browser_context, site_instance);
@@ -172,7 +177,6 @@ WebContents::WebContents(const mate::Dictionary& options) {
     params.guest_delegate = guest_delegate_.get();
     web_contents = content::WebContents::Create(params);
   } else {
-    auto browser_context = AtomBrowserMainParts::Get()->browser_context();
     content::WebContents::CreateParams params(browser_context);
     web_contents = content::WebContents::Create(params);
   }
index c0a87a7ac1cb1cdeeac1bf30eaaa30cbb34585c4..8d86e8fae9111a7b3f9456eababdc6ed479b538c 100644 (file)
@@ -40,12 +40,14 @@ getNextInstanceId = (webContents) ->
   ++nextInstanceId
 
 # Generate URL encoded partition id.
-getPartitionId = (partition='default') ->
+getPartitionId = (partition) ->
   persist = partition.startsWith('persist:')
   # Guest site url will be chrome-guest://fake-host/{persist}?{partitionId}
   partitionId = "chrome-guest://fake-host/"
-  partitionId += if persist then 'persist?' else '?'
-  partitionId += crypto.createHash('sha256').update(partition).digest('hex')
+  if partition
+    partitionId += if persist then 'persist?' else '?'
+    partitionId += crypto.createHash('sha256').update(partition).digest('hex')
+  return partitionId
 
 # Create a new guest instance.
 createGuest = (embedder, params) ->
index ec8529655272e612c0da8d6e89cb73d6896f66fc..cafcc5762e7aa916426b74e0926a8b6d9e85ade9 100644 (file)
@@ -140,7 +140,7 @@ If "on", the guest page will have web security disabled.
 
 Sets the storage partition used by the `webview`. If the storage partition ID starts with `persist:`,
 the `webview` will use a persistent storage partition available to all `webview` in the app with
-the same storage partition ID. If the ID is unset or if there is no `persist:` prefix, the `webview` will
+the same storage partition ID. if there is no `persist:` prefix, the `webview` will
 use an in-memory storage partition. By assigning the same partition ID, multiple `webview`
 can share the same storage partition.