Combine launch and current status login item APIs
This commit is contained in:
parent
2406c82ef5
commit
60ab71a706
4 changed files with 17 additions and 30 deletions
|
@ -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",
|
||||
|
|
|
@ -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<v8::Value> GetLoginItemLaunchStatus(mate::Arguments* args);
|
||||
|
||||
// Get login item status of app
|
||||
v8::Local<v8::Value> GetLoginItemStatus(mate::Arguments* args);
|
||||
|
||||
|
|
|
@ -150,19 +150,15 @@ bool Browser::ContinueUserActivity(const std::string& type,
|
|||
return prevent_default;
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> 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<v8::Value> 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue