| 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 "content/browser/permissions/permission_service_impl.h" |
| 10 #include "content/common/permission_service.mojom.h" |
| 10 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "mojo/common/strong_binding_set.h" |
| 11 #include "mojo/public/cpp/bindings/interface_request.h" | 13 #include "mojo/public/cpp/bindings/interface_request.h" |
| 12 | 14 |
| 13 namespace content { | 15 namespace content { |
| 14 | 16 |
| 15 class PermissionService; | |
| 16 class PermissionServiceImpl; | |
| 17 class RenderFrameHost; | 17 class RenderFrameHost; |
| 18 class RenderProcessHost; | 18 class RenderProcessHost; |
| 19 | 19 |
| 20 // Provides information to a PermissionService. It is used by the | 20 // Provides information to a PermissionService. It is used by the |
| 21 // PermissionService to handle request permission UI. | 21 // PermissionService to handle request permission UI. |
| 22 // There is one PermissionServiceContext per RenderFrameHost/RenderProcessHost | 22 // There is one PermissionServiceContext per RenderFrameHost/RenderProcessHost |
| 23 // which owns it. It then owns all PermissionService associated to their owner. | 23 // which owns it. It then owns all PermissionService associated to their owner. |
| 24 class PermissionServiceContext : public WebContentsObserver { | 24 class PermissionServiceContext : public WebContentsObserver { |
| 25 public: | 25 public: |
| 26 explicit PermissionServiceContext(RenderFrameHost* render_frame_host); | 26 explicit PermissionServiceContext(RenderFrameHost* render_frame_host); |
| 27 explicit PermissionServiceContext(RenderProcessHost* render_process_host); | 27 explicit PermissionServiceContext(RenderProcessHost* render_process_host); |
| 28 ~PermissionServiceContext() override; | 28 ~PermissionServiceContext() override; |
| 29 | 29 |
| 30 void CreateService(mojo::InterfaceRequest<PermissionService> request); | 30 void CreateService(mojo::InterfaceRequest<PermissionService> request); |
| 31 | 31 |
| 32 // Called by a PermissionService identified as |service| when it has a | |
| 33 // connection error in order to get unregistered and killed. | |
| 34 void ServiceHadConnectionError(PermissionServiceImpl* service); | |
| 35 | |
| 36 BrowserContext* GetBrowserContext() const; | 32 BrowserContext* GetBrowserContext() const; |
| 37 GURL GetEmbeddingOrigin() const; | 33 GURL GetEmbeddingOrigin() const; |
| 38 | 34 |
| 39 RenderFrameHost* render_frame_host() const; | 35 RenderFrameHost* render_frame_host() const; |
| 40 | 36 |
| 41 private: | 37 private: |
| 42 // WebContentsObserver | 38 // WebContentsObserver |
| 43 void RenderFrameHostChanged(RenderFrameHost* old_host, | 39 void RenderFrameHostChanged(RenderFrameHost* old_host, |
| 44 RenderFrameHost* new_host) override; | 40 RenderFrameHost* new_host) override; |
| 45 void FrameDeleted(RenderFrameHost* render_frame_host) override; | 41 void FrameDeleted(RenderFrameHost* render_frame_host) override; |
| 46 void DidNavigateAnyFrame(RenderFrameHost* render_frame_host, | 42 void DidNavigateAnyFrame(RenderFrameHost* render_frame_host, |
| 47 const LoadCommittedDetails& details, | 43 const LoadCommittedDetails& details, |
| 48 const FrameNavigateParams& params) override; | 44 const FrameNavigateParams& params) override; |
| 49 | 45 |
| 50 void CancelPendingOperations(RenderFrameHost*) const; | 46 void CancelPendingOperations(RenderFrameHost*) const; |
| 51 | 47 |
| 52 RenderFrameHost* render_frame_host_; | 48 RenderFrameHost* render_frame_host_; |
| 53 RenderProcessHost* render_process_host_; | 49 RenderProcessHost* render_process_host_; |
| 54 ScopedVector<PermissionServiceImpl> services_; | 50 mojo::StrongBindingSet<PermissionServiceImpl> services_; |
| 55 | 51 |
| 56 DISALLOW_COPY_AND_ASSIGN(PermissionServiceContext); | 52 DISALLOW_COPY_AND_ASSIGN(PermissionServiceContext); |
| 57 }; | 53 }; |
| 58 | 54 |
| 59 } // namespace content | 55 } // namespace content |
| 60 | 56 |
| 61 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_CONTEXT_H_ | 57 #endif // CONTENT_BROWSER_PERMISSIONS_PERMISSION_SERVICE_CONTEXT_H_ |
| OLD | NEW |