Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / devtools / devtools_embedder_message_dispatcher.h
blob604c0b744c198e04cc6292e12d1671f96ed256dc
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_
8 #include <map>
9 #include <string>
11 #include "base/callback.h"
13 namespace base {
14 class ListValue;
17 /**
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 {
24 public:
25 class Delegate {
26 public:
27 virtual ~Delegate() {}
29 virtual void ActivateWindow() = 0;
30 virtual void CloseWindow() = 0;
31 virtual void SetContentsInsets(
32 int top, int left, int bottom, int right) = 0;
33 virtual void MoveWindow(int x, int y) = 0;
34 // TODO(dgozman): remove once clients have switched to |SetIsDocked|.
35 virtual void SetDockSide(const std::string& side) = 0;
36 virtual void SetIsDocked(bool is_docked) = 0;
37 virtual void OpenInNewTab(const std::string& url) = 0;
38 virtual void SaveToFile(const std::string& url,
39 const std::string& content,
40 bool save_as) = 0;
41 virtual void AppendToFile(const std::string& url,
42 const std::string& content) = 0;
43 virtual void RequestFileSystems() = 0;
44 virtual void AddFileSystem() = 0;
45 virtual void RemoveFileSystem(const std::string& file_system_path) = 0;
46 virtual void UpgradeDraggedFileSystemPermissions(
47 const std::string& file_system_url) = 0;
48 virtual void IndexPath(int request_id,
49 const std::string& file_system_path) = 0;
50 virtual void StopIndexing(int request_id) = 0;
51 virtual void SearchInPath(int request_id,
52 const std::string& file_system_path,
53 const std::string& query) = 0;
56 explicit DevToolsEmbedderMessageDispatcher(Delegate* delegate);
58 ~DevToolsEmbedderMessageDispatcher();
60 std::string Dispatch(const std::string& method, base::ListValue* params);
62 private:
63 typedef base::Callback<bool(const base::ListValue&)> Handler;
64 void RegisterHandler(const std::string& method, const Handler& handler);
66 typedef std::map<std::string, Handler> HandlerMap;
67 HandlerMap handlers_;
70 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_