Chromium Code Reviews| Index: ios/chrome/browser/web/external_app_launcher.mm |
| diff --git a/ios/chrome/browser/web/external_app_launcher.mm b/ios/chrome/browser/web/external_app_launcher.mm |
| index 9489a55ca058771bbbdef29a9697749fa95f123d..b1535ef2985f34e25e90931e748d38cafa1a4798 100644 |
| --- a/ios/chrome/browser/web/external_app_launcher.mm |
| +++ b/ios/chrome/browser/web/external_app_launcher.mm |
| @@ -11,10 +11,12 @@ |
| #include "components/strings/grit/components_strings.h" |
| #include "ios/chrome/browser/experimental_flags.h" |
| #import "ios/chrome/browser/open_url_util.h" |
| +#import "ios/chrome/browser/web/mailto_url_rewriter.h" |
| #include "ios/chrome/grit/ios_strings.h" |
| #import "net/base/mac/url_conversions.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "url/gurl.h" |
| +#include "url/url_constants.h" |
| #if !defined(__has_feature) || !__has_feature(objc_arc) |
| #error "This file requires ARC support." |
| @@ -52,7 +54,7 @@ void RecordExternalApplicationOpened(bool opened) { |
| } |
| // Returns whether gURL has the scheme of a URL that initiates a call. |
| -BOOL UrlHasPhoneCallScheme(const GURL& gURL) { |
| +bool UrlHasPhoneCallScheme(const GURL& gURL) { |
| return gURL.SchemeIs("tel") || gURL.SchemeIs("facetime") || |
| gURL.SchemeIs("facetime-audio"); |
| } |
| @@ -186,6 +188,20 @@ NSString* PromptActionString(NSString* scheme) { |
| } |
| } |
| + // Replaces |URL| with a rewritten URL if it is of mailto: scheme. |
| + if (!experimental_flags::IsNativeAppLauncherEnabled() && |
| + gURL.SchemeIs(url::kMailToScheme)) { |
| + MailtoURLRewriter* rewriter = |
| + [[MailtoURLRewriter alloc] initWithStandardHandlers]; |
| + NSString* launchURL = [rewriter rewriteMailtoURL:gURL]; |
| + if (launchURL) { |
| + UMA_HISTOGRAM_BOOLEAN("MailtoURLRewriter.Rewritten", true); |
| + URL = [NSURL URLWithString:launchURL]; |
| + } else { |
| + UMA_HISTOGRAM_BOOLEAN("MailtoURLRewriter.Rewritten", false); |
|
Alexei Svitkine (slow)
2017/05/08 14:56:01
Each UMA macro expands to a bunch of code. Please
pkl (ping after 24h if needed)
2017/05/08 17:07:56
Great point! I was thinking of the number of times
|
| + } |
| + } |
| + |
| // If the following call returns YES, an external application is about to be |
| // launched and Chrome will go into the background now. |
| // TODO(crbug.com/622735): This call still needs to be updated. |