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_
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"
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
{
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
,
43 virtual void OpenInNewTab(const std::string
& url
) = 0;
44 virtual void SaveToFile(const std::string
& url
,
45 const std::string
& content
,
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
,
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
,
77 int boundary_value
) = 0;
78 virtual void SendJsonRequest(const DispatchCallback
& callback
,
79 const std::string
& browser_id
,
80 const std::string
& url
) = 0;
81 virtual void SendFrontendAPINotification(const std::string
& message
) = 0;
84 using DispatchCallback
= Delegate::DispatchCallback
;
86 virtual ~DevToolsEmbedderMessageDispatcher() {}
87 virtual bool Dispatch(const DispatchCallback
& callback
,
88 const std::string
& method
,
89 const base::ListValue
* params
) = 0;
91 static DevToolsEmbedderMessageDispatcher
* CreateForDevToolsFrontend(
95 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_