Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1568)

Unified Diff: chrome/browser/permissions/permission_util.cc

Issue 1803973002: Content Settings: Add RevocationObserver to measure when permissions are revoked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rewrite patch in permissions layer Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+}

Powered by Google App Engine
This is Rietveld 408576698