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

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

Issue 2675483002: Replace PermissionType in chrome/ with ContentSettingsType (Closed)
Patch Set: rebase Created 3 years, 10 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"
(...skipping 17 matching lines...) Expand all
28 DISMISSED = 2, 28 DISMISSED = 2,
29 IGNORED = 3, 29 IGNORED = 3,
30 REVOKED = 4, 30 REVOKED = 4,
31 REENABLED = 5, 31 REENABLED = 5,
32 REQUESTED = 6, 32 REQUESTED = 6,
33 33
34 // Always keep this at the end. 34 // Always keep this at the end.
35 PERMISSION_ACTION_NUM, 35 PERMISSION_ACTION_NUM,
36 }; 36 };
37 37
38 struct PermissionTypeHash {
39 std::size_t operator()(const content::PermissionType& type) const;
40 };
41
42 // A utility class for permissions. 38 // A utility class for permissions.
43 class PermissionUtil { 39 class PermissionUtil {
44 public: 40 public:
45 // Returns the permission string for the given PermissionType. 41 // Returns the permission string for the given permission.
46 static std::string GetPermissionString(content::PermissionType permission); 42 static std::string GetPermissionString(ContentSettingsType);
43 // TODO(timloh): Remove this function when possible.
raymes 2017/02/09 00:39:57 nit: Same here and below, "when possible" is too v
Timothy Loh 2017/02/10 07:25:38 Done.
44 static std::string GetPermissionString(content::PermissionType);
47 45
48 // Return the stringified version of the PermissionType enum that Safe 46 // Return the stringified version of the ContentSettingsType enum that
49 // Browsing uses for the API Blacklist. 47 // Safe Browsing uses for the API Blacklist.
50 static std::string ConvertPermissionTypeToSafeBrowsingName( 48 static std::string ConvertContentSettingsTypeToSafeBrowsingName(
51 const content::PermissionType& permission_type); 49 ContentSettingsType permission);
52 50
53 // Returns the request type corresponding to a permission type. 51 // Returns the request type corresponding to a permission type.
54 static PermissionRequestType GetRequestType(content::PermissionType type); 52 static PermissionRequestType GetRequestType(ContentSettingsType permission);
55 53
56 // Returns the gesture type corresponding to whether a permission request is 54 // Returns the gesture type corresponding to whether a permission request is
57 // made with or without a user gesture. 55 // made with or without a user gesture.
58 static PermissionRequestGestureType GetGestureType(bool user_gesture); 56 static PermissionRequestGestureType GetGestureType(bool user_gesture);
59 57
60 // Limited conversion of ContentSettingsType to PermissionType. Intended for 58 // Limited conversion of ContentSettingsType to PermissionType. Returns true
61 // recording Permission UMA metrics from areas of the codebase which have not 59 // if the conversion was performed.
62 // yet been converted to PermissionType. Returns true if the conversion was 60 // TODO(timloh): We shouldn't need this, remove this function when possible.
63 // performed.
64 // TODO(tsergeant): Remove this function once callsites operate on
65 // PermissionType directly.
66 static bool GetPermissionType(ContentSettingsType type, 61 static bool GetPermissionType(ContentSettingsType type,
67 content::PermissionType* out); 62 content::PermissionType* out);
68 63
69 static bool ShouldShowPersistenceToggle(); 64 static bool ShouldShowPersistenceToggle();
70 65
71 // A scoped class that will check the current resolved content setting on 66 // A scoped class that will check the current resolved content setting on
72 // construction and report a revocation metric accordingly if the revocation 67 // construction and report a revocation metric accordingly if the revocation
73 // condition is met (from ALLOW to something else). 68 // condition is met (from ALLOW to something else).
74 class ScopedRevocationReporter { 69 class ScopedRevocationReporter {
75 public: 70 public:
(...skipping 18 matching lines...) Expand all
94 ContentSettingsType content_type_; 89 ContentSettingsType content_type_;
95 PermissionSourceUI source_ui_; 90 PermissionSourceUI source_ui_;
96 bool is_initially_allowed_; 91 bool is_initially_allowed_;
97 }; 92 };
98 93
99 private: 94 private:
100 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil); 95 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil);
101 }; 96 };
102 97
103 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ 98 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698