2016-10-17 20:14:44 +02: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 file.
|
2013-11-08 17:06:06 +01:00
|
|
|
|
2019-02-12 19:43:44 +01:00
|
|
|
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FRONTEND_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FRONTEND_H_
|
2013-11-08 17:06:06 +01:00
|
|
|
|
2016-10-17 20:14:44 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2020-09-22 21:54:02 +02:00
|
|
|
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
2019-02-12 21:31:52 +01:00
|
|
|
#include "libcef/browser/devtools/devtools_file_manager.h"
|
2013-11-08 17:06:06 +01:00
|
|
|
|
2020-06-13 02:54:08 +02:00
|
|
|
#include "base/files/file_path.h"
|
2013-11-08 17:06:06 +01:00
|
|
|
#include "base/memory/ref_counted.h"
|
2015-03-04 02:00:13 +01:00
|
|
|
#include "base/memory/weak_ptr.h"
|
2015-04-23 12:03:42 +02:00
|
|
|
#include "base/values.h"
|
2013-11-08 17:06:06 +01:00
|
|
|
#include "content/public/browser/devtools_agent_host.h"
|
2014-09-04 19:53:40 +02:00
|
|
|
#include "content/public/browser/devtools_frontend_host.h"
|
2013-11-08 17:06:06 +01:00
|
|
|
#include "content/public/browser/web_contents_observer.h"
|
2015-03-04 02:00:13 +01:00
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class Value;
|
|
|
|
}
|
2013-11-08 17:06:06 +01:00
|
|
|
|
|
|
|
namespace content {
|
2017-07-27 01:19:27 +02:00
|
|
|
class NavigationHandle;
|
2013-11-08 17:06:06 +01:00
|
|
|
class RenderViewHost;
|
|
|
|
class WebContents;
|
2017-07-27 01:19:27 +02:00
|
|
|
} // namespace content
|
2013-11-08 17:06:06 +01:00
|
|
|
|
2017-02-28 23:40:28 +01:00
|
|
|
class PrefService;
|
|
|
|
|
2020-06-13 02:54:08 +02:00
|
|
|
enum class ProtocolMessageType {
|
|
|
|
METHOD,
|
|
|
|
RESULT,
|
|
|
|
EVENT,
|
|
|
|
};
|
|
|
|
|
2013-11-08 17:06:06 +01:00
|
|
|
class CefDevToolsFrontend : public content::WebContentsObserver,
|
2019-07-29 23:27:12 +02:00
|
|
|
public content::DevToolsAgentHostClient {
|
2013-11-08 17:06:06 +01:00
|
|
|
public:
|
2021-12-06 21:40:25 +01:00
|
|
|
CefDevToolsFrontend(const CefDevToolsFrontend&) = delete;
|
|
|
|
CefDevToolsFrontend& operator=(const CefDevToolsFrontend&) = delete;
|
|
|
|
|
2013-11-08 17:06:06 +01:00
|
|
|
static CefDevToolsFrontend* Show(
|
2020-09-22 21:54:02 +02:00
|
|
|
AlloyBrowserHostImpl* inspected_browser,
|
2013-11-08 17:06:06 +01:00
|
|
|
const CefWindowInfo& windowInfo,
|
|
|
|
CefRefPtr<CefClient> client,
|
2014-10-11 02:12:01 +02:00
|
|
|
const CefBrowserSettings& settings,
|
2020-06-13 02:54:08 +02:00
|
|
|
const CefPoint& inspect_element_at,
|
|
|
|
base::OnceClosure frontend_destroyed_callback);
|
2013-11-08 17:06:06 +01:00
|
|
|
|
2016-10-17 20:14:44 +02:00
|
|
|
void Activate();
|
2013-11-08 17:06:06 +01:00
|
|
|
void Focus();
|
2015-03-04 02:00:13 +01:00
|
|
|
void InspectElementAt(int x, int y);
|
2013-11-08 17:06:06 +01:00
|
|
|
void Close();
|
|
|
|
|
2021-08-20 01:40:49 +02:00
|
|
|
void CallClientFunction(
|
|
|
|
const std::string& object_name,
|
|
|
|
const std::string& method_name,
|
|
|
|
const base::Value arg1 = {},
|
|
|
|
const base::Value arg2 = {},
|
|
|
|
const base::Value arg3 = {},
|
|
|
|
base::OnceCallback<void(base::Value)> cb = base::NullCallback());
|
2015-03-04 02:00:13 +01:00
|
|
|
|
2018-02-15 01:12:09 +01:00
|
|
|
private:
|
2020-09-22 21:54:02 +02:00
|
|
|
CefDevToolsFrontend(AlloyBrowserHostImpl* frontend_browser,
|
2016-06-10 18:43:53 +02:00
|
|
|
content::WebContents* inspected_contents,
|
2020-06-13 02:54:08 +02:00
|
|
|
const CefPoint& inspect_element_at,
|
|
|
|
base::OnceClosure destroyed_callback);
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefDevToolsFrontend() override;
|
2013-11-08 17:06:06 +01:00
|
|
|
|
2015-03-04 02:00:13 +01:00
|
|
|
// content::DevToolsAgentHostClient implementation.
|
2017-12-07 22:44:24 +01:00
|
|
|
void AgentHostClosed(content::DevToolsAgentHost* agent_host) override;
|
2015-03-04 02:00:13 +01:00
|
|
|
void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host,
|
2020-03-04 01:29:39 +01:00
|
|
|
base::span<const uint8_t> message) override;
|
2022-07-21 19:26:10 +02:00
|
|
|
void HandleMessageFromDevToolsFrontend(base::Value::Dict message);
|
2015-03-04 02:00:13 +01:00
|
|
|
|
2016-10-17 20:14:44 +02:00
|
|
|
private:
|
2015-03-04 02:00:13 +01:00
|
|
|
// WebContentsObserver overrides
|
2017-07-27 01:19:27 +02:00
|
|
|
void ReadyToCommitNavigation(
|
|
|
|
content::NavigationHandle* navigation_handle) override;
|
2022-02-21 23:23:40 +01:00
|
|
|
void PrimaryMainDocumentElementAvailable() override;
|
2014-11-12 20:25:15 +01:00
|
|
|
void WebContentsDestroyed() override;
|
2013-11-08 17:06:06 +01:00
|
|
|
|
2023-01-30 18:43:54 +01:00
|
|
|
void SendMessageAck(int request_id, base::Value::Dict arg);
|
2013-11-08 17:06:06 +01:00
|
|
|
|
2020-06-13 02:54:08 +02:00
|
|
|
bool ProtocolLoggingEnabled() const;
|
|
|
|
void LogProtocolMessage(ProtocolMessageType type,
|
|
|
|
const base::StringPiece& message);
|
|
|
|
|
2017-02-28 23:40:28 +01:00
|
|
|
PrefService* GetPrefs() const;
|
|
|
|
|
2020-09-22 21:54:02 +02:00
|
|
|
CefRefPtr<AlloyBrowserHostImpl> frontend_browser_;
|
2015-03-19 23:06:16 +01:00
|
|
|
content::WebContents* inspected_contents_;
|
2013-11-08 17:06:06 +01:00
|
|
|
scoped_refptr<content::DevToolsAgentHost> agent_host_;
|
2016-10-17 20:14:44 +02:00
|
|
|
CefPoint inspect_element_at_;
|
2020-06-13 02:54:08 +02:00
|
|
|
base::OnceClosure frontend_destroyed_callback_;
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<content::DevToolsFrontendHost> frontend_host_;
|
2019-06-05 17:12:29 +02:00
|
|
|
|
|
|
|
class NetworkResourceLoader;
|
|
|
|
std::set<std::unique_ptr<NetworkResourceLoader>, base::UniquePtrComparator>
|
|
|
|
loaders_;
|
|
|
|
|
2017-07-27 01:19:27 +02:00
|
|
|
using ExtensionsAPIs = std::map<std::string, std::string>;
|
|
|
|
ExtensionsAPIs extensions_api_;
|
2019-02-12 21:31:52 +01:00
|
|
|
CefDevToolsFileManager file_manager_;
|
2020-06-13 02:54:08 +02:00
|
|
|
|
|
|
|
const base::FilePath protocol_log_file_;
|
|
|
|
|
2015-03-04 02:00:13 +01:00
|
|
|
base::WeakPtrFactory<CefDevToolsFrontend> weak_factory_;
|
2013-11-08 17:06:06 +01:00
|
|
|
};
|
|
|
|
|
2019-02-12 19:43:44 +01:00
|
|
|
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_FRONTEND_H_
|