Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / webui / media_router / media_router_webui_message_handler.h
blob99cc1d93c486b725d54e588b06240b71ebe11cfc
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
3 // found in the LICENSE file.
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_
8 #include <vector>
10 #include "base/macros.h"
11 #include "chrome/browser/media/router/issue.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"
14 #include "content/public/browser/web_ui_message_handler.h"
16 namespace base {
17 class DictionaryValue;
18 class ListValue;
19 } // namespace base
21 namespace media_router {
23 class Issue;
24 class MediaRoute;
25 class MediaRouterUI;
27 // The handler for Javascript messages related to the media router dialog.
28 class MediaRouterWebUIMessageHandler : public content::WebUIMessageHandler {
29 public:
30 explicit MediaRouterWebUIMessageHandler(MediaRouterUI* media_router_ui);
31 ~MediaRouterWebUIMessageHandler() override;
33 // Methods to update the status displayed by the dialog.
34 void UpdateSinks(const std::vector<MediaSinkWithCastModes>& sinks);
35 void UpdateRoutes(const std::vector<MediaRoute>& routes);
36 void UpdateCastModes(const CastModeSet& cast_modes,
37 const std::string& source_host);
38 void OnCreateRouteResponseReceived(const MediaSink::Id& sink_id,
39 const MediaRoute* route);
41 // Does not take ownership of |issue|. Note that |issue| can be nullptr, when
42 // there are no more issues.
43 void UpdateIssue(const Issue* issue);
45 private:
46 // WebUIMessageHandler implementation.
47 void RegisterMessages() override;
49 // Handlers for JavaScript messages.
50 // In all cases, |args| consists of a single DictionaryValue containing the
51 // actual parameters.
52 // See media_router_ui_interface.js for documentation on parameters.
53 void OnRequestInitialData(const base::ListValue* args);
54 void OnCreateRoute(const base::ListValue* args);
55 void OnActOnIssue(const base::ListValue* args);
56 void OnCloseRoute(const base::ListValue* args);
57 void OnCloseDialog(const base::ListValue* args);
59 // Performs an action for an Issue of |type|.
60 // |args| contains additional parameter that varies based on |type|.
61 // Returns |true| if the action was successfully performed.
62 bool ActOnIssueType(const IssueAction::Type& type,
63 const base::DictionaryValue* args);
65 // Keeps track of whether a command to close the dialog has been issued.
66 bool dialog_closing_;
68 MediaRouterUI* media_router_ui_;
70 DISALLOW_COPY_AND_ASSIGN(MediaRouterWebUIMessageHandler);
73 } // namespace media_router
75 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_WEBUI_MESSAGE_HANDLER_H_