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

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

Issue 2842013002: Use a mojo::StrongBindingSet to manage PermissionServiceImpls (Closed)
Patch Set: Rebased Created 3 years, 7 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 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/callback.h" 8 #include "base/callback.h"
9 #include "base/id_map.h" 9 #include "base/id_map.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "content/browser/permissions/permission_service_context.h" 12 #include "content/browser/permissions/permission_service_context.h"
13 #include "mojo/public/cpp/bindings/binding.h"
14 #include "third_party/WebKit/public/platform/modules/permissions/permission.mojo m.h" 13 #include "third_party/WebKit/public/platform/modules/permissions/permission.mojo m.h"
15 #include "url/origin.h" 14 #include "url/origin.h"
16 15
17 namespace content { 16 namespace content {
18 17
19 enum class PermissionType; 18 enum class PermissionType;
20 19
21 // Implements the PermissionService Mojo interface. 20 // Implements the PermissionService Mojo interface.
22 // This service can be created from a RenderFrameHost or a RenderProcessHost. 21 // This service can be created from a RenderFrameHost or a RenderProcessHost.
23 // It is owned by a PermissionServiceContext. 22 // It is owned by a PermissionServiceContext.
24 // It receives at PermissionServiceContext instance when created which allows it 23 // It receives at PermissionServiceContext instance when created which allows it
25 // 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
26 // 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
27 // WebContents for example. 26 // WebContents for example.
28 class PermissionServiceImpl : public blink::mojom::PermissionService { 27 class PermissionServiceImpl : public blink::mojom::PermissionService {
29 public: 28 public:
30 PermissionServiceImpl( 29 PermissionServiceImpl(PermissionServiceContext* context);
31 PermissionServiceContext* context,
32 mojo::InterfaceRequest<blink::mojom::PermissionService> request);
33 ~PermissionServiceImpl() override; 30 ~PermissionServiceImpl() override;
34 31
35 // Clear pending operations currently run by the service. This will be called
36 // by PermissionServiceContext when it will need the service to clear its
37 // state for example, if the frame changes.
38 void CancelPendingOperations();
39
40 private: 32 private:
41 using PermissionStatusCallback = 33 using PermissionStatusCallback =
42 base::Callback<void(blink::mojom::PermissionStatus)>; 34 base::Callback<void(blink::mojom::PermissionStatus)>;
43 35
44 struct PendingRequest { 36 struct PendingRequest {
45 PendingRequest(const RequestPermissionsCallback& callback, 37 PendingRequest(const RequestPermissionsCallback& callback,
46 int request_count); 38 int request_count);
47 ~PendingRequest(); 39 ~PendingRequest();
48 40
49 // Request ID received from the PermissionManager. 41 // Request ID received from the PermissionManager.
(...skipping 18 matching lines...) Expand all
68 const RequestPermissionsCallback& callback) override; 60 const RequestPermissionsCallback& callback) override;
69 void RevokePermission(blink::mojom::PermissionDescriptorPtr permission, 61 void RevokePermission(blink::mojom::PermissionDescriptorPtr permission,
70 const url::Origin& origin, 62 const url::Origin& origin,
71 const PermissionStatusCallback& callback) override; 63 const PermissionStatusCallback& callback) override;
72 void AddPermissionObserver( 64 void AddPermissionObserver(
73 blink::mojom::PermissionDescriptorPtr permission, 65 blink::mojom::PermissionDescriptorPtr permission,
74 const url::Origin& origin, 66 const url::Origin& origin,
75 blink::mojom::PermissionStatus last_known_status, 67 blink::mojom::PermissionStatus last_known_status,
76 blink::mojom::PermissionObserverPtr observer) override; 68 blink::mojom::PermissionObserverPtr observer) override;
77 69
78 void OnConnectionError();
79
80 void OnRequestPermissionResponse(int pending_request_id, 70 void OnRequestPermissionResponse(int pending_request_id,
81 blink::mojom::PermissionStatus status); 71 blink::mojom::PermissionStatus status);
82 void OnRequestPermissionsResponse( 72 void OnRequestPermissionsResponse(
83 int pending_request_id, 73 int pending_request_id,
84 const std::vector<blink::mojom::PermissionStatus>& result); 74 const std::vector<blink::mojom::PermissionStatus>& result);
85 75
86 blink::mojom::PermissionStatus GetPermissionStatus( 76 blink::mojom::PermissionStatus GetPermissionStatus(
87 const blink::mojom::PermissionDescriptorPtr& permission, 77 const blink::mojom::PermissionDescriptorPtr& permission,
88 const url::Origin& origin); 78 const url::Origin& origin);
89 blink::mojom::PermissionStatus GetPermissionStatusFromType( 79 blink::mojom::PermissionStatus GetPermissionStatusFromType(
90 PermissionType type, 80 PermissionType type,
91 const url::Origin& origin); 81 const url::Origin& origin);
92 void ResetPermissionStatus(PermissionType type, const url::Origin& origin); 82 void ResetPermissionStatus(PermissionType type, const url::Origin& origin);
93 83
94 RequestsMap pending_requests_; 84 RequestsMap pending_requests_;
95 // context_ owns |this|. 85 // context_ owns |this|.
96 PermissionServiceContext* context_; 86 PermissionServiceContext* context_;
97 mojo::Binding<blink::mojom::PermissionService> binding_;
98 base::WeakPtrFactory<PermissionServiceImpl> weak_factory_; 87 base::WeakPtrFactory<PermissionServiceImpl> weak_factory_;
99 88
100 DISALLOW_COPY_AND_ASSIGN(PermissionServiceImpl); 89 DISALLOW_COPY_AND_ASSIGN(PermissionServiceImpl);
101 }; 90 };
102 91
103 } // namespace content 92 } // namespace content
104 93
105 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_IMPL_H_ 94 #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