[ios] Add ActivityToMoveTab to window_activities
This CL adds a new NSUserActivity type for moving a tab to a new window. This CL is one in a series to add drag and drop functionality in a multi-window world. Dragging a tab (which will come in a later CL) to the edge of the screen in an iPad is a gesture to create a new window with that tab. A custom NSUserActivity is required to enable this gesture. Bug: 1087844 Change-Id: I0462f3074825f682ccc4c1e8345f22e310abdcc5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2236896 Reviewed-by: Mark Cogan <marq@chromium.org> Commit-Queue: edchin <edchin@chromium.org> Cr-Commit-Position: refs/heads/master@{#778848}
This commit is contained in:
ios/chrome/browser/window_activities
@ -10,7 +10,7 @@ source_set("window_activities") {
|
||||
]
|
||||
deps = [
|
||||
"//base",
|
||||
"//ios/chrome/browser",
|
||||
"//ios/chrome/browser:chrome_url_constants",
|
||||
"//ios/chrome/browser/url_loading",
|
||||
"//ios/web/public/navigation",
|
||||
"//net",
|
||||
|
@ -52,10 +52,17 @@ NSUserActivity* ActivityToLoadURL(WindowActivityOrigin origin,
|
||||
// |url|.
|
||||
NSUserActivity* ActivityToLoadURL(WindowActivityOrigin origin, const GURL& url);
|
||||
|
||||
// Create a new activity that moves a tab either between browsers, or reorders
|
||||
// within a browser.
|
||||
NSUserActivity* ActivityToMoveTab(NSString* tab_id);
|
||||
|
||||
// true if |activity| is one that indicates a URL load (including loading the
|
||||
// new tab page in a new tab).
|
||||
bool ActivityIsURLLoad(NSUserActivity* activity);
|
||||
|
||||
// true if |activity| is one that indicates a tab move.
|
||||
bool ActivityIsTabMove(NSUserActivity* activity);
|
||||
|
||||
// The URLLoadParams needed to perform the load defined in |activity|, if any.
|
||||
// If |activity| is not a URL load activity, the default UrlLoadParams are
|
||||
// returned.
|
||||
|
@ -17,12 +17,14 @@
|
||||
// Activity types.
|
||||
NSString* const kLoadURLActivityType = @"org.chromium.load.url";
|
||||
NSString* const kLoadIncognitoURLActivityType = @"org.chromium.load.otr-url";
|
||||
NSString* const kMoveTabActivityType = @"org.chromium.move-tab";
|
||||
|
||||
// User info keys.
|
||||
NSString* const kURLKey = @"LoadParams_URL";
|
||||
NSString* const kReferrerURLKey = @"LoadParams_ReferrerURL";
|
||||
NSString* const kReferrerPolicyKey = @"LoadParams_ReferrerPolicy";
|
||||
NSString* const kOriginKey = @"LoadParams_Origin";
|
||||
NSString* const kTabIdentifierKey = @"TabIdentifier";
|
||||
|
||||
namespace {
|
||||
|
||||
@ -74,11 +76,22 @@ NSUserActivity* ActivityToLoadURL(WindowActivityOrigin origin,
|
||||
return activity;
|
||||
}
|
||||
|
||||
NSUserActivity* ActivityToMoveTab(NSString* tab_id) {
|
||||
NSUserActivity* activity =
|
||||
[[NSUserActivity alloc] initWithActivityType:kMoveTabActivityType];
|
||||
[activity addUserInfoEntriesFromDictionary:@{kTabIdentifierKey : tab_id}];
|
||||
return activity;
|
||||
}
|
||||
|
||||
bool ActivityIsURLLoad(NSUserActivity* activity) {
|
||||
return [activity.activityType isEqualToString:kLoadURLActivityType] ||
|
||||
[activity.activityType isEqualToString:kLoadIncognitoURLActivityType];
|
||||
}
|
||||
|
||||
bool ActivityIsTabMove(NSUserActivity* activity) {
|
||||
return [activity.activityType isEqualToString:kMoveTabActivityType];
|
||||
}
|
||||
|
||||
UrlLoadParams LoadParamsFromActivity(NSUserActivity* activity) {
|
||||
if (!ActivityIsURLLoad(activity))
|
||||
return UrlLoadParams();
|
||||
|
Reference in New Issue
Block a user