Chromium Code Reviews| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 bool CreateRouteOrConnectRoute(const MediaSink::Id& sink_id, | |
|
mark a. foltz
2015/12/16 07:17:35
CreateOrConnectRoute?
matt.boetger
2015/12/18 23:37:15
Done. Also made it private.
| |
| 107 MediaCastMode cast_mode, | |
| 108 const MediaRoute::Id& route_id); | |
| 109 | |
| 110 // Calls MediaRouter to join the given route. | |
| 111 bool ConnectRemoteRoute(const MediaSink::Id& sink_id, | |
| 112 const MediaRoute::Id& route_id); | |
| 113 | |
| 106 // Calls MediaRouter to close the given route. | 114 // Calls MediaRouter to close the given route. |
| 107 void CloseRoute(const MediaRoute::Id& route_id); | 115 void CloseRoute(const MediaRoute::Id& route_id); |
| 108 | 116 |
| 109 // Calls MediaRouter to add the given issue. | 117 // Calls MediaRouter to add the given issue. |
| 110 void AddIssue(const Issue& issue); | 118 void AddIssue(const Issue& issue); |
| 111 | 119 |
| 112 // Calls MediaRouter to clear the given issue. | 120 // Calls MediaRouter to clear the given issue. |
| 113 void ClearIssue(const Issue::Id& issue_id); | 121 void ClearIssue(const Issue::Id& issue_id); |
| 114 | 122 |
| 115 // Returns the hostname of the default source's parent frame URL. | 123 // Returns the hostname of the default source's parent frame URL. |
| 116 std::string GetPresentationRequestSourceName() const; | 124 std::string GetPresentationRequestSourceName() const; |
| 117 std::string GetTruncatedPresentationRequestSourceName() const; | 125 std::string GetTruncatedPresentationRequestSourceName() const; |
| 118 bool HasPendingRouteRequest() const { | 126 bool HasPendingRouteRequest() const { |
| 119 return current_route_request_id_ != -1; | 127 return current_route_request_id_ != -1; |
| 120 } | 128 } |
| 121 const std::vector<MediaSinkWithCastModes>& sinks() const { return sinks_; } | 129 const std::vector<MediaSinkWithCastModes>& sinks() const { return sinks_; } |
| 122 const std::vector<MediaRoute>& routes() const { return routes_; } | 130 const std::vector<MediaRoute>& routes() const { return routes_; } |
| 131 const std::vector<MediaRoute::Id>& joinable_route_ids() const { | |
| 132 return joinable_route_ids_; | |
| 133 } | |
| 123 const std::set<MediaCastMode>& cast_modes() const { return cast_modes_; } | 134 const std::set<MediaCastMode>& cast_modes() const { return cast_modes_; } |
| 124 const content::WebContents* initiator() const { return initiator_; } | 135 const content::WebContents* initiator() const { return initiator_; } |
| 125 | 136 |
| 126 // Marked virtual for tests. | 137 // Marked virtual for tests. |
| 127 virtual const std::string& GetRouteProviderExtensionId() const; | 138 virtual const std::string& GetRouteProviderExtensionId() const; |
| 128 | 139 |
| 129 // Called to track UI metrics. | 140 // Called to track UI metrics. |
| 130 void SetUIInitializationTimer(const base::Time& start_time); | 141 void SetUIInitializationTimer(const base::Time& start_time); |
| 131 void OnUIInitiallyLoaded(); | 142 void OnUIInitiallyLoaded(); |
| 132 void OnUIInitialDataReceived(); | 143 void OnUIInitialDataReceived(); |
| 133 | 144 |
| 134 private: | 145 private: |
| 135 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, SortedSinks); | 146 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, SortedSinks); |
| 136 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, | 147 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, |
| 137 UIMediaRoutesObserverFiltersNonDisplayRoutes); | 148 UIMediaRoutesObserverFiltersNonDisplayRoutes); |
| 149 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, | |
| 150 UIMediaRoutesObserverFiltersNonDisplayJoinableRoutes); | |
| 138 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, GetExtensionNameExtensionPresent); | 151 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, GetExtensionNameExtensionPresent); |
| 139 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, | 152 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, |
| 140 GetExtensionNameEmptyWhenNotInstalled); | 153 GetExtensionNameEmptyWhenNotInstalled); |
| 141 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, | 154 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, |
| 142 GetExtensionNameEmptyWhenNotExtensionURL); | 155 GetExtensionNameEmptyWhenNotExtensionURL); |
| 143 | 156 |
| 144 class UIIssuesObserver; | 157 class UIIssuesObserver; |
| 158 | |
| 145 class UIMediaRoutesObserver : public MediaRoutesObserver { | 159 class UIMediaRoutesObserver : public MediaRoutesObserver { |
| 146 public: | 160 public: |
| 147 using RoutesUpdatedCallback = | 161 using RoutesUpdatedCallback = |
| 148 base::Callback<void(const std::vector<MediaRoute>&)>; | 162 base::Callback<void(const std::vector<MediaRoute>&, |
| 163 const std::vector<MediaRoute::Id>&)>; | |
| 149 UIMediaRoutesObserver(MediaRouter* router, | 164 UIMediaRoutesObserver(MediaRouter* router, |
| 150 const RoutesUpdatedCallback& callback); | 165 const RoutesUpdatedCallback& callback); |
| 166 UIMediaRoutesObserver(MediaRouter* router, const MediaSource::Id& source_id, | |
| 167 const RoutesUpdatedCallback& callback); | |
| 151 ~UIMediaRoutesObserver() override; | 168 ~UIMediaRoutesObserver() override; |
| 152 | 169 |
| 153 // MediaRoutesObserver | 170 // MediaRoutesObserver |
| 154 void OnRoutesUpdated(const std::vector<MediaRoute>& routes) override; | 171 void OnRoutesUpdated( |
| 172 const std::vector<MediaRoute>& routes, | |
| 173 const std::vector<MediaRoute::Id>& joinable_route_ids) override; | |
| 155 | 174 |
| 156 private: | 175 private: |
| 157 // Callback to the owning MediaRouterUI instance. | 176 // Callback to the owning MediaRouterUI instance. |
| 158 RoutesUpdatedCallback callback_; | 177 RoutesUpdatedCallback callback_; |
| 159 | 178 |
| 160 DISALLOW_COPY_AND_ASSIGN(UIMediaRoutesObserver); | 179 DISALLOW_COPY_AND_ASSIGN(UIMediaRoutesObserver); |
| 161 }; | 180 }; |
| 162 | 181 |
| 163 static std::string GetExtensionName(const GURL& url, | 182 static std::string GetExtensionName(const GURL& url, |
| 164 extensions::ExtensionRegistry* registry); | 183 extensions::ExtensionRegistry* registry); |
| 165 | 184 |
| 166 // QueryResultManager::Observer | 185 // QueryResultManager::Observer |
| 167 void OnResultsUpdated( | 186 void OnResultsUpdated( |
| 168 const std::vector<MediaSinkWithCastModes>& sinks) override; | 187 const std::vector<MediaSinkWithCastModes>& sinks) override; |
| 169 | 188 |
| 170 // Called by |issues_observer_| when the top issue has changed. | 189 // Called by |issues_observer_| when the top issue has changed. |
| 171 // If the UI is already initialized, notifies |handler_| to update the UI. | 190 // If the UI is already initialized, notifies |handler_| to update the UI. |
| 172 // Ignored if the UI is not yet initialized. | 191 // Ignored if the UI is not yet initialized. |
| 173 void SetIssue(const Issue* issue); | 192 void SetIssue(const Issue* issue); |
| 174 | 193 |
| 175 // Called by |routes_observer_| when the set of active routes has changed. | 194 // Called by |routes_observer_| when the set of active routes has changed. |
| 176 void OnRoutesUpdated(const std::vector<MediaRoute>& routes); | 195 void OnRoutesUpdated(const std::vector<MediaRoute>& routes, |
| 196 const std::vector<MediaRoute::Id>& joinable_route_ids); | |
| 177 | 197 |
| 178 // Callback passed to MediaRouter to receive response to route creation | 198 // Callback passed to MediaRouter to receive response to route creation |
| 179 // requests. | 199 // requests. |
| 180 void OnRouteResponseReceived(const int route_request_id, | 200 void OnRouteResponseReceived(const int route_request_id, |
| 181 const MediaSink::Id& sink_id, | 201 const MediaSink::Id& sink_id, |
| 182 const MediaRoute* route, | 202 const MediaRoute* route, |
| 183 const std::string& presentation_id, | 203 const std::string& presentation_id, |
| 184 const std::string& error); | 204 const std::string& error); |
| 185 | 205 |
| 186 // Creates and sends an issue if route creation times out. | 206 // Creates and sends an issue if route creation times out. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 // Sequential counter for route requests. Used to update | 242 // Sequential counter for route requests. Used to update |
| 223 // |current_route_request_id_| when there is a new route request. | 243 // |current_route_request_id_| when there is a new route request. |
| 224 int route_request_counter_; | 244 int route_request_counter_; |
| 225 | 245 |
| 226 // Used for locale-aware sorting of sinks by name. Set during |InitCommon()| | 246 // Used for locale-aware sorting of sinks by name. Set during |InitCommon()| |
| 227 // using the current locale. Set to null | 247 // using the current locale. Set to null |
| 228 scoped_ptr<icu::Collator> collator_; | 248 scoped_ptr<icu::Collator> collator_; |
| 229 | 249 |
| 230 std::vector<MediaSinkWithCastModes> sinks_; | 250 std::vector<MediaSinkWithCastModes> sinks_; |
| 231 std::vector<MediaRoute> routes_; | 251 std::vector<MediaRoute> routes_; |
| 252 std::vector<MediaRoute::Id> joinable_route_ids_; | |
| 232 CastModeSet cast_modes_; | 253 CastModeSet cast_modes_; |
| 233 | 254 |
| 234 scoped_ptr<QueryResultManager> query_result_manager_; | 255 scoped_ptr<QueryResultManager> query_result_manager_; |
| 235 | 256 |
| 236 // If set, then the result of the next presentation route request will | 257 // If set, then the result of the next presentation route request will |
| 237 // be handled by this object. | 258 // be handled by this object. |
| 238 scoped_ptr<CreatePresentationConnectionRequest> create_session_request_; | 259 scoped_ptr<CreatePresentationConnectionRequest> create_session_request_; |
| 239 | 260 |
| 240 // Set to the presentation request corresponding to the presentation cast | 261 // Set to the presentation request corresponding to the presentation cast |
| 241 // mode, if supported. Otherwise set to nullptr. | 262 // mode, if supported. Otherwise set to nullptr. |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 265 // NOTE: Weak pointers must be invalidated before all other member variables. | 286 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 266 // Therefore |weak_factory_| must be placed at the end. | 287 // Therefore |weak_factory_| must be placed at the end. |
| 267 base::WeakPtrFactory<MediaRouterUI> weak_factory_; | 288 base::WeakPtrFactory<MediaRouterUI> weak_factory_; |
| 268 | 289 |
| 269 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); | 290 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); |
| 270 }; | 291 }; |
| 271 | 292 |
| 272 } // namespace media_router | 293 } // namespace media_router |
| 273 | 294 |
| 274 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ | 295 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ |
| OLD | NEW |