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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "content/common/presentation/presentation_service.mojom.h" | 15 #include "content/common/presentation/presentation_service.mojom.h" |
| 16 #include "content/common/presentation/presentation_session.mojom.h" |
16 #include "content/public/browser/navigation_details.h" | 17 #include "content/public/browser/navigation_details.h" |
17 #include "content/public/browser/presentation_screen_availability_listener.h" | 18 #include "content/public/browser/presentation_screen_availability_listener.h" |
18 #include "content/public/browser/presentation_service_delegate.h" | 19 #include "content/public/browser/presentation_service_delegate.h" |
19 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
20 #include "content/public/common/frame_navigate_params.h" | 21 #include "content/public/common/frame_navigate_params.h" |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 | 24 |
24 struct FrameNavigateParams; | 25 struct FrameNavigateParams; |
25 struct LoadCommittedDetails; | 26 struct LoadCommittedDetails; |
(...skipping 16 matching lines...) Expand all Loading... |
42 ~PresentationServiceImpl() override; | 43 ~PresentationServiceImpl() override; |
43 | 44 |
44 // Static factory method to create an instance of PresentationServiceImpl. | 45 // Static factory method to create an instance of PresentationServiceImpl. |
45 // |render_frame_host|: The RFH the instance is associated with. | 46 // |render_frame_host|: The RFH the instance is associated with. |
46 // |request|: The instance will be bound to this request. Used for Mojo setup. | 47 // |request|: The instance will be bound to this request. Used for Mojo setup. |
47 static void CreateMojoService( | 48 static void CreateMojoService( |
48 RenderFrameHost* render_frame_host, | 49 RenderFrameHost* render_frame_host, |
49 mojo::InterfaceRequest<presentation::PresentationService> request); | 50 mojo::InterfaceRequest<presentation::PresentationService> request); |
50 | 51 |
51 private: | 52 private: |
52 typedef mojo::Callback<void(bool)> ScreenAvailabilityMojoCallback; | 53 using ScreenAvailabilityMojoCallback = mojo::Callback<void(bool)>; |
| 54 using NewSessionMojoCallback = |
| 55 mojo::Callback<void(presentation::PresentationSessionInfoPtr, |
| 56 presentation::PresentationErrorPtr)>; |
53 | 57 |
54 friend class PresentationServiceImplTest; | 58 friend class PresentationServiceImplTest; |
55 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, RemoveAllListeners); | 59 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, RemoveAllListeners); |
56 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 60 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
57 DidNavigateThisFrame); | 61 DidNavigateThisFrame); |
58 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 62 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
59 DidNavigateNotThisFrame); | 63 DidNavigateNotThisFrame); |
60 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 64 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
61 ThisRenderFrameDeleted); | 65 ThisRenderFrameDeleted); |
62 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 66 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
63 NotThisRenderFrameDeleted); | 67 NotThisRenderFrameDeleted); |
64 | 68 |
65 // |render_frame_host|: The RFH this instance is associated with. | 69 // |render_frame_host|: The RFH this instance is associated with. |
66 // |web_contents|: The WebContents to observe. | 70 // |web_contents|: The WebContents to observe. |
67 // |delegate|: Where Presentation API requests are delegated to. Not owned | 71 // |delegate|: Where Presentation API requests are delegated to. Not owned |
68 // by this class. | 72 // by this class. |
69 PresentationServiceImpl( | 73 PresentationServiceImpl( |
70 RenderFrameHost* render_frame_host, | 74 RenderFrameHost* render_frame_host, |
71 WebContents* web_contents, | 75 WebContents* web_contents, |
72 PresentationServiceDelegate* delegate); | 76 PresentationServiceDelegate* delegate); |
73 | 77 |
74 // PresentationService implementation. | 78 // PresentationService implementation. |
75 void GetScreenAvailability( | 79 void GetScreenAvailability( |
76 const mojo::String& presentation_url, | 80 const mojo::String& presentation_url, |
77 const ScreenAvailabilityMojoCallback& callback) override; | 81 const ScreenAvailabilityMojoCallback& callback) override; |
78 void OnScreenAvailabilityListenerRemoved() override; | 82 void OnScreenAvailabilityListenerRemoved() override; |
| 83 void StartSession( |
| 84 const mojo::String& presentation_url, |
| 85 const mojo::String& presentation_id, |
| 86 const NewSessionMojoCallback& callback) override; |
| 87 void JoinSession( |
| 88 const mojo::String& presentation_url, |
| 89 const mojo::String& presentation_id, |
| 90 const NewSessionMojoCallback& callback) override; |
79 | 91 |
80 // mojo::InterfaceImpl override. | 92 // mojo::InterfaceImpl override. |
81 // Note that this is called when the RenderFrameHost is deleted. | 93 // Note that this is called when the RenderFrameHost is deleted. |
82 void OnConnectionError() override; | 94 void OnConnectionError() override; |
83 | 95 |
84 // WebContentsObserver override. | 96 // WebContentsObserver override. |
85 void DidNavigateAnyFrame( | 97 void DidNavigateAnyFrame( |
86 content::RenderFrameHost* render_frame_host, | 98 content::RenderFrameHost* render_frame_host, |
87 const content::LoadCommittedDetails& details, | 99 const content::LoadCommittedDetails& details, |
88 const content::FrameNavigateParams& params) override; | 100 const content::FrameNavigateParams& params) override; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 availability_contexts_; | 155 availability_contexts_; |
144 | 156 |
145 std::string default_presentation_url_; | 157 std::string default_presentation_url_; |
146 | 158 |
147 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 159 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
148 }; | 160 }; |
149 | 161 |
150 } // namespace content | 162 } // namespace content |
151 | 163 |
152 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 164 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
OLD | NEW |