chromium/content/browser/devtools/protocol/target_handler.cc

// Copyright 2016 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/protocol/target_handler.h"

#include <memory>
#include <string_view>

#include "base/base64.h"
#include "base/containers/contains.h"
#include "base/containers/flat_map.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/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/strings/stringprintf.h"
#include "base/unguessable_token.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "content/browser/devtools/browser_devtools_agent_host.h"
#include "content/browser/devtools/devtools_agent_host_impl.h"
#include "content/browser/devtools/devtools_manager.h"
#include "content/browser/devtools/protocol/target_auto_attacher.h"
#include "content/browser/devtools/render_frame_devtools_agent_host.h"
#include "content/browser/devtools/web_contents_devtools_agent_host.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/browser/renderer_host/navigation_request.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/cors_origin_pattern_setter.h"
#include "content/public/browser/devtools_agent_host_client.h"
#include "content/public/browser/navigation_throttle.h"
#include "url/url_constants.h"

namespace content::protocol {

namespace {

constexpr net::NetworkTrafficAnnotationTag
    kSettingsProxyConfigTrafficAnnotation =;

static const char kNotAllowedError[] =;
static const char kMethod[] =;
static const char kResumeMethod[] =;

static const char kInitializerScript[] =;

static const char kTargetNotFound[] =;

std::unique_ptr<Target::TargetInfo> BuildTargetInfo(
    DevToolsAgentHost* agent_host) {}

static std::string TerminationStatusToString(base::TerminationStatus status) {}

class BrowserToPageConnector;

class BrowserToPageConnector {};

}  // namespace

// Throttle is owned externally by the navigation subsystem.
class TargetHandler::Throttle : public content::NavigationThrottle {};

class TargetHandler::ResponseThrottle : public TargetHandler::Throttle {};

class TargetHandler::RequestThrottle : public TargetHandler::Throttle {};

class TargetHandler::Session : public DevToolsAgentHostClient {};

void TargetHandler::Throttle::CleanupPointers() {}

void TargetHandler::Throttle::SetThrottledAgentHost(
    DevToolsAgentHost* agent_host) {}

const char* TargetHandler::Throttle::GetNameForLogging() {}

void TargetHandler::Throttle::Clear() {}

class TargetHandler::TargetFilter {};

TargetHandler::TargetHandler(AccessMode access_mode,
                             const std::string& owner_target_id,
                             TargetAutoAttacher* auto_attacher,
                             DevToolsSession* session)
    :{}

TargetHandler::~TargetHandler() = default;

// static
std::vector<TargetHandler*> TargetHandler::ForAgentHost(
    DevToolsAgentHostImpl* host) {}

void TargetHandler::Wire(UberDispatcher* dispatcher) {}

Response TargetHandler::Disable() {}

std::unique_ptr<NavigationThrottle> TargetHandler::CreateThrottleForNavigation(
    TargetAutoAttacher* auto_attacher,
    NavigationHandle* navigation_handle) {}

TargetHandler::Session* TargetHandler::FindWaitingSession(
    DevToolsAgentHost* host) {}

void TargetHandler::ClearThrottles() {}

void TargetHandler::SetAutoAttachInternal(bool auto_attach,
                                          bool wait_for_debugger_on_start,
                                          bool flatten,
                                          base::OnceClosure callback) {}

void TargetHandler::UpdateAgentHostObserver() {}

bool TargetHandler::AutoAttach(TargetAutoAttacher* source,
                               DevToolsAgentHost* host,
                               bool waiting_for_debugger) {}

void TargetHandler::AutoDetach(TargetAutoAttacher* source,
                               DevToolsAgentHost* host) {}

void TargetHandler::SetAttachedTargetsOfType(
    TargetAutoAttacher* source,
    const base::flat_set<scoped_refptr<DevToolsAgentHost>>& new_hosts,
    const std::string& type) {}

void TargetHandler::TargetInfoChanged(DevToolsAgentHost* host) {}

void TargetHandler::AutoAttacherDestroyed(TargetAutoAttacher* auto_attacher) {}

bool TargetHandler::ShouldWaitForDebuggerOnStart(
    NavigationRequest* navigation_request) const {}

bool TargetHandler::ShouldThrottlePopups() const {}

void TargetHandler::DisableAutoAttachOfServiceWorkers() {}

Response TargetHandler::FindSession(Maybe<std::string> session_id,
                                    Maybe<std::string> target_id,
                                    Session** session) {}

// ----------------- Protocol ----------------------

Response TargetHandler::SetDiscoverTargets(
    bool discover,
    Maybe<protocol::Array<protocol::Target::FilterEntry>> filter) {}

void TargetHandler::SetAutoAttach(
    bool auto_attach,
    bool wait_for_debugger_on_start,
    Maybe<bool> flatten,
    Maybe<protocol::Array<protocol::Target::FilterEntry>> filter,
    std::unique_ptr<SetAutoAttachCallback> callback) {}

void TargetHandler::AutoAttachRelated(
    const std::string& targetId,
    bool wait_for_debugger_on_start,
    Maybe<protocol::Array<protocol::Target::FilterEntry>> filter,
    std::unique_ptr<AutoAttachRelatedCallback> callback) {}

Response TargetHandler::SetRemoteLocations(
    std::unique_ptr<protocol::Array<Target::RemoteLocation>>) {}

Response TargetHandler::AttachToTarget(const std::string& target_id,
                                       Maybe<bool> flatten,
                                       std::string* out_session_id) {}

Response TargetHandler::AttachToBrowserTarget(std::string* out_session_id) {}

Response TargetHandler::DetachFromTarget(Maybe<std::string> session_id,
                                         Maybe<std::string> target_id) {}

Response TargetHandler::SendMessageToTarget(const std::string& message,
                                            Maybe<std::string> session_id,
                                            Maybe<std::string> target_id) {}

Response TargetHandler::GetTargetInfo(
    Maybe<std::string> maybe_target_id,
    std::unique_ptr<Target::TargetInfo>* target_info) {}

Response TargetHandler::ActivateTarget(const std::string& target_id) {}

Response TargetHandler::CloseTarget(const std::string& target_id,
                                    bool* out_success) {}

Response TargetHandler::ExposeDevToolsProtocol(
    const std::string& target_id,
    Maybe<std::string> binding_name) {}

Response TargetHandler::CreateTarget(const std::string& url,
                                     Maybe<int> width,
                                     Maybe<int> height,
                                     Maybe<std::string> context_id,
                                     Maybe<bool> enable_begin_frame_control,
                                     Maybe<bool> new_window,
                                     Maybe<bool> background,
                                     Maybe<bool> for_tab,
                                     std::string* out_target_id) {}

Response TargetHandler::GetTargets(
    Maybe<protocol::Array<protocol::Target::FilterEntry>> filter,
    std::unique_ptr<protocol::Array<Target::TargetInfo>>* target_infos) {}

// -------------- DevToolsAgentHostObserver -----------------

bool TargetHandler::ShouldForceDevToolsAgentHostCreation() {}

void TargetHandler::DevToolsAgentHostCreated(DevToolsAgentHost* host) {}

void TargetHandler::DevToolsAgentHostNavigated(DevToolsAgentHost* host) {}

void TargetHandler::DevToolsAgentHostDestroyed(DevToolsAgentHost* host) {}

void TargetHandler::DevToolsAgentHostAttached(DevToolsAgentHost* host) {}

void TargetHandler::DevToolsAgentHostDetached(DevToolsAgentHost* host) {}

void TargetHandler::DevToolsAgentHostCrashed(DevToolsAgentHost* host,
                                             base::TerminationStatus status) {}

// ----------------- More protocol methods -------------------

void TargetHandler::CreateBrowserContext(
    Maybe<bool> in_disposeOnDetach,
    Maybe<String> in_proxyServer,
    Maybe<String> in_proxyBypassList,
    Maybe<protocol::Array<String>> in_originsToGrantUniversalNetworkAccess,
    std::unique_ptr<CreateBrowserContextCallback> callback) {}

protocol::Response TargetHandler::GetBrowserContexts(
    std::unique_ptr<protocol::Array<protocol::String>>* browser_context_ids) {}

void TargetHandler::DisposeBrowserContext(
    const std::string& context_id,
    std::unique_ptr<DisposeBrowserContextCallback> callback) {}

void TargetHandler::ApplyNetworkContextParamsOverrides(
    BrowserContext* browser_context,
    network::mojom::NetworkContextParams* context_params) {}

void TargetHandler::AddWorkerThrottle(
    DevToolsAgentHost* agent_host,
    scoped_refptr<DevToolsThrottleHandle> throttle_handle) {}

}  // namespace content::protocol