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

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

Issue 2859953002: Reland [Media Router] Custom Controls 3 - add plumbing through MRUI and MRWebUIMessageHandler (Closed)
Patch Set: Fix test failures Created 3 years, 7 months 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_WEBUI_MESSAGE_HANDLER_ H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_WEBUI_MESSAGE_HANDLER_ H_
6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_WEBUI_MESSAGE_HANDLER_ H_ 6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_WEBUI_MESSAGE_HANDLER_ H_
7 7
8 #include <unordered_map> 8 #include <unordered_map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "chrome/browser/ui/webui/media_router/media_cast_mode.h" 12 #include "chrome/browser/ui/webui/media_router/media_cast_mode.h"
13 #include "chrome/browser/ui/webui/media_router/media_sink_with_cast_modes.h" 13 #include "chrome/browser/ui/webui/media_router/media_sink_with_cast_modes.h"
14 #include "chrome/common/media_router/issue.h" 14 #include "chrome/common/media_router/issue.h"
15 #include "chrome/common/media_router/media_status.h"
15 #include "components/signin/core/browser/account_info.h" 16 #include "components/signin/core/browser/account_info.h"
16 #include "content/public/browser/web_ui_message_handler.h" 17 #include "content/public/browser/web_ui_message_handler.h"
17 #include "ui/gfx/geometry/size.h" 18 #include "ui/gfx/geometry/size.h"
18 19
19 namespace base { 20 namespace base {
20 class DictionaryValue; 21 class DictionaryValue;
21 class ListValue; 22 class ListValue;
22 } // namespace base 23 } // namespace base
23 24
24 namespace content { 25 namespace content {
(...skipping 24 matching lines...) Expand all
49 const MediaRoute* route); 50 const MediaRoute* route);
50 void ReturnSearchResult(const std::string& sink_id); 51 void ReturnSearchResult(const std::string& sink_id);
51 52
52 void UpdateIssue(const Issue& issue); 53 void UpdateIssue(const Issue& issue);
53 void ClearIssue(); 54 void ClearIssue();
54 55
55 // Updates the maximum dialog height to allow the WebUI properly scale when 56 // Updates the maximum dialog height to allow the WebUI properly scale when
56 // the browser window changes. 57 // the browser window changes.
57 void UpdateMaxDialogHeight(int height); 58 void UpdateMaxDialogHeight(int height);
58 59
60 // Notifies the WebUI with an updated MediaStatus. Overridden in tests.
61 virtual void UpdateMediaRouteStatus(const MediaStatus& status);
62
63 // Notifies the WebUI that the controller for the selected route has been
64 // invalidated.
65 void OnRouteControllerInvalidated();
66
59 void SetWebUIForTest(content::WebUI* webui); 67 void SetWebUIForTest(content::WebUI* webui);
60 void set_incognito_for_test(bool incognito) { incognito_ = incognito; } 68 void set_incognito_for_test(bool incognito) { incognito_ = incognito; }
61 69
62 private: 70 private:
63 FRIEND_TEST_ALL_PREFIXES(MediaRouterWebUIMessageHandlerTest, 71 FRIEND_TEST_ALL_PREFIXES(MediaRouterWebUIMessageHandlerTest,
64 RecordCastModeSelection); 72 RecordCastModeSelection);
65 FRIEND_TEST_ALL_PREFIXES(MediaRouterWebUIMessageHandlerTest, 73 FRIEND_TEST_ALL_PREFIXES(MediaRouterWebUIMessageHandlerTest,
66 RetrieveCastModeSelection); 74 RetrieveCastModeSelection);
75 FRIEND_TEST_ALL_PREFIXES(MediaRouterWebUIMessageHandlerTest,
76 OnRouteDetailsOpenedAndClosed);
77 FRIEND_TEST_ALL_PREFIXES(MediaRouterWebUIMessageHandlerTest,
78 OnMediaCommandsReceived);
79 FRIEND_TEST_ALL_PREFIXES(MediaRouterWebUIMessageHandlerTest,
80 OnInvalidMediaCommandsReceived);
67 81
68 // WebUIMessageHandler implementation. 82 // WebUIMessageHandler implementation.
69 void RegisterMessages() override; 83 void RegisterMessages() override;
70 84
71 // Handlers for JavaScript messages. 85 // Handlers for JavaScript messages.
72 // See media_router_ui_interface.js for documentation on parameters. 86 // See media_router_ui_interface.js for documentation on parameters.
73 void OnRequestInitialData(const base::ListValue* args); 87 void OnRequestInitialData(const base::ListValue* args);
74 void OnCreateRoute(const base::ListValue* args); 88 void OnCreateRoute(const base::ListValue* args);
75 void OnAcknowledgeFirstRunFlow(const base::ListValue* args); 89 void OnAcknowledgeFirstRunFlow(const base::ListValue* args);
76 void OnActOnIssue(const base::ListValue* args); 90 void OnActOnIssue(const base::ListValue* args);
77 void OnCloseRoute(const base::ListValue* args); 91 void OnCloseRoute(const base::ListValue* args);
78 void OnJoinRoute(const base::ListValue* args); 92 void OnJoinRoute(const base::ListValue* args);
79 void OnCloseDialog(const base::ListValue* args); 93 void OnCloseDialog(const base::ListValue* args);
80 void OnReportBlur(const base::ListValue* args); 94 void OnReportBlur(const base::ListValue* args);
81 void OnReportClickedSinkIndex(const base::ListValue* args); 95 void OnReportClickedSinkIndex(const base::ListValue* args);
82 void OnReportFilter(const base::ListValue* args); 96 void OnReportFilter(const base::ListValue* args);
83 void OnReportInitialAction(const base::ListValue* args); 97 void OnReportInitialAction(const base::ListValue* args);
84 void OnReportInitialState(const base::ListValue* args); 98 void OnReportInitialState(const base::ListValue* args);
85 void OnReportNavigateToView(const base::ListValue* args); 99 void OnReportNavigateToView(const base::ListValue* args);
86 void OnReportRouteCreation(const base::ListValue* args); 100 void OnReportRouteCreation(const base::ListValue* args);
87 void OnReportRouteCreationOutcome(const base::ListValue* args); 101 void OnReportRouteCreationOutcome(const base::ListValue* args);
88 void OnReportSelectedCastMode(const base::ListValue* args); 102 void OnReportSelectedCastMode(const base::ListValue* args);
89 void OnReportSinkCount(const base::ListValue* args); 103 void OnReportSinkCount(const base::ListValue* args);
90 void OnReportTimeToClickSink(const base::ListValue* args); 104 void OnReportTimeToClickSink(const base::ListValue* args);
91 void OnReportTimeToInitialActionClose(const base::ListValue* args); 105 void OnReportTimeToInitialActionClose(const base::ListValue* args);
106 void OnMediaControllerAvailable(const base::ListValue* args);
107 void OnMediaControllerClosed(const base::ListValue* args);
92 void OnSearchSinksAndCreateRoute(const base::ListValue* args); 108 void OnSearchSinksAndCreateRoute(const base::ListValue* args);
93 void OnInitialDataReceived(const base::ListValue* args); 109 void OnInitialDataReceived(const base::ListValue* args);
94 110
111 // Handlers for JavaScript messages to control the media.
112 void OnPlayCurrentMedia(const base::ListValue* args);
113 void OnPauseCurrentMedia(const base::ListValue* args);
114 void OnSeekCurrentMedia(const base::ListValue* args);
115 void OnSetCurrentMediaMute(const base::ListValue* args);
116 void OnSetCurrentMediaVolume(const base::ListValue* args);
117
95 // Performs an action for an Issue of |type|. 118 // Performs an action for an Issue of |type|.
96 // |args| contains additional parameter that varies based on |type|. 119 // |args| contains additional parameter that varies based on |type|.
97 // Returns |true| if the action was successfully performed. 120 // Returns |true| if the action was successfully performed.
98 bool ActOnIssueType(IssueInfo::Action type, 121 bool ActOnIssueType(IssueInfo::Action type,
99 const base::DictionaryValue* args); 122 const base::DictionaryValue* args);
100 123
101 // May update the first run flow related properties in the WebUI. This is 124 // May update the first run flow related properties in the WebUI. This is
102 // called after the initial data is received to avoid unnecessary work when 125 // called after the initial data is received to avoid unnecessary work when
103 // initializing the WebUI. 126 // initializing the WebUI.
104 void MaybeUpdateFirstRunFlowData(); 127 void MaybeUpdateFirstRunFlowData();
(...skipping 17 matching lines...) Expand all
122 // used when updating sinks to determine if identity should be displayed. 145 // used when updating sinks to determine if identity should be displayed.
123 // Marked virtual for tests. 146 // Marked virtual for tests.
124 virtual AccountInfo GetAccountInfo(); 147 virtual AccountInfo GetAccountInfo();
125 148
126 // |true| if the associated Profile is incognito. 149 // |true| if the associated Profile is incognito.
127 bool incognito_; 150 bool incognito_;
128 151
129 // Keeps track of whether a command to close the dialog has been issued. 152 // Keeps track of whether a command to close the dialog has been issued.
130 bool dialog_closing_; 153 bool dialog_closing_;
131 154
155 // The media status currently shown in the UI.
156 base::Optional<MediaStatus> current_media_status_;
157
132 MediaRouterUI* media_router_ui_; 158 MediaRouterUI* media_router_ui_;
133 159
134 DISALLOW_COPY_AND_ASSIGN(MediaRouterWebUIMessageHandler); 160 DISALLOW_COPY_AND_ASSIGN(MediaRouterWebUIMessageHandler);
135 }; 161 };
136 162
137 } // namespace media_router 163 } // namespace media_router
138 164
139 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_WEBUI_MESSAGE_HANDL ER_H_ 165 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_WEBUI_MESSAGE_HANDL ER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698