| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/web/external_app_launcher.h" | 5 #import "ios/chrome/browser/web/external_app_launcher.h" |
| 6 | 6 |
| 7 #include "base/ios/ios_util.h" | 7 #include "base/ios/ios_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 12 #include "components/strings/grit/components_strings.h" | 12 #include "components/strings/grit/components_strings.h" |
| 13 #include "ios/chrome/browser/experimental_flags.h" | |
| 14 #import "ios/chrome/browser/open_url_util.h" | 13 #import "ios/chrome/browser/open_url_util.h" |
| 15 #import "ios/chrome/browser/web/mailto_url_rewriter.h" | 14 #import "ios/chrome/browser/web/mailto_url_rewriter.h" |
| 16 #include "ios/chrome/grit/ios_strings.h" | 15 #include "ios/chrome/grit/ios_strings.h" |
| 17 #import "net/base/mac/url_conversions.h" | 16 #import "net/base/mac/url_conversions.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 20 #include "url/url_constants.h" | 19 #include "url/url_constants.h" |
| 21 | 20 |
| 22 #if !defined(__has_feature) || !__has_feature(objc_arc) | 21 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 23 #error "This file requires ARC support." | 22 #error "This file requires ARC support." |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 if (!linkClicked && UrlHasAppStoreScheme(gURL)) { | 162 if (!linkClicked && UrlHasAppStoreScheme(gURL)) { |
| 164 NSString* prompt = l10n_util::GetNSString(IDS_IOS_OPEN_IN_ANOTHER_APP); | 163 NSString* prompt = l10n_util::GetNSString(IDS_IOS_OPEN_IN_ANOTHER_APP); |
| 165 NSString* openLabel = | 164 NSString* openLabel = |
| 166 l10n_util::GetNSString(IDS_IOS_APP_LAUNCHER_OPEN_APP_BUTTON_LABEL); | 165 l10n_util::GetNSString(IDS_IOS_APP_LAUNCHER_OPEN_APP_BUTTON_LABEL); |
| 167 [self openExternalAppWithURL:URL prompt:prompt openLabel:openLabel]; | 166 [self openExternalAppWithURL:URL prompt:prompt openLabel:openLabel]; |
| 168 return YES; | 167 return YES; |
| 169 } | 168 } |
| 170 } | 169 } |
| 171 | 170 |
| 172 // Replaces |URL| with a rewritten URL if it is of mailto: scheme. | 171 // Replaces |URL| with a rewritten URL if it is of mailto: scheme. |
| 173 if (!experimental_flags::IsNativeAppLauncherEnabled() && | 172 if (gURL.SchemeIs(url::kMailToScheme)) { |
| 174 gURL.SchemeIs(url::kMailToScheme)) { | |
| 175 MailtoURLRewriter* rewriter = | 173 MailtoURLRewriter* rewriter = |
| 176 [[MailtoURLRewriter alloc] initWithStandardHandlers]; | 174 [[MailtoURLRewriter alloc] initWithStandardHandlers]; |
| 177 NSString* launchURL = [rewriter rewriteMailtoURL:gURL]; | 175 NSString* launchURL = [rewriter rewriteMailtoURL:gURL]; |
| 178 if (launchURL) | 176 if (launchURL) |
| 179 URL = [NSURL URLWithString:launchURL]; | 177 URL = [NSURL URLWithString:launchURL]; |
| 180 UMA_HISTOGRAM_BOOLEAN("IOS.MailtoURLRewritten", launchURL != nil); | 178 UMA_HISTOGRAM_BOOLEAN("IOS.MailtoURLRewritten", launchURL != nil); |
| 181 } | 179 } |
| 182 | 180 |
| 183 // If the following call returns YES, an external application is about to be | 181 // If the following call returns YES, an external application is about to be |
| 184 // launched and Chrome will go into the background now. | 182 // launched and Chrome will go into the background now. |
| 185 // TODO(crbug.com/622735): This call still needs to be updated. | 183 // TODO(crbug.com/622735): This call still needs to be updated. |
| 186 // It's heavily nested so some refactoring is needed. | 184 // It's heavily nested so some refactoring is needed. |
| 187 return [[UIApplication sharedApplication] openURL:URL]; | 185 return [[UIApplication sharedApplication] openURL:URL]; |
| 188 } | 186 } |
| 189 | 187 |
| 190 @end | 188 @end |
| OLD | NEW |