Add API to add/remove app as login item

This commit is contained in:
Kevin Sawicki 2016-07-06 13:26:16 -07:00
parent b55f55cfc4
commit c5610b2186
3 changed files with 20 additions and 0 deletions

View file

@ -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))

View file

@ -140,6 +140,12 @@ class Browser : public WindowListObserver {
// Get login item status of app
v8::Local<v8::Value> 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)

View file

@ -166,6 +166,16 @@ v8::Local<v8::Value> 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();
}