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_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 23 matching lines...) Expand all Loading... |
34 class MediaRouter; | 34 class MediaRouter; |
35 class MediaRouterDialogCallbacks; | 35 class MediaRouterDialogCallbacks; |
36 class MediaRouterMojoImpl; | 36 class MediaRouterMojoImpl; |
37 class MediaRouterWebUIMessageHandler; | 37 class MediaRouterWebUIMessageHandler; |
38 class MediaRoutesObserver; | 38 class MediaRoutesObserver; |
39 class MediaSink; | 39 class MediaSink; |
40 class MediaSinksObserver; | 40 class MediaSinksObserver; |
41 class CreatePresentationSessionRequest; | 41 class CreatePresentationSessionRequest; |
42 | 42 |
43 // Implements the chrome://media-router user interface. | 43 // Implements the chrome://media-router user interface. |
44 class MediaRouterUI | 44 class MediaRouterUI : public ConstrainedWebDialogUI, |
45 : public ConstrainedWebDialogUI, | 45 public QueryResultManager::Observer, |
46 public QueryResultManager::Observer, | 46 public PresentationServiceDelegateImpl:: |
47 public PresentationServiceDelegateImpl::DefaultMediaSourceObserver { | 47 DefaultPresentationRequestObserver { |
48 public: | 48 public: |
49 // |web_ui| owns this object and is used to initialize the base class. | 49 // |web_ui| owns this object and is used to initialize the base class. |
50 explicit MediaRouterUI(content::WebUI* web_ui); | 50 explicit MediaRouterUI(content::WebUI* web_ui); |
51 ~MediaRouterUI() override; | 51 ~MediaRouterUI() override; |
52 | 52 |
53 // Initializes internal state (e.g. starts listening for MediaSinks) for | 53 // Initializes internal state (e.g. starts listening for MediaSinks) for |
54 // targeting the default MediaSource (if any) of the initiator tab that owns | 54 // targeting the default MediaSource (if any) of the initiator tab that owns |
55 // |delegate|, as well as mirroring sources of that tab. | 55 // |delegate|, as well as mirroring sources of that tab. |
56 // The contents of the UI will change as the default MediaSource changes. | 56 // The contents of the UI will change as the default MediaSource changes. |
57 // If there is a default MediaSource, then DEFAULT MediaCastMode will be | 57 // If there is a default MediaSource, then DEFAULT MediaCastMode will be |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // requests. | 156 // requests. |
157 void OnRouteResponseReceived(const int route_request_id, | 157 void OnRouteResponseReceived(const int route_request_id, |
158 const MediaSink::Id& sink_id, | 158 const MediaSink::Id& sink_id, |
159 const MediaRoute* route, | 159 const MediaRoute* route, |
160 const std::string& presentation_id, | 160 const std::string& presentation_id, |
161 const std::string& error); | 161 const std::string& error); |
162 | 162 |
163 // Creates and sends an issue if route creation times out. | 163 // Creates and sends an issue if route creation times out. |
164 void RouteCreationTimeout(); | 164 void RouteCreationTimeout(); |
165 | 165 |
166 // Sets the source host name to be displayed in the UI. | 166 // Initializes the dialog with mirroring sources derived from |initiator|. |
167 // Gets cast modes from |query_result_manager_| and forwards it to UI. | 167 void InitCommon(content::WebContents* initiator); |
168 // One of the Init* functions must have been called before. | |
169 void UpdateSourceHostAndCastModes(const GURL& frame_url); | |
170 | 168 |
171 // Initializes the dialog with mirroring sources derived from |initiator|, | 169 // PresentationServiceDelegateImpl::DefaultPresentationObserver |
172 // and optional |default_source| and |default_frame_url| if any. | 170 void OnDefaultPresentationChanged( |
173 void InitCommon(content::WebContents* initiator, | 171 const PresentationRequest* presentation_request) override; |
174 const MediaSource& default_source, | |
175 const GURL& default_frame_url); | |
176 | |
177 // PresentationServiceDelegateImpl::DefaultMediaSourceObserver | |
178 void OnDefaultMediaSourceChanged(const MediaSource& source, | |
179 const GURL& frame_url) override; | |
180 | 172 |
181 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted | 173 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted |
182 // only after it has deleted |this|. | 174 // only after it has deleted |this|. |
183 MediaRouterWebUIMessageHandler* handler_; | 175 MediaRouterWebUIMessageHandler* handler_; |
184 | 176 |
185 // These are non-null while this instance is registered to receive | 177 // These are non-null while this instance is registered to receive |
186 // updates from them. | 178 // updates from them. |
187 scoped_ptr<IssuesObserver> issues_observer_; | 179 scoped_ptr<IssuesObserver> issues_observer_; |
188 scoped_ptr<MediaRoutesObserver> routes_observer_; | 180 scoped_ptr<MediaRoutesObserver> routes_observer_; |
189 | 181 |
(...skipping 11 matching lines...) Expand all Loading... |
201 | 193 |
202 std::vector<MediaSinkWithCastModes> sinks_; | 194 std::vector<MediaSinkWithCastModes> sinks_; |
203 std::vector<MediaRoute> routes_; | 195 std::vector<MediaRoute> routes_; |
204 CastModeSet cast_modes_; | 196 CastModeSet cast_modes_; |
205 GURL frame_url_; | 197 GURL frame_url_; |
206 | 198 |
207 scoped_ptr<QueryResultManager> query_result_manager_; | 199 scoped_ptr<QueryResultManager> query_result_manager_; |
208 | 200 |
209 // If set, then the result of the next presentation route request will | 201 // If set, then the result of the next presentation route request will |
210 // be handled by this object. | 202 // be handled by this object. |
211 scoped_ptr<CreatePresentationSessionRequest> presentation_request_; | 203 scoped_ptr<CreatePresentationSessionRequest> create_session_request_; |
| 204 |
| 205 // Set to the presentation request corresponding to the presentation cast |
| 206 // mode, if supported. Otherwise set to nullptr. |
| 207 scoped_ptr<PresentationRequest> presentation_request_; |
212 | 208 |
213 // It's possible for PresentationServiceDelegateImpl to be destroyed before | 209 // It's possible for PresentationServiceDelegateImpl to be destroyed before |
214 // this class. | 210 // this class. |
215 // (e.g. if a tab with the UI open is closed, then the tab WebContents will | 211 // (e.g. if a tab with the UI open is closed, then the tab WebContents will |
216 // be destroyed first momentarily before the UI WebContents). | 212 // be destroyed first momentarily before the UI WebContents). |
217 // Holding a WeakPtr to PresentationServiceDelegateImpl is the cleanest way to | 213 // Holding a WeakPtr to PresentationServiceDelegateImpl is the cleanest way to |
218 // handle this. | 214 // handle this. |
219 // TODO(imcheng): hold a weak ptr to an abstract type instead. | 215 // TODO(imcheng): hold a weak ptr to an abstract type instead. |
220 base::WeakPtr<PresentationServiceDelegateImpl> presentation_service_delegate_; | 216 base::WeakPtr<PresentationServiceDelegateImpl> presentation_service_delegate_; |
221 | 217 |
222 content::WebContents* initiator_; | 218 content::WebContents* initiator_; |
223 | 219 |
224 // Pointer to the MediaRouter for this instance's BrowserContext. | 220 // Pointer to the MediaRouter for this instance's BrowserContext. |
225 MediaRouterMojoImpl* router_; | 221 MediaRouterMojoImpl* router_; |
226 | 222 |
227 // Timer used to implement a timeout on a create route request. | 223 // Timer used to implement a timeout on a create route request. |
228 base::OneShotTimer route_creation_timer_; | 224 base::OneShotTimer route_creation_timer_; |
229 | 225 |
230 // NOTE: Weak pointers must be invalidated before all other member variables. | 226 // NOTE: Weak pointers must be invalidated before all other member variables. |
231 // Therefore |weak_factory_| must be placed at the end. | 227 // Therefore |weak_factory_| must be placed at the end. |
232 base::WeakPtrFactory<MediaRouterUI> weak_factory_; | 228 base::WeakPtrFactory<MediaRouterUI> weak_factory_; |
233 | 229 |
234 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); | 230 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); |
235 }; | 231 }; |
236 | 232 |
237 } // namespace media_router | 233 } // namespace media_router |
238 | 234 |
239 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ | 235 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ |
OLD | NEW |