• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "ui/gfx/insets.h"
13 #include "ui/gfx/rect.h"
14 #include "ui/gfx/size.h"
15 
16 namespace base {
17 class ListValue;
18 }
19 
20 /**
21  * Dispatcher for messages sent from the DevTools frontend running in an
22  * isolated renderer (on chrome-devtools://) to the embedder in the browser.
23  *
24  * The messages are sent via InspectorFrontendHost.sendMessageToEmbedder method.
25  */
26 class DevToolsEmbedderMessageDispatcher {
27  public:
28   class Delegate {
29    public:
~Delegate()30     virtual ~Delegate() {}
31 
32     virtual void ActivateWindow() = 0;
33     virtual void CloseWindow() = 0;
34     virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0;
35     virtual void SetContentsResizingStrategy(
36         const gfx::Insets& insets, const gfx::Size& min_size) = 0;
37     virtual void InspectElementCompleted() = 0;
38     virtual void InspectedURLChanged(const std::string& url) = 0;
39     virtual void MoveWindow(int x, int y) = 0;
40     virtual void SetIsDocked(bool is_docked) = 0;
41     virtual void OpenInNewTab(const std::string& url) = 0;
42     virtual void SaveToFile(const std::string& url,
43                             const std::string& content,
44                             bool save_as) = 0;
45     virtual void AppendToFile(const std::string& url,
46                               const std::string& content) = 0;
47     virtual void RequestFileSystems() = 0;
48     virtual void AddFileSystem() = 0;
49     virtual void RemoveFileSystem(const std::string& file_system_path) = 0;
50     virtual void UpgradeDraggedFileSystemPermissions(
51         const std::string& file_system_url) = 0;
52     virtual void IndexPath(int request_id,
53                            const std::string& file_system_path) = 0;
54     virtual void StopIndexing(int request_id) = 0;
55     virtual void SearchInPath(int request_id,
56                               const std::string& file_system_path,
57                               const std::string& query) = 0;
58     virtual void SetWhitelistedShortcuts(const std::string& message) = 0;
59     virtual void ZoomIn() = 0;
60     virtual void ZoomOut() = 0;
61     virtual void ResetZoom() = 0;
62     virtual void OpenUrlOnRemoteDeviceAndInspect(const std::string& browser_id,
63                                                  const std::string& url) = 0;
64 
65     virtual void Subscribe(const std::string& event_type) = 0;
66     virtual void Unsubscribe(const std::string& event_type) = 0;
67   };
68 
~DevToolsEmbedderMessageDispatcher()69   virtual ~DevToolsEmbedderMessageDispatcher() {}
70   virtual bool Dispatch(const std::string& method,
71                         const base::ListValue* params,
72                         std::string* error) = 0;
73 
74   static DevToolsEmbedderMessageDispatcher* createForDevToolsFrontend(
75       Delegate* delegate);
76 };
77 
78 #endif  // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_
79