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 74b5023071bb45c8beaa45d4cd80a0a928d74629..5c987b23a31e049dd86527f8e7ad39d5229f373e 100644 |
--- a/ios/chrome/browser/web/external_app_launcher.mm |
+++ b/ios/chrome/browser/web/external_app_launcher.mm |
@@ -4,6 +4,7 @@ |
#import "ios/chrome/browser/web/external_app_launcher.h" |
+#include "base/ios/ios_util.h" |
#include "base/ios/weak_nsobject.h" |
#include "base/logging.h" |
#include "base/metrics/histogram_macros.h" |
@@ -52,8 +53,8 @@ void RecordExternalApplicationOpened(bool opened) { |
@interface ExternalAppLauncher () |
// Returns the Phone/FaceTime call argument from |URL|. |
+ (NSString*)formatCallArgument:(NSURL*)URL; |
-// Ask user for confirmation before dialing FaceTime destination. |
-- (void)openFaceTimePromptForURL:(NSURL*)telURL; |
+// Ask user for confirmation before dialing Phone or FaceTime destinations. |
+- (void)openPromptForURL:(NSURL*)telURL; |
Eugene But (OOO till 7-30)
2017/04/13 22:47:30
s/telURL/URL ?
pkl (ping after 24h if needed)
2017/04/14 00:34:50
Done.
|
// Ask user for confirmation before moving to external app. |
- (void)openExternalAppWithPromptForURL:(NSURL*)URL; |
// Presents a configured alert controller on the root view controller. |
@@ -96,8 +97,10 @@ void RecordExternalApplicationOpened(bool opened) { |
}]; |
} |
-- (void)openFaceTimePromptForURL:(NSURL*)URL { |
- NSString* openTitle = l10n_util::GetNSString(IDS_IOS_FACETIME_BUTTON); |
+- (void)openPromptForURL:(NSURL*)URL { |
+ NSString* openTitle = [URL.scheme isEqualToString:@"facetime"] |
Eugene But (OOO till 7-30)
2017/04/13 22:47:30
Do you want to DCHECK that URL.scheme is ether fac
pkl (ping after 24h if needed)
2017/04/14 00:34:50
Refactored into a anonymous function and do the NO
|
+ ? l10n_util::GetNSString(IDS_IOS_FACETIME_BUTTON) |
+ : l10n_util::GetNSString(IDS_IOS_PHONE_CALL_BUTTON); |
[self presentAlertControllerWithMessage:[[self class] formatCallArgument:URL] |
openTitle:openTitle |
openHandler:^(UIAlertAction* action) { |
@@ -136,26 +139,22 @@ void RecordExternalApplicationOpened(bool opened) { |
return NO; |
NSURL* URL = net::NSURLWithGURL(gURL); |
- if (gURL.SchemeIs("facetime") || gURL.SchemeIs("facetime-audio")) { |
+ // iOS 10.3.2 introduced new prompts when facetime: and facetime-audio: |
+ // URL schemes are opened. It is no longer necessary for Chrome to present |
+ // another prompt before the system-provided prompt. |
+ if (!base::ios::IsRunningOnOrLater(10, 3, 2) && |
+ (gURL.SchemeIs("tel") || gURL.SchemeIs("facetime") || |
Eugene But (OOO till 7-30)
2017/04/13 22:47:30
Do you want to create constants for these custom u
pkl (ping after 24h if needed)
2017/04/14 00:34:50
Refactored so all the strings are nearby to not cl
|
+ gURL.SchemeIs("facetime-audio"))) { |
// Showing an alert view immediately has a side-effect where focus is |
// taken from the UIWebView so quickly that mouseup events are lost and |
// buttons get 'stuck' in the on position. The solution is to defer |
// showing the view. |
- [self performSelector:@selector(openFaceTimePromptForURL:) |
+ [self performSelector:@selector(openPromptForURL:) |
withObject:URL |
afterDelay:0.0]; |
return YES; |
} |
- // Use telprompt instead of tel because telprompt returns user back to |
- // Chrome after phone call is completed/aborted. |
- if (gURL.SchemeIs("tel")) { |
- GURL::Replacements replacements; |
- replacements.SetSchemeStr("telprompt"); |
- URL = net::NSURLWithGURL(gURL.ReplaceComponents(replacements)); |
- DCHECK([[URL scheme] isEqualToString:@"telprompt"]); |
- } |
- |
// Don't open external application if chrome is not active. |
if ([[UIApplication sharedApplication] applicationState] != |
UIApplicationStateActive) |