Forbid using protocol module before app is ready, fixes #661

This commit is contained in:
Cheng Zhao 2014-10-30 22:27:29 +08:00
parent c0cd8fca80
commit 9ed6ad8165
2 changed files with 11 additions and 13 deletions

View file

@ -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);

View file

@ -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