OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/web/public/url_scheme_util.h" | 5 #import "ios/web/public/url_scheme_util.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
10 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." |
| 13 #endif |
| 14 |
11 namespace web { | 15 namespace web { |
12 | 16 |
13 bool UrlHasWebScheme(const GURL& url) { | 17 bool UrlHasWebScheme(const GURL& url) { |
14 return url.SchemeIs(url::kHttpScheme) || | 18 return url.SchemeIs(url::kHttpScheme) || |
15 url.SchemeIs(url::kHttpsScheme) || | 19 url.SchemeIs(url::kHttpsScheme) || |
16 url.SchemeIs(url::kDataScheme); | 20 url.SchemeIs(url::kDataScheme); |
17 } | 21 } |
18 | 22 |
19 bool UrlHasWebScheme(NSURL* url) { | 23 bool UrlHasWebScheme(NSURL* url) { |
20 NSString* scheme = [url scheme]; | 24 NSString* scheme = [url scheme]; |
21 if (![scheme length]) | 25 if (![scheme length]) |
22 return false; | 26 return false; |
23 | 27 |
24 // Use the GURL implementation, but with a scheme-only URL to avoid | 28 // Use the GURL implementation, but with a scheme-only URL to avoid |
25 // unnecessary parsing in GURL construction. | 29 // unnecessary parsing in GURL construction. |
26 NSString* schemeURLString = [scheme stringByAppendingString:@":"]; | 30 NSString* schemeURLString = [scheme stringByAppendingString:@":"]; |
27 GURL gurl([schemeURLString UTF8String]); | 31 GURL gurl([schemeURLString UTF8String]); |
28 return UrlHasWebScheme(gurl); | 32 return UrlHasWebScheme(gurl); |
29 } | 33 } |
30 | 34 |
31 } // namespace web | 35 } // namespace web |
OLD | NEW |