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

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

Issue 1139203003: [Media Router] MediaRouterUI + WebUI handler implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add back use of MediaRouterMojoImpl Created 5 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/media_router/media_router_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/media/router/issue.h"
9 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" 12 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
13 #include "chrome/browser/ui/webui/media_router/media_cast_mode.h"
14 #include "chrome/browser/ui/webui/media_router/media_sink_with_cast_modes.h"
15 #include "chrome/browser/ui/webui/media_router/query_result_manager.h"
10 #include "content/public/browser/web_ui_data_source.h" 16 #include "content/public/browser/web_ui_data_source.h"
11 17
12 namespace media_router { 18 namespace media_router {
13 19
20 class IssuesObserver;
14 class MediaRouterWebUIMessageHandler; 21 class MediaRouterWebUIMessageHandler;
22 class MediaRoutesObserver;
15 23
16 // Implements the chrome://media-router user interface. 24 // Implements the chrome://media-router user interface.
17 class MediaRouterUI : public ConstrainedWebDialogUI { 25 class MediaRouterUI : public ConstrainedWebDialogUI,
26 public QueryResultManager::Observer {
18 public: 27 public:
19 // |web_ui| owns this object and is used to initialize the base class. 28 // |web_ui| owns this object and is used to initialize the base class.
20 explicit MediaRouterUI(content::WebUI* web_ui); 29 explicit MediaRouterUI(content::WebUI* web_ui);
21 ~MediaRouterUI() override; 30 ~MediaRouterUI() override;
22 31
23 // Closes the media router UI. 32 // Closes the media router UI.
24 void Close(); 33 void Close();
25 34
35 // Notifies this instance that the UI has been initialized.
36 void UIInitialized();
37
38 // Requests a route be created from the source determined by the preferred
39 // MediaCastMode, to the sink given by |sink_id|.
40 // The preferred cast mode is determined from the set of currently supported
41 // cast modes in |cast_modes_|.
42 // Returns false if unable to request the route.
43 // |OnRouteResponseReceived()| will be invoked when the route request
44 // completes.
45 bool CreateRoute(const MediaSinkId& sink_id);
46
47 // Requests a route be created from the source mapped to
48 // |cast_mode_override|, to the sink given by |sink_id|.
49 // Returns true if a route request is successfully submitted.
50 bool CreateRouteWithCastModeOverride(const MediaSinkId& sink_id,
51 MediaCastMode cast_mode_override);
52
53 // Calls MediaRouter to close the given route.
54 void CloseRoute(const MediaRouteId& route_id);
55
56 // Calls MediaRouter to clear the given issue.
57 void ClearIssue(const Issue::IssueId& issue_id);
58
59 // Returns the header text that should be displayed in the UI when it is
60 // initially loaded. The header text is determined by the preferred cast mode.
61 std::string GetInitialHeaderText() const;
62
63 bool has_pending_route_request() const { return has_pending_route_request_; }
64 const std::vector<MediaSinkWithCastModes>& sinks() const { return sinks_; }
65 const std::vector<MediaRoute>& routes() const { return routes_; }
66 const std::set<MediaCastMode>& cast_modes() const { return cast_modes_; }
67
26 private: 68 private:
69 class UIIssuesObserver;
70 class UIMediaRoutesObserver;
71
72 // QueryResultManager::Observer
73 void OnResultsUpdated(
74 const std::vector<MediaSinkWithCastModes>& sinks) override;
75
76 // Called by |issues_observer_| when the top issue has changed.
77 // If the UI is already initialized, notifies |handler_| to update the UI.
78 // Ignored if the UI is not yet initialized.
79 void SetIssue(const Issue* issue);
80
81 // Called by |routes_observer_| when the set of active routes has changed.
82 void OnRoutesUpdated(const std::vector<MediaRoute>& routes);
83
84 // Callback passed to MediaRouter to receive response to route creation
85 // requests.
86 void OnRouteResponseReceived(scoped_ptr<MediaRoute> route,
87 const std::string& error);
88
89 bool DoCreateRoute(const MediaSinkId& sink_id, MediaCastMode cast_mode);
90
27 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted 91 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted
28 // only after it has deleted |this|. 92 // only after it has deleted |this|.
29 MediaRouterWebUIMessageHandler* handler_; 93 MediaRouterWebUIMessageHandler* handler_;
30 94
95 // These are non-null while this instance is registered to receive
96 // updates from them.
97 scoped_ptr<IssuesObserver> issues_observer_;
98 scoped_ptr<MediaRoutesObserver> routes_observer_;
99
100 // Set to true by |handler_| when the UI has been initialized.
101 bool ui_initialized_;
102
103 // Set to |true| if there is a pending route request for this UI.
104 bool has_pending_route_request_;
105
106 std::vector<MediaSinkWithCastModes> sinks_;
107 std::vector<MediaRoute> routes_;
108 CastModeSet cast_modes_;
109
110 scoped_ptr<QueryResultManager> query_result_manager_;
111
112 // Cached pointer to the MediaRouter for this instance's BrowserContext.
113 MediaRouter* router_;
114
115 // NOTE: Weak pointers must be invalidated before all other member variables.
116 // Therefore |weak_factory_| must be placed at the end.
117 base::WeakPtrFactory<MediaRouterUI> weak_factory_;
118
31 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); 119 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI);
32 }; 120 };
33 121
34 } // namespace media_router 122 } // namespace media_router
35 123
36 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ 124 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_
OLDNEW
« no previous file with comments | « no previous file | 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