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..348892e5d1523be701aa21a356b6aab3c60cb8c3 100644 |
--- a/components/content_settings/core/common/content_settings_pattern.cc |
+++ b/components/content_settings/core/common/content_settings_pattern.cc |
@@ -21,6 +21,19 @@ namespace { |
// The component supports only one scheme for simplicity. |
const char* non_port_non_domain_wildcard_scheme = NULL; |
+// Keep it consistent with enum SchemeType in content_settings_pattern.h. |
+const char* const kSchemeNames[] = { |
+ "wildcard", |
+ "other", |
+ url::kHttpScheme, |
+ url::kHttpsScheme, |
+ url::kFileScheme, |
+ "chrome-extension", |
+}; |
+ |
+static_assert(arraysize(kSchemeNames) == ContentSettingsPattern::SCHEME_MAX, |
+ "kSchemeNames should have SCHEME_MAX elements"); |
+ |
std::string GetDefaultPort(const std::string& scheme) { |
if (scheme == url::kHttpScheme) |
return "80"; |
@@ -590,6 +603,17 @@ std::string ContentSettingsPattern::ToString() const { |
return std::string(); |
} |
+ContentSettingsPattern::SchemeType ContentSettingsPattern::GetScheme() const { |
+ if (parts_.is_scheme_wildcard) |
+ return SCHEME_WILDCARD; |
+ |
+ for (size_t i = 2; i < arraysize(kSchemeNames); ++i) { |
+ if (parts_.scheme == kSchemeNames[i]) |
+ 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 |