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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "chrome/browser/media/router/issue.h" | |
| 9 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | 12 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
| 13 #include "chrome/browser/ui/webui/media_router/media_cast_mode.h" | |
| 14 #include "chrome/browser/ui/webui/media_router/media_sink_with_cast_modes.h" | |
| 15 #include "chrome/browser/ui/webui/media_router/query_result_manager.h" | |
| 10 #include "content/public/browser/web_ui_data_source.h" | 16 #include "content/public/browser/web_ui_data_source.h" |
| 11 | 17 |
| 12 namespace media_router { | 18 namespace media_router { |
| 13 | 19 |
| 20 class IssuesObserver; | |
| 14 class MediaRouterWebUIMessageHandler; | 21 class MediaRouterWebUIMessageHandler; |
| 22 class MediaRoutesObserver; | |
| 15 | 23 |
| 16 // Implements the chrome://media-router user interface. | 24 // Implements the chrome://media-router user interface. |
| 17 class MediaRouterUI : public ConstrainedWebDialogUI { | 25 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.
| |
| 26 public QueryResultManager::Observer { | |
| 18 public: | 27 public: |
| 19 // |web_ui| owns this object and is used to initialize the base class. | 28 // |web_ui| owns this object and is used to initialize the base class. |
| 20 explicit MediaRouterUI(content::WebUI* web_ui); | 29 explicit MediaRouterUI(content::WebUI* web_ui); |
| 21 ~MediaRouterUI() override; | 30 ~MediaRouterUI() override; |
| 22 | 31 |
| 32 // QueryResultManager::Observer | |
| 33 void OnResultsUpdated(const std::vector<MediaSinkWithCastModes>& sinks) | |
| 34 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.
| |
| 35 | |
| 36 // 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.
| |
| 37 void OnRoutesUpdated(const std::vector<MediaRoute>& routes); | |
| 38 | |
| 23 // Closes the media router UI. | 39 // Closes the media router UI. |
| 24 void Close(); | 40 void Close(); |
| 25 | 41 |
| 42 // 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.
| |
| 43 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.
| |
| 44 | |
| 45 // Submits a route request for using MediaSink |sink_id| and source | |
| 46 // 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.
| |
| 47 // The preferred cast mode is determined from the set of currently supported | |
| 48 // cast modes in |cast_modes_|. | |
| 49 // 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.
| |
| 50 // 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
| |
| 51 bool CreateRoute(const MediaSinkId& sink_id); | |
| 52 | |
| 53 // Submits a route request for using MediaSink |sink_id| and source | |
| 54 // 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
| |
| 55 // Returns true if a route request is successfully submitted. | |
| 56 // 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.
| |
| 57 bool CreateRouteWithCastModeOverride( | |
| 58 const MediaSinkId& sink_id, MediaCastMode cast_mode_override); | |
| 59 | |
| 60 // Calls MediaRouter to close the given route. | |
| 61 void CloseRoute(const MediaRouteId& route_id); | |
| 62 | |
| 63 // 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.
| |
| 64 void SetIssue(const Issue* issue); | |
| 65 | |
| 66 // 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
| |
| 67 void ClearIssue(const Issue::IssueId& issue_id); | |
| 68 | |
| 69 // Returns the header text that should be displayed in the UI when it is | |
| 70 // 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.
| |
| 71 std::string GetInitialHeaderText() const; | |
| 72 | |
| 73 bool has_pending_route_request() const { return has_pending_route_request_; } | |
| 74 const std::string& source_host() const { return source_host_; } | |
| 75 const std::vector<MediaSinkWithCastModes>& sinks() const { return sinks_; } | |
| 76 const std::vector<MediaRoute>& routes() const { return routes_; } | |
| 77 const std::set<MediaCastMode>& cast_modes() const { return cast_modes_; } | |
| 78 | |
| 26 private: | 79 private: |
| 80 // 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.
| |
| 81 void OnRouteResponseReceived(scoped_ptr<MediaRoute> route, | |
| 82 const std::string& error); | |
| 83 | |
| 84 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
| |
| 85 | |
| 27 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted | 86 // Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted |
| 28 // only after it has deleted |this|. | 87 // only after it has deleted |this|. |
| 29 MediaRouterWebUIMessageHandler* handler_; | 88 MediaRouterWebUIMessageHandler* handler_; |
| 30 | 89 |
| 90 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.
| |
| 91 scoped_ptr<MediaRoutesObserver> routes_observer_; | |
| 92 | |
| 93 // 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.
| |
| 94 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
| |
| 95 | |
| 96 // 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
| |
| 97 bool has_pending_route_request_; | |
| 98 | |
| 99 std::vector<MediaSinkWithCastModes> sinks_; | |
| 100 std::vector<MediaRoute> routes_; | |
| 101 CastModeSet cast_modes_; | |
| 102 // TODO(imcheng): Set |source_host_| once DEFAULT mode is supported. | |
| 103 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
| |
| 104 | |
| 105 scoped_ptr<QueryResultManager> query_result_manager_; | |
| 106 | |
| 107 // 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".
| |
| 108 MediaRouter* router_; | |
| 109 | |
| 110 // NOTE: Weak pointers must be invalidated before all other member variables. | |
| 111 // Therefore |weak_factory_| must be placed at the end. | |
| 112 base::WeakPtrFactory<MediaRouterUI> weak_factory_; | |
| 113 | |
| 31 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); | 114 DISALLOW_COPY_AND_ASSIGN(MediaRouterUI); |
| 32 }; | 115 }; |
| 33 | 116 |
| 34 } // namespace media_router | 117 } // namespace media_router |
| 35 | 118 |
| 36 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ | 119 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_ |
| OLD | NEW |