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 CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_ |
6 #define CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_ |
7 | 7 |
8 #include "components/permissions/permission_status.mojom.h" | |
9 #include "content/common/content_export.h" | 8 #include "content/common/content_export.h" |
| 9 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat
us.mojom.h" |
10 | 10 |
11 class GURL; | 11 class GURL; |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 enum class PermissionType; | 14 enum class PermissionType; |
15 class RenderFrameHost; | 15 class RenderFrameHost; |
16 | 16 |
17 // This class allows the content layer to manipulate permissions. It has to be | 17 // This class allows the content layer to manipulate permissions. It has to be |
18 // implemented by the embedder which ultimately handles the permission | 18 // implemented by the embedder which ultimately handles the permission |
19 // management for the content layer. | 19 // management for the content layer. |
(...skipping 10 matching lines...) Expand all Loading... |
30 // When the permission request is handled, whether it failed, timed out or | 30 // When the permission request is handled, whether it failed, timed out or |
31 // succeeded, the |callback| will be run. | 31 // succeeded, the |callback| will be run. |
32 // Returns a request id which can be used to cancel the permission (see | 32 // Returns a request id which can be used to cancel the permission (see |
33 // CancelPermissionRequest). This can be kNoPendingOperation if | 33 // CancelPermissionRequest). This can be kNoPendingOperation if |
34 // there is no further need to cancel the permission in which case |callback| | 34 // there is no further need to cancel the permission in which case |callback| |
35 // was invoked. | 35 // was invoked. |
36 virtual int RequestPermission( | 36 virtual int RequestPermission( |
37 PermissionType permission, | 37 PermissionType permission, |
38 RenderFrameHost* render_frame_host, | 38 RenderFrameHost* render_frame_host, |
39 const GURL& requesting_origin, | 39 const GURL& requesting_origin, |
40 const base::Callback<void(permissions::mojom::PermissionStatus)>& | 40 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) = 0; |
41 callback) = 0; | |
42 | 41 |
43 // Requests multiple permissions on behalf of a frame identified by | 42 // Requests multiple permissions on behalf of a frame identified by |
44 // render_frame_host. | 43 // render_frame_host. |
45 // When the permission request is handled, whether it failed, timed out or | 44 // When the permission request is handled, whether it failed, timed out or |
46 // succeeded, the |callback| will be run. The order of statuses in the | 45 // succeeded, the |callback| will be run. The order of statuses in the |
47 // returned vector will correspond to the order of requested permission | 46 // returned vector will correspond to the order of requested permission |
48 // types. | 47 // types. |
49 // Returns a request id which can be used to cancel the request (see | 48 // Returns a request id which can be used to cancel the request (see |
50 // CancelPermissionRequest). This can be kNoPendingOperation if | 49 // CancelPermissionRequest). This can be kNoPendingOperation if |
51 // there is no further need to cancel the permission in which case |callback| | 50 // there is no further need to cancel the permission in which case |callback| |
52 // was invoked. | 51 // was invoked. |
53 virtual int RequestPermissions( | 52 virtual int RequestPermissions( |
54 const std::vector<PermissionType>& permission, | 53 const std::vector<PermissionType>& permission, |
55 RenderFrameHost* render_frame_host, | 54 RenderFrameHost* render_frame_host, |
56 const GURL& requesting_origin, | 55 const GURL& requesting_origin, |
57 const base::Callback< | 56 const base::Callback<void( |
58 void(const std::vector<permissions::mojom::PermissionStatus>&)>& | 57 const std::vector<blink::mojom::PermissionStatus>&)>& callback) = 0; |
59 callback) = 0; | |
60 | 58 |
61 // Cancels a previous permission request specified by |request_id|. Cancelling | 59 // Cancels a previous permission request specified by |request_id|. Cancelling |
62 // an already cancelled request or providing the |request_id| | 60 // an already cancelled request or providing the |request_id| |
63 // kNoPendingOperation is a no-op. | 61 // kNoPendingOperation is a no-op. |
64 virtual void CancelPermissionRequest(int request_id) = 0; | 62 virtual void CancelPermissionRequest(int request_id) = 0; |
65 | 63 |
66 // Returns the permission status of a given requesting_origin/embedding_origin | 64 // Returns the permission status of a given requesting_origin/embedding_origin |
67 // tuple. This is not taking a RenderFrameHost because the call might happen | 65 // tuple. This is not taking a RenderFrameHost because the call might happen |
68 // outside of a frame context. | 66 // outside of a frame context. |
69 virtual permissions::mojom::PermissionStatus GetPermissionStatus( | 67 virtual blink::mojom::PermissionStatus GetPermissionStatus( |
70 PermissionType permission, | 68 PermissionType permission, |
71 const GURL& requesting_origin, | 69 const GURL& requesting_origin, |
72 const GURL& embedding_origin) = 0; | 70 const GURL& embedding_origin) = 0; |
73 | 71 |
74 // Sets the permission back to its default for the requesting_origin/ | 72 // Sets the permission back to its default for the requesting_origin/ |
75 // embedding_origin tuple. | 73 // embedding_origin tuple. |
76 virtual void ResetPermission(PermissionType permission, | 74 virtual void ResetPermission(PermissionType permission, |
77 const GURL& requesting_origin, | 75 const GURL& requesting_origin, |
78 const GURL& embedding_origin) = 0; | 76 const GURL& embedding_origin) = 0; |
79 | 77 |
80 // Registers a permission usage. | 78 // Registers a permission usage. |
81 // TODO(mlamouri): see if we can remove this from the PermissionManager. | 79 // TODO(mlamouri): see if we can remove this from the PermissionManager. |
82 virtual void RegisterPermissionUsage(PermissionType permission, | 80 virtual void RegisterPermissionUsage(PermissionType permission, |
83 const GURL& requesting_origin, | 81 const GURL& requesting_origin, |
84 const GURL& embedding_origin) = 0; | 82 const GURL& embedding_origin) = 0; |
85 | 83 |
86 // Runs the given |callback| whenever the |permission| associated with the | 84 // Runs the given |callback| whenever the |permission| associated with the |
87 // pair { requesting_origin, embedding_origin } changes. | 85 // pair { requesting_origin, embedding_origin } changes. |
88 // Returns the subscription_id to be used to unsubscribe. Can be | 86 // Returns the subscription_id to be used to unsubscribe. Can be |
89 // kNoPendingOperation if the subscribe was not successful. | 87 // kNoPendingOperation if the subscribe was not successful. |
90 virtual int SubscribePermissionStatusChange( | 88 virtual int SubscribePermissionStatusChange( |
91 PermissionType permission, | 89 PermissionType permission, |
92 const GURL& requesting_origin, | 90 const GURL& requesting_origin, |
93 const GURL& embedding_origin, | 91 const GURL& embedding_origin, |
94 const base::Callback<void(permissions::mojom::PermissionStatus)>& | 92 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) = 0; |
95 callback) = 0; | |
96 | 93 |
97 // Unregisters from permission status change notifications. | 94 // Unregisters from permission status change notifications. |
98 // The |subscription_id| must match the value returned by the | 95 // The |subscription_id| must match the value returned by the |
99 // SubscribePermissionStatusChange call. Unsubscribing | 96 // SubscribePermissionStatusChange call. Unsubscribing |
100 // an already unsubscribed |subscription_id| or providing the | 97 // an already unsubscribed |subscription_id| or providing the |
101 // |subscription_id| kNoPendingOperation is a no-op. | 98 // |subscription_id| kNoPendingOperation is a no-op. |
102 virtual void UnsubscribePermissionStatusChange(int subscription_id) = 0; | 99 virtual void UnsubscribePermissionStatusChange(int subscription_id) = 0; |
103 }; | 100 }; |
104 | 101 |
105 } // namespace content | 102 } // namespace content |
106 | 103 |
107 #endif // CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_ | 104 #endif // CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_ |
OLD | NEW |