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

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

Issue 1415103006: Non-Local Join for Media Router and Presentation API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing ChromeOS System Tray Test Created 4 years, 11 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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Notifies this instance that the UI has been initialized. 96 // Notifies this instance that the UI has been initialized.
97 void UIInitialized(); 97 void UIInitialized();
98 98
99 // Requests a route be created from the source mapped to 99 // Requests a route be created from the source mapped to
100 // |cast_mode|, to the sink given by |sink_id|. 100 // |cast_mode|, to the sink given by |sink_id|.
101 // Returns true if a route request is successfully submitted. 101 // Returns true if a route request is successfully submitted.
102 // |OnRouteResponseReceived()| will be invoked when the route request 102 // |OnRouteResponseReceived()| will be invoked when the route request
103 // completes. 103 // completes.
104 bool CreateRoute(const MediaSink::Id& sink_id, MediaCastMode cast_mode); 104 bool CreateRoute(const MediaSink::Id& sink_id, MediaCastMode cast_mode);
105 105
106 // Calls MediaRouter to join the given route.
107 bool ConnectRoute(const MediaSink::Id& sink_id,
108 const MediaRoute::Id& route_id);
109
106 // Calls MediaRouter to close the given route. 110 // Calls MediaRouter to close the given route.
107 void CloseRoute(const MediaRoute::Id& route_id); 111 void CloseRoute(const MediaRoute::Id& route_id);
108 112
109 // Calls MediaRouter to add the given issue. 113 // Calls MediaRouter to add the given issue.
110 void AddIssue(const Issue& issue); 114 void AddIssue(const Issue& issue);
111 115
112 // Calls MediaRouter to clear the given issue. 116 // Calls MediaRouter to clear the given issue.
113 void ClearIssue(const Issue::Id& issue_id); 117 void ClearIssue(const Issue::Id& issue_id);
114 118
115 // Returns the hostname of the default source's parent frame URL. 119 // Returns the hostname of the default source's parent frame URL.
116 std::string GetPresentationRequestSourceName() const; 120 std::string GetPresentationRequestSourceName() const;
117 std::string GetTruncatedPresentationRequestSourceName() const; 121 std::string GetTruncatedPresentationRequestSourceName() const;
118 bool HasPendingRouteRequest() const { 122 bool HasPendingRouteRequest() const {
119 return current_route_request_id_ != -1; 123 return current_route_request_id_ != -1;
120 } 124 }
121 const std::vector<MediaSinkWithCastModes>& sinks() const { return sinks_; } 125 const std::vector<MediaSinkWithCastModes>& sinks() const { return sinks_; }
122 const std::vector<MediaRoute>& routes() const { return routes_; } 126 const std::vector<MediaRoute>& routes() const { return routes_; }
127 const std::vector<MediaRoute::Id>& joinable_route_ids() const {
128 return joinable_route_ids_;
129 }
123 const std::set<MediaCastMode>& cast_modes() const { return cast_modes_; } 130 const std::set<MediaCastMode>& cast_modes() const { return cast_modes_; }
124 const content::WebContents* initiator() const { return initiator_; } 131 const content::WebContents* initiator() const { return initiator_; }
125 132
126 // Marked virtual for tests. 133 // Marked virtual for tests.
127 virtual const std::string& GetRouteProviderExtensionId() const; 134 virtual const std::string& GetRouteProviderExtensionId() const;
128 135
129 // Called to track UI metrics. 136 // Called to track UI metrics.
130 void SetUIInitializationTimer(const base::Time& start_time); 137 void SetUIInitializationTimer(const base::Time& start_time);
131 void OnUIInitiallyLoaded(); 138 void OnUIInitiallyLoaded();
132 void OnUIInitialDataReceived(); 139 void OnUIInitialDataReceived();
133 140
134 private: 141 private:
135 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, SortedSinks); 142 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, SortedSinks);
136 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, 143 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest,
137 UIMediaRoutesObserverFiltersNonDisplayRoutes); 144 UIMediaRoutesObserverFiltersNonDisplayRoutes);
145 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest,
146 UIMediaRoutesObserverFiltersNonDisplayJoinableRoutes);
138 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, GetExtensionNameExtensionPresent); 147 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, GetExtensionNameExtensionPresent);
139 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, 148 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest,
140 GetExtensionNameEmptyWhenNotInstalled); 149 GetExtensionNameEmptyWhenNotInstalled);
141 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, 150 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest,
142 GetExtensionNameEmptyWhenNotExtensionURL); 151 GetExtensionNameEmptyWhenNotExtensionURL);
143 152
144 class UIIssuesObserver; 153 class UIIssuesObserver;
154
145 class UIMediaRoutesObserver : public MediaRoutesObserver { 155 class UIMediaRoutesObserver : public MediaRoutesObserver {
146 public: 156 public:
147 using RoutesUpdatedCallback = 157 using RoutesUpdatedCallback =
148 base::Callback<void(const std::vector<MediaRoute>&)>; 158 base::Callback<void(const std::vector<MediaRoute>&,
149 UIMediaRoutesObserver(MediaRouter* router, 159 const std::vector<MediaRoute::Id>&)>;
160 UIMediaRoutesObserver(MediaRouter* router, const MediaSource::Id& source_id,
150 const RoutesUpdatedCallback& callback); 161 const RoutesUpdatedCallback& callback);
151 ~UIMediaRoutesObserver() override; 162 ~UIMediaRoutesObserver() override;
152 163
153 // MediaRoutesObserver 164 // MediaRoutesObserver
154 void OnRoutesUpdated(const std::vector<MediaRoute>& routes) override; 165 void OnRoutesUpdated(
166 const std::vector<MediaRoute>& routes,
167 const std::vector<MediaRoute::Id>& joinable_route_ids) override;
155 168
156 private: 169 private:
157 // Callback to the owning MediaRouterUI instance. 170 // Callback to the owning MediaRouterUI instance.
158 RoutesUpdatedCallback callback_; 171 RoutesUpdatedCallback callback_;
159 172
160 DISALLOW_COPY_AND_ASSIGN(UIMediaRoutesObserver); 173 DISALLOW_COPY_AND_ASSIGN(UIMediaRoutesObserver);
161 }; 174 };
162 175
163 static std::string GetExtensionName(const GURL& url, 176 static std::string GetExtensionName(const GURL& url,
164 extensions::ExtensionRegistry* registry); 177 extensions::ExtensionRegistry* registry);
165 178
166 // QueryResultManager::Observer 179 // QueryResultManager::Observer
167 void OnResultsUpdated( 180 void OnResultsUpdated(
168 const std::vector<MediaSinkWithCastModes>& sinks) override; 181 const std::vector<MediaSinkWithCastModes>& sinks) override;
169 182
170 // Called by |issues_observer_| when the top issue has changed. 183 // Called by |issues_observer_| when the top issue has changed.
171 // If the UI is already initialized, notifies |handler_| to update the UI. 184 // If the UI is already initialized, notifies |handler_| to update the UI.
172 // Ignored if the UI is not yet initialized. 185 // Ignored if the UI is not yet initialized.
173 void SetIssue(const Issue* issue); 186 void SetIssue(const Issue* issue);
174 187
175 // Called by |routes_observer_| when the set of active routes has changed. 188 // Called by |routes_observer_| when the set of active routes has changed.
176 void OnRoutesUpdated(const std::vector<MediaRoute>& routes); 189 void OnRoutesUpdated(const std::vector<MediaRoute>& routes,
190 const std::vector<MediaRoute::Id>& joinable_route_ids);
177 191
178 // Callback passed to MediaRouter to receive response to route creation 192 // Callback passed to MediaRouter to receive response to route creation
179 // requests. 193 // requests.
180 void OnRouteResponseReceived(const int route_request_id, 194 void OnRouteResponseReceived(const int route_request_id,
181 const MediaSink::Id& sink_id, 195 const MediaSink::Id& sink_id,
182 const MediaRoute* route, 196 const MediaRoute* route,
183 const std::string& presentation_id, 197 const std::string& presentation_id,
184 const std::string& error); 198 const std::string& error);
185 199
186 // Creates and sends an issue if route creation times out. 200 // Creates and sends an issue if route creation times out.
187 void RouteCreationTimeout(); 201 void RouteCreationTimeout();
188 202
189 // Initializes the dialog with mirroring sources derived from |initiator|. 203 // Initializes the dialog with mirroring sources derived from |initiator|.
190 void InitCommon(content::WebContents* initiator); 204 void InitCommon(content::WebContents* initiator);
191 205
192 // PresentationServiceDelegateImpl::DefaultPresentationObserver 206 // PresentationServiceDelegateImpl::DefaultPresentationObserver
193 void OnDefaultPresentationChanged( 207 void OnDefaultPresentationChanged(
194 const PresentationRequest& presentation_request) override; 208 const PresentationRequest& presentation_request) override;
195 void OnDefaultPresentationRemoved() override; 209 void OnDefaultPresentationRemoved() override;
196 210
211 // Creates a brand new route or, if a |route_id| is supplied, connects to a
212 // non-local route. This is used for connecting to a non-local route.
213 // Returns true if a route request is successfully submitted.
214 // OnRouteResponseReceived() will be invoked when the route request
215 // completes.
216 bool CreateOrConnectRoute(const MediaSink::Id& sink_id,
217 MediaCastMode cast_mode,
218 const MediaRoute::Id& route_id);
219
197 // Updates the set of supported cast modes and sends the updated set to 220 // Updates the set of supported cast modes and sends the updated set to
198 // |handler_|. 221 // |handler_|.
199 void UpdateCastModes(); 222 void UpdateCastModes();
200 223
201 // Returns the default presentation request's frame URL if there is one. 224 // Returns the default presentation request's frame URL if there is one.
202 // Otherwise returns an empty GURL. 225 // Otherwise returns an empty GURL.
203 GURL GetFrameURL() const; 226 GURL GetFrameURL() const;
204 227
205 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted 228 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted
206 // only after it has deleted |this|. 229 // only after it has deleted |this|.
(...skipping 13 matching lines...) Expand all
220 // Sequential counter for route requests. Used to update 243 // Sequential counter for route requests. Used to update
221 // |current_route_request_id_| when there is a new route request. 244 // |current_route_request_id_| when there is a new route request.
222 int route_request_counter_; 245 int route_request_counter_;
223 246
224 // Used for locale-aware sorting of sinks by name. Set during |InitCommon()| 247 // Used for locale-aware sorting of sinks by name. Set during |InitCommon()|
225 // using the current locale. Set to null 248 // using the current locale. Set to null
226 scoped_ptr<icu::Collator> collator_; 249 scoped_ptr<icu::Collator> collator_;
227 250
228 std::vector<MediaSinkWithCastModes> sinks_; 251 std::vector<MediaSinkWithCastModes> sinks_;
229 std::vector<MediaRoute> routes_; 252 std::vector<MediaRoute> routes_;
253 std::vector<MediaRoute::Id> joinable_route_ids_;
230 CastModeSet cast_modes_; 254 CastModeSet cast_modes_;
231 255
232 scoped_ptr<QueryResultManager> query_result_manager_; 256 scoped_ptr<QueryResultManager> query_result_manager_;
233 257
234 // If set, then the result of the next presentation route request will 258 // If set, then the result of the next presentation route request will
235 // be handled by this object. 259 // be handled by this object.
236 scoped_ptr<CreatePresentationConnectionRequest> create_session_request_; 260 scoped_ptr<CreatePresentationConnectionRequest> create_session_request_;
237 261
238 // Set to the presentation request corresponding to the presentation cast 262 // Set to the presentation request corresponding to the presentation cast
239 // mode, if supported. Otherwise set to nullptr. 263 // mode, if supported. Otherwise set to nullptr.
(...skipping 23 matching lines...) Expand all
263 // NOTE: Weak pointers must be invalidated before all other member variables. 287 // NOTE: Weak pointers must be invalidated before all other member variables.
264 // Therefore |weak_factory_| must be placed at the end. 288 // Therefore |weak_factory_| must be placed at the end.
265 base::WeakPtrFactory<MediaRouterUI> weak_factory_; 289 base::WeakPtrFactory<MediaRouterUI> weak_factory_;
266 290
267 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); 291 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI);
268 }; 292 };
269 293
270 } // namespace media_router 294 } // namespace media_router
271 295
272 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ 296 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698