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..4e0bbd55fc7ab0df67d19642f2a16c24f9642640 100644 |
| --- a/chrome/common/content_settings_pattern_parser.cc |
| +++ b/chrome/common/content_settings_pattern_parser.cc |
| @@ -5,16 +5,19 @@ |
| #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/embedder_variables.h" |
| +#include "url/url_constants.h" |
| namespace { |
| -const char* kUrlPathSeparator = "/"; |
| -const char* kUrlPortSeparator = ":"; |
| +const char kDomainWildcard[] = "[*.]"; |
| +const size_t kDomainWildcardLength = 4; |
| +const char kHostWildcard[] = "*"; |
| +const char kPathWildcard[] = "*"; |
| +const char kPortWildcard[] = "*"; |
| +const char kSchemeWildcard[] = "*"; |
| +const char kUrlPathSeparator[] = "/"; |
| +const char kUrlPortSeparator[] = ":"; |
| class Component { |
| public: |
| @@ -33,19 +36,6 @@ 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, |
| ContentSettingsPattern::BuilderInterface* builder) { |
| if (pattern_spec == "*") { |
| @@ -69,11 +59,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,8 +162,8 @@ void PatternParser::Parse(const std::string& pattern_spec, |
| builder->WithPort(port); |
| } |
| } else { |
| - if (scheme != std::string(extensions::kExtensionScheme) && |
| - scheme != std::string(url::kFileScheme)) |
| + if (!content_settings::IsNonPortScheme(scheme) && |
| + scheme != url::kFileScheme) |
| builder->WithPortWildcard(); |
| } |
| @@ -187,7 +177,6 @@ void PatternParser::Parse(const std::string& pattern_spec, |
| } |
| } |
| -// static |
|
vabr (Chromium)
2014/08/20 09:52:22
The header still declares this method as static. P
vasilii
2014/08/21 14:58:02
Done.
|
| std::string PatternParser::ToString( |
| const ContentSettingsPattern::PatternParts& parts) { |
| // Return the most compact form to support legacy code and legacy pattern |
| @@ -217,7 +206,7 @@ std::string PatternParser::ToString( |
| } |
| str += parts.host; |
| - if (parts.scheme == std::string(extensions::kExtensionScheme)) { |
| + if (content_settings::IsNonPortScheme(parts.scheme)) { |
|
vabr (Chromium)
2014/08/20 09:52:22
I believe this path should work for file: as well.
vasilii
2014/08/21 14:58:02
It's handled above. The file path can be wildcard.
vabr (Chromium)
2014/08/21 15:31:41
Ah, I see. Special casing the file URL here makes
vasilii
2014/08/22 13:02:45
I don't know if there are other places where the d
|
| str += parts.path.empty() ? std::string(kUrlPathSeparator) : parts.path; |
| return str; |
| } |