Wire everything up
This commit is contained in:
parent
c38f2fcf75
commit
cdd51fa96d
4 changed files with 20 additions and 8 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/native_mate_converters/command_line_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/command_line.h"
|
||||
|
@ -268,7 +269,19 @@ v8::Local<v8::Value> App::DefaultSession(v8::Isolate* isolate) {
|
|||
return v8::Local<v8::Value>::New(isolate, default_session_);
|
||||
}
|
||||
|
||||
bool App::MakeSingleInstance(const SingleInstanceCallback& callback) {
|
||||
bool App::MakeSingleInstance(const ProcessSingleton::NotificationCallback& callback) {
|
||||
auto browser = Browser::Get();
|
||||
browser->SetSingleInstanceCallback(&callback);
|
||||
|
||||
switch(browser->GetSingleInstanceResult()) {
|
||||
case ProcessSingleton::NotifyResult::PROCESS_NONE:
|
||||
return false;
|
||||
case ProcessSingleton::NotifyResult::LOCK_ERROR:
|
||||
case ProcessSingleton::NotifyResult::PROFILE_IN_USE:
|
||||
case ProcessSingleton::NotifyResult::PROCESS_NOTIFIED:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "atom/browser/api/event_emitter.h"
|
||||
#include "atom/browser/browser_observer.h"
|
||||
#include "atom/browser/process_singleton.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "content/public/browser/gpu_data_manager_observer.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
@ -25,8 +26,6 @@ namespace atom {
|
|||
|
||||
namespace api {
|
||||
|
||||
using SingleInstanceCallback = base::Callback<void(const std::string&)>;
|
||||
|
||||
class App : public mate::EventEmitter,
|
||||
public BrowserObserver,
|
||||
public content::GpuDataManagerObserver {
|
||||
|
@ -70,8 +69,8 @@ class App : public mate::EventEmitter,
|
|||
void SetAppUserModelId(const std::string& app_id);
|
||||
|
||||
void AllowNTLMCredentialsForAllDomains(bool should_allow);
|
||||
|
||||
bool MakeSingleInstance(const SingleInstanceCallback& callback);
|
||||
|
||||
bool MakeSingleInstance(const ProcessSingleton::NotificationCallback& callback);
|
||||
|
||||
std::string GetLocale();
|
||||
v8::Local<v8::Value> DefaultSession(v8::Isolate* isolate);
|
||||
|
|
|
@ -171,7 +171,7 @@ ProcessSingleton::NotifyResult Browser::GetSingleInstanceResult() {
|
|||
return process_notify_result_;
|
||||
}
|
||||
|
||||
void Browser::SetSingleInstanceCallback(ProcessSingleton::NotificationCallback* callback) {
|
||||
void Browser::SetSingleInstanceCallback(const ProcessSingleton::NotificationCallback* callback) {
|
||||
process_notify_callback_ = callback;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class Browser : public WindowListObserver {
|
|||
void ClearRecentDocuments();
|
||||
|
||||
ProcessSingleton::NotifyResult GetSingleInstanceResult();
|
||||
void SetSingleInstanceCallback(ProcessSingleton::NotificationCallback* callback);
|
||||
void SetSingleInstanceCallback(const ProcessSingleton::NotificationCallback* callback);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// Bounce the dock icon.
|
||||
|
@ -176,7 +176,7 @@ class Browser : public WindowListObserver {
|
|||
|
||||
scoped_ptr<AtomProcessSingleton> process_singleton_;
|
||||
ProcessSingleton::NotifyResult process_notify_result_;
|
||||
ProcessSingleton::NotificationCallback* process_notify_callback_;
|
||||
const ProcessSingleton::NotificationCallback* process_notify_callback_;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
base::string16 app_user_model_id_;
|
||||
|
|
Loading…
Reference in a new issue