From 60ab71a70698ba16c5c8496d6a559e85965d0ff8 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 6 Jul 2016 13:57:20 -0700 Subject: [PATCH] Combine launch and current status login item APIs --- atom/browser/api/atom_api_app.cc | 2 -- atom/browser/browser.h | 3 --- atom/browser/browser_mac.mm | 16 ++++++---------- spec/api-app-spec.js | 26 +++++++++++--------------- 4 files changed, 17 insertions(+), 30 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 979c7b45fe2b..4eb026549a33 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -527,8 +527,6 @@ void App::BuildPrototype( .SetMethod("show", base::Bind(&Browser::Show, browser)) .SetMethod("setUserActivity", base::Bind(&Browser::SetUserActivity, browser)) - .SetMethod("getLoginItemLaunchStatus", - base::Bind(&Browser::GetLoginItemLaunchStatus, browser)) .SetMethod("getLoginItemStatus", base::Bind(&Browser::GetLoginItemStatus, browser)) .SetMethod("setAsLoginItem", diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 6921e946d466..6aeb6ed0923e 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -135,9 +135,6 @@ class Browser : public WindowListObserver { // Set docks' icon. void DockSetIcon(const gfx::Image& image); - // Get login item status of current app launch - v8::Local GetLoginItemLaunchStatus(mate::Arguments* args); - // Get login item status of app v8::Local GetLoginItemStatus(mate::Arguments* args); diff --git a/atom/browser/browser_mac.mm b/atom/browser/browser_mac.mm index 0bc2187a9cd4..6207a221e644 100644 --- a/atom/browser/browser_mac.mm +++ b/atom/browser/browser_mac.mm @@ -150,19 +150,15 @@ bool Browser::ContinueUserActivity(const std::string& type, return prevent_default; } -v8::Local Browser::GetLoginItemLaunchStatus(mate::Arguments* args) { - mate::Dictionary dict = mate::Dictionary::CreateEmpty(args->isolate()); - dict.Set("loginItem", base::mac::WasLaunchedAsLoginOrResumeItem()); - dict.Set("hidden", base::mac::WasLaunchedAsHiddenLoginItem()); - dict.Set("restoreState", base::mac::WasLaunchedAsLoginItemRestoreState()); - return dict.GetHandle(); -} - v8::Local Browser::GetLoginItemStatus(mate::Arguments* args) { bool hidden = false; mate::Dictionary dict = mate::Dictionary::CreateEmpty(args->isolate()); - dict.Set("loginItem", base::mac::CheckLoginItemStatus(&hidden)); - dict.Set("hidden", hidden); + dict.Set("openAtLogin", base::mac::CheckLoginItemStatus(&hidden)); + dict.Set("openAsHidden", hidden); + dict.Set("restoreState", base::mac::WasLaunchedAsLoginItemRestoreState()); + dict.Set("openedAtLogin", base::mac::WasLaunchedAsLoginOrResumeItem()); + dict.Set("openedAsHidden", base::mac::WasLaunchedAsHiddenLoginItem()); + return dict.GetHandle(); } diff --git a/spec/api-app-spec.js b/spec/api-app-spec.js index fdb71548401d..af6a7c7e6887 100644 --- a/spec/api-app-spec.js +++ b/spec/api-app-spec.js @@ -302,29 +302,25 @@ describe('app module', function () { describe('app.getLoginItemStatus API', function () { if (process.platform !== 'darwin') return + beforeEach(function () { + assert.equal(app.getLoginItemStatus().openedAtLogin, false) + assert.equal(app.getLoginItemStatus().openedAsHidden, false) + assert.equal(app.getLoginItemStatus().restoreState, false) + }) + afterEach(function () { app.removeAsLoginItem() - assert.equal(app.getLoginItemStatus().loginItem, false) + assert.equal(app.getLoginItemStatus().openAtLogin, false) }) it('returns the login item status of the app', function () { app.setAsLoginItem(true) - assert.equal(app.getLoginItemStatus().loginItem, true) - assert.equal(app.getLoginItemStatus().hidden, true) + assert.equal(app.getLoginItemStatus().openAtLogin, true) + assert.equal(app.getLoginItemStatus().openAsHidden, true) app.setAsLoginItem(false) - assert.equal(app.getLoginItemStatus().loginItem, true) - assert.equal(app.getLoginItemStatus().hidden, false) - }) - }) - - describe('app.getLoginItemLaunchStatus API', function () { - if (process.platform !== 'darwin') return - - it('returns the login item status launch of the app', function () { - assert.equal(app.getLoginItemLaunchStatus().loginItem, false) - assert.equal(app.getLoginItemLaunchStatus().hidden, false) - assert.equal(app.getLoginItemLaunchStatus().restoreState, false) + assert.equal(app.getLoginItemStatus().openAtLogin, true) + assert.equal(app.getLoginItemStatus().openAsHidden, false) }) }) })