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/permission/public/interfaces/permission_status.mojom.h" |
8 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
9 #include "content/public/common/permission_status.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 11 matching lines...) Expand all Loading... |
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 bool user_gesture, | 40 bool user_gesture, |
41 const base::Callback<void(PermissionStatus)>& callback) = 0; | 41 const base::Callback<void(permission::Status)>& callback) = 0; |
42 | 42 |
43 // Cancels a previous permission request specified by |request_id|. Cancelling | 43 // Cancels a previous permission request specified by |request_id|. Cancelling |
44 // an already cancelled request or providing the |request_id| | 44 // an already cancelled request or providing the |request_id| |
45 // kNoPendingOperation is a no-op. | 45 // kNoPendingOperation is a no-op. |
46 virtual void CancelPermissionRequest(int request_id) = 0; | 46 virtual void CancelPermissionRequest(int request_id) = 0; |
47 | 47 |
48 // Returns the permission status of a given requesting_origin/embedding_origin | 48 // Returns the permission status of a given requesting_origin/embedding_origin |
49 // tuple. This is not taking a RenderFrameHost because the call might happen | 49 // tuple. This is not taking a RenderFrameHost because the call might happen |
50 // outside of a frame context. | 50 // outside of a frame context. |
51 virtual PermissionStatus GetPermissionStatus( | 51 virtual permission::Status GetPermissionStatus( |
52 PermissionType permission, | 52 PermissionType permission, |
53 const GURL& requesting_origin, | 53 const GURL& requesting_origin, |
54 const GURL& embedding_origin) = 0; | 54 const GURL& embedding_origin) = 0; |
55 | 55 |
56 // Sets the permission back to its default for the requesting_origin/ | 56 // Sets the permission back to its default for the requesting_origin/ |
57 // embedding_origin tuple. | 57 // embedding_origin tuple. |
58 virtual void ResetPermission(PermissionType permission, | 58 virtual void ResetPermission(PermissionType permission, |
59 const GURL& requesting_origin, | 59 const GURL& requesting_origin, |
60 const GURL& embedding_origin) = 0; | 60 const GURL& embedding_origin) = 0; |
61 | 61 |
62 // Registers a permission usage. | 62 // Registers a permission usage. |
63 // TODO(mlamouri): see if we can remove this from the PermissionManager. | 63 // TODO(mlamouri): see if we can remove this from the PermissionManager. |
64 virtual void RegisterPermissionUsage(PermissionType permission, | 64 virtual void RegisterPermissionUsage(PermissionType permission, |
65 const GURL& requesting_origin, | 65 const GURL& requesting_origin, |
66 const GURL& embedding_origin) = 0; | 66 const GURL& embedding_origin) = 0; |
67 | 67 |
68 // Runs the given |callback| whenever the |permission| associated with the | 68 // Runs the given |callback| whenever the |permission| associated with the |
69 // pair { requesting_origin, embedding_origin } changes. | 69 // pair { requesting_origin, embedding_origin } changes. |
70 // Returns the subscription_id to be used to unsubscribe. Can be | 70 // Returns the subscription_id to be used to unsubscribe. Can be |
71 // kNoPendingOperation if the subscribe was not successful. | 71 // kNoPendingOperation if the subscribe was not successful. |
72 virtual int SubscribePermissionStatusChange( | 72 virtual int SubscribePermissionStatusChange( |
73 PermissionType permission, | 73 PermissionType permission, |
74 const GURL& requesting_origin, | 74 const GURL& requesting_origin, |
75 const GURL& embedding_origin, | 75 const GURL& embedding_origin, |
76 const base::Callback<void(PermissionStatus)>& callback) = 0; | 76 const base::Callback<void(permission::Status)>& callback) = 0; |
77 | 77 |
78 // Unregisters from permission status change notifications. | 78 // Unregisters from permission status change notifications. |
79 // The |subscription_id| must match the value returned by the | 79 // The |subscription_id| must match the value returned by the |
80 // SubscribePermissionStatusChange call. Unsubscribing | 80 // SubscribePermissionStatusChange call. Unsubscribing |
81 // an already unsubscribed |subscription_id| or providing the | 81 // an already unsubscribed |subscription_id| or providing the |
82 // |subscription_id| kNoPendingOperation is a no-op. | 82 // |subscription_id| kNoPendingOperation is a no-op. |
83 virtual void UnsubscribePermissionStatusChange(int subscription_id) = 0; | 83 virtual void UnsubscribePermissionStatusChange(int subscription_id) = 0; |
84 }; | 84 }; |
85 | 85 |
86 } // namespace content | 86 } // namespace content |
87 | 87 |
88 #endif // CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_ | 88 #endif // CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_ |
OLD | NEW |