diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index f032e7043d67..979c7b45fe2b 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -531,6 +531,10 @@ void App::BuildPrototype( base::Bind(&Browser::GetLoginItemLaunchStatus, browser)) .SetMethod("getLoginItemStatus", base::Bind(&Browser::GetLoginItemStatus, browser)) + .SetMethod("setAsLoginItem", + base::Bind(&Browser::SetAsLoginItem, browser)) + .SetMethod("removeAsLoginItem", + base::Bind(&Browser::RemoveAsLoginItem, browser)) #endif #if defined(OS_WIN) .SetMethod("setUserTasks", base::Bind(&Browser::SetUserTasks, browser)) diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 32fa67b30744..6921e946d466 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -140,6 +140,12 @@ class Browser : public WindowListObserver { // Get login item status of app v8::Local GetLoginItemStatus(mate::Arguments* args); + + // Set app as a login item + void SetAsLoginItem(mate::Arguments* args); + + // Remove app as a login item + void RemoveAsLoginItem(); #endif // defined(OS_MACOSX) #if defined(OS_WIN) diff --git a/atom/browser/browser_mac.mm b/atom/browser/browser_mac.mm index 0da56347ef66..0bc2187a9cd4 100644 --- a/atom/browser/browser_mac.mm +++ b/atom/browser/browser_mac.mm @@ -166,6 +166,16 @@ v8::Local Browser::GetLoginItemStatus(mate::Arguments* args) { return dict.GetHandle(); } +void Browser::SetAsLoginItem(mate::Arguments* args) { + bool hidden = false; + args->GetNext(&hidden); + base::mac::AddToLoginItems(hidden); +} + +void Browser::RemoveAsLoginItem() { + base::mac::RemoveFromLoginItems(); +} + std::string Browser::GetExecutableFileVersion() const { return brightray::GetApplicationVersion(); }