2013-12-02 17:38:24 +00:00
|
|
|
// Copyright 2013 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE-CHROMIUM file.
|
|
|
|
|
|
|
|
#ifndef BRIGHTRAY_BROWSER_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_
|
|
|
|
#define BRIGHTRAY_BROWSER_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "base/callback.h"
|
2015-03-09 02:02:38 +00:00
|
|
|
#include "ui/gfx/geometry/insets.h"
|
|
|
|
#include "ui/gfx/geometry/rect.h"
|
|
|
|
#include "ui/gfx/geometry/size.h"
|
2013-12-02 17:38:24 +00:00
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class ListValue;
|
2015-06-05 03:03:47 +00:00
|
|
|
class Value;
|
2018-04-18 01:46:27 +00:00
|
|
|
} // namespace base
|
2013-12-02 17:38:24 +00:00
|
|
|
|
|
|
|
namespace brightray {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatcher for messages sent from the DevTools frontend running in an
|
|
|
|
* isolated renderer (on chrome-devtools://) to the embedder in the browser.
|
|
|
|
*
|
|
|
|
* The messages are sent via InspectorFrontendHost.sendMessageToEmbedder method.
|
|
|
|
*/
|
|
|
|
class DevToolsEmbedderMessageDispatcher {
|
|
|
|
public:
|
|
|
|
class Delegate {
|
|
|
|
public:
|
2015-06-05 03:03:47 +00:00
|
|
|
using DispatchCallback = base::Callback<void(const base::Value*)>;
|
|
|
|
|
2013-12-02 17:38:24 +00:00
|
|
|
virtual ~Delegate() {}
|
|
|
|
|
|
|
|
virtual void ActivateWindow() = 0;
|
|
|
|
virtual void CloseWindow() = 0;
|
2015-06-05 03:03:47 +00:00
|
|
|
virtual void LoadCompleted() = 0;
|
2014-09-01 11:15:07 +00:00
|
|
|
virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0;
|
2014-07-08 07:58:38 +00:00
|
|
|
virtual void InspectElementCompleted() = 0;
|
2015-06-05 03:03:47 +00:00
|
|
|
virtual void InspectedURLChanged(const std::string& url) = 0;
|
|
|
|
virtual void SetIsDocked(const DispatchCallback& callback,
|
|
|
|
bool is_docked) = 0;
|
2013-12-02 17:38:24 +00:00
|
|
|
virtual void OpenInNewTab(const std::string& url) = 0;
|
2018-07-06 03:19:21 +00:00
|
|
|
virtual void ShowItemInFolder(const std::string& file_system_path) = 0;
|
2013-12-02 17:38:24 +00:00
|
|
|
virtual void SaveToFile(const std::string& url,
|
|
|
|
const std::string& content,
|
|
|
|
bool save_as) = 0;
|
|
|
|
virtual void AppendToFile(const std::string& url,
|
|
|
|
const std::string& content) = 0;
|
|
|
|
virtual void RequestFileSystems() = 0;
|
2016-03-15 02:23:40 +00:00
|
|
|
virtual void AddFileSystem(const std::string& file_system_path) = 0;
|
2013-12-02 17:38:24 +00:00
|
|
|
virtual void RemoveFileSystem(const std::string& file_system_path) = 0;
|
2014-07-08 07:58:38 +00:00
|
|
|
virtual void UpgradeDraggedFileSystemPermissions(
|
|
|
|
const std::string& file_system_url) = 0;
|
2015-06-05 03:03:47 +00:00
|
|
|
virtual void IndexPath(int index_request_id,
|
2013-12-02 17:38:24 +00:00
|
|
|
const std::string& file_system_path) = 0;
|
2015-06-05 03:03:47 +00:00
|
|
|
virtual void StopIndexing(int index_request_id) = 0;
|
|
|
|
virtual void LoadNetworkResource(const DispatchCallback& callback,
|
|
|
|
const std::string& url,
|
|
|
|
const std::string& headers,
|
|
|
|
int stream_id) = 0;
|
|
|
|
virtual void SearchInPath(int search_request_id,
|
2013-12-02 17:38:24 +00:00
|
|
|
const std::string& file_system_path,
|
|
|
|
const std::string& query) = 0;
|
2015-06-05 03:03:47 +00:00
|
|
|
virtual void SetWhitelistedShortcuts(const std::string& message) = 0;
|
2018-07-06 03:19:21 +00:00
|
|
|
virtual void SetEyeDropperActive(bool active) = 0;
|
|
|
|
virtual void ShowCertificateViewer(const std::string& cert_chain) = 0;
|
2014-07-08 07:58:38 +00:00
|
|
|
virtual void ZoomIn() = 0;
|
|
|
|
virtual void ZoomOut() = 0;
|
|
|
|
virtual void ResetZoom() = 0;
|
2018-07-06 03:19:21 +00:00
|
|
|
virtual void SetDevicesDiscoveryConfig(
|
|
|
|
bool discover_usb_devices,
|
|
|
|
bool port_forwarding_enabled,
|
|
|
|
const std::string& port_forwarding_config,
|
|
|
|
bool network_discovery_enabled,
|
|
|
|
const std::string& network_discovery_config) = 0;
|
2015-06-05 03:03:47 +00:00
|
|
|
virtual void SetDevicesUpdatesEnabled(bool enabled) = 0;
|
2018-07-06 03:19:21 +00:00
|
|
|
virtual void PerformActionOnRemotePage(const std::string& page_id,
|
|
|
|
const std::string& action) = 0;
|
|
|
|
virtual void OpenRemotePage(const std::string& browser_id,
|
|
|
|
const std::string& url) = 0;
|
|
|
|
virtual void OpenNodeFrontend() = 0;
|
2016-03-08 14:28:28 +00:00
|
|
|
virtual void DispatchProtocolMessageFromDevToolsFrontend(
|
|
|
|
const std::string& message) = 0;
|
2015-06-05 03:03:47 +00:00
|
|
|
virtual void SendJsonRequest(const DispatchCallback& callback,
|
|
|
|
const std::string& browser_id,
|
|
|
|
const std::string& url) = 0;
|
2015-08-06 05:39:23 +00:00
|
|
|
virtual void GetPreferences(const DispatchCallback& callback) = 0;
|
|
|
|
virtual void SetPreference(const std::string& name,
|
|
|
|
const std::string& value) = 0;
|
|
|
|
virtual void RemovePreference(const std::string& name) = 0;
|
|
|
|
virtual void ClearPreferences() = 0;
|
2018-07-06 03:19:21 +00:00
|
|
|
virtual void ConnectionReady() = 0;
|
2017-10-30 11:36:13 +00:00
|
|
|
virtual void RegisterExtensionsAPI(const std::string& origin,
|
|
|
|
const std::string& script) = 0;
|
2013-12-02 17:38:24 +00:00
|
|
|
};
|
|
|
|
|
2015-06-05 03:03:47 +00:00
|
|
|
using DispatchCallback = Delegate::DispatchCallback;
|
2013-12-02 17:38:24 +00:00
|
|
|
|
2015-06-05 03:03:47 +00:00
|
|
|
virtual ~DevToolsEmbedderMessageDispatcher() {}
|
|
|
|
virtual bool Dispatch(const DispatchCallback& callback,
|
|
|
|
const std::string& method,
|
|
|
|
const base::ListValue* params) = 0;
|
2013-12-02 17:38:24 +00:00
|
|
|
|
2015-06-05 03:03:47 +00:00
|
|
|
static DevToolsEmbedderMessageDispatcher* CreateForDevToolsFrontend(
|
|
|
|
Delegate* delegate);
|
2013-12-02 17:38:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace brightray
|
|
|
|
|
|
|
|
#endif // BRIGHTRAY_BROWSER_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_
|