Commit c370542e authored by Justin Cohen's avatar Justin Cohen Committed by Chromium LUCI CQ

ios: Fix NSUserActivityTypeBrowsingWeb handling.

Correct NSUserActivityTypeBrowsingWeb handling for default browser.

Bug: 1156134
Change-Id: I2595889731e71c8039f982122c64e044e5df64bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575151
Auto-Submit: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834253}
parent afeb34c4
......@@ -66,8 +66,6 @@ class GURL;
completeURL:(const GURL&)completeURL
NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithUniversalLink:(const GURL&)universalLink;
- (instancetype)initWithURLs:(const std::vector<GURL>&)URLs;
@end
......
......@@ -59,15 +59,6 @@
return self;
}
// TODO(crbug.com/1021752): Remove this stub since |universalLink| is unused.
- (instancetype)initWithUniversalLink:(const GURL&)universalLink {
// If a new tab with |_externalURL| needs to be opened after the App
// was launched as the result of a Universal Link navigation, the only
// supported possibility at this time is the New Tab Page.
self = [self initWithExternalURL:GURL(kChromeUINewTabURL)
completeURL:GURL(kChromeUINewTabURL)];
return self;
}
- (NSString*)description {
NSMutableString* description =
......
......@@ -94,24 +94,15 @@ std::vector<GURL> createGURLVectorFromIntentURLs(NSArray<NSURL*>* intentURLs) {
NSURL* webpageURL = userActivity.webpageURL;
if ([userActivity.activityType
isEqualToString:handoff::kChromeHandoffActivityType]) {
isEqualToString:handoff::kChromeHandoffActivityType] ||
[userActivity.activityType
isEqualToString:NSUserActivityTypeBrowsingWeb]) {
// App was launched by iOS as a result of Handoff.
NSString* originString = base::mac::ObjCCast<NSString>(
userActivity.userInfo[handoff::kOriginKey]);
handoff::Origin origin = handoff::OriginFromString(originString);
UMA_HISTOGRAM_ENUMERATION("IOS.Handoff.Origin", origin,
handoff::ORIGIN_COUNT);
} else if ([userActivity.activityType
isEqualToString:NSUserActivityTypeBrowsingWeb]) {
// App was launched as the result of a Universal Link navigation.
GURL gurl = net::GURLWithNSURL(webpageURL);
AppStartupParameters* startupParams =
[[AppStartupParameters alloc] initWithUniversalLink:gurl];
[connectionInformation setStartupParameters:startupParams];
base::RecordAction(base::UserMetricsAction("IOSLaunchedByUniversalLink"));
if (startupParams)
webpageURL = net::NSURLWithGURL([startupParams externalURL]);
} else if (spotlight::IsSpotlightAvailable() &&
[userActivity.activityType
isEqualToString:CSSearchableItemActionType]) {
......
......@@ -371,8 +371,7 @@ TEST_F(UserActivityHandlerTest, ContinueUserActivityForeground) {
EXPECT_TRUE(result);
}
// Tests that a new tab is created when application is started via Universal
// Link.
// Tests that a new tab is created when application is started via handoff.
TEST_F(UserActivityHandlerTest, ContinueUserActivityBrowsingWeb) {
NSUserActivity* userActivity = [[NSUserActivity alloc]
initWithActivityType:NSUserActivityTypeBrowsingWeb];
......@@ -398,14 +397,12 @@ TEST_F(UserActivityHandlerTest, ContinueUserActivityBrowsingWeb) {
browserState:GetInterfaceProvider()
.currentInterface.browserState];
GURL newTabURL(kChromeUINewTabURL);
EXPECT_EQ(newTabURL, tabOpener.urlLoadParams.web_params.url);
const GURL gurl = net::GURLWithNSURL(nsurl);
EXPECT_EQ(gurl, tabOpener.urlLoadParams.web_params.url);
EXPECT_TRUE(tabOpener.urlLoadParams.web_params.virtual_url.is_empty());
// AppStartupParameters default to opening pages in non-Incognito mode.
EXPECT_EQ(ApplicationModeForTabOpening::NORMAL, [tabOpener applicationMode]);
EXPECT_TRUE(result);
// Verifies that a new tab is being requested.
EXPECT_EQ(newTabURL,
[[connectionInformationMock startupParameters] externalURL]);
}
// Tests that continueUserActivity sets startupParameters accordingly to the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment