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/chrome_url_util.h" | 5 #import "ios/chrome/browser/chrome_url_util.h" |
6 | 6 |
7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/scoped_block.h" | 10 #include "base/mac/scoped_block.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 bool UrlHasChromeScheme(const GURL& url) { | 38 bool UrlHasChromeScheme(const GURL& url) { |
39 return url.SchemeIs(kChromeUIScheme); | 39 return url.SchemeIs(kChromeUIScheme); |
40 } | 40 } |
41 | 41 |
42 bool UrlHasChromeScheme(NSURL* url) { | 42 bool UrlHasChromeScheme(NSURL* url) { |
43 return net::UrlSchemeIs(url, base::SysUTF8ToNSString(kChromeUIScheme)); | 43 return net::UrlSchemeIs(url, base::SysUTF8ToNSString(kChromeUIScheme)); |
44 } | 44 } |
45 | 45 |
46 bool IsHandledProtocol(const std::string& scheme) { | 46 bool IsHandledProtocol(const std::string& scheme) { |
47 DCHECK_EQ(scheme, base::ToLowerASCII(scheme)); | 47 DCHECK_EQ(scheme, base::ToLowerASCII(scheme)); |
48 if (scheme == url::kAboutScheme) | 48 static const char* const kProtocolList[] = { |
49 return true; | 49 kChromeUIScheme, url::kDataScheme, url::kAboutScheme, url::kHttpScheme, |
50 if (scheme == url::kDataScheme) | 50 url::kHttpsScheme, url::kWsScheme, url::kWssScheme, |
51 return true; | 51 }; |
52 if (scheme == kChromeUIScheme) | 52 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { |
53 return true; | 53 if (scheme == kProtocolList[i]) |
54 return net::URLRequest::IsHandledProtocol(scheme); | 54 return true; |
| 55 } |
| 56 return false; |
55 } | 57 } |
56 | 58 |
57 @implementation ChromeAppConstants { | 59 @implementation ChromeAppConstants { |
58 base::scoped_nsobject<NSString> _callbackScheme; | 60 base::scoped_nsobject<NSString> _callbackScheme; |
59 base::mac::ScopedBlock<AppIconURLProvider> _appIconURLProvider; | 61 base::mac::ScopedBlock<AppIconURLProvider> _appIconURLProvider; |
60 } | 62 } |
61 | 63 |
62 + (ChromeAppConstants*)sharedInstance { | 64 + (ChromeAppConstants*)sharedInstance { |
63 static ChromeAppConstants* g_instance = [[ChromeAppConstants alloc] init]; | 65 static ChromeAppConstants* g_instance = [[ChromeAppConstants alloc] init]; |
64 return g_instance; | 66 return g_instance; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 105 |
104 - (void)setCallbackSchemeForTesting:(NSString*)scheme { | 106 - (void)setCallbackSchemeForTesting:(NSString*)scheme { |
105 _callbackScheme.reset([scheme copy]); | 107 _callbackScheme.reset([scheme copy]); |
106 } | 108 } |
107 | 109 |
108 - (void)setAppIconURLProviderForTesting:(AppIconURLProvider)block { | 110 - (void)setAppIconURLProviderForTesting:(AppIconURLProvider)block { |
109 _appIconURLProvider.reset(block, base::scoped_policy::RETAIN); | 111 _appIconURLProvider.reset(block, base::scoped_policy::RETAIN); |
110 } | 112 } |
111 | 113 |
112 @end | 114 @end |
OLD | NEW |