| 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_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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class MediaRouterUI; | 25 class MediaRouterUI; |
| 26 | 26 |
| 27 // The handler for Javascript messages related to the media router dialog. | 27 // The handler for Javascript messages related to the media router dialog. |
| 28 class MediaRouterWebUIMessageHandler : public content::WebUIMessageHandler { | 28 class MediaRouterWebUIMessageHandler : public content::WebUIMessageHandler { |
| 29 public: | 29 public: |
| 30 explicit MediaRouterWebUIMessageHandler(MediaRouterUI* media_router_ui); | 30 explicit MediaRouterWebUIMessageHandler(MediaRouterUI* media_router_ui); |
| 31 ~MediaRouterWebUIMessageHandler() override; | 31 ~MediaRouterWebUIMessageHandler() override; |
| 32 | 32 |
| 33 // Methods to update the status displayed by the dialog. | 33 // Methods to update the status displayed by the dialog. |
| 34 void UpdateSinks(const std::vector<MediaSinkWithCastModes>& sinks); | 34 void UpdateSinks(const std::vector<MediaSinkWithCastModes>& sinks); |
| 35 void UpdateRoutes(const std::vector<MediaRoute>& routes); | 35 void UpdateRoutes(const std::vector<MediaRoute>& routes, |
| 36 const std::vector<MediaRoute::Id>& joinable_route_ids); |
| 36 void UpdateCastModes(const CastModeSet& cast_modes, | 37 void UpdateCastModes(const CastModeSet& cast_modes, |
| 37 const std::string& source_host); | 38 const std::string& source_host); |
| 38 void OnCreateRouteResponseReceived(const MediaSink::Id& sink_id, | 39 void OnCreateRouteResponseReceived(const MediaSink::Id& sink_id, |
| 39 const MediaRoute* route); | 40 const MediaRoute* route); |
| 40 | 41 |
| 41 // Does not take ownership of |issue|. Note that |issue| can be nullptr, when | 42 // Does not take ownership of |issue|. Note that |issue| can be nullptr, when |
| 42 // there are no more issues. | 43 // there are no more issues. |
| 43 void UpdateIssue(const Issue* issue); | 44 void UpdateIssue(const Issue* issue); |
| 44 | 45 |
| 45 // Notifies the dialog that the route creation attempt timed out. | 46 // Notifies the dialog that the route creation attempt timed out. |
| 46 void NotifyRouteCreationTimeout(); | 47 void NotifyRouteCreationTimeout(); |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 // WebUIMessageHandler implementation. | 50 // WebUIMessageHandler implementation. |
| 50 void RegisterMessages() override; | 51 void RegisterMessages() override; |
| 51 | 52 |
| 52 // Handlers for JavaScript messages. | 53 // Handlers for JavaScript messages. |
| 53 // In all cases, |args| consists of a single DictionaryValue containing the | 54 // In all cases, |args| consists of a single DictionaryValue containing the |
| 54 // actual parameters. | 55 // actual parameters. |
| 55 // See media_router_ui_interface.js for documentation on parameters. | 56 // See media_router_ui_interface.js for documentation on parameters. |
| 56 void OnRequestInitialData(const base::ListValue* args); | 57 void OnRequestInitialData(const base::ListValue* args); |
| 57 void OnCreateRoute(const base::ListValue* args); | 58 void OnCreateRoute(const base::ListValue* args); |
| 58 void OnActOnIssue(const base::ListValue* args); | 59 void OnActOnIssue(const base::ListValue* args); |
| 59 void OnCloseRoute(const base::ListValue* args); | 60 void OnCloseRoute(const base::ListValue* args); |
| 61 void OnJoinRoute(const base::ListValue* args); |
| 60 void OnCloseDialog(const base::ListValue* args); | 62 void OnCloseDialog(const base::ListValue* args); |
| 61 void OnReportClickedSinkIndex(const base::ListValue* args); | 63 void OnReportClickedSinkIndex(const base::ListValue* args); |
| 62 void OnReportNavigateToView(const base::ListValue* args); | 64 void OnReportNavigateToView(const base::ListValue* args); |
| 63 void OnReportSelectedCastMode(const base::ListValue* args); | 65 void OnReportSelectedCastMode(const base::ListValue* args); |
| 64 void OnReportSinkCount(const base::ListValue* args); | 66 void OnReportSinkCount(const base::ListValue* args); |
| 65 void OnInitialDataReceived(const base::ListValue* args); | 67 void OnInitialDataReceived(const base::ListValue* args); |
| 66 | 68 |
| 67 // Performs an action for an Issue of |type|. | 69 // Performs an action for an Issue of |type|. |
| 68 // |args| contains additional parameter that varies based on |type|. | 70 // |args| contains additional parameter that varies based on |type|. |
| 69 // Returns |true| if the action was successfully performed. | 71 // Returns |true| if the action was successfully performed. |
| 70 bool ActOnIssueType(const IssueAction::Type& type, | 72 bool ActOnIssueType(const IssueAction::Type& type, |
| 71 const base::DictionaryValue* args); | 73 const base::DictionaryValue* args); |
| 72 | 74 |
| 73 // Keeps track of whether a command to close the dialog has been issued. | 75 // Keeps track of whether a command to close the dialog has been issued. |
| 74 bool dialog_closing_; | 76 bool dialog_closing_; |
| 75 | 77 |
| 76 MediaRouterUI* media_router_ui_; | 78 MediaRouterUI* media_router_ui_; |
| 77 | 79 |
| 78 DISALLOW_COPY_AND_ASSIGN(MediaRouterWebUIMessageHandler); | 80 DISALLOW_COPY_AND_ASSIGN(MediaRouterWebUIMessageHandler); |
| 79 }; | 81 }; |
| 80 | 82 |
| 81 } // namespace media_router | 83 } // namespace media_router |
| 82 | 84 |
| 83 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_WEBUI_MESSAGE_HANDL
ER_H_ | 85 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_WEBUI_MESSAGE_HANDL
ER_H_ |
| OLD | NEW |