#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "content/browser/devtools/devtools_frontend_host_impl.h"
#include <stddef.h>
#include <memory>
#include <string>
#include "base/feature_list.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "content/browser/bad_message.h"
#include "content/common/features.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_client.h"
#include "content/public/common/url_constants.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "ui/base/webui/resource_path.h"
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "components/crash/content/browser/error_reporting/javascript_error_report.h"
#include "components/crash/content/browser/error_reporting/js_error_report_processor.h"
#endif
extern const webui::ResourcePath kDevtoolsResources[];
extern const size_t kDevtoolsResourcesSize;
namespace content {
namespace {
const char kCompatibilityScript[] = …;
const char kCompatibilityScriptSourceURL[] = …;
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
std::string RedactURL(const GURL& url) { … }
#endif
}
std::unique_ptr<DevToolsFrontendHost> DevToolsFrontendHost::Create(
RenderFrameHost* frame_host,
const HandleMessageCallback& handle_message_callback) { … }
std::unique_ptr<DevToolsFrontendHostImpl>
DevToolsFrontendHostImpl::CreateForTesting(
RenderFrameHost* frame_host,
const HandleMessageCallback& handle_message_callback) { … }
void DevToolsFrontendHost::SetupExtensionsAPI(
RenderFrameHost* frame_host,
const std::string& extension_api) { … }
scoped_refptr<base::RefCountedMemory>
DevToolsFrontendHost::GetFrontendResourceBytes(const std::string& path) { … }
std::string DevToolsFrontendHost::GetFrontendResource(const std::string& path) { … }
DevToolsFrontendHostImpl::DevToolsFrontendHostImpl(
RenderFrameHost* frame_host,
const HandleMessageCallback& handle_message_callback)
: … { … }
DevToolsFrontendHostImpl::~DevToolsFrontendHostImpl() = default;
void DevToolsFrontendHostImpl::BadMessageReceived() { … }
void DevToolsFrontendHostImpl::DispatchEmbedderMessage(
base::Value::Dict message) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
void DevToolsFrontendHostImpl::OnDidAddMessageToConsole(
RenderFrameHost* source_frame,
blink::mojom::ConsoleMessageLevel log_level,
const std::u16string& message,
int32_t line_no,
const std::u16string& source_id,
const std::optional<std::u16string>& untrusted_stack_trace) { … }
#endif
}