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 <memory> |
8 #include <set> | 9 #include <set> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
13 #include "base/macros.h" | 14 #include "base/macros.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/timer/timer.h" | 16 #include "base/timer/timer.h" |
17 #include "chrome/browser/media/router/issue.h" | 17 #include "chrome/browser/media/router/issue.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/presentation_service_delegate_impl.h" | 19 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" |
20 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | 20 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
21 #include "chrome/browser/ui/webui/media_router/media_cast_mode.h" | 21 #include "chrome/browser/ui/webui/media_router/media_cast_mode.h" |
22 #include "chrome/browser/ui/webui/media_router/media_sink_with_cast_modes.h" | 22 #include "chrome/browser/ui/webui/media_router/media_sink_with_cast_modes.h" |
23 #include "chrome/browser/ui/webui/media_router/query_result_manager.h" | 23 #include "chrome/browser/ui/webui/media_router/query_result_manager.h" |
24 #include "content/public/browser/web_ui_data_source.h" | 24 #include "content/public/browser/web_ui_data_source.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // Init* methods can only be called once. | 81 // Init* methods can only be called once. |
82 // |initiator|: Reference to the WebContents that initiated the dialog. | 82 // |initiator|: Reference to the WebContents that initiated the dialog. |
83 // Must not be null. | 83 // Must not be null. |
84 // |delegate|: PresentationServiceDelegateImpl of the initiator tab. | 84 // |delegate|: PresentationServiceDelegateImpl of the initiator tab. |
85 // Must not be null. | 85 // Must not be null. |
86 // |presentation_request|: The presentation request. This instance will take | 86 // |presentation_request|: The presentation request. This instance will take |
87 // ownership of it. Must not be null. | 87 // ownership of it. Must not be null. |
88 void InitWithPresentationSessionRequest( | 88 void InitWithPresentationSessionRequest( |
89 content::WebContents* initiator, | 89 content::WebContents* initiator, |
90 const base::WeakPtr<PresentationServiceDelegateImpl>& delegate, | 90 const base::WeakPtr<PresentationServiceDelegateImpl>& delegate, |
91 scoped_ptr<CreatePresentationConnectionRequest> presentation_request); | 91 std::unique_ptr<CreatePresentationConnectionRequest> |
| 92 presentation_request); |
92 | 93 |
93 // Closes the media router UI. | 94 // Closes the media router UI. |
94 void Close(); | 95 void Close(); |
95 | 96 |
96 // Notifies this instance that the UI has been initialized. | 97 // Notifies this instance that the UI has been initialized. |
97 void UIInitialized(); | 98 void UIInitialized(); |
98 | 99 |
99 // Requests a route be created from the source mapped to | 100 // Requests a route be created from the source mapped to |
100 // |cast_mode|, to the sink given by |sink_id|. | 101 // |cast_mode|, to the sink given by |sink_id|. |
101 // Returns true if a route request is successfully submitted. | 102 // Returns true if a route request is successfully submitted. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // Returns the default presentation request's frame URL if there is one. | 237 // Returns the default presentation request's frame URL if there is one. |
237 // Otherwise returns an empty GURL. | 238 // Otherwise returns an empty GURL. |
238 GURL GetFrameURL() const; | 239 GURL GetFrameURL() const; |
239 | 240 |
240 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted | 241 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted |
241 // only after it has deleted |this|. | 242 // only after it has deleted |this|. |
242 MediaRouterWebUIMessageHandler* handler_; | 243 MediaRouterWebUIMessageHandler* handler_; |
243 | 244 |
244 // These are non-null while this instance is registered to receive | 245 // These are non-null while this instance is registered to receive |
245 // updates from them. | 246 // updates from them. |
246 scoped_ptr<IssuesObserver> issues_observer_; | 247 std::unique_ptr<IssuesObserver> issues_observer_; |
247 scoped_ptr<MediaRoutesObserver> routes_observer_; | 248 std::unique_ptr<MediaRoutesObserver> routes_observer_; |
248 | 249 |
249 // Set to true by |handler_| when the UI has been initialized. | 250 // Set to true by |handler_| when the UI has been initialized. |
250 bool ui_initialized_; | 251 bool ui_initialized_; |
251 | 252 |
252 // Set to -1 if not tracking a pending route request. | 253 // Set to -1 if not tracking a pending route request. |
253 int current_route_request_id_; | 254 int current_route_request_id_; |
254 | 255 |
255 // Sequential counter for route requests. Used to update | 256 // Sequential counter for route requests. Used to update |
256 // |current_route_request_id_| when there is a new route request. | 257 // |current_route_request_id_| when there is a new route request. |
257 int route_request_counter_; | 258 int route_request_counter_; |
258 | 259 |
259 // Used for locale-aware sorting of sinks by name. Set during |InitCommon()| | 260 // Used for locale-aware sorting of sinks by name. Set during |InitCommon()| |
260 // using the current locale. Set to null | 261 // using the current locale. Set to null |
261 scoped_ptr<icu::Collator> collator_; | 262 std::unique_ptr<icu::Collator> collator_; |
262 | 263 |
263 std::vector<MediaSinkWithCastModes> sinks_; | 264 std::vector<MediaSinkWithCastModes> sinks_; |
264 std::vector<MediaRoute> routes_; | 265 std::vector<MediaRoute> routes_; |
265 std::vector<MediaRoute::Id> joinable_route_ids_; | 266 std::vector<MediaRoute::Id> joinable_route_ids_; |
266 CastModeSet cast_modes_; | 267 CastModeSet cast_modes_; |
267 | 268 |
268 scoped_ptr<QueryResultManager> query_result_manager_; | 269 std::unique_ptr<QueryResultManager> query_result_manager_; |
269 | 270 |
270 // If set, then the result of the next presentation route request will | 271 // If set, then the result of the next presentation route request will |
271 // be handled by this object. | 272 // be handled by this object. |
272 scoped_ptr<CreatePresentationConnectionRequest> create_session_request_; | 273 std::unique_ptr<CreatePresentationConnectionRequest> create_session_request_; |
273 | 274 |
274 // Set to the presentation request corresponding to the presentation cast | 275 // Set to the presentation request corresponding to the presentation cast |
275 // mode, if supported. Otherwise set to nullptr. | 276 // mode, if supported. Otherwise set to nullptr. |
276 scoped_ptr<PresentationRequest> presentation_request_; | 277 std::unique_ptr<PresentationRequest> presentation_request_; |
277 | 278 |
278 // It's possible for PresentationServiceDelegateImpl to be destroyed before | 279 // It's possible for PresentationServiceDelegateImpl to be destroyed before |
279 // this class. | 280 // this class. |
280 // (e.g. if a tab with the UI open is closed, then the tab WebContents will | 281 // (e.g. if a tab with the UI open is closed, then the tab WebContents will |
281 // be destroyed first momentarily before the UI WebContents). | 282 // be destroyed first momentarily before the UI WebContents). |
282 // Holding a WeakPtr to PresentationServiceDelegateImpl is the cleanest way to | 283 // Holding a WeakPtr to PresentationServiceDelegateImpl is the cleanest way to |
283 // handle this. | 284 // handle this. |
284 // TODO(imcheng): hold a weak ptr to an abstract type instead. | 285 // TODO(imcheng): hold a weak ptr to an abstract type instead. |
285 base::WeakPtr<PresentationServiceDelegateImpl> presentation_service_delegate_; | 286 base::WeakPtr<PresentationServiceDelegateImpl> presentation_service_delegate_; |
286 | 287 |
287 content::WebContents* initiator_; | 288 content::WebContents* initiator_; |
288 | 289 |
289 // Pointer to the MediaRouter for this instance's BrowserContext. | 290 // Pointer to the MediaRouter for this instance's BrowserContext. |
290 MediaRouter* router_; | 291 MediaRouter* router_; |
291 | 292 |
292 // The start time for UI initialization metrics timer. When a dialog has been | 293 // The start time for UI initialization metrics timer. When a dialog has been |
293 // been painted and initialized with initial data, this should be cleared. | 294 // been painted and initialized with initial data, this should be cleared. |
294 base::Time start_time_; | 295 base::Time start_time_; |
295 | 296 |
296 // NOTE: Weak pointers must be invalidated before all other member variables. | 297 // NOTE: Weak pointers must be invalidated before all other member variables. |
297 // Therefore |weak_factory_| must be placed at the end. | 298 // Therefore |weak_factory_| must be placed at the end. |
298 base::WeakPtrFactory<MediaRouterUI> weak_factory_; | 299 base::WeakPtrFactory<MediaRouterUI> weak_factory_; |
299 | 300 |
300 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); | 301 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); |
301 }; | 302 }; |
302 | 303 |
303 } // namespace media_router | 304 } // namespace media_router |
304 | 305 |
305 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ | 306 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ |
OLD | NEW |