| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "content/common/url_schemes.h" | 5 #include "content/common/url_schemes.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "content/common/savable_url_schemes.h" | 15 #include "content/common/savable_url_schemes.h" |
| 16 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
| 17 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
| 18 #include "url/url_util.h" | 18 #include "url/url_util.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 void AddStandardSchemeHelper(const std::string& scheme) { | 22 void AddStandardSchemeHelper(const url::SchemeWithType& scheme) { |
| 23 url::AddStandardScheme(scheme.c_str()); | 23 url::AddStandardScheme(scheme.scheme, scheme.type); |
| 24 } | 24 } |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 void RegisterContentSchemes(bool lock_standard_schemes) { | 30 void RegisterContentSchemes(bool lock_standard_schemes) { |
| 31 std::vector<std::string> additional_standard_schemes; | 31 std::vector<url::SchemeWithType> additional_standard_schemes; |
| 32 std::vector<std::string> additional_savable_schemes; | 32 std::vector<std::string> additional_savable_schemes; |
| 33 GetContentClient()->AddAdditionalSchemes(&additional_standard_schemes, | 33 GetContentClient()->AddAdditionalSchemes(&additional_standard_schemes, |
| 34 &additional_savable_schemes); | 34 &additional_savable_schemes); |
| 35 | 35 |
| 36 url::AddStandardScheme(kChromeDevToolsScheme); | 36 url::AddStandardScheme(kChromeDevToolsScheme, url::SCHEME_WITHOUT_PORT); |
| 37 url::AddStandardScheme(kChromeUIScheme); | 37 url::AddStandardScheme(kChromeUIScheme, url::SCHEME_WITHOUT_PORT); |
| 38 url::AddStandardScheme(kGuestScheme); | 38 url::AddStandardScheme(kGuestScheme, url::SCHEME_WITHOUT_PORT); |
| 39 url::AddStandardScheme(kMetadataScheme); | 39 url::AddStandardScheme(kMetadataScheme, url::SCHEME_WITHOUT_AUTHORITY); |
| 40 std::for_each(additional_standard_schemes.begin(), | 40 std::for_each(additional_standard_schemes.begin(), |
| 41 additional_standard_schemes.end(), | 41 additional_standard_schemes.end(), |
| 42 AddStandardSchemeHelper); | 42 AddStandardSchemeHelper); |
| 43 | 43 |
| 44 // Prevent future modification of the standard schemes list. This is to | 44 // Prevent future modification of the standard schemes list. This is to |
| 45 // prevent accidental creation of data races in the program. AddStandardScheme | 45 // prevent accidental creation of data races in the program. AddStandardScheme |
| 46 // isn't threadsafe so must be called when GURL isn't used on any other | 46 // isn't threadsafe so must be called when GURL isn't used on any other |
| 47 // thread. This is really easy to mess up, so we say that all calls to | 47 // thread. This is really easy to mess up, so we say that all calls to |
| 48 // AddStandardScheme in Chrome must be inside this function. | 48 // AddStandardScheme in Chrome must be inside this function. |
| 49 if (lock_standard_schemes) | 49 if (lock_standard_schemes) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 68 savable_schemes[default_schemes_count + i] = | 68 savable_schemes[default_schemes_count + i] = |
| 69 base::strdup(additional_savable_schemes[i].c_str()); | 69 base::strdup(additional_savable_schemes[i].c_str()); |
| 70 } | 70 } |
| 71 savable_schemes[default_schemes_count + schemes] = 0; | 71 savable_schemes[default_schemes_count + schemes] = 0; |
| 72 | 72 |
| 73 SetSavableSchemes(savable_schemes); | 73 SetSavableSchemes(savable_schemes); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace content | 77 } // namespace content |
| OLD | NEW |