chromium/chrome/browser/devtools/device/devtools_device_discovery.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "chrome/browser/devtools/device/devtools_device_discovery.h"

#include <map>
#include <string_view>

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/user_metrics.h"
#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_features.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/devtools_external_agent_proxy.h"
#include "content/public/browser/devtools_external_agent_proxy_delegate.h"

BrowserThread;
DevToolsAgentHost;
RemoteBrowser;
RemoteDevice;
RemotePage;

namespace {

const char kPageListRequest[] =;
const char kVersionRequest[] =;
const char kClosePageRequest[] =;
const char kActivatePageRequest[] =;
const char kBrowserTargetSocket[] =;
const int kPollingIntervalMs =;

const char kPageReloadCommand[] =;

const char kWebViewSocketPrefix[] =;

static void ScheduleTaskDefault(base::OnceClosure task) {}

// ProtocolCommand ------------------------------------------------------------

class ProtocolCommand
    : public AndroidDeviceManager::AndroidWebSocket::Delegate {};

ProtocolCommand::ProtocolCommand(
    scoped_refptr<AndroidDeviceManager::Device> device,
    const std::string& socket,
    const std::string& target_path,
    const std::string& command)
    :{}

void ProtocolCommand::OnSocketOpened() {}

void ProtocolCommand::OnFrameRead(const std::string& message) {}

void ProtocolCommand::OnSocketClosed() {}

ProtocolCommand::~ProtocolCommand() {}

// AgentHostDelegate ----------------------------------------------------------

class WebSocketProxy : public AndroidDeviceManager::AndroidWebSocket::Delegate {};

class AgentHostDelegate : public content::DevToolsExternalAgentProxyDelegate {};

static std::string GetStringProperty(const base::Value::Dict& value,
                                     const std::string& name) {}

static std::string BuildUniqueTargetId(const std::string& serial,
                                       const std::string& browser_id,
                                       const base::Value::Dict& value) {}

static std::string GetFrontendURLFromValue(const base::Value::Dict& value,
                                           const std::string& browser_version) {}

static std::string GetTargetPath(const base::Value::Dict& value) {}

// static
scoped_refptr<content::DevToolsAgentHost>
AgentHostDelegate::GetOrCreateAgentHost(
    scoped_refptr<AndroidDeviceManager::Device> device,
    const std::string& browser_id,
    const std::string& browser_version,
    const std::string& local_id,
    const std::string& target_path,
    const std::string& type,
    const base::Value::Dict* value) {}

AgentHostDelegate::AgentHostDelegate(
    scoped_refptr<AndroidDeviceManager::Device> device,
    const std::string& browser_id,
    const std::string& browser_version,
    const std::string& local_id,
    const std::string& target_path,
    const std::string& type,
    const base::Value::Dict* value)
    :{}

AgentHostDelegate::~AgentHostDelegate() = default;

void AgentHostDelegate::Attach(content::DevToolsExternalAgentProxy* proxy) {}

void AgentHostDelegate::Detach(content::DevToolsExternalAgentProxy* proxy) {}

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

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

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

GURL AgentHostDelegate::GetURL() {}

GURL AgentHostDelegate::GetFaviconURL() {}

std::string AgentHostDelegate::GetFrontendURL() {}

bool AgentHostDelegate::Activate() {}

void AgentHostDelegate::Reload() {}

bool AgentHostDelegate::Close() {}

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

void AgentHostDelegate::SendMessageToBackend(
    content::DevToolsExternalAgentProxy* proxy,
    base::span<const uint8_t> message) {}

}  // namespace

// DevToolsDeviceDiscovery::DiscoveryRequest ----------------------------------

class DevToolsDeviceDiscovery::DiscoveryRequest
    : public base::RefCountedThreadSafe<DiscoveryRequest,
                                        BrowserThread::DeleteOnUIThread> {};

// static
void DevToolsDeviceDiscovery::DiscoveryRequest::Start(
    AndroidDeviceManager* device_manager,
    base::OnceCallback<void(const CompleteDevices&)> callback) {}

