| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // Notifies this instance that the UI has been initialized. | 87 // Notifies this instance that the UI has been initialized. |
| 88 void UIInitialized(); | 88 void UIInitialized(); |
| 89 | 89 |
| 90 // Requests a route be created from the source mapped to | 90 // Requests a route be created from the source mapped to |
| 91 // |cast_mode|, to the sink given by |sink_id|. | 91 // |cast_mode|, to the sink given by |sink_id|. |
| 92 // Returns true if a route request is successfully submitted. | 92 // Returns true if a route request is successfully submitted. |
| 93 // |OnRouteResponseReceived()| will be invoked when the route request | 93 // |OnRouteResponseReceived()| will be invoked when the route request |
| 94 // completes. | 94 // completes. |
| 95 bool CreateRoute(const MediaSink::Id& sink_id, MediaCastMode cast_mode); | 95 bool CreateRoute(const MediaSink::Id& sink_id, MediaCastMode cast_mode); |
| 96 | 96 |
| 97 // Calls MediaRouter to join the given route. |
| 98 bool JoinRoute(const MediaSink::Id& sink_id, const MediaRoute::Id& route_id); |
| 99 |
| 97 // Calls MediaRouter to close the given route. | 100 // Calls MediaRouter to close the given route. |
| 98 void CloseRoute(const MediaRoute::Id& route_id); | 101 void CloseRoute(const MediaRoute::Id& route_id); |
| 99 | 102 |
| 100 // Calls MediaRouter to add the given issue. | 103 // Calls MediaRouter to add the given issue. |
| 101 void AddIssue(const Issue& issue); | 104 void AddIssue(const Issue& issue); |
| 102 | 105 |
| 103 // Calls MediaRouter to clear the given issue. | 106 // Calls MediaRouter to clear the given issue. |
| 104 void ClearIssue(const Issue::Id& issue_id); | 107 void ClearIssue(const Issue::Id& issue_id); |
| 105 | 108 |
| 106 // Returns the hostname of the default source's parent frame URL. | 109 // Returns the hostname of the default source's parent frame URL. |
| 107 std::string GetFrameURLHost() const; | 110 std::string GetFrameURLHost() const; |
| 108 bool HasPendingRouteRequest() const { | 111 bool HasPendingRouteRequest() const { |
| 109 return current_route_request_id_ != -1; | 112 return current_route_request_id_ != -1; |
| 110 } | 113 } |
| 111 const GURL& frame_url() const { return frame_url_; } | 114 const GURL& frame_url() const { return frame_url_; } |
| 112 const std::vector<MediaSinkWithCastModes>& sinks() const { return sinks_; } | 115 const std::vector<MediaSinkWithCastModes>& sinks() const { return sinks_; } |
| 113 const std::vector<MediaRoute>& routes() const { return routes_; } | 116 const std::vector<MediaRoute>& routes() const { return routes_; } |
| 117 const std::vector<MediaRoute::Id>& joinable_route_ids() const { |
| 118 return joinable_route_ids_; |
| 119 } |
| 114 const std::set<MediaCastMode>& cast_modes() const { return cast_modes_; } | 120 const std::set<MediaCastMode>& cast_modes() const { return cast_modes_; } |
| 115 const content::WebContents* initiator() const { return initiator_; } | 121 const content::WebContents* initiator() const { return initiator_; } |
| 116 | 122 |
| 117 // Marked virtual for tests. | 123 // Marked virtual for tests. |
| 118 virtual const std::string& GetRouteProviderExtensionId() const; | 124 virtual const std::string& GetRouteProviderExtensionId() const; |
| 119 | 125 |
| 120 private: | 126 private: |
| 121 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, | 127 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, |
| 122 UIMediaRoutesObserverFiltersNonDisplayRoutes); | 128 UIMediaRoutesObserverFiltersNonDisplayRoutes); |
| 129 FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, |
| 130 UIMediaRoutesObserverFiltersNonDisplayJoinableRoutes); |
| 123 | 131 |
| 124 class UIIssuesObserver; | 132 class UIIssuesObserver; |
| 133 |
| 125 class UIMediaRoutesObserver : public MediaRoutesObserver { | 134 class UIMediaRoutesObserver : public MediaRoutesObserver { |
| 126 public: | 135 public: |
| 127 using RoutesUpdatedCallback = | 136 using RoutesUpdatedCallback = |
| 128 base::Callback<void(const std::vector<MediaRoute>&)>; | 137 base::Callback<void(const std::vector<MediaRoute>&, |
| 129 UIMediaRoutesObserver(MediaRouter* router, | 138 const std::vector<MediaRoute::Id>&)>; |
| 139 UIMediaRoutesObserver(MediaRouter* router, const MediaSource::Id source_id, |
| 130 const RoutesUpdatedCallback& callback); | 140 const RoutesUpdatedCallback& callback); |
| 131 ~UIMediaRoutesObserver() override; | 141 ~UIMediaRoutesObserver() override; |
| 132 | 142 |
| 133 // MediaRoutesObserver | 143 // MediaRoutesObserver |
| 134 void OnRoutesUpdated(const std::vector<MediaRoute>& routes) override; | 144 void OnRoutesUpdated( |
| 145 const std::vector<MediaRoute>& routes, |
| 146 const std::vector<MediaRoute::Id>& joinable_route_ids) override; |
| 135 | 147 |
| 136 private: | 148 private: |
| 137 // Callback to the owning MediaRouterUI instance. | 149 // Callback to the owning MediaRouterUI instance. |
| 138 RoutesUpdatedCallback callback_; | 150 RoutesUpdatedCallback callback_; |
| 139 | 151 |
| 140 DISALLOW_COPY_AND_ASSIGN(UIMediaRoutesObserver); | 152 DISALLOW_COPY_AND_ASSIGN(UIMediaRoutesObserver); |
| 141 }; | 153 }; |
| 142 | 154 |
| 143 // QueryResultManager::Observer | 155 // QueryResultManager::Observer |
| 144 void OnResultsUpdated( | 156 void OnResultsUpdated( |
| 145 const std::vector<MediaSinkWithCastModes>& sinks) override; | 157 const std::vector<MediaSinkWithCastModes>& sinks) override; |
| 146 | 158 |
| 147 // Called by |issues_observer_| when the top issue has changed. | 159 // Called by |issues_observer_| when the top issue has changed. |
| 148 // If the UI is already initialized, notifies |handler_| to update the UI. | 160 // If the UI is already initialized, notifies |handler_| to update the UI. |
| 149 // Ignored if the UI is not yet initialized. | 161 // Ignored if the UI is not yet initialized. |
| 150 void SetIssue(const Issue* issue); | 162 void SetIssue(const Issue* issue); |
| 151 | 163 |
| 152 // Called by |routes_observer_| when the set of active routes has changed. | 164 // Called by |routes_observer_| when the set of active routes has changed. |
| 153 void OnRoutesUpdated(const std::vector<MediaRoute>& routes); | 165 void OnRoutesUpdated(const std::vector<MediaRoute>& routes, |
| 166 const std::vector<MediaRoute::Id>& joinable_route_ids); |
| 154 | 167 |
| 155 // Callback passed to MediaRouter to receive response to route creation | 168 // Callback passed to MediaRouter to receive response to route creation |
| 156 // requests. | 169 // requests. |
| 157 void OnRouteResponseReceived(const int route_request_id, | 170 void OnRouteResponseReceived(const int route_request_id, |
| 158 const MediaSink::Id& sink_id, | 171 const MediaSink::Id& sink_id, |
| 159 const MediaRoute* route, | 172 const MediaRoute* route, |
| 160 const std::string& presentation_id, | 173 const std::string& presentation_id, |
| 161 const std::string& error); | 174 const std::string& error); |
| 162 | 175 |
| 163 // Creates and sends an issue if route creation times out. | 176 // Creates and sends an issue if route creation times out. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 194 | 207 |
| 195 // Set to -1 if not tracking a pending route request. | 208 // Set to -1 if not tracking a pending route request. |
| 196 int current_route_request_id_; | 209 int current_route_request_id_; |
| 197 | 210 |
| 198 // Sequential counter for route requests. Used to update | 211 // Sequential counter for route requests. Used to update |
| 199 // |current_route_request_id_| when there is a new route request. | 212 // |current_route_request_id_| when there is a new route request. |
| 200 int route_request_counter_; | 213 int route_request_counter_; |
| 201 | 214 |
| 202 std::vector<MediaSinkWithCastModes> sinks_; | 215 std::vector<MediaSinkWithCastModes> sinks_; |
| 203 std::vector<MediaRoute> routes_; | 216 std::vector<MediaRoute> routes_; |
| 217 std::vector<MediaRoute::Id> joinable_route_ids_; |
| 204 CastModeSet cast_modes_; | 218 CastModeSet cast_modes_; |
| 205 GURL frame_url_; | 219 GURL frame_url_; |
| 206 | 220 |
| 207 scoped_ptr<QueryResultManager> query_result_manager_; | 221 scoped_ptr<QueryResultManager> query_result_manager_; |
| 208 | 222 |
| 209 // If set, then the result of the next presentation route request will | 223 // If set, then the result of the next presentation route request will |
| 210 // be handled by this object. | 224 // be handled by this object. |
| 211 scoped_ptr<CreatePresentationSessionRequest> presentation_request_; | 225 scoped_ptr<CreatePresentationSessionRequest> presentation_request_; |
| 212 | 226 |
| 213 // It's possible for PresentationServiceDelegateImpl to be destroyed before | 227 // It's possible for PresentationServiceDelegateImpl to be destroyed before |
| (...skipping 16 matching lines...) Expand all Loading... |
| 230 // NOTE: Weak pointers must be invalidated before all other member variables. | 244 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 231 // Therefore |weak_factory_| must be placed at the end. | 245 // Therefore |weak_factory_| must be placed at the end. |
| 232 base::WeakPtrFactory<MediaRouterUI> weak_factory_; | 246 base::WeakPtrFactory<MediaRouterUI> weak_factory_; |
| 233 | 247 |
| 234 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); | 248 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); |
| 235 }; | 249 }; |
| 236 | 250 |
| 237 } // namespace media_router | 251 } // namespace media_router |
| 238 | 252 |
| 239 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ | 253 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ |
| OLD | NEW |