Initialize defaultSession after app is ready
This commit is contained in:
parent
0ebd4d04ad
commit
c2f14e6053
1 changed files with 12 additions and 7 deletions
|
@ -133,6 +133,14 @@ void App::OnWillFinishLaunching() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnFinishLaunching() {
|
void App::OnFinishLaunching() {
|
||||||
|
// Create the defaultSession.
|
||||||
|
v8::Locker locker(isolate());
|
||||||
|
v8::HandleScope handle_scope(isolate());
|
||||||
|
auto browser_context = static_cast<AtomBrowserContext*>(
|
||||||
|
AtomBrowserMainParts::Get()->browser_context());
|
||||||
|
auto handle = Session::CreateFrom(isolate(), browser_context);
|
||||||
|
default_session_.Reset(isolate(), handle.ToV8());
|
||||||
|
|
||||||
Emit("ready");
|
Emit("ready");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,13 +181,10 @@ void App::SetAppUserModelId(const std::string& app_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Local<v8::Value> App::DefaultSession(v8::Isolate* isolate) {
|
v8::Local<v8::Value> App::DefaultSession(v8::Isolate* isolate) {
|
||||||
if (default_session_.IsEmpty()) {
|
if (default_session_.IsEmpty())
|
||||||
auto browser_context = static_cast<AtomBrowserContext*>(
|
return v8::Null(isolate);
|
||||||
AtomBrowserMainParts::Get()->browser_context());
|
else
|
||||||
auto handle = Session::CreateFrom(isolate, browser_context);
|
return v8::Local<v8::Value>::New(isolate, default_session_);
|
||||||
default_session_.Reset(isolate, handle.ToV8());
|
|
||||||
}
|
|
||||||
return v8::Local<v8::Value>::New(isolate, default_session_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
|
mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
|
||||||
|
|
Loading…
Reference in a new issue