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

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

Issue 1342833002: permissions: handle request ids for permissions in permission manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test failures Created 5 years, 3 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 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.
20 class CONTENT_EXPORT PermissionManager { 20 class CONTENT_EXPORT PermissionManager {
21 public: 21 public:
22 virtual ~PermissionManager() = default; 22 virtual ~PermissionManager() = default;
23 23
24 // Requests a permission on behalf of a frame identified by render_frame_host. 24 // Requests a permission on behalf of a frame identified by render_frame_host.
25 // The |request_id| is an identifier that can later be used if the request is
26 // cancelled (see CancelPermissionRequest).
27 // When the permission request is handled, whether it failed, timed out or 25 // When the permission request is handled, whether it failed, timed out or
28 // succeeded, the |callback| will be run. 26 // succeeded, the |callback| will be run.
29 virtual void RequestPermission( 27 // Returns a request id which can be used to cancel the permission (see
28 // CancelPermissionRequest). This can be kCancelUnsubscribeNoOp if there is
29 // no further need to cancel the permission but |callback| MUST have been
mlamouri (slow - plz ping) 2015/09/16 14:42:57 nit: drop "but", it sounds like the caller has to
Lalit Maganti 2015/09/16 16:41:10 Done.
30 // invoked in this case.
31 virtual int RequestPermission(
30 PermissionType permission, 32 PermissionType permission,
31 RenderFrameHost* render_frame_host, 33 RenderFrameHost* render_frame_host,
32 int request_id,
33 const GURL& requesting_origin, 34 const GURL& requesting_origin,
34 bool user_gesture, 35 bool user_gesture,
35 const base::Callback<void(PermissionStatus)>& callback) = 0; 36 const base::Callback<void(PermissionStatus)>& callback) = 0;
36 37
37 // Cancels a previously requested permission. The given parameter must match 38 // Cancels a previous permission request specified by |request_id|. Cancelling
38 // the ones passed to the RequestPermission call. 39 // an already cancelled request or providing the |request_id|
39 virtual void CancelPermissionRequest(PermissionType permission, 40 // kCancelUnsubscribeNoOp is a no-op.
40 RenderFrameHost* render_frame_host, 41 virtual void CancelPermissionRequest(int request_id) = 0;
41 int request_id,
42 const GURL& requesting_origin) = 0;
43 42
44 // Returns the permission status of a given requesting_origin/embedding_origin 43 // Returns the permission status of a given requesting_origin/embedding_origin
45 // tuple. This is not taking a RenderFrameHost because the call might happen 44 // tuple. This is not taking a RenderFrameHost because the call might happen
46 // outside of a frame context. 45 // outside of a frame context.
47 virtual PermissionStatus GetPermissionStatus( 46 virtual PermissionStatus GetPermissionStatus(
48 PermissionType permission, 47 PermissionType permission,
49 const GURL& requesting_origin, 48 const GURL& requesting_origin,
50 const GURL& embedding_origin) = 0; 49 const GURL& embedding_origin) = 0;
51 50
52 // Sets the permission back to its default for the requesting_origin/ 51 // Sets the permission back to its default for the requesting_origin/
53 // embedding_origin tuple. 52 // embedding_origin tuple.
54 virtual void ResetPermission(PermissionType permission, 53 virtual void ResetPermission(PermissionType permission,
55 const GURL& requesting_origin, 54 const GURL& requesting_origin,
56 const GURL& embedding_origin) = 0; 55 const GURL& embedding_origin) = 0;
57 56
58 // Registers a permission usage. 57 // Registers a permission usage.
59 // TODO(mlamouri): see if we can remove this from the PermissionManager. 58 // TODO(mlamouri): see if we can remove this from the PermissionManager.
60 virtual void RegisterPermissionUsage(PermissionType permission, 59 virtual void RegisterPermissionUsage(PermissionType permission,
61 const GURL& requesting_origin, 60 const GURL& requesting_origin,
62 const GURL& embedding_origin) = 0; 61 const GURL& embedding_origin) = 0;
63 62
64 // Runs the given |callback| whenever the |permission| associated with the 63 // Runs the given |callback| whenever the |permission| associated with the
65 // pair { requesting_origin, embedding_origin } changes. 64 // pair { requesting_origin, embedding_origin } changes.
66 // Returns the subscription_id to be used to unsubscribe. 65 // Returns the subscription_id to be used to unsubscribe. Can be
66 // kCancelUnsubscribeNoOp if the subscribe was not successful.
67 virtual int SubscribePermissionStatusChange( 67 virtual int SubscribePermissionStatusChange(
68 PermissionType permission, 68 PermissionType permission,
69 const GURL& requesting_origin, 69 const GURL& requesting_origin,
70 const GURL& embedding_origin, 70 const GURL& embedding_origin,
71 const base::Callback<void(PermissionStatus)>& callback) = 0; 71 const base::Callback<void(PermissionStatus)>& callback) = 0;
72 72
73 // Unregisters from permission status change notifications. 73 // Unregisters from permission status change notifications.
74 // The |subscription_id| must match the value returned by the 74 // The |subscription_id| must match the value returned by the
75 // SubscribePermissionStatusChange call. 75 // SubscribePermissionStatusChange call. Unsubscribing
76 // an already unsubscribed |subscription_id| or providing the
77 // |subscription_id| kCancelUnsubscribeNoOp is a no-op.
76 virtual void UnsubscribePermissionStatusChange(int subscription_id) = 0; 78 virtual void UnsubscribePermissionStatusChange(int subscription_id) = 0;
79
80 // Constant retured when registering and subscribing if
81 // cancelling/unsubscribing at a later stage would have no effect.
82 static const int kCancelUnsubscribeNoOp = -1;
mlamouri (slow - plz ping) 2015/09/16 14:42:57 style: kFooBar isn't right per coding style. nit:
Lalit Maganti 2015/09/16 16:41:10 style: Which style guide is this? I had a look at
77 }; 83 };
78 84
79 } // namespace content 85 } // namespace content
80 86
81 #endif // CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_ 87 #endif // CONTENT_PUBLIC_BROWSER_PERMISSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698