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