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" |
11 #include "chrome/browser/permissions/permission_request.h" | 11 #include "chrome/browser/permissions/permission_request.h" |
12 #include "components/content_settings/core/common/content_settings.h" | 12 #include "components/content_settings/core/common/content_settings.h" |
13 #include "components/content_settings/core/common/content_settings_types.h" | 13 #include "components/content_settings/core/common/content_settings_types.h" |
14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
15 | 15 |
16 class Profile; | 16 class Profile; |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 enum class PermissionType; | 19 enum class PermissionType; |
20 } // namespace content | 20 } // namespace content |
21 | 21 |
22 enum class PermissionSourceUI; | 22 enum class PermissionSourceUI; |
| 23 enum class PermissionStatusSource; |
23 | 24 |
24 // This enum backs a UMA histogram, so it must be treated as append-only. | 25 // This enum backs a UMA histogram, so it must be treated as append-only. |
25 enum class PermissionAction { | 26 enum class PermissionAction { |
26 GRANTED = 0, | 27 GRANTED = 0, |
27 DENIED = 1, | 28 DENIED = 1, |
28 DISMISSED = 2, | 29 DISMISSED = 2, |
29 IGNORED = 3, | 30 IGNORED = 3, |
30 REVOKED = 4, | 31 REVOKED = 4, |
31 REENABLED = 5, | 32 REENABLED = 5, |
32 REQUESTED = 6, | 33 REQUESTED = 6, |
(...skipping 26 matching lines...) Expand all Loading... |
59 // to remove the usage in PermissionUmaUtil, which uses PermissionType as a | 60 // to remove the usage in PermissionUmaUtil, which uses PermissionType as a |
60 // histogram value to count permission request metrics. | 61 // histogram value to count permission request metrics. |
61 static bool GetPermissionType(ContentSettingsType type, | 62 static bool GetPermissionType(ContentSettingsType type, |
62 content::PermissionType* out); | 63 content::PermissionType* out); |
63 | 64 |
64 // Checks whether the given ContentSettingsType is a permission. Use this | 65 // Checks whether the given ContentSettingsType is a permission. Use this |
65 // to determine whether a specific ContentSettingsType is supported by the | 66 // to determine whether a specific ContentSettingsType is supported by the |
66 // PermissionManager. | 67 // PermissionManager. |
67 static bool IsPermission(ContentSettingsType type); | 68 static bool IsPermission(ContentSettingsType type); |
68 | 69 |
| 70 // Converts a content_settings::SettingSource to a PermissionStatusSource. |
| 71 static PermissionStatusSource ConvertSettingSourceToPermissionStatusSource( |
| 72 content_settings::SettingSource source); |
| 73 |
69 static bool ShouldShowPersistenceToggle(ContentSettingsType type); | 74 static bool ShouldShowPersistenceToggle(ContentSettingsType type); |
70 | 75 |
71 // A scoped class that will check the current resolved content setting on | 76 // A scoped class that will check the current resolved content setting on |
72 // construction and report a revocation metric accordingly if the revocation | 77 // construction and report a revocation metric accordingly if the revocation |
73 // condition is met (from ALLOW to something else). | 78 // condition is met (from ALLOW to something else). |
74 class ScopedRevocationReporter { | 79 class ScopedRevocationReporter { |
75 public: | 80 public: |
76 ScopedRevocationReporter(Profile* profile, | 81 ScopedRevocationReporter(Profile* profile, |
77 const GURL& primary_url, | 82 const GURL& primary_url, |
78 const GURL& secondary_url, | 83 const GURL& secondary_url, |
(...skipping 15 matching lines...) Expand all Loading... |
94 ContentSettingsType content_type_; | 99 ContentSettingsType content_type_; |
95 PermissionSourceUI source_ui_; | 100 PermissionSourceUI source_ui_; |
96 bool is_initially_allowed_; | 101 bool is_initially_allowed_; |
97 }; | 102 }; |
98 | 103 |
99 private: | 104 private: |
100 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil); | 105 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil); |
101 }; | 106 }; |
102 | 107 |
103 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ | 108 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ |
OLD | NEW |