chromium/content/browser/devtools/render_frame_devtools_agent_host.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/browser/devtools/render_frame_devtools_agent_host.h"

#include <set>
#include <string>
#include <tuple>
#include <utility>

#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/lazy_instance.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "components/viz/common/buildflags.h"
#include "content/browser/bad_message.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/devtools/devtools_manager.h"
#include "content/browser/devtools/devtools_renderer_channel.h"
#include "content/browser/devtools/devtools_session.h"
#include "content/browser/devtools/frame_auto_attacher.h"
#include "content/browser/devtools/protocol/audits_handler.h"
#include "content/browser/devtools/protocol/background_service_handler.h"
#include "content/browser/devtools/protocol/browser_handler.h"
#include "content/browser/devtools/protocol/device_access_handler.h"
#include "content/browser/devtools/protocol/device_orientation_handler.h"
#include "content/browser/devtools/protocol/dom_handler.h"
#include "content/browser/devtools/protocol/emulation_handler.h"
#include "content/browser/devtools/protocol/fedcm_handler.h"
#include "content/browser/devtools/protocol/fetch_handler.h"
#include "content/browser/devtools/protocol/handler_helpers.h"
#include "content/browser/devtools/protocol/input_handler.h"
#include "content/browser/devtools/protocol/inspector_handler.h"
#include "content/browser/devtools/protocol/io_handler.h"
#include "content/browser/devtools/protocol/log_handler.h"
#include "content/browser/devtools/protocol/memory_handler.h"
#include "content/browser/devtools/protocol/network_handler.h"
#include "content/browser/devtools/protocol/overlay_handler.h"
#include "content/browser/devtools/protocol/page_handler.h"
#include "content/browser/devtools/protocol/preload_handler.h"
#include "content/browser/devtools/protocol/protocol.h"
#include "content/browser/devtools/protocol/schema_handler.h"
#include "content/browser/devtools/protocol/security_handler.h"
#include "content/browser/devtools/protocol/service_worker_handler.h"
#include "content/browser/devtools/protocol/storage_handler.h"
#include "content/browser/devtools/protocol/system_info_handler.h"
#include "content/browser/devtools/protocol/target_handler.h"
#include "content/browser/devtools/protocol/tracing_handler.h"
#include "content/browser/devtools/web_contents_devtools_agent_host.h"
#include "content/browser/fenced_frame/fenced_frame.h"
#include "content/browser/renderer_host/navigation_request.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/site_instance_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/web_package/signed_exchange_envelope.h"
#include "content/public/browser/back_forward_cache.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_widget_host_iterator.h"
#include "content/public/browser/web_contents_delegate.h"
#include "services/network/public/mojom/network_service.mojom.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/mojom/devtools/devtools_agent.mojom.h"

#if BUILDFLAG(IS_ANDROID)
#include "content/browser/renderer_host/compositor_impl_android.h"
#include "content/public/browser/render_widget_host_view.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "services/device/public/mojom/wake_lock_context.mojom.h"
#else
#include "content/browser/devtools/protocol/webauthn_handler.h"
#endif

#if BUILDFLAG(USE_VIZ_DEBUGGER)
#include "content/browser/devtools/protocol/visual_debugger_handler.h"
#endif

