feat: allow resigning current NSUserActivity (#18659)
* feat: allow resigning current NSUserActivity * wrap in @available check
This commit is contained in:
		
					parent
					
						
							
								b30484d3a9
							
						
					
				
			
			
				commit
				
					
						abab90f563
					
				
			
		
					 6 changed files with 23 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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_) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue