]> khamidou — GitHub mirrors - electron.git/commitdiff
Parse partition in webContents.create
authorCheng Zhao <zcbenz@gmail.com>
Sun, 6 Sep 2015 01:22:32 +0000 (09:22 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sun, 6 Sep 2015 02:54:34 +0000 (10:54 +0800)
atom/browser/api/atom_api_web_contents.cc
atom/browser/lib/guest-view-manager.coffee

index 77fbf9f1de8a89ececcfa4c16dd520690e2982da..d22f7aab61fdedb7d831a2bae41204824077c442 100644 (file)
@@ -165,9 +165,12 @@ WebContents::WebContents(v8::Isolate* isolate,
   std::string partition;
   mate::Handle<api::Session> 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.
index c7ec439f96f0f6d6dc3375f5fbc8fc73ec78d730..1c05b65b2dc0dc459d125be90db9d62fd56907c1 100644 (file)
@@ -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.