Chromium Code Reviews| Index: chrome/common/content_settings_pattern_parser.cc |
| diff --git a/chrome/common/content_settings_pattern_parser.cc b/chrome/common/content_settings_pattern_parser.cc |
| index 6cfb4bb7b2e9fa816754ecc855a0d1f81a278c58..071dfc1e59ce3226452d30f822edaa3db4d050aa 100644 |
| --- a/chrome/common/content_settings_pattern_parser.cc |
| +++ b/chrome/common/content_settings_pattern_parser.cc |
| @@ -5,14 +5,17 @@ |
| #include "chrome/common/content_settings_pattern_parser.h" |
| #include "base/strings/string_util.h" |
| -#include "chrome/common/url_constants.h" |
| -#include "extensions/common/constants.h" |
| -#include "net/base/net_util.h" |
| -#include "url/gurl.h" |
| -#include "url/url_canon.h" |
| +#include "components/content_settings/core/common/content_settings_client.h" |
| +#include "url/url_constants.h" |
| namespace { |
| +const char* kDomainWildcard = "[*.]"; |
|
Bernhard Bauer
2014/08/11 08:43:50
If you're touching this code anyway: const char kC
vasilii
2014/08/11 13:57:18
DomainWildcard is used in Builder too. Below we ha
Bernhard Bauer
2014/08/11 14:06:43
Declare it as an array of characters, not as a poi
vasilii
2014/08/11 16:37:47
Done.
|
| +const size_t kDomainWildcardLength = 4; |
| +const char* kHostWildcard = "*"; |
| +const char* kPathWildcard = "*"; |
| +const char* kPortWildcard = "*"; |
| +const char* kSchemeWildcard = "*"; |
| const char* kUrlPathSeparator = "/"; |
| const char* kUrlPortSeparator = ":"; |
| @@ -33,21 +36,10 @@ class Component { |
| namespace content_settings { |
| -const char* PatternParser::kDomainWildcard = "[*.]"; |
| - |
| -const size_t PatternParser::kDomainWildcardLength = 4; |
| - |
| -const char* PatternParser::kSchemeWildcard = "*"; |
| - |
| -const char* PatternParser::kHostWildcard = "*"; |
| - |
| -const char* PatternParser::kPortWildcard = "*"; |
| - |
| -const char* PatternParser::kPathWildcard = "*"; |
| - |
| -// static |
| -void PatternParser::Parse(const std::string& pattern_spec, |
| +void PatternParser::Parse(ContentSettingsClient* client, |
| + const std::string& pattern_spec, |
| ContentSettingsPattern::BuilderInterface* builder) { |
| + DCHECK(client); |
| if (pattern_spec == "*") { |
| builder->WithSchemeWildcard(); |
| builder->WithDomainWildcard(); |
| @@ -69,11 +61,11 @@ void PatternParser::Parse(const std::string& pattern_spec, |
| return; |
| // Test if a scheme pattern is in the spec. |
| - current_pos = pattern_spec.find( |
| - std::string(url::kStandardSchemeSeparator), start); |
| + const std::string standard_scheme_separator(url::kStandardSchemeSeparator); |
| + current_pos = pattern_spec.find(standard_scheme_separator, start); |
| if (current_pos != std::string::npos) { |
| scheme_component = Component(start, current_pos); |
| - start = current_pos + strlen(url::kStandardSchemeSeparator); |
| + start = current_pos + standard_scheme_separator.size(); |
| current_pos = start; |
| } else { |
| current_pos = start; |
| @@ -172,7 +164,7 @@ void PatternParser::Parse(const std::string& pattern_spec, |
| builder->WithPort(port); |
| } |
| } else { |
| - if (scheme != std::string(extensions::kExtensionScheme) && |
| + if (!client->IsExtensionScheme(scheme) && |
| scheme != std::string(url::kFileScheme)) |
| builder->WithPortWildcard(); |
| } |
| @@ -187,9 +179,10 @@ void PatternParser::Parse(const std::string& pattern_spec, |
| } |
| } |
| -// static |
| std::string PatternParser::ToString( |
| + ContentSettingsClient* client, |
| const ContentSettingsPattern::PatternParts& parts) { |
| + DCHECK(client); |
| // Return the most compact form to support legacy code and legacy pattern |
| // strings. |
| if (parts.is_scheme_wildcard && |
| @@ -217,7 +210,7 @@ std::string PatternParser::ToString( |
| } |
| str += parts.host; |
| - if (parts.scheme == std::string(extensions::kExtensionScheme)) { |
| + if (client->IsExtensionScheme(parts.scheme)) { |
| str += parts.path.empty() ? std::string(kUrlPathSeparator) : parts.path; |
| return str; |
| } |