Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Side by Side Diff: content/public/browser/permission_manager.h

Issue 1726323002: Have Permission{Manager,Service} use Origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/public/common/permission_status.mojom.h"
10 10
11 class GURL; 11 namespace url {
12 class Origin;
13 }
12 14
13 namespace content { 15 namespace content {
14 enum class PermissionType; 16 enum class PermissionType;
15 class RenderFrameHost; 17 class RenderFrameHost;
16 18
17 // This class allows the content layer to manipulate permissions. It has to be 19 // This class allows the content layer to manipulate permissions. It has to be
18 // implemented by the embedder which ultimately handles the permission 20 // implemented by the embedder which ultimately handles the permission
19 // management for the content layer. 21 // management for the content layer.
20 class CONTENT_EXPORT PermissionManager { 22 class CONTENT_EXPORT PermissionManager {
21 public: 23 public:
22 // Constant retured when registering and subscribing if 24 // Constant retured when registering and subscribing if
23 // cancelling/unsubscribing at a later stage would have no effect. 25 // cancelling/unsubscribing at a later stage would have no effect.
24 static const int kNoPendingOperation = -1; 26 static const int kNoPendingOperation = -1;
25 27
26 virtual ~PermissionManager() = default; 28 virtual ~PermissionManager() = default;
27 29
28 // Requests a permission on behalf of a frame identified by 30 // Requests a permission on behalf of a frame identified by
29 // render_frame_host. 31 // render_frame_host.
30 // When the permission request is handled, whether it failed, timed out or 32 // When the permission request is handled, whether it failed, timed out or
31 // succeeded, the |callback| will be run. 33 // succeeded, the |callback| will be run.
32 // Returns a request id which can be used to cancel the permission (see 34 // Returns a request id which can be used to cancel the permission (see
33 // CancelPermissionRequest). This can be kNoPendingOperation if 35 // CancelPermissionRequest). This can be kNoPendingOperation if
34 // there is no further need to cancel the permission in which case |callback| 36 // there is no further need to cancel the permission in which case |callback|
35 // was invoked. 37 // was invoked.
36 virtual int RequestPermission( 38 virtual int RequestPermission(
37 PermissionType permission, 39 PermissionType permission,
38 RenderFrameHost* render_frame_host, 40 RenderFrameHost* render_frame_host,
39 const GURL& requesting_origin, 41 const url::Origin& requesting_origin,
40 const base::Callback<void(mojom::PermissionStatus)>& callback) = 0; 42 const base::Callback<void(mojom::PermissionStatus)>& callback) = 0;
41 43
42 // Requests multiple permissions on behalf of a frame identified by 44 // Requests multiple permissions on behalf of a frame identified by
43 // render_frame_host. 45 // render_frame_host.
44 // When the permission request is handled, whether it failed, timed out or 46 // 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 47 // succeeded, the |callback| will be run. The order of statuses in the
46 // returned vector will correspond to the order of requested permission 48 // returned vector will correspond to the order of requested permission
47 // types. 49 // types.
48 // Returns a request id which can be used to cancel the request (see 50 // Returns a request id which can be used to cancel the request (see
49 // CancelPermissionRequest). This can be kNoPendingOperation if 51 // CancelPermissionRequest). This can be kNoPendingOperation if
50 // there is no further need to cancel the permission in which case |callback| 52 // there is no further need to cancel the permission in which case |callback|
51 // was invoked. 53 // was invoked.
52 virtual int RequestPermissions( 54 virtual int RequestPermissions(
53 const std::vector<PermissionType>& permission, 55 const std::vector<PermissionType>& permission,
54 RenderFrameHost* render_frame_host, 56 RenderFrameHost* render_frame_host,
55 const GURL& requesting_origin, 57 const url::Origin& requesting_origin,
56 const base::Callback<void(const std::vector<mojom::PermissionStatus>&)>& 58 const base::Callback<void(const std::vector<mojom::PermissionStatus>&)>&
57 callback) = 0; 59 callback) = 0;
58 60
59 // Cancels a previous permission request specified by |request_id|. Cancelling 61 // Cancels a previous permission request specified by |request_id|. Cancelling
60 // an already cancelled request or providing the |request_id| 62 // an already cancelled request or providing the |request_id|
61 // kNoPendingOperation is a no-op. 63 // kNoPendingOperation is a no-op.
62 virtual void CancelPermissionRequest(int request_id) = 0; 64 virtual void CancelPermissionRequest(int request_id) = 0;
63 65
64 // Returns the permission status of a given requesting_origin/embedding_origin 66 // Returns the permission status of a given requesting_origin/embedding_origin
65 // tuple. This is not taking a RenderFrameHost because the call might happen 67 // tuple. This is not taking a RenderFrameHost because the call might happen
66 // outside of a frame context. 68 // outside of a frame context.
67 virtual mojom::PermissionStatus GetPermissionStatus( 69 virtual mojom::PermissionStatus GetPermissionStatus(
68 PermissionType permission, 70 PermissionType permission,
69 const GURL& requesting_origin, 71 const url::Origin& requesting_origin,
70 const GURL& embedding_origin) = 0; 72 const url::Origin& embedding_origin) = 0;
71 73
72 // Sets the permission back to its default for the requesting_origin/ 74 // Sets the permission back to its default for the requesting_origin/
73 // embedding_origin tuple. 75 // embedding_origin tuple.
74 virtual void ResetPermission(PermissionType permission, 76 virtual void ResetPermission(PermissionType permission,
75 const GURL& requesting_origin, 77 const url::Origin& requesting_origin,
76 const GURL& embedding_origin) = 0; 78 const url::Origin& embedding_origin) = 0;
77 79
78 // Registers a permission usage. 80 // Registers a permission usage.
79 // TODO(mlamouri): see if we can remove this from the PermissionManager. 81 // TODO(mlamouri): see if we can remove this from the PermissionManager.
80 virtual void RegisterPermissionUsage(PermissionType permission, 82 virtual void RegisterPermissionUsage(PermissionType permission,
81 const GURL& requesting_origin, 83 const url::Origin& requesting_origin,
82 const GURL& embedding_origin) = 0; 84 const url::Origin& embedding_origin) = 0;
83 85
84 // Runs the given |callback| whenever the |permission| associated with the 86 // Runs the given |callback| whenever the |permission| associated with the
85 // pair { requesting_origin, embedding_origin } changes. 87 // pair { requesting_origin, embedding_origin } changes.
86 // Returns the subscription_id to be used to unsubscribe. Can be 88 // Returns the subscription_id to be used to unsubscribe. Can be
87 // kNoPendingOperation if the subscribe was not successful. 89 // kNoPendingOperation if the subscribe was not successful.
88 virtual int SubscribePermissionStatusChange( 90 virtual int SubscribePermissionStatusChange(
89 PermissionType permission, 91 PermissionType permission,
90 const GURL& requesting_origin, 92 const url::Origin& requesting_origin,
91 const GURL& embedding_origin, 93 const url::Origin& embedding_origin,
92 const base::Callback<void(mojom::PermissionStatus)>& callback) = 0; 94 const base::Callback<void(mojom::PermissionStatus)>& callback) = 0;
93 95
94 // Unregisters from permission status change notifications. 96 // Unregisters from permission status change notifications.
95 // The |subscription_id| must match the value returned by the 97 // The |subscription_id| must match the value returned by the
96 // SubscribePermissionStatusChange call. Unsubscribing 98 // SubscribePermissionStatusChange call. Unsubscribing
97 // an already unsubscribed |subscription_id| or providing the 99 // an already unsubscribed |subscription_id| or providing the
98 // |subscription_id| kNoPendingOperation is a no-op. 100 // |subscription_id| kNoPendingOperation is a no-op.
99 virtual void UnsubscribePermissionStatusChange(int subscription_id) = 0; 101 virtual void UnsubscribePermissionStatusChange(int subscription_id) = 0;
100 }; 102 };
101 103
102 } // namespace content 104 } // namespace content
103 105
104 #endif // CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_ 106 #endif // CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698