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

Unified Diff: components/content_settings/core/browser/host_content_settings_map.cc

Issue 1849673002: Add metrics for user manually added exceptions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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/browser/host_content_settings_map.cc
diff --git a/components/content_settings/core/browser/host_content_settings_map.cc b/components/content_settings/core/browser/host_content_settings_map.cc
index 978aff41c2b478be224d5ca13d801825741151ce..8a7585bfca5a8ab6b59c31a7c177b14530393b9c 100644
--- a/components/content_settings/core/browser/host_content_settings_map.cc
+++ b/components/content_settings/core/browser/host_content_settings_map.cc
@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/macros.h"
+#include "base/metrics/histogram.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -168,6 +169,8 @@ HostContentSettingsMap::HostContentSettingsMap(PrefService* prefs,
content_settings_providers_[DEFAULT_PROVIDER] = default_provider;
MigrateOldSettings();
+
+ RecordNumberOfExceptions();
}
// static
@@ -487,6 +490,30 @@ void HostContentSettingsMap::MigrateOldSettings() {
}
}
+void HostContentSettingsMap::RecordNumberOfExceptions() {
+ for (const content_settings::WebsiteSettingsInfo* info :
+ *content_settings::WebsiteSettingsRegistry::GetInstance()) {
+ ContentSettingsType content_type = info->type();
+ const std::string type_name = info->name();
+
+ ContentSettingsForOneType settings;
+ GetSettingsForOneType(content_type, std::string(), &settings);
+ size_t num_exceptions = 0;
+ for (const ContentSettingPatternSource& setting_entry : settings) {
+ if (setting_entry.source == "preference")
+ ++num_exceptions;
+ }
+
+ std::string histogram_name =
+ "ContentSettings.Exceptions." + type_name;
+
+ base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet(
+ histogram_name, 1, 1000, 30,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ histogram_pointer->Add(num_exceptions);
+ }
+}
+
ContentSetting HostContentSettingsMap::GetContentSettingAndMaybeUpdateLastUsage(
const GURL& primary_url,
const GURL& secondary_url,
« no previous file with comments | « components/content_settings/core/browser/host_content_settings_map.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698