Commit b1c163ea authored by dschuyler's avatar dschuyler Committed by Commit bot

[MD settings] UMA and RevocationReporter in site settings

This CL adds UMA and Revocation reporting from site settings when a site
exception is added or removed. The goal is to match the behavior of the
old options.

BUG=718544

Review-Url: https://codereview.chromium.org/2861793005
Cr-Commit-Position: refs/heads/master@{#469561}
parent a11f72c8
...@@ -16,7 +16,10 @@ ...@@ -16,7 +16,10 @@
#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.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/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/profiles/profile.h"
#include "chrome/browser/ui/webui/site_settings_helper.h" #include "chrome/browser/ui/webui/site_settings_helper.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h" #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
...@@ -452,10 +455,10 @@ void SiteSettingsHandler::HandleGetExceptionList(const base::ListValue* args) { ...@@ -452,10 +455,10 @@ void SiteSettingsHandler::HandleGetExceptionList(const base::ListValue* args) {
void SiteSettingsHandler::HandleResetCategoryPermissionForOrigin( void SiteSettingsHandler::HandleResetCategoryPermissionForOrigin(
const base::ListValue* args) { const base::ListValue* args) {
CHECK_EQ(4U, args->GetSize()); CHECK_EQ(4U, args->GetSize());
std::string primary_pattern; std::string primary_pattern_string;
CHECK(args->GetString(0, &primary_pattern)); CHECK(args->GetString(0, &primary_pattern_string));
std::string secondary_pattern; std::string secondary_pattern_string;
CHECK(args->GetString(1, &secondary_pattern)); CHECK(args->GetString(1, &secondary_pattern_string));
std::string type; std::string type;
CHECK(args->GetString(2, &type)); CHECK(args->GetString(2, &type));
bool incognito; bool incognito;
...@@ -476,21 +479,32 @@ void SiteSettingsHandler::HandleResetCategoryPermissionForOrigin( ...@@ -476,21 +479,32 @@ void SiteSettingsHandler::HandleResetCategoryPermissionForOrigin(
HostContentSettingsMap* map = HostContentSettingsMap* map =
HostContentSettingsMapFactory::GetForProfile(profile); HostContentSettingsMapFactory::GetForProfile(profile);
map->SetContentSettingCustomScope(
ContentSettingsPattern::FromString(primary_pattern), ContentSettingsPattern primary_pattern =
secondary_pattern.empty() ? ContentSettingsPattern::FromString(primary_pattern_string);
ContentSettingsPattern::Wildcard() : ContentSettingsPattern secondary_pattern =
ContentSettingsPattern::FromString(secondary_pattern), secondary_pattern_string.empty()
content_type, "", CONTENT_SETTING_DEFAULT); ? 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( void SiteSettingsHandler::HandleSetCategoryPermissionForOrigin(
const base::ListValue* args) { const base::ListValue* args) {
CHECK_EQ(5U, args->GetSize()); CHECK_EQ(5U, args->GetSize());
std::string primary_pattern; std::string primary_pattern_string;
CHECK(args->GetString(0, &primary_pattern)); CHECK(args->GetString(0, &primary_pattern_string));
std::string secondary_pattern; // TODO(dschuyler): Review whether |secondary_pattern_string| should be used.
CHECK(args->GetString(1, &secondary_pattern)); std::string secondary_pattern_string;
CHECK(args->GetString(1, &secondary_pattern_string));
std::string type; std::string type;
CHECK(args->GetString(2, &type)); CHECK(args->GetString(2, &type));
std::string value; std::string value;
...@@ -515,12 +529,22 @@ void SiteSettingsHandler::HandleSetCategoryPermissionForOrigin( ...@@ -515,12 +529,22 @@ void SiteSettingsHandler::HandleSetCategoryPermissionForOrigin(
HostContentSettingsMap* map = HostContentSettingsMap* map =
HostContentSettingsMapFactory::GetForProfile(profile); HostContentSettingsMapFactory::GetForProfile(profile);
map->SetContentSettingCustomScope(
ContentSettingsPattern::FromString(primary_pattern), ContentSettingsPattern primary_pattern =
secondary_pattern.empty() ? ContentSettingsPattern::FromString(primary_pattern_string);
ContentSettingsPattern::Wildcard() : ContentSettingsPattern secondary_pattern =
ContentSettingsPattern::FromString(secondary_pattern), secondary_pattern_string.empty()
content_type, "", setting); ? 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, "", setting);
WebSiteSettingsUmaUtil::LogPermissionChange(content_type, setting);
} }
void SiteSettingsHandler::HandleGetSiteDetails( void SiteSettingsHandler::HandleGetSiteDetails(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment