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