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

Side by Side Diff: content/browser/permissions/permission_service_impl.h

Issue 1513973002: PermissionServiceContext using mojo::StrongBindingSet. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-geolocation-untangle
Patch Set: Created 5 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ 5 #ifndef CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_
6 #define CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ 6 #define CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_
7 7
8 #include "base/id_map.h" 8 #include "base/id_map.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "content/browser/permissions/permission_service_context.h"
12 #include "content/common/permission_service.mojom.h" 11 #include "content/common/permission_service.mojom.h"
13 #include "mojo/public/cpp/bindings/binding.h" 12 #include "mojo/common/strong_binding_set.h"
13 #include "url/gurl.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 enum class PermissionType; 17 enum class PermissionType;
18 class PermissionServiceContext;
18 19
19 // Implements the PermissionService Mojo interface. 20 // Implements the PermissionService Mojo interface.
20 // This service can be created from a RenderFrameHost or a RenderProcessHost. 21 // This service can be created from a RenderFrameHost or a RenderProcessHost.
21 // It is owned by a PermissionServiceContext. 22 // It is owned by a PermissionServiceContext.
22 // It receives at PermissionServiceContext instance when created which allows it 23 // It receives at PermissionServiceContext instance when created which allows it
23 // to have some information about the current context. That enables the service 24 // to have some information about the current context. That enables the service
24 // to know whether it can show UI and have knowledge of the associated 25 // to know whether it can show UI and have knowledge of the associated
25 // WebContents for example. 26 // WebContents for example.
26 class PermissionServiceImpl : public PermissionService { 27 class PermissionServiceImpl : public PermissionService {
27 public: 28 public:
28 ~PermissionServiceImpl() override; 29 ~PermissionServiceImpl() override;
29 30
30 // Clear pending operations currently run by the service. This will be called 31 // Clear pending operations currently run by the service. This will be called
31 // by PermissionServiceContext when it will need the service to clear its 32 // by PermissionServiceContext when it will need the service to clear its
32 // state for example, if the frame changes. 33 // state for example, if the frame changes.
33 void CancelPendingOperations(); 34 void CancelPendingOperations();
34 35
35 protected: 36 protected:
36 friend PermissionServiceContext; 37 friend mojo::StrongBindingSet<PermissionServiceImpl>;
37 38
38 PermissionServiceImpl(PermissionServiceContext* context, 39 explicit PermissionServiceImpl(PermissionServiceContext* context);
39 mojo::InterfaceRequest<PermissionService> request);
40 40
41 private: 41 private:
42 using PermissionStatusCallback = mojo::Callback<void(PermissionStatus)>; 42 using PermissionStatusCallback = mojo::Callback<void(PermissionStatus)>;
43 using PermissionsStatusCallback = 43 using PermissionsStatusCallback =
44 mojo::Callback<void(mojo::Array<PermissionStatus>)>; 44 mojo::Callback<void(mojo::Array<PermissionStatus>)>;
45 45
46 struct PendingRequest { 46 struct PendingRequest {
47 PendingRequest(const PermissionsStatusCallback& callback, 47 PendingRequest(const PermissionsStatusCallback& callback,
48 int request_count); 48 int request_count);
49 ~PendingRequest(); 49 ~PendingRequest();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 const PermissionsStatusCallback& callback) override; 82 const PermissionsStatusCallback& callback) override;
83 void RevokePermission(PermissionName permission, 83 void RevokePermission(PermissionName permission,
84 const mojo::String& origin, 84 const mojo::String& origin,
85 const PermissionStatusCallback& callback) override; 85 const PermissionStatusCallback& callback) override;
86 void GetNextPermissionChange( 86 void GetNextPermissionChange(
87 PermissionName permission, 87 PermissionName permission,
88 const mojo::String& origin, 88 const mojo::String& origin,
89 PermissionStatus last_known_status, 89 PermissionStatus last_known_status,
90 const PermissionStatusCallback& callback) override; 90 const PermissionStatusCallback& callback) override;
91 91
92 void OnConnectionError();
93
94 void OnRequestPermissionResponse( 92 void OnRequestPermissionResponse(
95 int pending_request_id, 93 int pending_request_id,
96 PermissionStatus status); 94 PermissionStatus status);
97 void OnRequestPermissionsResponse( 95 void OnRequestPermissionsResponse(
98 int pending_request_id, 96 int pending_request_id,
99 const std::vector<PermissionStatus>& result); 97 const std::vector<PermissionStatus>& result);
100 98
101 PermissionStatus GetPermissionStatusFromName(PermissionName permission, 99 PermissionStatus GetPermissionStatusFromName(PermissionName permission,
102 const GURL& origin); 100 const GURL& origin);
103 PermissionStatus GetPermissionStatusFromType(PermissionType type, 101 PermissionStatus GetPermissionStatusFromType(PermissionType type,
104 const GURL& origin); 102 const GURL& origin);
105 void ResetPermissionStatus(PermissionType type, const GURL& origin); 103 void ResetPermissionStatus(PermissionType type, const GURL& origin);
106 104
107 void OnPermissionStatusChanged(int pending_subscription_id, 105 void OnPermissionStatusChanged(int pending_subscription_id,
108 PermissionStatus status); 106 PermissionStatus status);
109 107
110 RequestsMap pending_requests_; 108 RequestsMap pending_requests_;
111 SubscriptionsMap pending_subscriptions_; 109 SubscriptionsMap pending_subscriptions_;
112 // context_ owns |this|. 110 // context_ owns |this|.
113 PermissionServiceContext* context_; 111 PermissionServiceContext* context_;
114 mojo::Binding<PermissionService> binding_;
115 base::WeakPtrFactory<PermissionServiceImpl> weak_factory_; 112 base::WeakPtrFactory<PermissionServiceImpl> weak_factory_;
116 113
117 DISALLOW_COPY_AND_ASSIGN(PermissionServiceImpl); 114 DISALLOW_COPY_AND_ASSIGN(PermissionServiceImpl);
118 }; 115 };
119 116
120 } // namespace content 117 } // namespace content
121 118
122 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ 119 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/permissions/permission_service_context.cc ('k') | content/browser/permissions/permission_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698