Parse partition in webContents.create
This commit is contained in:
parent
2454dccde0
commit
5eb0bedbbc
2 changed files with 6 additions and 12 deletions
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue