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 // Anonymous namespace for internal constants. | |
19 namespace { | |
20 const char kGeolocationPermissionName[] = "Geolocation"; | |
21 const char kNotificationPermissionName[] = "Notifications"; | |
22 const char kMidiSysExnPermissionName[] = "MidiSysEx"; | |
23 const char kPushMessagingPermissionName[] = "PushMessaging"; | |
24 const char kDurableStoragePermissionName[] = "DurableStorage"; | |
25 const char kProtectedMediaPermissionName[] = "ProtectedMediaIdentifier"; | |
26 const char kAudioCapturePermissionName[] = "AudioCapture"; | |
27 const char kVideoCapturePermissionName[] = "VideoCapture"; | |
28 const char kMidiPermissionName[] = "Midi"; | |
29 const char kBackgroundSyncPermissionName[] = "BackgroundSync"; | |
30 const char kFlashPermissionName[] = "Flash"; | |
raymes
2017/01/24 05:15:17
Is it necessary to define these as constants?
meredithl
2017/01/24 23:20:21
Not since I've changed the conversion to return a
| |
31 } // namespace | |
32 | |
18 namespace content { | 33 namespace content { |
19 enum class PermissionType; | 34 enum class PermissionType; |
20 } // namespace content | 35 } // namespace content |
21 | 36 |
22 enum class PermissionSourceUI; | 37 enum class PermissionSourceUI; |
23 | 38 |
24 // This enum backs a UMA histogram, so it must be treated as append-only. | 39 // This enum backs a UMA histogram, so it must be treated as append-only. |
25 enum PermissionAction { | 40 enum PermissionAction { |
26 GRANTED = 0, | 41 GRANTED = 0, |
27 DENIED = 1, | 42 DENIED = 1, |
(...skipping 10 matching lines...) Expand all Loading... | |
38 struct PermissionTypeHash { | 53 struct PermissionTypeHash { |
39 std::size_t operator()(const content::PermissionType& type) const; | 54 std::size_t operator()(const content::PermissionType& type) const; |
40 }; | 55 }; |
41 | 56 |
42 // A utility class for permissions. | 57 // A utility class for permissions. |
43 class PermissionUtil { | 58 class PermissionUtil { |
44 public: | 59 public: |
45 // Returns the permission string for the given PermissionType. | 60 // Returns the permission string for the given PermissionType. |
46 static std::string GetPermissionString(content::PermissionType permission); | 61 static std::string GetPermissionString(content::PermissionType permission); |
47 | 62 |
63 // Converts between the stringified PermissionType enum that Safe Browsing | |
64 // returns to a content::PermissionType. | |
65 static content::PermissionType ConvertSafeBrowsingNameToPermissionType( | |
66 const std::string& sb_name); | |
67 | |
48 // Returns the request type corresponding to a permission type. | 68 // Returns the request type corresponding to a permission type. |
49 static PermissionRequestType GetRequestType(content::PermissionType type); | 69 static PermissionRequestType GetRequestType(content::PermissionType type); |
50 | 70 |
51 // Returns the gesture type corresponding to whether a permission request is | 71 // Returns the gesture type corresponding to whether a permission request is |
52 // made with or without a user gesture. | 72 // made with or without a user gesture. |
53 static PermissionRequestGestureType GetGestureType(bool user_gesture); | 73 static PermissionRequestGestureType GetGestureType(bool user_gesture); |
54 | 74 |
55 // Limited conversion of ContentSettingsType to PermissionType. Intended for | 75 // Limited conversion of ContentSettingsType to PermissionType. Intended for |
56 // recording Permission UMA metrics from areas of the codebase which have not | 76 // recording Permission UMA metrics from areas of the codebase which have not |
57 // yet been converted to PermissionType. Returns true if the conversion was | 77 // yet been converted to PermissionType. Returns true if the conversion was |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 ContentSettingsType content_type_; | 109 ContentSettingsType content_type_; |
90 PermissionSourceUI source_ui_; | 110 PermissionSourceUI source_ui_; |
91 bool is_initially_allowed_; | 111 bool is_initially_allowed_; |
92 }; | 112 }; |
93 | 113 |
94 private: | 114 private: |
95 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil); | 115 DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUtil); |
96 }; | 116 }; |
97 | 117 |
98 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ | 118 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ |
OLD | NEW |