Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 static std::string GetPermissionString(content::PermissionType); | |
|
raymes
2017/02/07 04:46:15
nit: add a TODO to remove this version of the func
Timothy Loh
2017/02/08 04:01:06
Done, I think we can remove this when we add MIDI
| |
| 47 | 44 |
| 48 // Return the stringified version of the PermissionType enum that Safe | 45 // Return the stringified version of the ContentSettingsTypeType enum that |
|
raymes
2017/02/07 04:46:15
nit: ContentSettingsType
Timothy Loh
2017/02/08 04:01:06
Done.
| |
| 49 // Browsing uses for the API Blacklist. | 46 // Safe Browsing uses for the API Blacklist. |
| 50 static std::string ConvertPermissionTypeToSafeBrowsingName( | 47 static std::string ConvertContentSettingsTypeToSafeBrowsingName( |
| 51 const content::PermissionType& permission_type); | 48 ContentSettingsType permission); |
| 52 | 49 |
| 53 // Returns the request type corresponding to a permission type. | 50 // Returns the request type corresponding to a permission type. |
| 54 static PermissionRequestType GetRequestType(content::PermissionType type); | 51 static PermissionRequestType GetRequestType(ContentSettingsType permission); |
| 55 | 52 |
| 56 // Returns the gesture type corresponding to whether a permission request is | 53 // Returns the gesture type corresponding to whether a permission request is |
| 57 // made with or without a user gesture. | 54 // made with or without a user gesture. |
| 58 static PermissionRequestGestureType GetGestureType(bool user_gesture); | 55 static PermissionRequestGestureType GetGestureType(bool user_gesture); |
| 59 | 56 |
| 60 // Limited conversion of ContentSettingsType to PermissionType. Intended for | 57 // Limited conversion of ContentSettingsType to PermissionType. Returns true |
| 61 // recording Permission UMA metrics from areas of the codebase which have not | 58 // if the conversion was performed. |
| 62 // yet been converted to PermissionType. Returns true if the conversion was | |
| 63 // performed. | |
| 64 // TODO(tsergeant): Remove this function once callsites operate on | |
| 65 // PermissionType directly. | |
|
raymes
2017/02/07 04:46:15
nit: leave a TODO to remove this
Timothy Loh
2017/02/08 04:01:06
Done.
| |
| 66 static bool GetPermissionType(ContentSettingsType type, | 59 static bool GetPermissionType(ContentSettingsType type, |
| 67 content::PermissionType* out); | 60 content::PermissionType* out); |
| 68 | 61 |
| 69 static bool ShouldShowPersistenceToggle(); | 62 static bool ShouldShowPersistenceToggle(); |
| 70 | 63 |
| 71 // A scoped class that will check the current resolved content setting on | 64 // A scoped class that will check the current resolved content setting on |
| 72 // construction and report a revocation metric accordingly if the revocation | 65 // construction and report a revocation metric accordingly if the revocation |
| 73 // condition is met (from ALLOW to something else). | 66 // condition is met (from ALLOW to something else). |
| 74 class ScopedRevocationReporter { | 67 class ScopedRevocationReporter { |
| 75 public: | 68 public: |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 94 ContentSettingsType content_type_; | 87 ContentSettingsType content_type_; |
| 95 PermissionSourceUI source_ui_; | 88 PermissionSourceUI source_ui_; |
| 96 bool is_initially_allowed_; | 89 bool is_initially_allowed_; |
| 97 }; | 90 }; |
| 98 | 91 |
| 99 private: | 92 private: |
| 100 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil); | 93 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil); |
| 101 }; | 94 }; |
| 102 | 95 |
| 103 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ | 96 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ |
| OLD | NEW |