1 // Copyright 2013 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_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_
11 #include "base/callback.h"
18 * Dispatcher for messages sent from the DevTools frontend running in an
19 * isolated renderer (on chrome-devtools://) to the embedder in the browser.
21 * The messages are sent via InspectorFrontendHost.sendMessageToEmbedder method.
23 class DevToolsEmbedderMessageDispatcher {
27 virtual ~Delegate() {}
29 virtual void ActivateWindow() = 0;
30 virtual void CloseWindow() = 0;
31 virtual void SetWindowBounds(int x, int y, int width, int height) = 0;
32 virtual void MoveWindow(int x, int y) = 0;
33 virtual void SetDockSide(const std::string& side) = 0;
34 virtual void OpenInNewTab(const std::string& url) = 0;
35 virtual void SaveToFile(const std::string& url,
36 const std::string& content,
38 virtual void AppendToFile(const std::string& url,
39 const std::string& content) = 0;
40 virtual void RequestFileSystems() = 0;
41 virtual void AddFileSystem() = 0;
42 virtual void RemoveFileSystem(const std::string& file_system_path) = 0;
43 virtual void IndexPath(int request_id,
44 const std::string& file_system_path) = 0;
45 virtual void StopIndexing(int request_id) = 0;
46 virtual void SearchInPath(int request_id,
47 const std::string& file_system_path,
48 const std::string& query) = 0;
51 explicit DevToolsEmbedderMessageDispatcher(Delegate* delegate);
53 ~DevToolsEmbedderMessageDispatcher();
55 std::string Dispatch(const std::string& method, base::ListValue* params);
58 typedef base::Callback<bool(const base::ListValue&)> Handler;
59 void RegisterHandler(const std::string& method, const Handler& handler);
61 typedef std::map<std::string, Handler> HandlerMap;
65 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_