namespace content {

namespace {
RenderFrameDevToolsMap;
base::LazyInstance<RenderFrameDevToolsMap>::Leaky g_agent_host_instances =;

static bool g_was_ever_attached_to_any_frame =;

RenderFrameDevToolsAgentHost* FindAgentHost(FrameTreeNode* frame_tree_node) {}

bool ShouldCreateDevToolsForNode(FrameTreeNode* ftn) {}

}  // namespace

FrameTreeNode* GetFrameTreeNodeAncestor(FrameTreeNode* frame_tree_node) {}

// static
scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetOrCreateFor(
    WebContents* web_contents) {}

// static
DevToolsAgentHostImpl* RenderFrameDevToolsAgentHost::GetFor(
    FrameTreeNode* frame_tree_node) {}

// static
DevToolsAgentHostImpl* RenderFrameDevToolsAgentHost::GetFor(
    RenderFrameHostImpl* rfh) {}

scoped_refptr<DevToolsAgentHost> RenderFrameDevToolsAgentHost::GetOrCreateFor(
    FrameTreeNode* frame_tree_node) {}

// static
bool RenderFrameDevToolsAgentHost::ShouldCreateDevToolsForHost(
    RenderFrameHostImpl* rfh) {}

// static
scoped_refptr<RenderFrameDevToolsAgentHost>
RenderFrameDevToolsAgentHost::CreateForLocalRootOrEmbeddedPageNavigation(
    NavigationRequest* request) {}

// static
scoped_refptr<RenderFrameDevToolsAgentHost>
RenderFrameDevToolsAgentHost::FindForDangling(FrameTreeNode* frame_tree_node) {}

// static
bool DevToolsAgentHost::HasFor(WebContents* web_contents) {}

// static
bool RenderFrameDevToolsAgentHost::WasEverAttachedToAnyFrame() {}

// static
bool DevToolsAgentHost::IsDebuggerAttached(WebContents* web_contents) {}

// static
bool RenderFrameDevToolsAgentHost::IsDebuggerAttached(
    WebContents* web_contents) {}

// static
void RenderFrameDevToolsAgentHost::AddAllAgentHosts(
    DevToolsAgentHost::List* result) {}

// static
void RenderFrameDevToolsAgentHost::AttachToWebContents(
    WebContents* web_contents) {}

// static
void RenderFrameDevToolsAgentHost::UpdateRawHeadersAccess(
    RenderFrameHostImpl* rfh) {}

RenderFrameDevToolsAgentHost::RenderFrameDevToolsAgentHost(
    FrameTreeNode* frame_tree_node,
    RenderFrameHostImpl* frame_host)
    :{}

void RenderFrameDevToolsAgentHost::SetFrameTreeNode(
    FrameTreeNode* frame_tree_node) {}

BrowserContext* RenderFrameDevToolsAgentHost::GetBrowserContext() {}

WebContents* RenderFrameDevToolsAgentHost::GetWebContents() {}

bool RenderFrameDevToolsAgentHost::AttachSession(DevToolsSession* session,
                                                 bool acquire_wake_lock) {}

void RenderFrameDevToolsAgentHost::DetachSession(DevToolsSession* session) {}

void RenderFrameDevToolsAgentHost::InspectElement(RenderFrameHost* frame_host,
                                                  int x,
                                                  int y) {}

RenderFrameDevToolsAgentHost::~RenderFrameDevToolsAgentHost() {}

void RenderFrameDevToolsAgentHost::ReadyToCommitNavigation(
    NavigationHandle* navigation_handle) {}

void RenderFrameDevToolsAgentHost::DidFinishNavigation(
    NavigationHandle* navigation_handle) {}

void RenderFrameDevToolsAgentHost::UpdateFrameHost(
    RenderFrameHostImpl* frame_host) {}

void RenderFrameDevToolsAgentHost::DidStartNavigation(
    NavigationHandle* navigation_handle) {}

void RenderFrameDevToolsAgentHost::RenderFrameHostChanged(
    RenderFrameHost* old_host,
    RenderFrameHost* new_host) {}

void RenderFrameDevToolsAgentHost::FrameDeleted(int frame_tree_node_id) {}

void RenderFrameDevToolsAgentHost::RenderFrameDeleted(RenderFrameHost* rfh) {}

void RenderFrameDevToolsAgentHost::DestroyOnRenderFrameGone() {}

#if BUILDFLAG(IS_ANDROID)
device::mojom::WakeLock* RenderFrameDevToolsAgentHost::GetWakeLock() {
  // Here is a lazy binding, and will not reconnect after connection error.
  if (!wake_lock_) {
    mojo::PendingReceiver<device::mojom::WakeLock> receiver =
        wake_lock_.BindNewPipeAndPassReceiver();
    device::mojom::WakeLockContext* wake_lock_context =
        web_contents()->GetWakeLockContext();
    if (wake_lock_context) {
      wake_lock_context->GetWakeLock(
          device::mojom::WakeLockType::kPreventDisplaySleep,
          device::mojom::WakeLockReason::kOther, "DevTools",
          std::move(receiver));
    }
  }
  return wake_lock_.get();
}
#endif

void RenderFrameDevToolsAgentHost::ChangeFrameHostAndObservedProcess(
    RenderFrameHostImpl* frame_host) {}

void RenderFrameDevToolsAgentHost::UpdateFrameAlive() {}

void RenderFrameDevToolsAgentHost::RenderProcessExited(
    RenderProcessHost* host,
    const ChildProcessTerminationInfo& info) {}

void RenderFrameDevToolsAgentHost::OnVisibilityChanged(
    content::Visibility visibility) {}

void RenderFrameDevToolsAgentHost::OnNavigationRequestWillBeSent(
    const NavigationRequest& navigation_request) {}

void RenderFrameDevToolsAgentHost::DidCreateFencedFrame(
    FencedFrame* fenced_frame) {}

void RenderFrameDevToolsAgentHost::DisconnectWebContents() {}

void RenderFrameDevToolsAgentHost::ConnectWebContents(WebContents* wc) {}

std::string RenderFrameDevToolsAgentHost::GetParentId() {}

std::string RenderFrameDevToolsAgentHost::GetOpenerId() {}

std::string RenderFrameDevToolsAgentHost::GetOpenerFrameId() {}

bool RenderFrameDevToolsAgentHost::CanAccessOpener() {}

std::string RenderFrameDevToolsAgentHost::GetType() {}

std::string RenderFrameDevToolsAgentHost::GetTitle() {}

std::string RenderFrameDevToolsAgentHost::GetDescription() {}

GURL RenderFrameDevToolsAgentHost::GetURL() {}

GURL RenderFrameDevToolsAgentHost::GetFaviconURL() {}

bool RenderFrameDevToolsAgentHost::Activate() {}

void RenderFrameDevToolsAgentHost::Reload() {}

bool RenderFrameDevToolsAgentHost::Close() {}

base::TimeTicks RenderFrameDevToolsAgentHost::GetLastActivityTime() {}

void RenderFrameDevToolsAgentHost::UpdateRendererChannel(bool force) {}

protocol::TargetAutoAttacher* RenderFrameDevToolsAgentHost::auto_attacher() {}

namespace {

constexpr char kSubtypeDisconnected[] =;
constexpr char kSubtypePrerender[] =;
constexpr char kSubtypeFenced[] =;

}  // namespace

std::string RenderFrameDevToolsAgentHost::GetSubtype() {}

RenderProcessHost* RenderFrameDevToolsAgentHost::GetProcessHost() {}

void RenderFrameDevToolsAgentHost::MainThreadDebuggerPaused() {}

void RenderFrameDevToolsAgentHost::MainThreadDebuggerResumed() {}

bool RenderFrameDevToolsAgentHost::IsChildFrame() {}

bool RenderFrameDevToolsAgentHost::ShouldAllowSession(
    RenderFrameHost* frame_host,
    DevToolsSession* session) {}

void RenderFrameDevToolsAgentHost::UpdateResourceLoaderFactories() {}

std::optional<network::CrossOriginEmbedderPolicy>
RenderFrameDevToolsAgentHost::cross_origin_embedder_policy(
    const std::string& id) {}

std::optional<network::CrossOriginOpenerPolicy>
RenderFrameDevToolsAgentHost::cross_origin_opener_policy(
    const std::string& id) {}

std::optional<std::vector<network::mojom::ContentSecurityPolicyHeader>>
RenderFrameDevToolsAgentHost::content_security_policy(const std::string& id) {}

bool RenderFrameDevToolsAgentHost::HasSessionsWithoutTabTargetSupport() const {}

}  // namespace content