Chromium Code Reviews| Index: chrome/browser/ui/webui/media_router/media_router_ui.h |
| diff --git a/chrome/browser/ui/webui/media_router/media_router_ui.h b/chrome/browser/ui/webui/media_router/media_router_ui.h |
| index 6fcb3040300d9805fec477a81a70434ba8f6a607..8dbc972b4e1a355a93d1c4fe4fab6816c47d2dc8 100644 |
| --- a/chrome/browser/ui/webui/media_router/media_router_ui.h |
| +++ b/chrome/browser/ui/webui/media_router/media_router_ui.h |
| @@ -6,28 +6,111 @@ |
| #define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ |
| #include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "chrome/browser/media/router/issue.h" |
| #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
| +#include "chrome/browser/ui/webui/media_router/media_cast_mode.h" |
| +#include "chrome/browser/ui/webui/media_router/media_sink_with_cast_modes.h" |
| +#include "chrome/browser/ui/webui/media_router/query_result_manager.h" |
| #include "content/public/browser/web_ui_data_source.h" |
| namespace media_router { |
| +class IssuesObserver; |
| class MediaRouterWebUIMessageHandler; |
| +class MediaRoutesObserver; |
| // Implements the chrome://media-router user interface. |
| -class MediaRouterUI : public ConstrainedWebDialogUI { |
| +class MediaRouterUI : public ConstrainedWebDialogUI, |
|
Wez
2015/05/20 17:51:46
nit: MediaRouterUi would be the preferred name acc
imcheng (use chromium acct)
2015/05/20 22:01:13
Acknowledged.
|
| + public QueryResultManager::Observer { |
| public: |
| // |web_ui| owns this object and is used to initialize the base class. |
| explicit MediaRouterUI(content::WebUI* web_ui); |
| ~MediaRouterUI() override; |
| + // QueryResultManager::Observer |
| + void OnResultsUpdated(const std::vector<MediaSinkWithCastModes>& sinks) |
| + override; |
|
Wez
2015/05/20 17:51:46
Do we expect callers to invoke this? If not then c
imcheng (use chromium acct)
2015/05/20 22:01:13
Done.
|
| + |
| + // Called by |routes_observer_| when the set of active routes has changed. |
|
Wez
2015/05/20 17:51:46
Would it make sense for this to be private and for
imcheng (use chromium acct)
2015/05/20 22:01:13
Done.
|
| + void OnRoutesUpdated(const std::vector<MediaRoute>& routes); |
| + |
| // Closes the media router UI. |
| void Close(); |
| +// Notifies that the UI has been initialized. |
|
Wez
2015/05/20 17:51:46
nit: Indentation?
(BTW, you know about git cl for
Wez
2015/05/20 17:51:46
Not clear from this comment who/what is being noti
imcheng (use chromium acct)
2015/05/20 22:01:12
Done.
imcheng (use chromium acct)
2015/05/20 22:01:13
Done.
|
| + void UIInitialized(); |
|
Wez
2015/05/20 17:51:46
nit: CamelCase applies even to acronyms & abbrevia
imcheng (use chromium acct)
2015/05/20 22:01:13
Acknowledged.
|
| + |
| + // Submits a route request for using MediaSink |sink_id| and source |
| + // determined by the preferred MediaCastMode. |
|
Wez
2015/05/20 17:51:46
It's unclear in this context what "using MediaSink
imcheng (use chromium acct)
2015/05/20 22:01:12
Done.
|
| + // The preferred cast mode is determined from the set of currently supported |
| + // cast modes in |cast_modes_|. |
| + // Returns true if a route request is successfully submitted. |
|
Wez
2015/05/20 17:51:46
Since a "success" result only indicates that the r
imcheng (use chromium acct)
2015/05/20 22:01:13
Done.
|
| + // One of the Init* functions must have been called before. |
|
Wez
2015/05/20 17:51:47
There are no Init* functions...?
imcheng (use chromium acct)
2015/05/20 22:01:12
Init* functions are not upstreamed yet. I will rem
|
| + bool CreateRoute(const MediaSinkId& sink_id); |
| + |
| + // Submits a route request for using MediaSink |sink_id| and source |
| + // determined by |cast_mode_override|. |
|
Wez
2015/05/20 17:51:46
There seems to be some confusion between "mode" an
imcheng (use chromium acct)
2015/05/20 22:01:13
A cast mode maps to a source in the context of a M
|
| + // Returns true if a route request is successfully submitted. |
| + // One of the Init* functions must have been called before. |
|
Wez
2015/05/20 17:51:46
See above re Init* functions?
imcheng (use chromium acct)
2015/05/20 22:01:13
Done.
|
| + bool CreateRouteWithCastModeOverride( |
| + const MediaSinkId& sink_id, MediaCastMode cast_mode_override); |
| + |
| + // Calls MediaRouter to close the given route. |
| + void CloseRoute(const MediaRouteId& route_id); |
| + |
| + // If the UI is already initialized, notifies |handler_| to update the UI. |
|
Wez
2015/05/20 17:51:46
nit: What does it do if the UI is not initialized?
imcheng (use chromium acct)
2015/05/20 22:01:13
Done.
|
| + void SetIssue(const Issue* issue); |
| + |
| + // Calls MediaRouter to clear the given issue. |
|
Wez
2015/05/20 17:51:47
nit: What does it mean to "clear" the issue? Is th
imcheng (use chromium acct)
2015/05/20 22:01:13
Yes, the MediaRouter API that's called by this is
|
| + void ClearIssue(const Issue::IssueId& issue_id); |
| + |
| + // Returns the header text that should be displayed in the UI when it is |
| + // initially loaded. (i.e., user has not selected a cast mode override yet) |
|
Wez
2015/05/20 17:51:46
nit: You mean "e.g.", not "i.e.", I think? "e.g."
imcheng (use chromium acct)
2015/05/20 22:01:12
It's really neither. So I will just reword it.
|
| + std::string GetInitialHeaderText() const; |
| + |
| + bool has_pending_route_request() const { return has_pending_route_request_; } |
| + const std::string& source_host() const { return source_host_; } |
| + const std::vector<MediaSinkWithCastModes>& sinks() const { return sinks_; } |
| + const std::vector<MediaRoute>& routes() const { return routes_; } |
| + const std::set<MediaCastMode>& cast_modes() const { return cast_modes_; } |
| + |
| private: |
| + // Callback from Media Router for a route creation request. |
|
Wez
2015/05/20 17:51:46
nit: "Callback passed to MediaRouter to receive re
imcheng (use chromium acct)
2015/05/20 22:01:13
Done.
|
| + void OnRouteResponseReceived(scoped_ptr<MediaRoute> route, |
| + const std::string& error); |
| + |
| + bool DoCreateRoute(const MediaSinkId& sink_id, MediaCastMode cast_mode); |
|
Wez
2015/05/20 17:51:46
Do we need this? Why can't CreateRoute() just call
imcheng (use chromium acct)
2015/05/20 22:01:13
I think it's a bit more explicit this way. In the
|
| + |
| // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted |
| // only after it has deleted |this|. |
| MediaRouterWebUIMessageHandler* handler_; |
| + scoped_ptr<IssuesObserver> issues_observer_; |
|
Wez
2015/05/20 17:51:46
nit: Add a comment to this block of members to exp
imcheng (use chromium acct)
2015/05/20 22:01:13
Done.
|
| + scoped_ptr<MediaRoutesObserver> routes_observer_; |
| + |
| + // Keeps track of whether initial settings have been requested. |
|
Wez
2015/05/20 17:51:46
initial settings for what?
requested by whom?
imcheng (use chromium acct)
2015/05/20 22:01:12
Done.
|
| + bool ui_initialized_; |
|
Wez
2015/05/20 17:51:46
nit: is_initialized_?
imcheng (use chromium acct)
2015/05/20 22:01:13
There are a couple of things to keep track of init
|
| + |
| + // Set to |true| if there is a pending route request for this UI. |
|
Wez
2015/05/20 17:51:46
Does this basically mean it's true when we're tryi
imcheng (use chromium acct)
2015/05/20 22:01:13
Yes. Since this class interfaces with media router
|
| + bool has_pending_route_request_; |
| + |
| + std::vector<MediaSinkWithCastModes> sinks_; |
| + std::vector<MediaRoute> routes_; |
| + CastModeSet cast_modes_; |
| + // TODO(imcheng): Set |source_host_| once DEFAULT mode is supported. |
| + std::string source_host_; |
|
Wez
2015/05/20 17:51:46
Do we need this variable if DEFAULT mode is not ye
imcheng (use chromium acct)
2015/05/20 22:01:13
I can remove this for now. DEFAULT mode is already
|
| + |
| + scoped_ptr<QueryResultManager> query_result_manager_; |
| + |
| + // Does not own this object. |
|
Wez
2015/05/20 17:51:46
This comment's pretty ambiguous - are you saying |
imcheng (use chromium acct)
2015/05/20 22:01:12
How about "Not owned by this instance."?
MediaRou
Wez
2015/05/21 22:58:37
I'd suggest "Cached pointer to the MediaRouter for
imcheng (use chromium acct)
2015/05/22 00:02:01
Ok. But I replaced "our" with "this instance's".
|
| + MediaRouter* router_; |
| + |
| + // NOTE: Weak pointers must be invalidated before all other member variables. |
| + // Therefore |weak_factory_| must be placed at the end. |
| + base::WeakPtrFactory<MediaRouterUI> weak_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); |
| }; |