- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / devtools / devtools_embedder_message_dispatcher.h
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.
4
5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/callback.h"
12
13 namespace base {
14 class ListValue;
15 }
16
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.
20  *
21  * The messages are sent via InspectorFrontendHost.sendMessageToEmbedder method.
22  */
23 class DevToolsEmbedderMessageDispatcher {
24  public:
25   class Delegate {
26    public:
27     virtual ~Delegate() {}
28
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,
37                             bool save_as) = 0;
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;
49   };
50
51   explicit DevToolsEmbedderMessageDispatcher(Delegate* delegate);
52
53   ~DevToolsEmbedderMessageDispatcher();
54
55   std::string Dispatch(const std::string& method, base::ListValue* params);
56
57  private:
58   typedef base::Callback<bool(const base::ListValue&)> Handler;
59   void RegisterHandler(const std::string& method, const Handler& handler);
60
61   typedef std::map<std::string, Handler> HandlerMap;
62   HandlerMap handlers_;
63 };
64
65 #endif  // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_