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;
|
std::string partition;
|
||||||
mate::Handle<api::Session> session;
|
mate::Handle<api::Session> session;
|
||||||
if (options.Get("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;
|
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);
|
session = Session::FromPartition(isolate, partition, in_memory);
|
||||||
} else {
|
} else {
|
||||||
// Use the default session if not specified.
|
// Use the default session if not specified.
|
||||||
|
|
|
@ -38,21 +38,12 @@ moveLastToFirst = (list) ->
|
||||||
getNextInstanceId = (webContents) ->
|
getNextInstanceId = (webContents) ->
|
||||||
++nextInstanceId
|
++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.
|
# Create a new guest instance.
|
||||||
createGuest = (embedder, params) ->
|
createGuest = (embedder, params) ->
|
||||||
webViewManager ?= process.atomBinding 'web_view_manager'
|
webViewManager ?= process.atomBinding 'web_view_manager'
|
||||||
|
|
||||||
id = getNextInstanceId embedder
|
id = getNextInstanceId embedder
|
||||||
[partition, inMemory] = parsePartition params.partition
|
guest = webContents.create {isGuest: true, partition: params.partition, embedder}
|
||||||
guest = webContents.create {isGuest: true, partition, inMemory, embedder}
|
|
||||||
guestInstances[id] = {guest, embedder}
|
guestInstances[id] = {guest, embedder}
|
||||||
|
|
||||||
# Destroy guest when the embedder is gone or navigated.
|
# Destroy guest when the embedder is gone or navigated.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue