From: Cheng Zhao Date: Thu, 30 Oct 2014 14:27:29 +0000 (+0800) Subject: Forbid using protocol module before app is ready, fixes #661 X-Git-Tag: v0.19.1~10 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=9ed6ad816590b83b11b75e077223d605e8719e53;p=electron.git Forbid using protocol module before app is ready, fixes #661 --- diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 46cc4c26..ed4cf2c5 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -148,20 +148,15 @@ void App::SetDesktopName(const std::string& desktop_name) { mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder( v8::Isolate* isolate) { - Browser* browser = Browser::Get(); + auto browser = base::Unretained(Browser::Get()); return mate::ObjectTemplateBuilder(isolate) - .SetMethod("quit", base::Bind(&Browser::Quit, - base::Unretained(browser))) - .SetMethod("focus", base::Bind(&Browser::Focus, - base::Unretained(browser))) - .SetMethod("getVersion", base::Bind(&Browser::GetVersion, - base::Unretained(browser))) - .SetMethod("setVersion", base::Bind(&Browser::SetVersion, - base::Unretained(browser))) - .SetMethod("getName", base::Bind(&Browser::GetName, - base::Unretained(browser))) - .SetMethod("setName", base::Bind(&Browser::SetName, - base::Unretained(browser))) + .SetMethod("quit", base::Bind(&Browser::Quit, browser)) + .SetMethod("focus", base::Bind(&Browser::Focus, browser)) + .SetMethod("getVersion", base::Bind(&Browser::GetVersion, browser)) + .SetMethod("setVersion", base::Bind(&Browser::SetVersion, browser)) + .SetMethod("getName", base::Bind(&Browser::GetName, browser)) + .SetMethod("setName", base::Bind(&Browser::SetName, browser)) + .SetMethod("isReady", base::Bind(&Browser::is_ready, browser)) .SetMethod("getDataPath", &App::GetDataPath) .SetMethod("resolveProxy", &App::ResolveProxy) .SetMethod("setDesktopName", &App::SetDesktopName); diff --git a/atom/browser/api/lib/protocol.coffee b/atom/browser/api/lib/protocol.coffee index 65d256f0..045dc956 100644 --- a/atom/browser/api/lib/protocol.coffee +++ b/atom/browser/api/lib/protocol.coffee @@ -1,3 +1,6 @@ +app = require 'app' +throw new Error('Can not initialize protocol module before app is ready') unless app.isReady() + protocol = process.atomBinding('protocol').protocol EventEmitter = require('events').EventEmitter