Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / devtools / devtools_embedder_message_dispatcher.h
blobbadf46f83ef98cf0a0280ece1ef29ed116d0dbdd
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 GetPreferences(const DispatchCallback& callback) = 0;
70 virtual void SetPreference(const std::string& name,
71 const std::string& value) = 0;
72 virtual void RemovePreference(const std::string& name) = 0;
73 virtual void ClearPreferences() = 0;
74 virtual void SendMessageToBrowser(const std::string& message) = 0;
75 virtual void RecordEnumeratedHistogram(const std::string& name,
76 int sample,
77 int boundary_value) = 0;
78 virtual void SendJsonRequest(const DispatchCallback& callback,
79 const std::string& browser_id,
80 const std::string& url) = 0;
83 using DispatchCallback = Delegate::DispatchCallback;
85 virtual ~DevToolsEmbedderMessageDispatcher() {}
86 virtual bool Dispatch(const DispatchCallback& callback,
87 const std::string& method,
88 const base::ListValue* params) = 0;
90 static DevToolsEmbedderMessageDispatcher* CreateForDevToolsFrontend(
91 Delegate* delegate);
94 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_