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 // Identifies the source or reason for a permission status being returned. This |
| 39 // enum backs an UMA histogram and must be treated as append-only. |
| 40 enum class PermissionStatusSource { |
| 41 // The reason for the status is not specified. |
| 42 UNSPECIFIED, |
| 43 |
| 44 // The status is the result of being blocked due to the user dismissing a |
| 45 // permission prompt multiple times. |
| 46 MULTIPLE_DISMISSALS, |
| 47 |
| 48 // The status is the result of being blocked because the permission is on the |
| 49 // safe browsing blacklist. |
| 50 SAFE_BROWSING_BLACKLIST, |
| 51 |
| 52 // The status is the result of being blocked by the permissions kill switch. |
| 53 KILL_SWITCH, |
| 54 }; |
| 55 |
| 56 struct PermissionResult { |
| 57 PermissionResult(ContentSetting content_setting, |
| 58 PermissionStatusSource source); |
| 59 ~PermissionResult(); |
| 60 |
| 61 ContentSetting content_setting; |
| 62 PermissionStatusSource source; |
| 63 }; |
| 64 |
38 // A utility class for permissions. | 65 // A utility class for permissions. |
39 class PermissionUtil { | 66 class PermissionUtil { |
40 public: | 67 public: |
41 // Returns the permission string for the given permission. | 68 // Returns the permission string for the given permission. |
42 static std::string GetPermissionString(ContentSettingsType); | 69 static std::string GetPermissionString(ContentSettingsType); |
43 | 70 |
44 // Return the stringified version of the ContentSettingsType enum that | 71 // Return the stringified version of the ContentSettingsType enum that |
45 // Safe Browsing uses for the API Blacklist. | 72 // Safe Browsing uses for the API Blacklist. |
46 static std::string ConvertContentSettingsTypeToSafeBrowsingName( | 73 static std::string ConvertContentSettingsTypeToSafeBrowsingName( |
47 ContentSettingsType permission); | 74 ContentSettingsType permission); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 ContentSettingsType content_type_; | 116 ContentSettingsType content_type_; |
90 PermissionSourceUI source_ui_; | 117 PermissionSourceUI source_ui_; |
91 bool is_initially_allowed_; | 118 bool is_initially_allowed_; |
92 }; | 119 }; |
93 | 120 |
94 private: | 121 private: |
95 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil); | 122 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil); |
96 }; | 123 }; |
97 | 124 |
98 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ | 125 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ |
OLD | NEW |