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 CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "chrome/browser/media/router/media_router.h" | 17 #include "chrome/browser/media/router/media_router.h" |
18 #include "chrome/browser/media/router/media_source.h" | 18 #include "chrome/browser/media/router/media_source.h" |
19 #include "chrome/browser/media/router/render_frame_host_id.h" | |
19 #include "content/public/browser/presentation_service_delegate.h" | 20 #include "content/public/browser/presentation_service_delegate.h" |
20 #include "content/public/browser/web_contents_observer.h" | 21 #include "content/public/browser/web_contents_observer.h" |
21 #include "content/public/browser/web_contents_user_data.h" | 22 #include "content/public/browser/web_contents_user_data.h" |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 class RenderFrameHost; | 25 class RenderFrameHost; |
25 class PresentationScreenAvailabilityListener; | 26 class PresentationScreenAvailabilityListener; |
26 class WebContents; | 27 class WebContents; |
27 struct PresentationSessionInfo; | 28 struct PresentationSessionInfo; |
28 struct PresentationSessionMessage; | 29 struct PresentationSessionMessage; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 int render_frame_id, | 69 int render_frame_id, |
69 content::PresentationScreenAvailabilityListener* listener) override; | 70 content::PresentationScreenAvailabilityListener* listener) override; |
70 void RemoveScreenAvailabilityListener( | 71 void RemoveScreenAvailabilityListener( |
71 int render_process_id, | 72 int render_process_id, |
72 int render_frame_id, | 73 int render_frame_id, |
73 content::PresentationScreenAvailabilityListener* listener) override; | 74 content::PresentationScreenAvailabilityListener* listener) override; |
74 void Reset(int render_process_id, int render_frame_id) override; | 75 void Reset(int render_process_id, int render_frame_id) override; |
75 void SetDefaultPresentationUrl( | 76 void SetDefaultPresentationUrl( |
76 int render_process_id, | 77 int render_process_id, |
77 int render_frame_id, | 78 int render_frame_id, |
78 const std::string& default_presentation_url) override; | 79 const std::string& default_presentation_url, |
80 const PresentationSessionStartedCallback& callback) override; | |
79 void StartSession(int render_process_id, | 81 void StartSession(int render_process_id, |
80 int render_frame_id, | 82 int render_frame_id, |
81 const std::string& presentation_url, | 83 const std::string& presentation_url, |
82 const PresentationSessionSuccessCallback& success_cb, | 84 const PresentationSessionStartedCallback& success_cb, |
83 const PresentationSessionErrorCallback& error_cb) override; | 85 const PresentationSessionErrorCallback& error_cb) override; |
84 void JoinSession(int render_process_id, | 86 void JoinSession(int render_process_id, |
85 int render_frame_id, | 87 int render_frame_id, |
86 const std::string& presentation_url, | 88 const std::string& presentation_url, |
87 const std::string& presentation_id, | 89 const std::string& presentation_id, |
88 const PresentationSessionSuccessCallback& success_cb, | 90 const PresentationSessionStartedCallback& success_cb, |
89 const PresentationSessionErrorCallback& error_cb) override; | 91 const PresentationSessionErrorCallback& error_cb) override; |
90 void CloseSession(int render_process_id, | 92 void CloseSession(int render_process_id, |
91 int render_frame_id, | 93 int render_frame_id, |
92 const std::string& presentation_id) override; | 94 const std::string& presentation_id) override; |
93 void ListenForSessionMessages( | 95 void ListenForSessionMessages( |
94 int render_process_id, | 96 int render_process_id, |
95 int render_frame_id, | 97 int render_frame_id, |
96 const content::PresentationSessionInfo& session, | 98 const content::PresentationSessionInfo& session, |
97 const content::PresentationSessionMessageCallback& message_cb) override; | 99 const content::PresentationSessionMessageCallback& message_cb) override; |
98 void SendMessage(int render_process_id, | 100 void SendMessage( |
99 int render_frame_id, | 101 int render_process_id, |
100 const content::PresentationSessionInfo& session, | 102 int render_frame_id, |
101 scoped_ptr<content::PresentationSessionMessage> message, | 103 const content::PresentationSessionInfo& session, |
102 const SendMessageCallback& send_message_cb) override; | 104 scoped_ptr<content::PresentationSessionMessage> message, |
105 const content::SendMessageCallback& send_message_cb) override; | |
103 bool ListenForSessionStateChange( | 106 bool ListenForSessionStateChange( |
104 int render_process_id, | 107 int render_process_id, |
105 int render_frame_id, | 108 int render_frame_id, |
106 content::PresentationSessionStateListener* listener) override; | 109 content::PresentationSessionStateListener* listener) override; |
110 void NotifyWhenReceiverSessionIsAvailable( | |
111 int render_process_id, | |
112 int render_frame_id, | |
113 const content::PresentationReceiverSessionAvailableCallback& callback) | |
114 override; | |
107 | 115 |
108 // Callback invoked when there is a route response from CreateRoute/JoinRoute | 116 // Callback invoked when there is a route response from CreateRoute/JoinRoute |
109 // outside of a Presentation API request. This could be due to | 117 // outside of a Presentation API request. This could be due to |
110 // browser action (e.g., browser initiated media router dialog) or | 118 // browser action (e.g., browser initiated media router dialog) or |
111 // a media route provider (e.g., autojoin). | 119 // a media route provider (e.g., autojoin). |
112 void OnRouteResponse(const MediaRoute* route, | 120 void OnRouteResponse(const MediaRoute* route, |
113 const std::string& presentation_id, | 121 const std::string& presentation_id, |
114 const std::string& error); | 122 const std::string& error); |
115 | 123 |
116 // Returns the default MediaSource for this tab if there is one. | 124 // Returns the default MediaSource for this tab if there is one. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 explicit PresentationServiceDelegateImpl(content::WebContents* web_contents); | 165 explicit PresentationServiceDelegateImpl(content::WebContents* web_contents); |
158 | 166 |
159 // Returns |listener|'s presentation URL as a MediaSource. If |listener| does | 167 // Returns |listener|'s presentation URL as a MediaSource. If |listener| does |
160 // not have a persentation URL, returns the tab mirroring MediaSource. | 168 // not have a persentation URL, returns the tab mirroring MediaSource. |
161 MediaSource GetMediaSourceFromListener( | 169 MediaSource GetMediaSourceFromListener( |
162 content::PresentationScreenAvailabilityListener* listener); | 170 content::PresentationScreenAvailabilityListener* listener); |
163 | 171 |
164 void OnJoinRouteResponse(int render_process_id, | 172 void OnJoinRouteResponse(int render_process_id, |
165 int render_frame_id, | 173 int render_frame_id, |
166 const content::PresentationSessionInfo& session, | 174 const content::PresentationSessionInfo& session, |
167 const PresentationSessionSuccessCallback& success_cb, | 175 const PresentationSessionStartedCallback& success_cb, |
168 const PresentationSessionErrorCallback& error_cb, | 176 const PresentationSessionErrorCallback& error_cb, |
169 const MediaRoute* route, | 177 const MediaRoute* route, |
170 const std::string& presentation_id, | 178 const std::string& presentation_id, |
171 const std::string& error_text); | 179 const std::string& error_text); |
172 | 180 |
173 void OnStartSessionSucceeded( | 181 void OnStartSessionSucceeded( |
174 int render_process_id, | 182 int render_process_id, |
175 int render_frame_id, | 183 int render_frame_id, |
176 const PresentationSessionSuccessCallback& success_cb, | 184 const PresentationSessionStartedCallback& success_cb, |
177 const content::PresentationSessionInfo& new_session, | 185 const content::PresentationSessionInfo& new_session, |
178 const MediaRoute::Id& route_id); | 186 const MediaRoute& route); |
179 | 187 |
180 // Returns |true| if the frame is the main frame of |web_contents_|. | 188 // Returns |true| if the frame is the main frame of |web_contents_|. |
181 bool IsMainFrame(int render_process_id, int render_frame_id) const; | 189 bool IsMainFrame(int render_process_id, int render_frame_id) const; |
182 | 190 |
183 // Updates tab-level default MediaSource, default frame URL, and the | 191 // Updates tab-level default MediaSource, default frame URL, and the |
184 // originating frame. If the source or frame URL changed, notify the | 192 // originating frame. If the source or frame URL changed, notify the |
185 // observers. | 193 // observers. |
186 void UpdateDefaultMediaSourceAndNotifyObservers( | 194 void UpdateDefaultMediaSourceAndNotifyObservers( |
187 const RenderFrameHostId& render_frame_host_id, | 195 const RenderFrameHostId& render_frame_host_id, |
188 const MediaSource& new_default_source, | 196 const MediaSource& new_default_source, |
189 const GURL& new_default_frame_url); | 197 const GURL& new_default_frame_url); |
190 | 198 |
191 // ID of RenderFrameHost that contains the default presentation. | 199 // ID of RenderFrameHost that contains the default presentation. |
192 RenderFrameHostId default_presentation_render_frame_host_id_; | 200 RenderFrameHostId default_presentation_render_frame_host_id_; |
193 // Default MediaSource for the tab associated with this instance. | 201 // Default MediaSource for the tab associated with this instance. |
194 MediaSource default_source_; | 202 MediaSource default_source_; |
195 // URL of the frame that contains the default MediaSource. | 203 // URL of the frame that contains the default MediaSource. |
196 GURL default_frame_url_; | 204 GURL default_frame_url_; |
197 | 205 |
198 // References to the observers listening for changes to default media source. | 206 // References to the observers listening for changes to default media source. |
199 base::ObserverList< | 207 base::ObserverList< |
200 DefaultMediaSourceObserver> default_media_source_observers_; | 208 DefaultMediaSourceObserver> default_media_source_observers_; |
201 | 209 |
202 // References to the WebContents that owns this instance, and associated | 210 // References to the WebContents that owns this instance, and associated |
203 // browser profile's MediaRouter instance. | 211 // browser profile's MediaRouter instance. |
204 content::WebContents* web_contents_; | 212 content::WebContents* const web_contents_; |
205 MediaRouter* router_; | 213 MediaRouter* router_; |
206 | 214 |
207 scoped_ptr<PresentationFrameManager> frame_manager_; | 215 scoped_ptr<PresentationFrameManager> frame_manager_; |
miu
2015/10/20 00:56:50
This should not be a scoped_ptr<> type. Avoid the
imcheng
2016/06/13 22:30:01
PresentationFrameManager is defined in the .cc fil
| |
216 scoped_ptr<PresentationController> controller_; | |
miu
2015/10/20 00:56:50
This new data member appears to be unused.
imcheng
2016/06/13 22:30:01
Removed.
| |
208 | 217 |
209 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; | 218 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; |
210 | 219 |
211 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); | 220 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); |
212 }; | 221 }; |
213 | 222 |
214 } // namespace media_router | 223 } // namespace media_router |
215 | 224 |
216 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ | 225 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
OLD | NEW |