| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "ios/web/public/url_schemes.h" | 5 #include "ios/web/public/url_schemes.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ios/web/public/web_client.h" | 10 #include "ios/web/public/web_client.h" |
| 11 #include "url/url_util.h" | 11 #include "url/url_util.h" |
| 12 | 12 |
| 13 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 14 #error "This file requires ARC support." |
| 15 #endif |
| 16 |
| 13 namespace web { | 17 namespace web { |
| 14 | 18 |
| 15 namespace { | 19 namespace { |
| 16 void AddStandardSchemeHelper(const url::SchemeWithType& scheme) { | 20 void AddStandardSchemeHelper(const url::SchemeWithType& scheme) { |
| 17 url::AddStandardScheme(scheme.scheme, scheme.type); | 21 url::AddStandardScheme(scheme.scheme, scheme.type); |
| 18 } | 22 } |
| 19 } // namespace | 23 } // namespace |
| 20 | 24 |
| 21 void RegisterWebSchemes(bool lock_schemes) { | 25 void RegisterWebSchemes(bool lock_schemes) { |
| 22 std::vector<url::SchemeWithType> additional_standard_schemes; | 26 std::vector<url::SchemeWithType> additional_standard_schemes; |
| 23 GetWebClient()->AddAdditionalSchemes(&additional_standard_schemes); | 27 GetWebClient()->AddAdditionalSchemes(&additional_standard_schemes); |
| 24 std::for_each(additional_standard_schemes.begin(), | 28 std::for_each(additional_standard_schemes.begin(), |
| 25 additional_standard_schemes.end(), AddStandardSchemeHelper); | 29 additional_standard_schemes.end(), AddStandardSchemeHelper); |
| 26 | 30 |
| 27 // Prevent future modification of the schemes lists. This is to prevent | 31 // Prevent future modification of the schemes lists. This is to prevent |
| 28 // accidental creation of data races in the program. Add*Scheme aren't | 32 // accidental creation of data races in the program. Add*Scheme aren't |
| 29 // threadsafe so must be called when GURL isn't used on any other thread. This | 33 // threadsafe so must be called when GURL isn't used on any other thread. This |
| 30 // is really easy to mess up, so we say that all calls to Add*Scheme in Chrome | 34 // is really easy to mess up, so we say that all calls to Add*Scheme in Chrome |
| 31 // must be inside this function. | 35 // must be inside this function. |
| 32 if (lock_schemes) | 36 if (lock_schemes) |
| 33 url::LockSchemeRegistries(); | 37 url::LockSchemeRegistries(); |
| 34 } | 38 } |
| 35 | 39 |
| 36 } // namespace web | 40 } // namespace web |
| OLD | NEW |