Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Unified Diff: components/content_settings/core/common/content_settings_pattern.cc

Issue 2226643002: Add metrics for schemes of content setting exceptions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: collect data in one run Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d6246d21acd90cfbddd24f1a277443ba615d3642 100644
--- a/components/content_settings/core/common/content_settings_pattern.cc
+++ b/components/content_settings/core/common/content_settings_pattern.cc
@@ -21,6 +21,14 @@ namespace {
// The component supports only one scheme for simplicity.
const char* non_port_non_domain_wildcard_scheme = NULL;
+const char* const kSchemeNames[] = {
+ "unknown",
msramek 2016/08/08 17:33:12 I would add kFileSystemScheme as well. It seems to
lshang 2016/08/09 01:56:40 I considered this scheme, but as you can see in th
msramek 2016/08/09 10:47:43 Acknowledged.
+ url::kHttpScheme,
+ url::kHttpsScheme,
+ url::kFileScheme,
+ "chrome-extension",
+};
+
std::string GetDefaultPort(const std::string& scheme) {
if (scheme == url::kHttpScheme)
return "80";
@@ -590,6 +598,19 @@ std::string ContentSettingsPattern::ToString() const {
return std::string();
}
+ContentSettingsPattern::SchemeType ContentSettingsPattern::GetScheme() const {
+ if (parts_.is_scheme_wildcard)
+ return SCHEME_UNKNOWN;
msramek 2016/08/08 17:33:12 I would leave UNKNOWN for something that is really
lshang 2016/08/09 01:56:40 Done. Good point!
+ SchemeType scheme = SCHEME_UNKNOWN;
+ for (int i = 1; i < SCHEME_MAX; ++i) {
+ if (parts_.scheme == kSchemeNames[i]) {
+ scheme = static_cast<SchemeType>(i);
+ break;
+ }
+ }
+ return scheme;
msramek 2016/08/08 17:33:12 Optional style suggestion: Consider returning the
lshang 2016/08/09 01:56:40 Done. And I also changed UNKNOWN to OTHER, which I
+}
+
ContentSettingsPattern::Relation ContentSettingsPattern::Compare(
const ContentSettingsPattern& other) const {
// Two invalid patterns are identical in the way they behave. They don't match

Powered by Google App Engine
This is Rietveld 408576698