Index: components/content_settings/core/common/content_settings_pattern.cc |
diff --git a/components/content_settings/core/common/content_settings_pattern.cc b/components/content_settings/core/common/content_settings_pattern.cc |
index aa895948153c07fa1536be3d9346c80c9a2462c3..b9dbe6af393593cf856c784ea3ec645eb9d2cdc3 100644 |
--- a/components/content_settings/core/common/content_settings_pattern.cc |
+++ b/components/content_settings/core/common/content_settings_pattern.cc |
@@ -21,6 +21,15 @@ namespace { |
// The component supports only one scheme for simplicity. |
const char* non_port_non_domain_wildcard_scheme = NULL; |
+const char* const kSchemeNames[] = { |
+ "wildcard", |
+ url::kHttpScheme, |
+ url::kHttpsScheme, |
+ url::kFileScheme, |
+ "chrome-extension", |
+ "other", |
+}; |
+ |
std::string GetDefaultPort(const std::string& scheme) { |
if (scheme == url::kHttpScheme) |
return "80"; |
@@ -590,6 +599,18 @@ std::string ContentSettingsPattern::ToString() const { |
return std::string(); |
} |
+ContentSettingsPattern::SchemeType ContentSettingsPattern::GetScheme() const { |
+ if (parts_.is_scheme_wildcard) |
+ return SCHEME_WILDCARD; |
+ |
+ for (int i = 1; i < SCHEME_MAX - 1; ++i) { |
msramek
2016/08/09 10:47:43
We're iterating over kSchemeNames, so I would spec
lshang
2016/08/10 04:32:35
Done. Good advice!
|
+ if (parts_.scheme == kSchemeNames[i]) { |
msramek
2016/08/09 10:47:43
nit: No braces needed for a one-line for() :)
lshang
2016/08/10 04:32:35
Done.
|
+ return static_cast<SchemeType>(i); |
+ } |
+ } |
+ return SCHEME_OTHER; |
+} |
+ |
ContentSettingsPattern::Relation ContentSettingsPattern::Compare( |
const ContentSettingsPattern& other) const { |
// Two invalid patterns are identical in the way they behave. They don't match |