}
bool App::MakeSingleInstance(v8::Local<v8::Function> callback) {
+ auto browser = Browser::Get();
single_instance_callback_ = callback;
+ browser->InitializeSingleInstance();
+
ProcessSingleton::NotificationCallback cb;
mate::Converter<ProcessSingleton::NotificationCallback>::FromV8(isolate(), single_instance_callback_, &cb);
- auto browser = Browser::Get();
browser->SetSingleInstanceCallback(cb);
switch(browser->GetSingleInstanceResult()) {
}
void Browser::WillFinishLaunching() {
- base::FilePath userDir;
- PathService::Get(brightray::DIR_USER_DATA, &userDir);
-
- auto no_refcount_this = base::Unretained(this);
- process_singleton_.reset(new AtomProcessSingleton(
- userDir,
- base::Bind(&Browser::OnProcessSingletonNotification, no_refcount_this)));
-
- LOG(ERROR) << "Setting up Process Singleton: " << userDir.value();
- process_notify_result_ = process_singleton_->NotifyOtherProcessOrCreate();
-
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillFinishLaunching());
}
is_quiting_ = false;
return;
}
-
+
process_singleton_->Cleanup();
Shutdown();
}
return !prevent_default;
}
+void Browser::InitializeSingleInstance() {
+ base::FilePath userDir;
+ PathService::Get(brightray::DIR_USER_DATA, &userDir);
+
+ auto no_refcount_this = base::Unretained(this);
+ process_singleton_.reset(new AtomProcessSingleton(
+ userDir,
+ base::Bind(&Browser::OnProcessSingletonNotification, no_refcount_this)));
+
+ process_notify_result_ = process_singleton_->NotifyOtherProcessOrCreate();
+}
+
ProcessSingleton::NotifyResult Browser::GetSingleInstanceResult() {
LOG(ERROR) << "Process Notify Result: " << process_notify_result_;
return process_notify_result_;
// Clear the recent documents list.
void ClearRecentDocuments();
+ void InitializeSingleInstance();
ProcessSingleton::NotifyResult GetSingleInstanceResult();
void SetSingleInstanceCallback(ProcessSingleton::NotificationCallback callback);
// WindowListObserver implementations:
void OnWindowCloseCancelled(NativeWindow* window) override;
void OnWindowAllClosed() override;
-
+
bool OnProcessSingletonNotification(
const base::CommandLine& command_line,
const base::FilePath& current_directory);