Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: chrome/browser/ui/webui/media_router/media_router_ui.h

Issue 2724513002: (Not for review) Dummy C++ side Custom Controls implementation (Closed)
Patch Set: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/optional.h"
16 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
17 #include "chrome/browser/media/router/issue.h" 18 #include "chrome/browser/media/router/issue.h"
19 #include "chrome/browser/media/router/media_route_status_observer.h"
18 #include "chrome/browser/media/router/media_source.h" 20 #include "chrome/browser/media/router/media_source.h"
19 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" 21 #include "chrome/browser/media/router/presentation_service_delegate_impl.h"
20 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" 22 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
21 #include "chrome/browser/ui/webui/media_router/media_cast_mode.h" 23 #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" 24 #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" 25 #include "chrome/browser/ui/webui/media_router/query_result_manager.h"
24 #include "content/public/browser/web_ui_data_source.h" 26 #include "content/public/browser/web_ui_data_source.h"
25 #include "third_party/icu/source/common/unicode/uversion.h" 27 #include "third_party/icu/source/common/unicode/uversion.h"
26 #include "url/gurl.h" 28 #include "url/gurl.h"
27 29
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // Marked virtual for tests. 159 // Marked virtual for tests.
158 virtual const std::string& GetRouteProviderExtensionId() const; 160 virtual const std::string& GetRouteProviderExtensionId() const;
159 161
160 // Called to track UI metrics. 162 // Called to track UI metrics.
161 void SetUIInitializationTimer(const base::Time& start_time); 163 void SetUIInitializationTimer(const base::Time& start_time);
162 void OnUIInitiallyLoaded(); 164 void OnUIInitiallyLoaded();
163 void OnUIInitialDataReceived(); 165 void OnUIInitialDataReceived();
164 166
165 void UpdateMaxDialogHeight(int height); 167 void UpdateMaxDialogHeight(int height);
166 168
169 // Sends media commands to |route_controller_| if it is set.
170 void PlayRoute();
171 void PauseRoute();
172 void SeekRoute(uint32_t time);
173 void SetRouteMute(bool mute);
174 void SetRouteVolume(float volume);
175
176 // Gets a reference to the MediaRouteController for |route_id| and
177 // instantiates an observer for media status updates for the route.
178 void OnUIDetailsViewOpened(MediaRoute::Id route_id);
179
180 // Resets |route_controller_| and |route_status_observer_|.
181 void OnUIDetailsViewClosed();
182
167 void InitForTest(MediaRouter* router, 183 void InitForTest(MediaRouter* router,
168 content::WebContents* initiator, 184 content::WebContents* initiator,
169 MediaRouterWebUIMessageHandler* handler, 185 MediaRouterWebUIMessageHandler* handler,
170 std::unique_ptr<CreatePresentationConnectionRequest> 186 std::unique_ptr<CreatePresentationConnectionRequest>
171 create_session_request); 187 create_session_request);
172 188
173 private: 189 private:
174 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, SortedSinks); 190 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, SortedSinks);
175 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, SortSinksByIconType); 191 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, SortSinksByIconType);
176 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, FilterNonDisplayRoutes); 192 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, FilterNonDisplayRoutes);
(...skipping 28 matching lines...) Expand all
205 const std::vector<MediaRoute>& routes, 221 const std::vector<MediaRoute>& routes,
206 const std::vector<MediaRoute::Id>& joinable_route_ids) override; 222 const std::vector<MediaRoute::Id>& joinable_route_ids) override;
207 223
208 private: 224 private:
209 // Callback to the owning MediaRouterUI instance. 225 // Callback to the owning MediaRouterUI instance.
210 RoutesUpdatedCallback callback_; 226 RoutesUpdatedCallback callback_;
211 227
212 DISALLOW_COPY_AND_ASSIGN(UIMediaRoutesObserver); 228 DISALLOW_COPY_AND_ASSIGN(UIMediaRoutesObserver);
213 }; 229 };
214 230
231 class UIMediaRouteStatusObserver : public MediaRouteStatusObserver {
232 public:
233 UIMediaRouteStatusObserver(MediaRouterWebUIMessageHandler* handler);
234 ~UIMediaRouteStatusObserver() override;
235
236 // MediaRouteStatusObserver
237 void OnMediaRouteStatusUpdated(const MediaStatus& status) override;
238
239 private:
240 MediaRouterWebUIMessageHandler* handler_;
241
242 DISALLOW_COPY_AND_ASSIGN(UIMediaRouteStatusObserver);
243 };
244
215 static std::string GetExtensionName(const GURL& url, 245 static std::string GetExtensionName(const GURL& url,
216 extensions::ExtensionRegistry* registry); 246 extensions::ExtensionRegistry* registry);
217 247
218 // QueryResultManager::Observer 248 // QueryResultManager::Observer
219 void OnResultsUpdated( 249 void OnResultsUpdated(
220 const std::vector<MediaSinkWithCastModes>& sinks) override; 250 const std::vector<MediaSinkWithCastModes>& sinks) override;
221 251
222 // Called by |issues_observer_| when the top issue has changed. 252 // Called by |issues_observer_| when the top issue has changed.
223 // If the UI is already initialized, notifies |handler_| to update the UI. 253 // If the UI is already initialized, notifies |handler_| to update the UI.
224 // Ignored if the UI is not yet initialized. 254 // Ignored if the UI is not yet initialized.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 void UpdateRoutesToCastModesMapping(); 314 void UpdateRoutesToCastModesMapping();
285 315
286 // Returns the default presentation request's frame URL if there is one. 316 // Returns the default presentation request's frame URL if there is one.
287 // Otherwise returns an empty GURL. 317 // Otherwise returns an empty GURL.
288 GURL GetFrameURL() const; 318 GURL GetFrameURL() const;
289 319
290 // Returns the serialized origin for |initiator_|, or the serialization of an 320 // Returns the serialized origin for |initiator_|, or the serialization of an
291 // opaque origin ("null") if |initiator_| is not set. 321 // opaque origin ("null") if |initiator_| is not set.
292 std::string GetSerializedInitiatorOrigin() const; 322 std::string GetSerializedInitiatorOrigin() const;
293 323
324 // Returns true if |routes_| contains a route with |route_id|.
325 bool IsValidRouteId(const MediaRoute::Id& route_id) const;
326
294 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted 327 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted
295 // only after it has deleted |this|. 328 // only after it has deleted |this|.
296 MediaRouterWebUIMessageHandler* handler_ = nullptr; 329 MediaRouterWebUIMessageHandler* handler_ = nullptr;
297 330
298 // These are non-null while this instance is registered to receive 331 // These are non-null while this instance is registered to receive
299 // updates from them. 332 // updates from them.
300 std::unique_ptr<IssuesObserver> issues_observer_; 333 std::unique_ptr<IssuesObserver> issues_observer_;
301 std::unique_ptr<MediaRoutesObserver> routes_observer_; 334 std::unique_ptr<MediaRoutesObserver> routes_observer_;
302 335
303 // Set to true by |handler_| when the UI has been initialized. 336 // Set to true by |handler_| when the UI has been initialized.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 374
342 content::WebContents* initiator_; 375 content::WebContents* initiator_;
343 376
344 // Pointer to the MediaRouter for this instance's BrowserContext. 377 // Pointer to the MediaRouter for this instance's BrowserContext.
345 MediaRouter* router_; 378 MediaRouter* router_;
346 379
347 // The start time for UI initialization metrics timer. When a dialog has been 380 // The start time for UI initialization metrics timer. When a dialog has been
348 // been painted and initialized with initial data, this should be cleared. 381 // been painted and initialized with initial data, this should be cleared.
349 base::Time start_time_; 382 base::Time start_time_;
350 383
384 // The ID of the media route shown in the route details view.
385 base::Optional<MediaRoute::Id> selected_route_;
386
387 // The media controller for |selected_route_|.
388 MediaRouteController* route_controller_ = nullptr;
389
390 // The observer for the media status of |selected_route_| that notifies
391 // |handler_| of updates.
392 std::unique_ptr<UIMediaRouteStatusObserver> route_status_observer_;
393
351 // NOTE: Weak pointers must be invalidated before all other member variables. 394 // NOTE: Weak pointers must be invalidated before all other member variables.
352 // Therefore |weak_factory_| must be placed at the end. 395 // Therefore |weak_factory_| must be placed at the end.
353 base::WeakPtrFactory<MediaRouterUI> weak_factory_; 396 base::WeakPtrFactory<MediaRouterUI> weak_factory_;
354 397
355 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); 398 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI);
356 }; 399 };
357 400
358 } // namespace media_router 401 } // namespace media_router
359 402
360 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ 403 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_
OLDNEW
« no previous file with comments | « chrome/browser/media/router/mojo/media_status.mojom ('k') | chrome/browser/ui/webui/media_router/media_router_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698