Commit ddb78604 authored by Mike Dougherty's avatar Mike Dougherty Committed by Commit Bot

[iOS] Log metrics when app is opened with http or https scheme URL

On iOS 14, when set as default browser, Chrome can receive http and
https URLs directly from system and third party apps. Extend the metrics
to capture this case separately from the default case where the source
application is unknown.

Bug: 1101058
Change-Id: Ieb269be5d93d00c07e23e25d366037667d986cd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315199Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792126}
parent 209760fa
...@@ -11,24 +11,30 @@ ...@@ -11,24 +11,30 @@
#import "ios/chrome/browser/first_run/first_run_metrics.h" #import "ios/chrome/browser/first_run/first_run_metrics.h"
// Values of the UMA Startup.MobileSessionCallerApp histogram. // Values of the UMA Startup.MobileSessionCallerApp histogram.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum MobileSessionCallerApp { enum MobileSessionCallerApp {
CALLER_APP_GOOGLE_SEARCH = 0, CALLER_APP_GOOGLE_SEARCH = 0,
CALLER_APP_GOOGLE_GMAIL, CALLER_APP_GOOGLE_GMAIL = 1,
CALLER_APP_GOOGLE_PLUS, CALLER_APP_GOOGLE_PLUS = 2,
CALLER_APP_GOOGLE_DRIVE, CALLER_APP_GOOGLE_DRIVE = 3,
CALLER_APP_GOOGLE_EARTH, CALLER_APP_GOOGLE_EARTH = 4,
CALLER_APP_GOOGLE_OTHER, CALLER_APP_GOOGLE_OTHER = 5,
CALLER_APP_OTHER, CALLER_APP_OTHER = 6,
CALLER_APP_APPLE_MOBILESAFARI, CALLER_APP_APPLE_MOBILESAFARI = 7,
CALLER_APP_APPLE_OTHER, CALLER_APP_APPLE_OTHER = 8,
CALLER_APP_GOOGLE_YOUTUBE, CALLER_APP_GOOGLE_YOUTUBE = 9,
CALLER_APP_GOOGLE_MAPS, CALLER_APP_GOOGLE_MAPS = 10,
CALLER_APP_NOT_AVAILABLE, // Includes being launched from Smart App Banner. // Includes being launched from Smart App Banner.
CALLER_APP_GOOGLE_CHROME_TODAY_EXTENSION, CALLER_APP_NOT_AVAILABLE = 11,
CALLER_APP_GOOGLE_CHROME_SEARCH_EXTENSION, CALLER_APP_GOOGLE_CHROME_TODAY_EXTENSION = 12,
CALLER_APP_GOOGLE_CHROME_CONTENT_EXTENSION, CALLER_APP_GOOGLE_CHROME_SEARCH_EXTENSION = 13,
CALLER_APP_GOOGLE_CHROME_SHARE_EXTENSION, CALLER_APP_GOOGLE_CHROME_CONTENT_EXTENSION = 14,
CALLER_APP_GOOGLE_CHROME, CALLER_APP_GOOGLE_CHROME_SHARE_EXTENSION = 15,
CALLER_APP_GOOGLE_CHROME = 16,
// An application launched Chrome with an http/https URL as the default
// browser.
CALLER_APP_THIRD_PARTY = 17,
MOBILE_SESSION_CALLER_APP_COUNT, MOBILE_SESSION_CALLER_APP_COUNT,
}; };
......
...@@ -35,14 +35,30 @@ NSString* const kSmartAppBannerKey = @"safarisab"; ...@@ -35,14 +35,30 @@ NSString* const kSmartAppBannerKey = @"safarisab";
const CGFloat kAppGroupTriggersVoiceSearchTimeout = 15.0; const CGFloat kAppGroupTriggersVoiceSearchTimeout = 15.0;
// Values of the UMA Startup.MobileSessionStartAction histogram. // Values of the UMA Startup.MobileSessionStartAction histogram.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum MobileSessionStartAction { enum MobileSessionStartAction {
// Logged when an application passes an http URL to Chrome using the custom
// registered scheme (f.e. googlechrome).
START_ACTION_OPEN_HTTP = 0, START_ACTION_OPEN_HTTP = 0,
START_ACTION_OPEN_HTTPS, // Logged when an application passes an https URL to Chrome using the custom
START_ACTION_OPEN_FILE, // registered scheme (f.e. googlechromes).
START_ACTION_XCALLBACK_OPEN, START_ACTION_OPEN_HTTPS = 1,
START_ACTION_XCALLBACK_OTHER, START_ACTION_OPEN_FILE = 2,
START_ACTION_OTHER, START_ACTION_XCALLBACK_OPEN = 3,
START_ACTION_XCALLBACK_APPGROUP_COMMAND, START_ACTION_XCALLBACK_OTHER = 4,
START_ACTION_OTHER = 5,
START_ACTION_XCALLBACK_APPGROUP_COMMAND = 6,
// Logged when any application passes an http URL to Chrome using the standard
// "http" scheme. This can happen when Chrome is set as the default browser
// on iOS 14+ as http openURL calls will be directed to Chrome by the system
// from all other apps.
START_ACTION_OPEN_HTTP_FROM_OS = 7,
// Logged when any application passes an https URL to Chrome using the
// standard "https" scheme. This can happen when Chrome is set as the default
// browser on iOS 14+ as http openURL calls will be directed to Chrome by the
// system from all other apps.
START_ACTION_OPEN_HTTPS_FROM_OS = 8,
MOBILE_SESSION_START_ACTION_COUNT, MOBILE_SESSION_START_ACTION_COUNT,
}; };
...@@ -147,19 +163,28 @@ enum SearchExtensionAction { ...@@ -147,19 +163,28 @@ enum SearchExtensionAction {
secureSourceApp:nil secureSourceApp:nil
completeURL:completeURL]; completeURL:completeURL];
} else { } else {
// Replace the scheme with https or http depending on whether the input GURL externalURL = gurl;
// |url| scheme ends with an 's'. MobileSessionStartAction action = START_ACTION_OTHER;
BOOL useHttps = gurl.scheme()[gurl.scheme().length() - 1] == 's'; if (gurl.SchemeIs(url::kHttpScheme)) {
MobileSessionStartAction action = action = START_ACTION_OPEN_HTTP_FROM_OS;
useHttps ? START_ACTION_OPEN_HTTPS : START_ACTION_OPEN_HTTP; } else if (gurl.SchemeIs(url::kHttpsScheme)) {
action = START_ACTION_OPEN_HTTPS_FROM_OS;
} else {
// Replace the scheme with https or http depending on whether the input
// |url| scheme ends with an 's'.
BOOL useHttps = gurl.scheme()[gurl.scheme().length() - 1] == 's';
action = useHttps ? START_ACTION_OPEN_HTTPS : START_ACTION_OPEN_HTTP;
GURL::Replacements replace_scheme;
if (useHttps)
replace_scheme.SetSchemeStr(url::kHttpsScheme);
else
replace_scheme.SetSchemeStr(url::kHttpScheme);
externalURL = gurl.ReplaceComponents(replace_scheme);
}
UMA_HISTOGRAM_ENUMERATION(kUMAMobileSessionStartActionHistogram, action, UMA_HISTOGRAM_ENUMERATION(kUMAMobileSessionStartActionHistogram, action,
MOBILE_SESSION_START_ACTION_COUNT); MOBILE_SESSION_START_ACTION_COUNT);
GURL::Replacements replace_scheme;
if (useHttps)
replace_scheme.SetSchemeStr(url::kHttpsScheme);
else
replace_scheme.SetSchemeStr(url::kHttpScheme);
GURL externalURL = gurl.ReplaceComponents(replace_scheme);
if (!externalURL.is_valid()) if (!externalURL.is_valid())
return nil; return nil;
return [[ChromeAppStartupParameters alloc] initWithExternalURL:externalURL return [[ChromeAppStartupParameters alloc] initWithExternalURL:externalURL
...@@ -387,8 +412,17 @@ enum SearchExtensionAction { ...@@ -387,8 +412,17 @@ enum SearchExtensionAction {
isEqualToString:app_group::kOpenCommandSourceShareExtension]) isEqualToString:app_group::kOpenCommandSourceShareExtension])
return CALLER_APP_GOOGLE_CHROME_SHARE_EXTENSION; return CALLER_APP_GOOGLE_CHROME_SHARE_EXTENSION;
if (![_declaredSourceApp length]) if (![_declaredSourceApp length]) {
if (self.completeURL.SchemeIs(url::kHttpScheme) ||
self.completeURL.SchemeIs(url::kHttpScheme)) {
// If Chrome is opened via the system default browser mechanism, the
// action should be differentiated from the case where the source is
// unknown.
return CALLER_APP_THIRD_PARTY;
}
return CALLER_APP_NOT_AVAILABLE; return CALLER_APP_NOT_AVAILABLE;
}
if ([_declaredSourceApp if ([_declaredSourceApp
isEqualToString:[[NSBundle mainBundle] bundleIdentifier]]) isEqualToString:[[NSBundle mainBundle] bundleIdentifier]])
return CALLER_APP_GOOGLE_CHROME; return CALLER_APP_GOOGLE_CHROME;
......
...@@ -86,6 +86,26 @@ TEST_F(AppStartupParametersTest, ParseURLWithHttpsParsedURL) { ...@@ -86,6 +86,26 @@ TEST_F(AppStartupParametersTest, ParseURLWithHttpsParsedURL) {
EXPECT_EQ("https://www.google.com/", [params externalURL].spec()); EXPECT_EQ("https://www.google.com/", [params externalURL].spec());
} }
// Tests that http url remains unchanged.
TEST_F(AppStartupParametersTest, ParseURLWithHttpURL) {
NSURL* url = [NSURL URLWithString:@"http://www.google.com"];
ChromeAppStartupParameters* params =
[ChromeAppStartupParameters newChromeAppStartupParametersWithURL:url
fromSourceApplication:nil];
EXPECT_EQ("http://www.google.com/", [params externalURL]);
}
// Tests that https url remains unchanged.
TEST_F(AppStartupParametersTest, ParseURLWithHttpsURL) {
NSURL* url = [NSURL URLWithString:@"https://www.google.com"];
ChromeAppStartupParameters* params =
[ChromeAppStartupParameters newChromeAppStartupParametersWithURL:url
fromSourceApplication:nil];
EXPECT_EQ("https://www.google.com/", [params externalURL]);
}
TEST_F(AppStartupParametersTest, ParseURLWithXCallbackURL) { TEST_F(AppStartupParametersTest, ParseURLWithXCallbackURL) {
NSURL* url = [NSURL URLWithString: NSURL* url = [NSURL URLWithString:
@"chromium-x-callback://x-callback-url/open?" @"chromium-x-callback://x-callback-url/open?"
......
...@@ -46899,6 +46899,12 @@ Called by update_use_counter_css.py.--> ...@@ -46899,6 +46899,12 @@ Called by update_use_counter_css.py.-->
<int value="14" label="Chrome Content Extension"/> <int value="14" label="Chrome Content Extension"/>
<int value="15" label="Chrome Share Extension"/> <int value="15" label="Chrome Share Extension"/>
<int value="16" label="Chrome"/> <int value="16" label="Chrome"/>
<int value="17" label="Third Party">
A non-Google application (more precisely an app that doesn't share an app
group with Chrome) launched Chrome with an http or https URL. This can
happen on iOS 14+ when Chrome is set as the default browser and a system app
(f.e. Messages) or an app from a 3rd party developer opens a URL.
</int>
</enum> </enum>
<enum name="MobileSessionShutdownType"> <enum name="MobileSessionShutdownType">
...@@ -46912,13 +46918,31 @@ Called by update_use_counter_css.py.--> ...@@ -46912,13 +46918,31 @@ Called by update_use_counter_css.py.-->
</enum> </enum>
<enum name="MobileSessionStartAction"> <enum name="MobileSessionStartAction">
<int value="0" label="Open http"/> <int value="0" label="Open http">
<int value="1" label="Open https"/> Logged when an application passes an http URL to Chrome using the custom
registered scheme (f.e. googlechrome).
</int>
<int value="1" label="Open https">
Logged when an application passes an https URL to Chrome using the custom
registered scheme (f.e. googlechromes).
</int>
<int value="2" label="Open file"/> <int value="2" label="Open file"/>
<int value="3" label="x-callback-url open"/> <int value="3" label="x-callback-url open"/>
<int value="4" label="x-callback-url other"/> <int value="4" label="x-callback-url other"/>
<int value="5" label="Other"/> <int value="5" label="Other"/>
<int value="6" label="x-callback-url app-group-command"/> <int value="6" label="x-callback-url app-group-command"/>
<int value="7" label="OS opened http">
Logged when any application passes an http URL to Chrome using the standard
&quot;http&quot; scheme. This can happen when Chrome is set as the default
browser on iOS 14+ as http openURL calls will be directed to Chrome by the
system from all other apps.
</int>
<int value="8" label="OS opened https">
Logged when any application passes an https URL to Chrome using the standard
&quot;https&quot; scheme. This can happen when Chrome is set as the default
browser on iOS 14+ as http openURL calls will be directed to Chrome by the
system from all other apps.
</int>
</enum> </enum>
<enum name="MobileStartingAction"> <enum name="MobileStartingAction">
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