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..d10f3d66aec9686906d461b5b453058042ca2628 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,18 @@ 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) { |
+ URL = [NSURL URLWithString:launchURL]; |
+ } |
+ UMA_HISTOGRAM_BOOLEAN("IOS.MailtoURLRewritten", launchURL != nil); |
+ } |
+ |
// 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. |