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/ios/weak_nsobject.h" | |
9 #include "base/logging.h" | 8 #include "base/logging.h" |
10 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
11 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
12 #include "components/strings/grit/components_strings.h" | 11 #include "components/strings/grit/components_strings.h" |
13 #include "ios/chrome/browser/experimental_flags.h" | 12 #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 #include "ios/chrome/grit/ios_strings.h" | 14 #include "ios/chrome/grit/ios_strings.h" |
16 #import "net/base/mac/url_conversions.h" | 15 #import "net/base/mac/url_conversions.h" |
17 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
18 #include "url/gurl.h" | 17 #include "url/gurl.h" |
19 | 18 |
| 19 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 20 #error "This file requires ARC support." |
| 21 #endif |
| 22 |
20 namespace { | 23 namespace { |
21 | 24 |
22 typedef void (^AlertHandler)(UIAlertAction* action); | 25 typedef void (^AlertHandler)(UIAlertAction* action); |
23 | 26 |
24 // Returns a set of NSStrings that are URL schemes for iTunes Stores. | 27 // Returns a set of NSStrings that are URL schemes for iTunes Stores. |
25 NSSet<NSString*>* ITMSSchemes() { | 28 NSSet<NSString*>* ITMSSchemes() { |
26 static NSSet<NSString*>* schemes; | 29 static NSSet<NSString*>* schemes; |
27 static dispatch_once_t once; | 30 static dispatch_once_t once; |
28 dispatch_once(&once, ^{ | 31 dispatch_once(&once, ^{ |
29 schemes = | 32 schemes = |
30 [[NSSet setWithObjects:@"itms", @"itmss", @"itms-apps", @"itms-appss", | 33 [NSSet setWithObjects:@"itms", @"itmss", @"itms-apps", @"itms-appss", |
31 // There's no evidence that itms-bookss is | 34 // There's no evidence that itms-bookss is |
32 // actually supported, but over-inclusion | 35 // actually supported, but over-inclusion |
33 // costs less than under-inclusion. | 36 // costs less than under-inclusion. |
34 @"itms-books", @"itms-bookss", nil] retain]; | 37 @"itms-books", @"itms-bookss", nil]; |
35 }); | 38 }); |
36 return schemes; | 39 return schemes; |
37 } | 40 } |
38 | 41 |
39 bool UrlHasAppStoreScheme(const GURL& gURL) { | 42 bool UrlHasAppStoreScheme(const GURL& gURL) { |
40 std::string scheme = gURL.scheme(); | 43 std::string scheme = gURL.scheme(); |
41 return [ITMSSchemes() containsObject:base::SysUTF8ToNSString(scheme)]; | 44 return [ITMSSchemes() containsObject:base::SysUTF8ToNSString(scheme)]; |
42 } | 45 } |
43 | 46 |
44 // Logs an entry for |Tab.ExternalApplicationOpened|. If the user decided to | 47 // Logs an entry for |Tab.ExternalApplicationOpened|. If the user decided to |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 187 } |
185 | 188 |
186 // If the following call returns YES, an external application is about to be | 189 // If the following call returns YES, an external application is about to be |
187 // launched and Chrome will go into the background now. | 190 // launched and Chrome will go into the background now. |
188 // TODO(crbug.com/622735): This call still needs to be updated. | 191 // TODO(crbug.com/622735): This call still needs to be updated. |
189 // It's heavily nested so some refactoring is needed. | 192 // It's heavily nested so some refactoring is needed. |
190 return [[UIApplication sharedApplication] openURL:URL]; | 193 return [[UIApplication sharedApplication] openURL:URL]; |
191 } | 194 } |
192 | 195 |
193 @end | 196 @end |
OLD | NEW |