If a user calls makeSingleInstance more than once, just ignore it

This commit is contained in:
Paul Betts 2015-10-21 12:29:00 -07:00
parent 38d6ff79c8
commit a160891a27
3 changed files with 12 additions and 11 deletions

View file

@ -271,15 +271,15 @@ v8::Local<v8::Value> App::DefaultSession(v8::Isolate* isolate) {
bool App::MakeSingleInstance(v8::Local<v8::Function> callback) { bool App::MakeSingleInstance(v8::Local<v8::Function> callback) {
auto browser = Browser::Get(); auto browser = Browser::Get();
single_instance_callback_ = callback; if (browser->InitializeSingleInstance()) {
single_instance_callback_ = callback;
browser->InitializeSingleInstance(); ProcessSingleton::NotificationCallback cb;
mate::Converter<ProcessSingleton::NotificationCallback>::FromV8(
isolate(), single_instance_callback_, &cb);
ProcessSingleton::NotificationCallback cb; browser->SetSingleInstanceCallback(cb);
mate::Converter<ProcessSingleton::NotificationCallback>::FromV8( }
isolate(), single_instance_callback_, &cb);
browser->SetSingleInstanceCallback(cb);
switch (browser->GetSingleInstanceResult()) { switch (browser->GetSingleInstanceResult()) {
case ProcessSingleton::NotifyResult::PROCESS_NONE: case ProcessSingleton::NotifyResult::PROCESS_NONE:

View file

@ -165,7 +165,7 @@ bool Browser::HandleBeforeQuit() {
return !prevent_default; return !prevent_default;
} }
void Browser::InitializeSingleInstance() { bool Browser::InitializeSingleInstance() {
base::FilePath userDir; base::FilePath userDir;
PathService::Get(brightray::DIR_USER_DATA, &userDir); PathService::Get(brightray::DIR_USER_DATA, &userDir);
@ -174,11 +174,12 @@ void Browser::InitializeSingleInstance() {
userDir, userDir,
base::Bind(&Browser::OnProcessSingletonNotification, no_refcount_this))); base::Bind(&Browser::OnProcessSingletonNotification, no_refcount_this)));
process_notify_result_ = process_singleton_->NotifyOtherProcessOrCreate();
if (is_ready_) { if (is_ready_) {
process_singleton_->Unlock(); process_singleton_->Unlock();
} }
process_notify_result_ = process_singleton_->NotifyOtherProcessOrCreate();
return true;
} }
ProcessSingleton::NotifyResult Browser::GetSingleInstanceResult() { ProcessSingleton::NotifyResult Browser::GetSingleInstanceResult() {

View file

@ -66,7 +66,7 @@ class Browser : public WindowListObserver {
// Clear the recent documents list. // Clear the recent documents list.
void ClearRecentDocuments(); void ClearRecentDocuments();
void InitializeSingleInstance(); bool InitializeSingleInstance();
ProcessSingleton::NotifyResult GetSingleInstanceResult(); ProcessSingleton::NotifyResult GetSingleInstanceResult();
void SetSingleInstanceCallback( void SetSingleInstanceCallback(
ProcessSingleton::NotificationCallback callback); ProcessSingleton::NotificationCallback callback);