blob: 7bfd3af997b650a78a70ff230c4d65cd24e052ac [file] [log] [blame]
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_BROWSER_WEBUI_CAST_WEBUI_MESSAGE_HANDLER_H_
#define CHROMECAST_BROWSER_WEBUI_CAST_WEBUI_MESSAGE_HANDLER_H_
#include <string>
#include <vector>
#include "base/values.h"
#include "content/public/browser/web_ui_message_handler.h"
namespace chromecast {
// Simple generic message handler for Web UIs. This class exposes a public
// method for running JS in the Web UI. This class is owned by the Web UI,
// but a reference is maintained inside of CastWebUI.
class CastWebUIMessageHandler : public content::WebUIMessageHandler {
public:
CastWebUIMessageHandler();
~CastWebUIMessageHandler() override;
// content::WebUIMessageHandler implementation:
void RegisterMessages() override;
void OnJavascriptDisallowed() override;
// Invoke a JS function in the Web UI.
void CallJavascriptFunction(const std::string& function,
std::vector<base::Value> args);
private:
bool javascript_called_ = false;
};
} // namespace chromecast
#endif // CHROMECAST_BROWSER_WEBUI_CAST_WEBUI_MESSAGE_HANDLER_H_