Chromium Code Reviews| Index: chrome/browser/permissions/permission_util.cc |
| diff --git a/chrome/browser/permissions/permission_util.cc b/chrome/browser/permissions/permission_util.cc |
| index d4369c4609207aa11728227c4ac19e1b48e2f388..4a84ba9ddac8939442c6b4c751cc3f7eae97a89a 100644 |
| --- a/chrome/browser/permissions/permission_util.cc |
| +++ b/chrome/browser/permissions/permission_util.cc |
| @@ -5,8 +5,12 @@ |
| #include "chrome/browser/permissions/permission_util.h" |
| #include "base/logging.h" |
| +#include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| +#include "chrome/browser/permissions/permission_uma_util.h" |
| +#include "components/content_settings/core/browser/host_content_settings_map.h" |
| #include "content/public/browser/permission_type.h" |
| + |
|
Bernhard Bauer
2016/03/22 10:13:29
Nit: This empty line is unnecessary.
tsergeant
2016/03/22 23:55:20
Done.
|
| using content::PermissionType; |
| // The returned strings must match the RAPPOR metrics in rappor.xml, |
| @@ -69,3 +73,32 @@ bool PermissionUtil::GetPermissionType(ContentSettingsType type, |
| } |
| return true; |
| } |
| + |
| +bool PermissionUtil::SetContentSettingRecordRevocation( |
| + Profile* profile, |
| + const GURL& primary_url, |
| + const GURL& secondary_url, |
| + ContentSettingsType content_type, |
| + std::string resource_identifier, |
| + ContentSetting setting) { |
| + HostContentSettingsMap* map = |
| + HostContentSettingsMapFactory::GetForProfile(profile); |
| + ContentSetting previous_value = map->GetContentSetting( |
| + primary_url, secondary_url, content_type, resource_identifier); |
| + |
| + map->SetContentSettingDefaultScope(primary_url, secondary_url, content_type, |
| + resource_identifier, setting); |
| + |
| + ContentSetting final_value = map->GetContentSetting( |
| + primary_url, secondary_url, content_type, resource_identifier); |
| + |
| + if (previous_value == CONTENT_SETTING_ALLOW && |
| + final_value != CONTENT_SETTING_ALLOW) { |
| + PermissionType permission_type; |
| + if (PermissionUtil::GetPermissionType(content_type, &permission_type)) { |
| + PermissionUmaUtil::PermissionRevoked(permission_type, primary_url); |
| + return true; |
| + } |
| + } |
| + return false; |
| +} |