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" | |
30 | 29 |
31 namespace content { | 30 namespace content { |
32 | 31 |
33 struct FrameNavigateParams; | 32 struct FrameNavigateParams; |
34 struct LoadCommittedDetails; | 33 struct LoadCommittedDetails; |
35 struct PresentationSessionMessage; | 34 struct PresentationSessionMessage; |
36 class RenderFrameHost; | 35 class RenderFrameHost; |
37 | 36 |
38 using NewSessionMojoCallback = mojo::Callback< | 37 using NewSessionMojoCallback = mojo::Callback< |
39 void(presentation::PresentationSessionInfoPtr, | 38 void(presentation::PresentationSessionInfoPtr, |
40 presentation::PresentationErrorPtr)>; | 39 presentation::PresentationErrorPtr)>; |
41 | 40 |
42 // Implementation of Mojo PresentationService. | 41 // Implementation of Mojo PresentationService. |
43 // It handles Presentation API requests coming from Blink / renderer process | 42 // It handles Presentation API requests coming from Blink / renderer process |
44 // and delegates the requests to the embedder's media router via | 43 // and delegates the requests to the embedder's media router via |
45 // PresentationServiceDelegate. | 44 // PresentationServiceDelegate. |
46 // An instance of this class tied to a RenderFrameHost and listens to events | 45 // An instance of this class tied to a RenderFrameHost and listens to events |
47 // related to the RFH via implementing WebContentsObserver. | 46 // related to the RFH via implementing WebContentsObserver. |
48 // This class is instantiated on-demand via Mojo's ConnectToRemoteService | 47 // This class is instantiated on-demand via Mojo's ConnectToRemoteService |
49 // from the renderer when the first presentation API request is handled. | 48 // from the renderer when the first presentation API request is handled. |
50 class CONTENT_EXPORT PresentationServiceImpl | 49 class CONTENT_EXPORT PresentationServiceImpl |
51 : public NON_EXPORTED_BASE(presentation::PresentationService), | 50 : 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 |
201 // WebContentsObserver override. | 205 // WebContentsObserver override. |
202 void DidNavigateAnyFrame( | 206 void DidNavigateAnyFrame( |
203 content::RenderFrameHost* render_frame_host, | 207 content::RenderFrameHost* render_frame_host, |
204 const content::LoadCommittedDetails& details, | 208 const content::LoadCommittedDetails& details, |
205 const content::FrameNavigateParams& params) override; | 209 const content::FrameNavigateParams& params) override; |
206 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; | 210 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
207 | 211 |
208 // PresentationServiceDelegate::Observer | 212 // PresentationServiceDelegate::Observer |
209 void OnDelegateDestroyed() override; | 213 void OnDelegateDestroyed() override; |
210 void OnDefaultPresentationStarted(const PresentationSessionInfo& session) | 214 void OnDefaultPresentationStarted(const PresentationSessionInfo& session) |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 304 |
301 // NOTE: Weak pointers must be invalidated before all other member variables. | 305 // NOTE: Weak pointers must be invalidated before all other member variables. |
302 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; | 306 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |
303 | 307 |
304 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 308 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
305 }; | 309 }; |
306 | 310 |
307 } // namespace content | 311 } // namespace content |
308 | 312 |
309 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 313 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
OLD | NEW |