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 "content/common/content_export.h" | 8 #include "content/common/content_export.h" |
9 #include "content/public/common/permission_status.mojom.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(mojom::PermissionStatus)>& callback) = 0; | 40 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) = 0; |
41 | 41 |
42 // Requests multiple permissions on behalf of a frame identified by | 42 // Requests multiple permissions on behalf of a frame identified by |
43 // render_frame_host. | 43 // render_frame_host. |
44 // 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 |
45 // 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 |
46 // returned vector will correspond to the order of requested permission | 46 // returned vector will correspond to the order of requested permission |
47 // types. | 47 // types. |
48 // 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 |
49 // CancelPermissionRequest). This can be kNoPendingOperation if | 49 // CancelPermissionRequest). This can be kNoPendingOperation if |
50 // 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| |
51 // was invoked. | 51 // was invoked. |
52 virtual int RequestPermissions( | 52 virtual int RequestPermissions( |
53 const std::vector<PermissionType>& permission, | 53 const std::vector<PermissionType>& permission, |
54 RenderFrameHost* render_frame_host, | 54 RenderFrameHost* render_frame_host, |
55 const GURL& requesting_origin, | 55 const GURL& requesting_origin, |
56 const base::Callback<void(const std::vector<mojom::PermissionStatus>&)>& | 56 const base::Callback<void( |
57 callback) = 0; | 57 const std::vector<blink::mojom::PermissionStatus>&)>& callback) = 0; |
58 | 58 |
59 // Cancels a previous permission request specified by |request_id|. Cancelling | 59 // Cancels a previous permission request specified by |request_id|. Cancelling |
60 // an already cancelled request or providing the |request_id| | 60 // an already cancelled request or providing the |request_id| |
61 // kNoPendingOperation is a no-op. | 61 // kNoPendingOperation is a no-op. |
62 virtual void CancelPermissionRequest(int request_id) = 0; | 62 virtual void CancelPermissionRequest(int request_id) = 0; |
63 | 63 |
64 // Returns the permission status of a given requesting_origin/embedding_origin | 64 // Returns the permission status of a given requesting_origin/embedding_origin |
65 // 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 |
66 // outside of a frame context. | 66 // outside of a frame context. |
67 virtual mojom::PermissionStatus GetPermissionStatus( | 67 virtual blink::mojom::PermissionStatus GetPermissionStatus( |
68 PermissionType permission, | 68 PermissionType permission, |
69 const GURL& requesting_origin, | 69 const GURL& requesting_origin, |
70 const GURL& embedding_origin) = 0; | 70 const GURL& embedding_origin) = 0; |
71 | 71 |
72 // Sets the permission back to its default for the requesting_origin/ | 72 // Sets the permission back to its default for the requesting_origin/ |
73 // embedding_origin tuple. | 73 // embedding_origin tuple. |
74 virtual void ResetPermission(PermissionType permission, | 74 virtual void ResetPermission(PermissionType permission, |
75 const GURL& requesting_origin, | 75 const GURL& requesting_origin, |
76 const GURL& embedding_origin) = 0; | 76 const GURL& embedding_origin) = 0; |
77 | 77 |
78 // Registers a permission usage. | 78 // Registers a permission usage. |
79 // TODO(mlamouri): see if we can remove this from the PermissionManager. | 79 // TODO(mlamouri): see if we can remove this from the PermissionManager. |
80 virtual void RegisterPermissionUsage(PermissionType permission, | 80 virtual void RegisterPermissionUsage(PermissionType permission, |
81 const GURL& requesting_origin, | 81 const GURL& requesting_origin, |
82 const GURL& embedding_origin) = 0; | 82 const GURL& embedding_origin) = 0; |
83 | 83 |
84 // Runs the given |callback| whenever the |permission| associated with the | 84 // Runs the given |callback| whenever the |permission| associated with the |
85 // pair { requesting_origin, embedding_origin } changes. | 85 // pair { requesting_origin, embedding_origin } changes. |
86 // Returns the subscription_id to be used to unsubscribe. Can be | 86 // Returns the subscription_id to be used to unsubscribe. Can be |
87 // kNoPendingOperation if the subscribe was not successful. | 87 // kNoPendingOperation if the subscribe was not successful. |
88 virtual int SubscribePermissionStatusChange( | 88 virtual int SubscribePermissionStatusChange( |
89 PermissionType permission, | 89 PermissionType permission, |
90 const GURL& requesting_origin, | 90 const GURL& requesting_origin, |
91 const GURL& embedding_origin, | 91 const GURL& embedding_origin, |
92 const base::Callback<void(mojom::PermissionStatus)>& callback) = 0; | 92 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) = 0; |
93 | 93 |
94 // Unregisters from permission status change notifications. | 94 // Unregisters from permission status change notifications. |
95 // The |subscription_id| must match the value returned by the | 95 // The |subscription_id| must match the value returned by the |
96 // SubscribePermissionStatusChange call. Unsubscribing | 96 // SubscribePermissionStatusChange call. Unsubscribing |
97 // an already unsubscribed |subscription_id| or providing the | 97 // an already unsubscribed |subscription_id| or providing the |
98 // |subscription_id| kNoPendingOperation is a no-op. | 98 // |subscription_id| kNoPendingOperation is a no-op. |
99 virtual void UnsubscribePermissionStatusChange(int subscription_id) = 0; | 99 virtual void UnsubscribePermissionStatusChange(int subscription_id) = 0; |
100 }; | 100 }; |
101 | 101 |
102 } // namespace content | 102 } // namespace content |
103 | 103 |
104 #endif // CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_ | 104 #endif // CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_ |
OLD | NEW |