From: Cheng Zhao Date: Sun, 6 Sep 2015 01:22:32 +0000 (+0800) Subject: Parse partition in webContents.create X-Git-Tag: v0.32.0~10^2~3 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=5eb0bedbbca8b9062d11ea412230ee5ab19db4d3;p=electron.git Parse partition in webContents.create --- diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 77fbf9f1..d22f7aab 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -165,9 +165,12 @@ WebContents::WebContents(v8::Isolate* isolate, std::string partition; mate::Handle session; if (options.Get("session", &session)) { - } else if (options.Get("partition", &partition)) { + } else if (options.Get("partition", &partition) && !partition.empty()) { bool in_memory = true; - options.Get("inMemory", &in_memory); + if (base::StartsWith(partition, "persist:", base::CompareCase::SENSITIVE)) { + in_memory = false; + partition = partition.substr(8); + } session = Session::FromPartition(isolate, partition, in_memory); } else { // Use the default session if not specified. diff --git a/atom/browser/lib/guest-view-manager.coffee b/atom/browser/lib/guest-view-manager.coffee index c7ec439f..1c05b65b 100644 --- a/atom/browser/lib/guest-view-manager.coffee +++ b/atom/browser/lib/guest-view-manager.coffee @@ -38,21 +38,12 @@ moveLastToFirst = (list) -> getNextInstanceId = (webContents) -> ++nextInstanceId -# Parse the partition string. -parsePartition = (partition) -> - return ['', false] unless partition - if partition.startsWith 'persist:' - [partition.substr('persist:'.length), false] - else - [partition, true] - # Create a new guest instance. createGuest = (embedder, params) -> webViewManager ?= process.atomBinding 'web_view_manager' id = getNextInstanceId embedder - [partition, inMemory] = parsePartition params.partition - guest = webContents.create {isGuest: true, partition, inMemory, embedder} + guest = webContents.create {isGuest: true, partition: params.partition, embedder} guestInstances[id] = {guest, embedder} # Destroy guest when the embedder is gone or navigated.