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

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

Issue 2842013002: Use a mojo::StrongBindingSet to manage PermissionServiceImpls (Closed)
Patch Set: 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_CONTEXT_H_ 5 #ifndef CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_CONTEXT_H_
6 #define CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_CONTEXT_H_ 6 #define CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_CONTEXT_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "content/public/browser/permission_type.h" 9 #include "content/public/browser/permission_type.h"
10 #include "content/public/browser/web_contents_observer.h" 10 #include "content/public/browser/web_contents_observer.h"
11 #include "mojo/public/cpp/bindings/interface_request.h" 11 #include "mojo/public/cpp/bindings/strong_binding_set.h"
12 12 #include "third_party/WebKit/public/platform/modules/permissions/permission.mojo m.h"
13 namespace blink {
14 namespace mojom {
15 class PermissionObserver;
16 class PermissionService;
17 }
18 }
19 13
20 namespace url { 14 namespace url {
21 class Origin; 15 class Origin;
22 } 16 }
23 17
24 namespace content { 18 namespace content {
25 19
26 class PermissionServiceImpl;
27 class RenderFrameHost; 20 class RenderFrameHost;
28 class RenderProcessHost; 21 class RenderProcessHost;
29 22
30 // Provides information to a PermissionService. It is used by the 23 // Provides information to a PermissionService. It is used by the
31 // PermissionServiceImpl to handle request permission UI. 24 // PermissionServiceImpl to handle request permission UI.
32 // There is one PermissionServiceContext per RenderFrameHost/RenderProcessHost 25 // There is one PermissionServiceContext per RenderFrameHost/RenderProcessHost
33 // which owns it. It then owns all PermissionServiceImpl associated to their 26 // which owns it. It then owns all PermissionServiceImpl associated to their
34 // owner. 27 // owner.
35 class PermissionServiceContext : public WebContentsObserver { 28 class PermissionServiceContext : public WebContentsObserver {
36 public: 29 public:
37 explicit PermissionServiceContext(RenderFrameHost* render_frame_host); 30 explicit PermissionServiceContext(RenderFrameHost* render_frame_host);
38 explicit PermissionServiceContext(RenderProcessHost* render_process_host); 31 explicit PermissionServiceContext(RenderProcessHost* render_process_host);
39 ~PermissionServiceContext() override; 32 ~PermissionServiceContext() override;
40 33
41 void CreateService( 34 void CreateService(blink::mojom::PermissionServiceRequest request);
42 mojo::InterfaceRequest<blink::mojom::PermissionService> request);
43 35
44 void CreateSubscription( 36 void CreateSubscription(PermissionType permission_type,
45 PermissionType permission_type, 37 const url::Origin& origin,
46 const url::Origin& origin, 38 blink::mojom::PermissionObserverPtr observer);
47 mojo::InterfacePtr<blink::mojom::PermissionObserver> observer);
48
49 // Called by a PermissionServiceImpl identified as |service| when it has a
50 // connection error in order to get unregistered and killed.
51 void ServiceHadConnectionError(PermissionServiceImpl* service);
52 39
53 // Called when the connection to a PermissionObserver has an error. 40 // Called when the connection to a PermissionObserver has an error.
54 void ObserverHadConnectionError(int subscription_id); 41 void ObserverHadConnectionError(int subscription_id);
55 42
56 BrowserContext* GetBrowserContext() const; 43 BrowserContext* GetBrowserContext() const;
57 GURL GetEmbeddingOrigin() const; 44 GURL GetEmbeddingOrigin() const;
58 45
59 RenderFrameHost* render_frame_host() const; 46 RenderFrameHost* render_frame_host() const;
60 47
61 private: 48 private:
62 class PermissionSubscription; 49 class PermissionSubscription;
63 50
64 // WebContentsObserver 51 // WebContentsObserver
65 void RenderFrameHostChanged(RenderFrameHost* old_host, 52 void RenderFrameHostChanged(RenderFrameHost* old_host,
66 RenderFrameHost* new_host) override; 53 RenderFrameHost* new_host) override;
67 void FrameDeleted(RenderFrameHost* render_frame_host) override; 54 void FrameDeleted(RenderFrameHost* render_frame_host) override;
68 void DidFinishNavigation(NavigationHandle* navigation_handle) override; 55 void DidFinishNavigation(NavigationHandle* navigation_handle) override;
69 56
70 void CancelPendingOperations(RenderFrameHost*); 57 void CancelPendingOperations(RenderFrameHost*);
71 58
72 RenderFrameHost* render_frame_host_; 59 RenderFrameHost* render_frame_host_;
73 RenderProcessHost* render_process_host_; 60 RenderProcessHost* render_process_host_;
74 std::vector<std::unique_ptr<PermissionServiceImpl>> services_; 61 mojo::StrongBindingSet<blink::mojom::PermissionService> services_;
75 std::unordered_map<int, std::unique_ptr<PermissionSubscription>> 62 std::unordered_map<int, std::unique_ptr<PermissionSubscription>>
76 subscriptions_; 63 subscriptions_;
77 64
78 DISALLOW_COPY_AND_ASSIGN(PermissionServiceContext); 65 DISALLOW_COPY_AND_ASSIGN(PermissionServiceContext);
79 }; 66 };
80 67
81 } // namespace content 68 } // namespace content
82 69
83 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_CONTEXT_H_ 70 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698