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);
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);
}
++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) ->
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.