#include "content/shell/browser/shell_devtools_bindings.h"
#include <stddef.h>
#include <string_view>
#include <utility>
#include <vector>
#include "base/base64.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/json/string_escape.h"
#include "base/memory/raw_ptr.h"
#include "base/no_destructor.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/uuid.h"
#include "base/values.h"
#include "build/build_config.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_client.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/shell_browser_main_parts.h"
#include "content/shell/browser/shell_content_browser_client.h"
#include "content/shell/browser/shell_devtools_manager_delegate.h"
#include "net/http/http_response_headers.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
#include "base/command_line.h"
#include "content/public/browser/devtools_frontend_host.h"
#include "content/shell/common/shell_switches.h"
#endif
namespace content {
namespace {
std::vector<ShellDevToolsBindings*>* GetShellDevtoolsBindingsInstances() { … }
base::Value::Dict BuildObjectForResponse(const net::HttpResponseHeaders* rh,
bool success,
int net_error) { … }
}
class ShellDevToolsBindings::NetworkResourceLoader
: public network::SimpleURLLoaderStreamConsumer { … };
constexpr size_t kShellMaxMessageChunkSize = …;
void ShellDevToolsBindings::InspectElementAt(int x, int y) { … }
ShellDevToolsBindings::ShellDevToolsBindings(WebContents* devtools_contents,
WebContents* inspected_contents,
ShellDevToolsDelegate* delegate)
: … { … }
ShellDevToolsBindings::~ShellDevToolsBindings() { … }
void ShellDevToolsBindings::ReadyToCommitNavigation(
NavigationHandle* navigation_handle) { … }
void ShellDevToolsBindings::AttachInternal() { … }
void ShellDevToolsBindings::Attach() { … }
void ShellDevToolsBindings::WebContentsDestroyed() { … }
void ShellDevToolsBindings::HandleMessageFromDevToolsFrontend(
base::Value::Dict message) { … }
void ShellDevToolsBindings::DispatchProtocolMessage(
DevToolsAgentHost* agent_host,
base::span<const uint8_t> message) { … }
void ShellDevToolsBindings::CallClientFunction(
const std::string& object_name,
const std::string& method_name,
base::Value arg1,
base::Value arg2,
base::Value arg3,
base::OnceCallback<void(base::Value)> cb) { … }
void ShellDevToolsBindings::SendMessageAck(int request_id,
base::Value::Dict arg) { … }
void ShellDevToolsBindings::AgentHostClosed(DevToolsAgentHost* agent_host) { … }
}