diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 6c5d1627f779..a558127bf84c 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -1417,6 +1417,8 @@ void App::BuildPrototype(v8::Isolate* isolate, .SetMethod( "invalidateCurrentActivity", base::BindRepeating(&Browser::InvalidateCurrentActivity, browser)) + .SetMethod("resignCurrentActivity", + base::BindRepeating(&Browser::ResignCurrentActivity, browser)) .SetMethod("updateCurrentActivity", base::BindRepeating(&Browser::UpdateCurrentActivity, browser)) // TODO(juturu): Remove in 2.0, deprecate before then with warnings diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 57397d00c599..9e1d78096a4b 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -128,9 +128,13 @@ class Browser : public WindowListObserver { // Returns the type name of the current user activity. std::string GetCurrentActivityType(); - // Invalidates the current user activity. + // Invalidates an activity and marks it as no longer eligible for + // continuation void InvalidateCurrentActivity(); + // Marks this activity object as inactive without invalidating it. + void ResignCurrentActivity(); + // Updates the current user activity void UpdateCurrentActivity(const std::string& type, const base::DictionaryValue& user_info); diff --git a/atom/browser/browser_mac.mm b/atom/browser/browser_mac.mm index f76d76438040..a8d1f8c72714 100644 --- a/atom/browser/browser_mac.mm +++ b/atom/browser/browser_mac.mm @@ -161,6 +161,10 @@ void Browser::InvalidateCurrentActivity() { [[AtomApplication sharedApplication] invalidateCurrentActivity]; } +void Browser::ResignCurrentActivity() { + [[AtomApplication sharedApplication] resignCurrentActivity]; +} + void Browser::UpdateCurrentActivity(const std::string& type, const base::DictionaryValue& user_info) { [[AtomApplication sharedApplication] diff --git a/atom/browser/mac/atom_application.h b/atom/browser/mac/atom_application.h index ad513dadb3e5..f8848470ecd4 100644 --- a/atom/browser/mac/atom_application.h +++ b/atom/browser/mac/atom_application.h @@ -132,6 +132,7 @@ typedef NS_ENUM(NSInteger, AVAuthorizationStatusMac) { withUserInfo:(NSDictionary*)userInfo withWebpageURL:(NSURL*)webpageURL; - (void)invalidateCurrentActivity; +- (void)resignCurrentActivity; - (void)updateCurrentActivity:(NSString*)type withUserInfo:(NSDictionary*)userInfo; diff --git a/atom/browser/mac/atom_application.mm b/atom/browser/mac/atom_application.mm index 9b0f9780f601..4bcd4fc70d19 100644 --- a/atom/browser/mac/atom_application.mm +++ b/atom/browser/mac/atom_application.mm @@ -93,6 +93,13 @@ inline void dispatch_sync_main(dispatch_block_t block) { } } +- (void)resignCurrentActivity { + if (@available(macOS 10.11, *)) { + if (currentActivity_) + [currentActivity_ resignCurrent]; + } +} + - (void)updateCurrentActivity:(NSString*)type withUserInfo:(NSDictionary*)userInfo { if (currentActivity_) { diff --git a/docs/api/app.md b/docs/api/app.md index b95e8016c942..9164437f9fed 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -964,11 +964,12 @@ Returns `String` - The type of the currently running activity. ### `app.invalidateCurrentActivity()` _macOS_ -* `type` String - Uniquely identifies the activity. Maps to - [`NSUserActivity.activityType`][activity-type]. - Invalidates the current [Handoff][handoff] user activity. +### `app.resignCurrentActivity()` _macOS_ + +Marks the current [Handoff][handoff] user activity as inactive without invalidating it. + ### `app.updateCurrentActivity(type, userInfo)` _macOS_ * `type` String - Uniquely identifies the activity. Maps to