DevToolsDeviceDiscovery::DiscoveryRequest::DiscoveryRequest(
    base::OnceCallback<void(const CompleteDevices&)> callback)
    :{}

DevToolsDeviceDiscovery::DiscoveryRequest::~DiscoveryRequest() {}

void DevToolsDeviceDiscovery::DiscoveryRequest::ReceivedDevices(
    const AndroidDeviceManager::Devices& devices) {}

void DevToolsDeviceDiscovery::DiscoveryRequest::ReceivedDeviceInfo(
    scoped_refptr<AndroidDeviceManager::Device> device,
    const AndroidDeviceManager::DeviceInfo& device_info) {}

void DevToolsDeviceDiscovery::DiscoveryRequest::ParseBrowserInfo(
    scoped_refptr<RemoteBrowser> browser,
    const std::string& version_response,
    bool& is_chrome) {}

void DevToolsDeviceDiscovery::DiscoveryRequest::ReceivedVersion(
    scoped_refptr<AndroidDeviceManager::Device> device,
    scoped_refptr<RemoteBrowser> browser,
    int result,
    const std::string& response) {}

void DevToolsDeviceDiscovery::DiscoveryRequest::ReceivedPages(
    scoped_refptr<AndroidDeviceManager::Device> device,
    scoped_refptr<RemoteBrowser> browser,
    int result,
    const std::string& response) {}

// DevToolsDeviceDiscovery::RemotePage ----------------------------------------

DevToolsDeviceDiscovery::RemotePage::RemotePage(
    scoped_refptr<AndroidDeviceManager::Device> device,
    const std::string& browser_id,
    const std::string& browser_version,
    base::Value::Dict dict)
    :{}

DevToolsDeviceDiscovery::RemotePage::~RemotePage() {}

scoped_refptr<content::DevToolsAgentHost>
DevToolsDeviceDiscovery::RemotePage::CreateTarget() {}

// DevToolsDeviceDiscovery::RemoteBrowser -------------------------------------

DevToolsDeviceDiscovery::RemoteBrowser::RemoteBrowser(
    const std::string& serial,
    const AndroidDeviceManager::BrowserInfo& browser_info)
    :{}

bool DevToolsDeviceDiscovery::RemoteBrowser::IsChrome() {}

std::string DevToolsDeviceDiscovery::RemoteBrowser::GetId() {}

DevToolsDeviceDiscovery::RemoteBrowser::ParsedVersion
DevToolsDeviceDiscovery::RemoteBrowser::GetParsedVersion() {}

DevToolsDeviceDiscovery::RemoteBrowser::~RemoteBrowser() {}

// DevToolsDeviceDiscovery::RemoteDevice --------------------------------------

DevToolsDeviceDiscovery::RemoteDevice::RemoteDevice(
    const std::string& serial,
    const AndroidDeviceManager::DeviceInfo& device_info)
    :{}

DevToolsDeviceDiscovery::RemoteDevice::~RemoteDevice() {}

// DevToolsDeviceDiscovery ----------------------------------------------------

DevToolsDeviceDiscovery::DevToolsDeviceDiscovery(
    AndroidDeviceManager* device_manager,
    DeviceListCallback callback)
    :{}

DevToolsDeviceDiscovery::~DevToolsDeviceDiscovery() {}

void DevToolsDeviceDiscovery::SetScheduler(
    base::RepeatingCallback<void(base::OnceClosure)> scheduler) {}

// static
scoped_refptr<content::DevToolsAgentHost>
DevToolsDeviceDiscovery::CreateBrowserAgentHost(
    scoped_refptr<AndroidDeviceManager::Device> device,
    scoped_refptr<RemoteBrowser> browser) {}

void DevToolsDeviceDiscovery::RequestDeviceList() {}

void DevToolsDeviceDiscovery::ReceivedDeviceList(
    const CompleteDevices& complete_devices) {}