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("show", base::Bind(&Browser::Show, browser))
|
||||||
.SetMethod("setUserActivity",
|
.SetMethod("setUserActivity",
|
||||||
base::Bind(&Browser::SetUserActivity, browser))
|
base::Bind(&Browser::SetUserActivity, browser))
|
||||||
.SetMethod("getLoginItemLaunchStatus",
|
|
||||||
base::Bind(&Browser::GetLoginItemLaunchStatus, browser))
|
|
||||||
.SetMethod("getLoginItemStatus",
|
.SetMethod("getLoginItemStatus",
|
||||||
base::Bind(&Browser::GetLoginItemStatus, browser))
|
base::Bind(&Browser::GetLoginItemStatus, browser))
|
||||||
.SetMethod("setAsLoginItem",
|
.SetMethod("setAsLoginItem",
|
||||||
|
|
|
@ -135,9 +135,6 @@ class Browser : public WindowListObserver {
|
||||||
// Set docks' icon.
|
// Set docks' icon.
|
||||||
void DockSetIcon(const gfx::Image& image);
|
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
|
// Get login item status of app
|
||||||
v8::Local<v8::Value> GetLoginItemStatus(mate::Arguments* args);
|
v8::Local<v8::Value> GetLoginItemStatus(mate::Arguments* args);
|
||||||
|
|
||||||
|
|
|
@ -150,19 +150,15 @@ bool Browser::ContinueUserActivity(const std::string& type,
|
||||||
return prevent_default;
|
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) {
|
v8::Local<v8::Value> Browser::GetLoginItemStatus(mate::Arguments* args) {
|
||||||
bool hidden = false;
|
bool hidden = false;
|
||||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(args->isolate());
|
mate::Dictionary dict = mate::Dictionary::CreateEmpty(args->isolate());
|
||||||
dict.Set("loginItem", base::mac::CheckLoginItemStatus(&hidden));
|
dict.Set("openAtLogin", base::mac::CheckLoginItemStatus(&hidden));
|
||||||
dict.Set("hidden", 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();
|
return dict.GetHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -302,29 +302,25 @@ describe('app module', function () {
|
||||||
describe('app.getLoginItemStatus API', function () {
|
describe('app.getLoginItemStatus API', function () {
|
||||||
if (process.platform !== 'darwin') return
|
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 () {
|
afterEach(function () {
|
||||||
app.removeAsLoginItem()
|
app.removeAsLoginItem()
|
||||||
assert.equal(app.getLoginItemStatus().loginItem, false)
|
assert.equal(app.getLoginItemStatus().openAtLogin, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns the login item status of the app', function () {
|
it('returns the login item status of the app', function () {
|
||||||
app.setAsLoginItem(true)
|
app.setAsLoginItem(true)
|
||||||
assert.equal(app.getLoginItemStatus().loginItem, true)
|
assert.equal(app.getLoginItemStatus().openAtLogin, true)
|
||||||
assert.equal(app.getLoginItemStatus().hidden, true)
|
assert.equal(app.getLoginItemStatus().openAsHidden, true)
|
||||||
|
|
||||||
app.setAsLoginItem(false)
|
app.setAsLoginItem(false)
|
||||||
assert.equal(app.getLoginItemStatus().loginItem, true)
|
assert.equal(app.getLoginItemStatus().openAtLogin, true)
|
||||||
assert.equal(app.getLoginItemStatus().hidden, false)
|
assert.equal(app.getLoginItemStatus().openAsHidden, 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)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue