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 NUM, | 35 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 | |
65 // A utility class for permissions. | 38 // A utility class for permissions. |
66 class PermissionUtil { | 39 class PermissionUtil { |
67 public: | 40 public: |
68 // Returns the permission string for the given permission. | 41 // Returns the permission string for the given permission. |
69 static std::string GetPermissionString(ContentSettingsType); | 42 static std::string GetPermissionString(ContentSettingsType); |
70 | 43 |
71 // Return the stringified version of the ContentSettingsType enum that | 44 // Return the stringified version of the ContentSettingsType enum that |
72 // Safe Browsing uses for the API Blacklist. | 45 // Safe Browsing uses for the API Blacklist. |
73 static std::string ConvertContentSettingsTypeToSafeBrowsingName( | 46 static std::string ConvertContentSettingsTypeToSafeBrowsingName( |
74 ContentSettingsType permission); | 47 ContentSettingsType permission); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 ContentSettingsType content_type_; | 89 ContentSettingsType content_type_; |
117 PermissionSourceUI source_ui_; | 90 PermissionSourceUI source_ui_; |
118 bool is_initially_allowed_; | 91 bool is_initially_allowed_; |
119 }; | 92 }; |
120 | 93 |
121 private: | 94 private: |
122 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil); | 95 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil); |
123 }; | 96 }; |
124 | 97 |
125 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ | 98 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ |
OLD | NEW |