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/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 withObject:URL | 170 withObject:URL |
171 afterDelay:0.0]; | 171 afterDelay:0.0]; |
172 return YES; | 172 return YES; |
173 } | 173 } |
174 | 174 |
175 // Don't open external application if chrome is not active. | 175 // Don't open external application if chrome is not active. |
176 if ([[UIApplication sharedApplication] applicationState] != | 176 if ([[UIApplication sharedApplication] applicationState] != |
177 UIApplicationStateActive) | 177 UIApplicationStateActive) |
178 return NO; | 178 return NO; |
179 | 179 |
180 if (experimental_flags::IsExternalApplicationPromptEnabled()) { | 180 // Prompt user to open itunes when opening it is not a result of a link |
181 // Prompt user to open itunes when opening it is not a result of a link | 181 // click. |
182 // click. | 182 if (!linkClicked && UrlHasAppStoreScheme(gURL)) { |
183 if (!linkClicked && UrlHasAppStoreScheme(gURL)) { | 183 [self performSelector:@selector(openExternalAppWithPromptForURL:) |
184 [self performSelector:@selector(openExternalAppWithPromptForURL:) | 184 withObject:URL |
185 withObject:URL | 185 afterDelay:0.0]; |
186 afterDelay:0.0]; | 186 return YES; |
187 return YES; | |
188 } | |
189 } | 187 } |
190 | 188 |
191 // Replaces |URL| with a rewritten URL if it is of mailto: scheme. | 189 // Replaces |URL| with a rewritten URL if it is of mailto: scheme. |
192 if (!experimental_flags::IsNativeAppLauncherEnabled() && | 190 if (!experimental_flags::IsNativeAppLauncherEnabled() && |
193 gURL.SchemeIs(url::kMailToScheme)) { | 191 gURL.SchemeIs(url::kMailToScheme)) { |
194 MailtoURLRewriter* rewriter = | 192 MailtoURLRewriter* rewriter = |
195 [[MailtoURLRewriter alloc] initWithStandardHandlers]; | 193 [[MailtoURLRewriter alloc] initWithStandardHandlers]; |
196 NSString* launchURL = [rewriter rewriteMailtoURL:gURL]; | 194 NSString* launchURL = [rewriter rewriteMailtoURL:gURL]; |
197 if (launchURL) { | 195 if (launchURL) { |
198 URL = [NSURL URLWithString:launchURL]; | 196 URL = [NSURL URLWithString:launchURL]; |
199 } | 197 } |
200 UMA_HISTOGRAM_BOOLEAN("IOS.MailtoURLRewritten", launchURL != nil); | 198 UMA_HISTOGRAM_BOOLEAN("IOS.MailtoURLRewritten", launchURL != nil); |
201 } | 199 } |
202 | 200 |
203 // If the following call returns YES, an external application is about to be | 201 // If the following call returns YES, an external application is about to be |
204 // launched and Chrome will go into the background now. | 202 // launched and Chrome will go into the background now. |
205 // TODO(crbug.com/622735): This call still needs to be updated. | 203 // TODO(crbug.com/622735): This call still needs to be updated. |
206 // It's heavily nested so some refactoring is needed. | 204 // It's heavily nested so some refactoring is needed. |
207 return [[UIApplication sharedApplication] openURL:URL]; | 205 return [[UIApplication sharedApplication] openURL:URL]; |
208 } | 206 } |
209 | 207 |
210 @end | 208 @end |
OLD | NEW |