Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / devtools / devtools_embedder_message_dispatcher.h
blob18c8d62cbae89c226df99cf594ce0f0b8e9c02c7
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"
12 #include "ui/gfx/geometry/insets.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/size.h"
16 namespace base {
17 class ListValue;
18 class Value;
21 /**
22 * Dispatcher for messages sent from the DevTools frontend running in an
23 * isolated renderer (on chrome-devtools://) to the embedder in the browser.
25 * The messages are sent via InspectorFrontendHost.sendMessageToEmbedder method.
27 class DevToolsEmbedderMessageDispatcher {
28 public:
29 class Delegate {
30 public:
31 using DispatchCallback = base::Callback<void(const base::Value*)>;
33 virtual ~Delegate() {}
35 virtual void ActivateWindow() = 0;
36 virtual void CloseWindow() = 0;
37 virtual void LoadCompleted() = 0;
38 virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0;
39 virtual void InspectElementCompleted() = 0;
40 virtual void InspectedURLChanged(const std::string& url) = 0;
41 virtual void SetIsDocked(const DispatchCallback& callback,
42 bool is_docked) = 0;
43 virtual void OpenInNewTab(const std::string& url) = 0;
44 virtual void SaveToFile(const std::string& url,
45 const std::string& content,
46 bool save_as) = 0;
47 virtual void AppendToFile(const std::string& url,
48 const std::string& content) = 0;
49 virtual void RequestFileSystems() = 0;
50 virtual void AddFileSystem() = 0;
51 virtual void RemoveFileSystem(const std::string& file_system_path) = 0;
52 virtual void UpgradeDraggedFileSystemPermissions(
53 const std::string& file_system_url) = 0;
54 virtual void IndexPath(int index_request_id,
55 const std::string& file_system_path) = 0;
56 virtual void StopIndexing(int index_request_id) = 0;
57 virtual void LoadNetworkResource(const DispatchCallback& callback,
58 const std::string& url,
59 const std::string& headers,
60 int stream_id) = 0;
61 virtual void SearchInPath(int search_request_id,
62 const std::string& file_system_path,
63 const std::string& query) = 0;
64 virtual void SetWhitelistedShortcuts(const std::string& message) = 0;
65 virtual void ZoomIn() = 0;
66 virtual void ZoomOut() = 0;
67 virtual void ResetZoom() = 0;
68 virtual void SetDevicesUpdatesEnabled(bool enabled) = 0;
69 virtual void SetDevicesDiscoveryConfig(
70 bool discover_usb_devices,
71 bool port_forwarding_enabled,
72 const std::string& port_forwarding_config) = 0;
73 virtual void PerformActionOnRemotePage(const std::string& page_id,
74 const std::string& action) = 0;
75 virtual void GetPreferences(const DispatchCallback& callback) = 0;
76 virtual void SetPreference(const std::string& name,
77 const std::string& value) = 0;
78 virtual void RemovePreference(const std::string& name) = 0;
79 virtual void ClearPreferences() = 0;
80 virtual void SendMessageToBrowser(const std::string& message) = 0;
81 virtual void RecordEnumeratedHistogram(const std::string& name,
82 int sample,
83 int boundary_value) = 0;
84 virtual void SendJsonRequest(const DispatchCallback& callback,
85 const std::string& browser_id,
86 const std::string& url) = 0;
87 virtual void SendFrontendAPINotification(const std::string& message) = 0;
90 using DispatchCallback = Delegate::DispatchCallback;
92 virtual ~DevToolsEmbedderMessageDispatcher() {}
93 virtual bool Dispatch(const DispatchCallback& callback,
94 const std::string& method,
95 const base::ListValue* params) = 0;
97 static DevToolsEmbedderMessageDispatcher* CreateForDevToolsFrontend(
98 Delegate* delegate);
101 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_