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 #include "chrome/browser/ui/webui/media_router/media_router_webui_message_handler.h"
8 #include "chrome/browser/ui/webui/media_router/media_router_ui.h"
9 #include "content/public/browser/web_ui.h"
11 namespace media_router
{
16 const char kGetInitialSettings
[] = "getInitialSettings";
17 const char kCreateRoute
[] = "requestRoute";
18 const char kActOnIssue
[] = "actOnIssue";
19 const char kCloseRoute
[] = "closeRoute";
20 const char kCloseDialog
[] = "closeDialog";
22 // TODO(imcheng): Define JS function names here.
26 MediaRouterWebUIMessageHandler::MediaRouterWebUIMessageHandler()
27 : dialog_closing_(false) {
30 MediaRouterWebUIMessageHandler::~MediaRouterWebUIMessageHandler() {
33 void MediaRouterWebUIMessageHandler::RegisterMessages() {
34 web_ui()->RegisterMessageCallback(
36 base::Bind(&MediaRouterWebUIMessageHandler::OnGetInitialSettings
,
37 base::Unretained(this)));
38 web_ui()->RegisterMessageCallback(
40 base::Bind(&MediaRouterWebUIMessageHandler::OnCreateRoute
,
41 base::Unretained(this)));
42 web_ui()->RegisterMessageCallback(
44 base::Bind(&MediaRouterWebUIMessageHandler::OnActOnIssue
,
45 base::Unretained(this)));
46 web_ui()->RegisterMessageCallback(
48 base::Bind(&MediaRouterWebUIMessageHandler::OnCloseRoute
,
49 base::Unretained(this)));
50 web_ui()->RegisterMessageCallback(
52 base::Bind(&MediaRouterWebUIMessageHandler::OnCloseDialog
,
53 base::Unretained(this)));
56 void MediaRouterWebUIMessageHandler::OnGetInitialSettings(
57 const base::ListValue
* args
) {
58 // TODO(imcheng): Implement.
62 void MediaRouterWebUIMessageHandler::OnCreateRoute(
63 const base::ListValue
* args
) {
64 // TODO(imcheng): Implement.
68 void MediaRouterWebUIMessageHandler::OnActOnIssue(
69 const base::ListValue
* args
) {
70 // TODO(imcheng): Implement.
74 void MediaRouterWebUIMessageHandler::OnCloseRoute(
75 const base::ListValue
* args
) {
76 // TODO(imcheng): Implement.
80 void MediaRouterWebUIMessageHandler::OnCloseDialog(
81 const base::ListValue
* args
) {
82 CHECK(!dialog_closing_
);
83 dialog_closing_
= true;
84 GetMediaRouterUI()->Close();
87 MediaRouterUI
* MediaRouterWebUIMessageHandler::GetMediaRouterUI() const {
88 MediaRouterUI
* media_router_ui
=
89 static_cast<MediaRouterUI
*>(web_ui()->GetController());
90 DCHECK(media_router_ui
);
91 return media_router_ui
;
94 } // namespace media_router