Chromium Code Reviews| 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..5be96ff1b4c96ee60226ee595b4fd99e05fdbe45 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_macros.h" |
|
Ilya Sherman
2016/04/20 00:15:42
nit: Since you're not using the macros, please inc
lshang
2016/04/20 05:24:02
Done. Thanks for reminding!
|
| #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.NumberOfSingleTypeExceptions." + 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, |