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..5d1610b532acc45b183236318107359d5e92762f 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" |
| #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(); |
| + |
| + CollectExceptionNumberUma(); |
| } |
| // static |
| @@ -487,6 +490,36 @@ void HostContentSettingsMap::MigrateOldSettings() { |
| } |
| } |
| +void HostContentSettingsMap::CollectExceptionNumberUma() { |
| + std::map<ContentSettingsType, std::string> type_info_map; |
| + for (const content_settings::ContentSettingsInfo* info : |
| + *content_settings::ContentSettingsRegistry::GetInstance()) |
| + type_info_map[info->website_settings_info()->type()] = |
| + info->website_settings_info()->name(); |
|
raymes
2016/04/14 06:21:59
I think we can just iterate through WebsiteSetting
lshang
2016/04/19 02:51:53
Done.
|
| + |
| + for (const content_settings::WebsiteSettingsInfo* info : |
| + *content_settings::WebsiteSettingsRegistry::GetInstance()) |
| + type_info_map[info->type()] = info->name(); |
| + |
| + for (const auto& type_info : type_info_map) { |
| + ContentSettingsForOneType settings; |
| + GetSettingsForOneType(type_info.first, 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.NumberOfExceptions." + type_info.second; |
| + |
| + base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet( |
| + histogram_name, 0, 1000, 1001, |
|
raymes
2016/04/14 06:21:59
nit: I think the min should be 1. I'm not sure how
lshang
2016/04/19 02:51:53
Done.
I also changed the name to 'ContentSettings.
|
| + base::HistogramBase::kUmaTargetedHistogramFlag); |
| + histogram_pointer->Add(num_exceptions); |
| + } |
| +} |
| + |
| ContentSetting HostContentSettingsMap::GetContentSettingAndMaybeUpdateLastUsage( |
| const GURL& primary_url, |
| const GURL& secondary_url, |