Chromium Code Reviews| Index: chrome/browser/ui/webui/settings/site_settings_handler.cc |
| diff --git a/chrome/browser/ui/webui/settings/site_settings_handler.cc b/chrome/browser/ui/webui/settings/site_settings_handler.cc |
| index 0ee7196c03a557cacecc568352e983046c46fd94..4aa3a1df44cb76c76aa5d05643fc8b2cd04f1ae5 100644 |
| --- a/chrome/browser/ui/webui/settings/site_settings_handler.cc |
| +++ b/chrome/browser/ui/webui/settings/site_settings_handler.cc |
| @@ -16,7 +16,10 @@ |
| #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| #include "chrome/browser/chrome_notification_types.h" |
| #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| +#include "chrome/browser/content_settings/web_site_settings_uma_util.h" |
| #include "chrome/browser/permissions/chooser_context_base.h" |
| +#include "chrome/browser/permissions/permission_uma_util.h" |
| +#include "chrome/browser/permissions/permission_util.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/webui/site_settings_helper.h" |
| #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| @@ -452,10 +455,10 @@ void SiteSettingsHandler::HandleGetExceptionList(const base::ListValue* args) { |
| void SiteSettingsHandler::HandleResetCategoryPermissionForOrigin( |
| const base::ListValue* args) { |
| CHECK_EQ(4U, args->GetSize()); |
| - std::string primary_pattern; |
| - CHECK(args->GetString(0, &primary_pattern)); |
| - std::string secondary_pattern; |
| - CHECK(args->GetString(1, &secondary_pattern)); |
| + std::string primary_pattern_string; |
| + CHECK(args->GetString(0, &primary_pattern_string)); |
| + std::string secondary_pattern_string; |
| + CHECK(args->GetString(1, &secondary_pattern_string)); |
| std::string type; |
| CHECK(args->GetString(2, &type)); |
| bool incognito; |
| @@ -476,21 +479,32 @@ void SiteSettingsHandler::HandleResetCategoryPermissionForOrigin( |
| HostContentSettingsMap* map = |
| HostContentSettingsMapFactory::GetForProfile(profile); |
| - map->SetContentSettingCustomScope( |
| - ContentSettingsPattern::FromString(primary_pattern), |
| - secondary_pattern.empty() ? |
| - ContentSettingsPattern::Wildcard() : |
| - ContentSettingsPattern::FromString(secondary_pattern), |
| - content_type, "", CONTENT_SETTING_DEFAULT); |
| + |
| + ContentSettingsPattern primary_pattern = |
| + ContentSettingsPattern::FromString(primary_pattern_string); |
| + ContentSettingsPattern secondary_pattern = |
| + secondary_pattern_string.empty() |
| + ? ContentSettingsPattern::Wildcard() |
| + : ContentSettingsPattern::FromString(secondary_pattern_string); |
| + PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( |
| + profile, primary_pattern, secondary_pattern, content_type, |
| + PermissionSourceUI::SITE_SETTINGS); |
| + |
| + map->SetContentSettingCustomScope(primary_pattern, secondary_pattern, |
| + content_type, "", CONTENT_SETTING_DEFAULT); |
| + |
| + WebSiteSettingsUmaUtil::LogPermissionChange( |
| + content_type, ContentSetting::CONTENT_SETTING_DEFAULT); |
| } |
| void SiteSettingsHandler::HandleSetCategoryPermissionForOrigin( |
| const base::ListValue* args) { |
| CHECK_EQ(5U, args->GetSize()); |
| - std::string primary_pattern; |
| - CHECK(args->GetString(0, &primary_pattern)); |
| - std::string secondary_pattern; |
| - CHECK(args->GetString(1, &secondary_pattern)); |
| + std::string primary_pattern_string; |
| + CHECK(args->GetString(0, &primary_pattern_string)); |
| + // TODO(dschuyler): |secondary_pattern_unused| is not used, remove it. |
|
Dan Beam
2017/05/04 19:37:45
why did the old code use it but the new one doesn'
dschuyler
2017/05/04 21:09:21
The reasoning was based on the JS sending an empty
|
| + std::string secondary_pattern_unused; |
| + CHECK(args->GetString(1, &secondary_pattern_unused)); |
| std::string type; |
| CHECK(args->GetString(2, &type)); |
| std::string value; |
| @@ -515,12 +529,19 @@ void SiteSettingsHandler::HandleSetCategoryPermissionForOrigin( |
| HostContentSettingsMap* map = |
| HostContentSettingsMapFactory::GetForProfile(profile); |
| - map->SetContentSettingCustomScope( |
| - ContentSettingsPattern::FromString(primary_pattern), |
| - secondary_pattern.empty() ? |
| - ContentSettingsPattern::Wildcard() : |
| - ContentSettingsPattern::FromString(secondary_pattern), |
| - content_type, "", setting); |
| + |
| + ContentSettingsPattern primary_pattern = |
| + ContentSettingsPattern::FromString(primary_pattern_string); |
| + |
| + PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( |
| + profile, primary_pattern, ContentSettingsPattern::Wildcard(), |
| + content_type, PermissionSourceUI::SITE_SETTINGS); |
| + |
| + map->SetContentSettingCustomScope(primary_pattern, |
| + ContentSettingsPattern::Wildcard(), |
| + content_type, "", setting); |
| + |
| + WebSiteSettingsUmaUtil::LogPermissionChange(content_type, setting); |
| } |
| void SiteSettingsHandler::HandleGetSiteDetails( |