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

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

Issue 2165733003: Add revocation reporter to permission util (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add-source-ui-to-permission-report
Patch Set: merge Created 4 years, 5 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.h
diff --git a/chrome/browser/permissions/permission_util.h b/chrome/browser/permissions/permission_util.h
index 9a43d1f2322b4c3173d0f81fba6afc73e6661494..6b8c32da05065323cf747a79d41c24fcac5f5245 100644
--- a/chrome/browser/permissions/permission_util.h
+++ b/chrome/browser/permissions/permission_util.h
@@ -18,6 +18,8 @@ namespace content {
enum class PermissionType;
} // namespace content
+enum class PermissionSourceUI;
+
struct PermissionTypeHash {
std::size_t operator()(const content::PermissionType& type) const;
};
@@ -37,22 +39,36 @@ class PermissionUtil {
static bool GetPermissionType(ContentSettingsType type,
content::PermissionType* out);
- // Helper method which proxies
- // HostContentSettingsMap::SetContentSettingDefaultScope(). Checks the content
- // setting value before and after the change to determine whether it has gone
- // from ALLOW to BLOCK or ASK, and records metrics accordingly. Should be
- // called from UI code when a user changes permissions for a particular origin
- // pair.
- // TODO(tsergeant): This is a temporary solution to begin gathering metrics.
- // We should integrate this better with the permissions layer. See
- // crbug.com/469221.
- static void SetContentSettingAndRecordRevocation(
- Profile* profile,
- const GURL& primary_url,
- const GURL& secondary_url,
- ContentSettingsType content_type,
- std::string resource_identifier,
- ContentSetting setting);
+ // A scoped class that will check the current resolved content setting on
+ // construction and report a revocation metric accordingly if the revocation
+ // condition is met (from ALLOW to something else).
+ class RevocationReporter {
+ public:
+ RevocationReporter(Profile* profile,
+ const GURL& primary_url,
+ const GURL& secondary_url,
+ ContentSettingsType content_type,
+ std::string resource_identifier,
raymes 2016/07/21 23:08:01 nit: do we need to pass this in?
+ PermissionSourceUI source_ui);
+
+ RevocationReporter(Profile* profile,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
+ ContentSettingsType content_type,
+ std::string resource_identifier,
+ PermissionSourceUI source_ui);
+
+ ~RevocationReporter();
+
+ private:
+ Profile* profile_;
+ const GURL& primary_url_;
+ const GURL& secondary_url_;
+ ContentSettingsType content_type_;
+ const std::string resource_identifier_;
+ PermissionSourceUI source_ui_;
+ bool is_initially_allowed_;
+ };
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil);

Powered by Google App Engine
This is Rietveld 408576698