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. |
kcarattini
2016/07/26 03:49:07
@tseargeant, I take it you consider this TODO comp
tsergeant
2016/07/26 03:58:53
Yup, I think this is a better long-term solution,
|
- // 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); |