| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
| 6 #define CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 6 #define CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/containers/scoped_ptr_map.h" | 15 #include "base/containers/scoped_ptr_map.h" |
| 16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/linked_ptr.h" | 18 #include "base/memory/linked_ptr.h" |
| 19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 20 #include "base/memory/scoped_vector.h" | 20 #include "base/memory/scoped_vector.h" |
| 21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
| 23 #include "content/common/presentation/presentation_service.mojom.h" | 23 #include "content/common/presentation/presentation_service.mojom.h" |
| 24 #include "content/public/browser/navigation_details.h" | 24 #include "content/public/browser/navigation_details.h" |
| 25 #include "content/public/browser/presentation_screen_availability_listener.h" | 25 #include "content/public/browser/presentation_screen_availability_listener.h" |
| 26 #include "content/public/browser/presentation_service_delegate.h" | 26 #include "content/public/browser/presentation_service_delegate.h" |
| 27 #include "content/public/browser/web_contents_observer.h" | 27 #include "content/public/browser/web_contents_observer.h" |
| 28 #include "content/public/common/frame_navigate_params.h" | 28 #include "content/public/common/frame_navigate_params.h" |
| 29 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
| 29 | 30 |
| 30 namespace content { | 31 namespace content { |
| 31 | 32 |
| 32 struct FrameNavigateParams; | 33 struct FrameNavigateParams; |
| 33 struct LoadCommittedDetails; | 34 struct LoadCommittedDetails; |
| 34 struct PresentationSessionMessage; | 35 struct PresentationSessionMessage; |
| 35 class RenderFrameHost; | 36 class RenderFrameHost; |
| 36 | 37 |
| 37 using NewSessionMojoCallback = mojo::Callback< | 38 using NewSessionMojoCallback = mojo::Callback< |
| 38 void(presentation::PresentationSessionInfoPtr, | 39 void(presentation::PresentationSessionInfoPtr, |
| 39 presentation::PresentationErrorPtr)>; | 40 presentation::PresentationErrorPtr)>; |
| 40 | 41 |
| 41 // Implementation of Mojo PresentationService. | 42 // Implementation of Mojo PresentationService. |
| 42 // It handles Presentation API requests coming from Blink / renderer process | 43 // It handles Presentation API requests coming from Blink / renderer process |
| 43 // and delegates the requests to the embedder's media router via | 44 // and delegates the requests to the embedder's media router via |
| 44 // PresentationServiceDelegate. | 45 // PresentationServiceDelegate. |
| 45 // An instance of this class tied to a RenderFrameHost and listens to events | 46 // An instance of this class tied to a RenderFrameHost and listens to events |
| 46 // related to the RFH via implementing WebContentsObserver. | 47 // related to the RFH via implementing WebContentsObserver. |
| 47 // This class is instantiated on-demand via Mojo's ConnectToRemoteService | 48 // This class is instantiated on-demand via Mojo's ConnectToRemoteService |
| 48 // from the renderer when the first presentation API request is handled. | 49 // from the renderer when the first presentation API request is handled. |
| 49 class CONTENT_EXPORT PresentationServiceImpl | 50 class CONTENT_EXPORT PresentationServiceImpl |
| 50 : public NON_EXPORTED_BASE(presentation::PresentationService), | 51 : public NON_EXPORTED_BASE(presentation::PresentationService), |
| 51 public mojo::ErrorHandler, | |
| 52 public WebContentsObserver, | 52 public WebContentsObserver, |
| 53 public PresentationServiceDelegate::Observer { | 53 public PresentationServiceDelegate::Observer { |
| 54 public: | 54 public: |
| 55 ~PresentationServiceImpl() override; | 55 ~PresentationServiceImpl() override; |
| 56 | 56 |
| 57 // Static factory method to create an instance of PresentationServiceImpl. | 57 // Static factory method to create an instance of PresentationServiceImpl. |
| 58 // |render_frame_host|: The RFH the instance is associated with. | 58 // |render_frame_host|: The RFH the instance is associated with. |
| 59 // |request|: The instance will be bound to this request. Used for Mojo setup. | 59 // |request|: The instance will be bound to this request. Used for Mojo setup. |
| 60 static void CreateMojoService( | 60 static void CreateMojoService( |
| 61 RenderFrameHost* render_frame_host, | 61 RenderFrameHost* render_frame_host, |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 void CloseSession( | 191 void CloseSession( |
| 192 const mojo::String& presentation_url, | 192 const mojo::String& presentation_url, |
| 193 const mojo::String& presentation_id) override; | 193 const mojo::String& presentation_id) override; |
| 194 void ListenForSessionStateChange() override; | 194 void ListenForSessionStateChange() override; |
| 195 void ListenForSessionMessages( | 195 void ListenForSessionMessages( |
| 196 presentation::PresentationSessionInfoPtr session) override; | 196 presentation::PresentationSessionInfoPtr session) override; |
| 197 | 197 |
| 198 // Creates a binding between this object and |request|. | 198 // Creates a binding between this object and |request|. |
| 199 void Bind(mojo::InterfaceRequest<presentation::PresentationService> request); | 199 void Bind(mojo::InterfaceRequest<presentation::PresentationService> request); |
| 200 | 200 |
| 201 // mojo::ErrorHandler override. | |
| 202 // Note that this is called when the RenderFrameHost is deleted. | |
| 203 void OnConnectionError() override; | |
| 204 | |
| 205 // WebContentsObserver override. | 201 // WebContentsObserver override. |
| 206 void DidNavigateAnyFrame( | 202 void DidNavigateAnyFrame( |
| 207 content::RenderFrameHost* render_frame_host, | 203 content::RenderFrameHost* render_frame_host, |
| 208 const content::LoadCommittedDetails& details, | 204 const content::LoadCommittedDetails& details, |
| 209 const content::FrameNavigateParams& params) override; | 205 const content::FrameNavigateParams& params) override; |
| 210 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; | 206 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
| 211 | 207 |
| 212 // PresentationServiceDelegate::Observer | 208 // PresentationServiceDelegate::Observer |
| 213 void OnDelegateDestroyed() override; | 209 void OnDelegateDestroyed() override; |
| 214 void OnDefaultPresentationStarted(const PresentationSessionInfo& session) | 210 void OnDefaultPresentationStarted(const PresentationSessionInfo& session) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 300 |
| 305 // NOTE: Weak pointers must be invalidated before all other member variables. | 301 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 306 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; | 302 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |
| 307 | 303 |
| 308 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 304 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
| 309 }; | 305 }; |
| 310 | 306 |
| 311 } // namespace content | 307 } // namespace content |
| 312 | 308 |
| 313 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 309 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
| OLD | NEW |