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

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: Rebase 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..b63b2e084485bf9b157a7809fd4a0e049d34af81 100644
--- a/chrome/browser/permissions/permission_util.h
+++ b/chrome/browser/permissions/permission_util.h
@@ -10,14 +10,16 @@
#include "base/macros.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
+#include "url/gurl.h"
-class GURL;
class Profile;
namespace content {
enum class PermissionType;
} // namespace content
+enum class PermissionSourceUI;
+
struct PermissionTypeHash {
std::size_t operator()(const content::PermissionType& type) const;
};
@@ -37,22 +39,27 @@ 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 ScopedRevocationReporter {
+ public:
+ ScopedRevocationReporter(Profile* profile,
+ const GURL& primary_url,
+ const GURL& secondary_url,
+ ContentSettingsType content_type,
+ PermissionSourceUI source_ui);
+
+ ~ScopedRevocationReporter();
+
+ private:
+ Profile* profile_;
+ const GURL primary_url_;
+ const GURL secondary_url_;
+ ContentSettingsType content_type_;
+ PermissionSourceUI source_ui_;
+ bool is_initially_allowed_;
+ };
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil);
« no previous file with comments | « chrome/browser/android/preferences/website_preference_bridge.cc ('k') | chrome/browser/permissions/permission_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698