If a user calls makeSingleInstance more than once, just ignore it
This commit is contained in:
parent
38d6ff79c8
commit
a160891a27
3 changed files with 12 additions and 11 deletions
|
@ -271,15 +271,15 @@ v8::Local<v8::Value> App::DefaultSession(v8::Isolate* isolate) {
|
|||
|
||||
bool App::MakeSingleInstance(v8::Local<v8::Function> callback) {
|
||||
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;
|
||||
mate::Converter<ProcessSingleton::NotificationCallback>::FromV8(
|
||||
isolate(), single_instance_callback_, &cb);
|
||||
|
||||
browser->SetSingleInstanceCallback(cb);
|
||||
browser->SetSingleInstanceCallback(cb);
|
||||
}
|
||||
|
||||
switch (browser->GetSingleInstanceResult()) {
|
||||
case ProcessSingleton::NotifyResult::PROCESS_NONE:
|
||||
|
|
|
@ -165,7 +165,7 @@ bool Browser::HandleBeforeQuit() {
|
|||
return !prevent_default;
|
||||
}
|
||||
|
||||
void Browser::InitializeSingleInstance() {
|
||||
bool Browser::InitializeSingleInstance() {
|
||||
base::FilePath userDir;
|
||||
PathService::Get(brightray::DIR_USER_DATA, &userDir);
|
||||
|
||||
|
@ -174,11 +174,12 @@ void Browser::InitializeSingleInstance() {
|
|||
userDir,
|
||||
base::Bind(&Browser::OnProcessSingletonNotification, no_refcount_this)));
|
||||
|
||||
process_notify_result_ = process_singleton_->NotifyOtherProcessOrCreate();
|
||||
|
||||
if (is_ready_) {
|
||||
process_singleton_->Unlock();
|
||||
}
|
||||
|
||||
process_notify_result_ = process_singleton_->NotifyOtherProcessOrCreate();
|
||||
return true;
|
||||
}
|
||||
|
||||
ProcessSingleton::NotifyResult Browser::GetSingleInstanceResult() {
|
||||
|
|
|
@ -66,7 +66,7 @@ class Browser : public WindowListObserver {
|
|||
// Clear the recent documents list.
|
||||
void ClearRecentDocuments();
|
||||
|
||||
void InitializeSingleInstance();
|
||||
bool InitializeSingleInstance();
|
||||
ProcessSingleton::NotifyResult GetSingleInstanceResult();
|
||||
void SetSingleInstanceCallback(
|
||||
ProcessSingleton::NotificationCallback callback);
|
||||
|
|
Loading…
Reference in a new issue