| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_content_settings_helpers.h" | 5 #include "chrome/browser/extensions/extension_content_settings_helpers.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/common/extensions/url_pattern.h" | 10 #include "chrome/common/extensions/url_pattern.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 NOTREACHED(); | 50 NOTREACHED(); |
| 51 return ""; | 51 return ""; |
| 52 } | 52 } |
| 53 | 53 |
| 54 } // namespace | 54 } // namespace |
| 55 | 55 |
| 56 namespace extension_content_settings_helpers { | 56 namespace extension_content_settings_helpers { |
| 57 | 57 |
| 58 ContentSettingsPattern ParseExtensionPattern(const std::string& pattern_str, | 58 ContentSettingsPattern ParseExtensionPattern(const std::string& pattern_str, |
| 59 std::string* error) { | 59 std::string* error) { |
| 60 URLPattern url_pattern(URLPattern::SCHEME_HTTP | | 60 const int kAllowedSchemes = |
| 61 URLPattern::SCHEME_HTTPS | | 61 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | |
| 62 URLPattern::SCHEME_FILE); | 62 URLPattern::SCHEME_FILE; |
| 63 URLPattern::ParseResult result = | 63 URLPattern url_pattern(URLPattern::USE_PORTS, kAllowedSchemes); |
| 64 url_pattern.Parse(pattern_str, URLPattern::USE_PORTS); | 64 URLPattern::ParseResult result = url_pattern.Parse(pattern_str); |
| 65 if (result != URLPattern::PARSE_SUCCESS) { | 65 if (result != URLPattern::PARSE_SUCCESS) { |
| 66 *error = URLPattern::GetParseResultString(result); | 66 *error = URLPattern::GetParseResultString(result); |
| 67 return ContentSettingsPattern(); | 67 return ContentSettingsPattern(); |
| 68 } else { | 68 } else { |
| 69 scoped_ptr<ContentSettingsPattern::BuilderInterface> builder( | 69 scoped_ptr<ContentSettingsPattern::BuilderInterface> builder( |
| 70 ContentSettingsPattern::CreateBuilder(false)); | 70 ContentSettingsPattern::CreateBuilder(false)); |
| 71 builder->WithHost(url_pattern.host()); | 71 builder->WithHost(url_pattern.host()); |
| 72 if (url_pattern.match_subdomains()) | 72 if (url_pattern.match_subdomains()) |
| 73 builder->WithDomainWildcard(); | 73 builder->WithDomainWildcard(); |
| 74 | 74 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 return false; | 138 return false; |
| 139 } | 139 } |
| 140 | 140 |
| 141 const char* ContentSettingToString(ContentSetting setting) { | 141 const char* ContentSettingToString(ContentSetting setting) { |
| 142 size_t index = static_cast<size_t>(setting); | 142 size_t index = static_cast<size_t>(setting); |
| 143 DCHECK_LT(index, arraysize(kContentSettingNames)); | 143 DCHECK_LT(index, arraysize(kContentSettingNames)); |
| 144 return kContentSettingNames[index]; | 144 return kContentSettingNames[index]; |
| 145 } | 145 } |
| 146 | 146 |
| 147 } // namespace extension_content_settings_helpers | 147 } // namespace extension_content_settings_helpers |
| OLD | NEW |