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

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

Issue 1406013003: [Presentation API / Media Router] Clean up default pres URL logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Original patch Created 5 years, 1 month 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 20 matching lines...) Expand all
31 31
32 class IssuesObserver; 32 class IssuesObserver;
33 class MediaRoute; 33 class MediaRoute;
34 class MediaRouter; 34 class MediaRouter;
35 class MediaRouterDialogCallbacks; 35 class MediaRouterDialogCallbacks;
36 class MediaRouterMojoImpl; 36 class MediaRouterMojoImpl;
37 class MediaRouterWebUIMessageHandler; 37 class MediaRouterWebUIMessageHandler;
38 class MediaRoutesObserver; 38 class MediaRoutesObserver;
39 class MediaSink; 39 class MediaSink;
40 class MediaSinksObserver; 40 class MediaSinksObserver;
41 class CreatePresentationSessionRequest; 41 class CreatePresentationConnectionRequest;
42 42
43 // Implements the chrome://media-router user interface. 43 // Implements the chrome://media-router user interface.
44 class MediaRouterUI 44 class MediaRouterUI : public ConstrainedWebDialogUI,
45 : public ConstrainedWebDialogUI, 45 public QueryResultManager::Observer,
46 public QueryResultManager::Observer, 46 public PresentationServiceDelegateImpl::
47 public PresentationServiceDelegateImpl::DefaultMediaSourceObserver { 47 DefaultPresentationRequestObserver {
48 public: 48 public:
49 // |web_ui| owns this object and is used to initialize the base class. 49 // |web_ui| owns this object and is used to initialize the base class.
50 explicit MediaRouterUI(content::WebUI* web_ui); 50 explicit MediaRouterUI(content::WebUI* web_ui);
51 ~MediaRouterUI() override; 51 ~MediaRouterUI() override;
52 52
53 // Initializes internal state (e.g. starts listening for MediaSinks) for 53 // Initializes internal state (e.g. starts listening for MediaSinks) for
54 // targeting the default MediaSource (if any) of the initiator tab that owns 54 // targeting the default MediaSource (if any) of the initiator tab that owns
55 // |delegate|, as well as mirroring sources of that tab. 55 // |delegate|, as well as mirroring sources of that tab.
56 // The contents of the UI will change as the default MediaSource changes. 56 // The contents of the UI will change as the default MediaSource changes.
57 // If there is a default MediaSource, then DEFAULT MediaCastMode will be 57 // If there is a default MediaSource, then DEFAULT MediaCastMode will be
(...skipping 14 matching lines...) Expand all
72 // Init* methods can only be called once. 72 // Init* methods can only be called once.
73 // |initiator|: Reference to the WebContents that initiated the dialog. 73 // |initiator|: Reference to the WebContents that initiated the dialog.
74 // Must not be null. 74 // Must not be null.
75 // |delegate|: PresentationServiceDelegateImpl of the initiator tab. 75 // |delegate|: PresentationServiceDelegateImpl of the initiator tab.
76 // Must not be null. 76 // Must not be null.
77 // |presentation_request|: The presentation request. This instance will take 77 // |presentation_request|: The presentation request. This instance will take
78 // ownership of it. Must not be null. 78 // ownership of it. Must not be null.
79 void InitWithPresentationSessionRequest( 79 void InitWithPresentationSessionRequest(
80 content::WebContents* initiator, 80 content::WebContents* initiator,
81 const base::WeakPtr<PresentationServiceDelegateImpl>& delegate, 81 const base::WeakPtr<PresentationServiceDelegateImpl>& delegate,
82 scoped_ptr<CreatePresentationSessionRequest> presentation_request); 82 scoped_ptr<CreatePresentationConnectionRequest> presentation_request);
83 83
84 // Closes the media router UI. 84 // Closes the media router UI.
85 void Close(); 85 void Close();
86 86
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.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // requests. 156 // requests.
157 void OnRouteResponseReceived(const int route_request_id, 157 void OnRouteResponseReceived(const int route_request_id,
158 const MediaSink::Id& sink_id, 158 const MediaSink::Id& sink_id,
159 const MediaRoute* route, 159 const MediaRoute* route,
160 const std::string& presentation_id, 160 const std::string& presentation_id,
161 const std::string& error); 161 const std::string& error);
162 162
163 // Creates and sends an issue if route creation times out. 163 // Creates and sends an issue if route creation times out.
164 void RouteCreationTimeout(); 164 void RouteCreationTimeout();
165 165
166 // Sets the source host name to be displayed in the UI. 166 // Initializes the dialog with mirroring sources derived from |initiator|.
167 // Gets cast modes from |query_result_manager_| and forwards it to UI. 167 void InitCommon(content::WebContents* initiator);
168 // One of the Init* functions must have been called before.
169 void UpdateSourceHostAndCastModes(const GURL& frame_url);
170 168
171 // Initializes the dialog with mirroring sources derived from |initiator|, 169 // PresentationServiceDelegateImpl::DefaultPresentationObserver
172 // and optional |default_source| and |default_frame_url| if any. 170 void OnDefaultPresentationChanged(
173 void InitCommon(content::WebContents* initiator, 171 const PresentationRequest& presentation_request) override;
174 const MediaSource& default_source, 172 void OnDefaultPresentationRemoved() override;
175 const GURL& default_frame_url);
176 173
177 // PresentationServiceDelegateImpl::DefaultMediaSourceObserver 174 // Updates the set of supported cast modes and sends the updated set to
178 void OnDefaultMediaSourceChanged(const MediaSource& source, 175 // |handler_|.
179 const GURL& frame_url) override; 176 void UpdateCastModes();
180 177
181 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted 178 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted
182 // only after it has deleted |this|. 179 // only after it has deleted |this|.
183 MediaRouterWebUIMessageHandler* handler_; 180 MediaRouterWebUIMessageHandler* handler_;
184 181
185 // These are non-null while this instance is registered to receive 182 // These are non-null while this instance is registered to receive
186 // updates from them. 183 // updates from them.
187 scoped_ptr<IssuesObserver> issues_observer_; 184 scoped_ptr<IssuesObserver> issues_observer_;
188 scoped_ptr<MediaRoutesObserver> routes_observer_; 185 scoped_ptr<MediaRoutesObserver> routes_observer_;
189 186
(...skipping 11 matching lines...) Expand all
201 198
202 std::vector<MediaSinkWithCastModes> sinks_; 199 std::vector<MediaSinkWithCastModes> sinks_;
203 std::vector<MediaRoute> routes_; 200 std::vector<MediaRoute> routes_;
204 CastModeSet cast_modes_; 201 CastModeSet cast_modes_;
205 GURL frame_url_; 202 GURL frame_url_;
206 203
207 scoped_ptr<QueryResultManager> query_result_manager_; 204 scoped_ptr<QueryResultManager> query_result_manager_;
208 205
209 // If set, then the result of the next presentation route request will 206 // If set, then the result of the next presentation route request will
210 // be handled by this object. 207 // be handled by this object.
211 scoped_ptr<CreatePresentationSessionRequest> presentation_request_; 208 scoped_ptr<CreatePresentationConnectionRequest> create_session_request_;
209
210 // Set to the presentation request corresponding to the presentation cast
211 // mode, if supported. Otherwise set to nullptr.
212 scoped_ptr<PresentationRequest> presentation_request_;
212 213
213 // It's possible for PresentationServiceDelegateImpl to be destroyed before 214 // It's possible for PresentationServiceDelegateImpl to be destroyed before
214 // this class. 215 // this class.
215 // (e.g. if a tab with the UI open is closed, then the tab WebContents will 216 // (e.g. if a tab with the UI open is closed, then the tab WebContents will
216 // be destroyed first momentarily before the UI WebContents). 217 // be destroyed first momentarily before the UI WebContents).
217 // Holding a WeakPtr to PresentationServiceDelegateImpl is the cleanest way to 218 // Holding a WeakPtr to PresentationServiceDelegateImpl is the cleanest way to
218 // handle this. 219 // handle this.
219 // TODO(imcheng): hold a weak ptr to an abstract type instead. 220 // TODO(imcheng): hold a weak ptr to an abstract type instead.
220 base::WeakPtr<PresentationServiceDelegateImpl> presentation_service_delegate_; 221 base::WeakPtr<PresentationServiceDelegateImpl> presentation_service_delegate_;
221 222
222 content::WebContents* initiator_; 223 content::WebContents* initiator_;
223 224
224 // Pointer to the MediaRouter for this instance's BrowserContext. 225 // Pointer to the MediaRouter for this instance's BrowserContext.
225 MediaRouterMojoImpl* router_; 226 MediaRouterMojoImpl* router_;
226 227
227 // Timer used to implement a timeout on a create route request. 228 // Timer used to implement a timeout on a create route request.
228 base::OneShotTimer route_creation_timer_; 229 base::OneShotTimer route_creation_timer_;
229 230
230 // NOTE: Weak pointers must be invalidated before all other member variables. 231 // NOTE: Weak pointers must be invalidated before all other member variables.
231 // Therefore |weak_factory_| must be placed at the end. 232 // Therefore |weak_factory_| must be placed at the end.
232 base::WeakPtrFactory<MediaRouterUI> weak_factory_; 233 base::WeakPtrFactory<MediaRouterUI> weak_factory_;
233 234
234 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); 235 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI);
235 }; 236 };
236 237
237 } // namespace media_router 238 } // namespace media_router
238 239
239 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ 240 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698