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

Side by Side Diff: chrome/browser/permissions/permission_util.h

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: Rebase Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "components/content_settings/core/common/content_settings.h"
11 #include "components/content_settings/core/common/content_settings_types.h" 12 #include "components/content_settings/core/common/content_settings_types.h"
12 13
14 class GURL;
15 class Profile;
16
13 namespace content { 17 namespace content {
14 enum class PermissionType; 18 enum class PermissionType;
15 } // namespace content 19 } // namespace content
16 20
17 // A utility class for permissions. 21 // A utility class for permissions.
18 class PermissionUtil { 22 class PermissionUtil {
19 public: 23 public:
20 // Returns the permission string for the given PermissionType. 24 // Returns the permission string for the given PermissionType.
21 static std::string GetPermissionString(content::PermissionType permission); 25 static std::string GetPermissionString(content::PermissionType permission);
22 26
23 // Limited conversion of ContentSettingsType to PermissionType. Intended for 27 // Limited conversion of ContentSettingsType to PermissionType. Intended for
24 // recording Permission UMA metrics from areas of the codebase which have not 28 // recording Permission UMA metrics from areas of the codebase which have not
25 // yet been converted to PermissionType. Returns true if the conversion was 29 // yet been converted to PermissionType. Returns true if the conversion was
26 // performed. 30 // performed.
27 // TODO(tsergeant): Remove this function once callsites operate on 31 // TODO(tsergeant): Remove this function once callsites operate on
28 // PermissionType directly. 32 // PermissionType directly.
29 static bool GetPermissionType(ContentSettingsType type, 33 static bool GetPermissionType(ContentSettingsType type,
30 content::PermissionType* out); 34 content::PermissionType* out);
31 35
36 // Helper method which proxies
37 // HostContentSettingsMap::SetContentSettingDefaultScope(). Checks the content
38 // setting value before and after the change to determine whether it has gone
39 // from ALLOW to BLOCK or ASK, and records metrics accordingly. Should be
40 // called from UI code when a user changes permissions for a particular origin
41 // pair.
42 // TODO(tsergeant): This is a temporary solution to begin gathering metrics.
43 // We should integrate this better with the permissions layer. See
44 // crbug.com/469221.
45 static void SetContentSettingAndRecordRevocation(
46 Profile* profile,
47 const GURL& primary_url,
48 const GURL& secondary_url,
49 ContentSettingsType content_type,
50 std::string resource_identifier,
51 ContentSetting setting);
52
32 private: 53 private:
33 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil); 54 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil);
34 }; 55 };
35 56
36 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ 57 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_uma_util.cc ('k') | chrome/browser/permissions/permission_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698