#include "chrome/browser/devtools/device/devtools_android_bridge.h"
#include <stddef.h>
#include <map>
#include <memory>
#include <set>
#include <utility>
#include <vector>
#include "base/base64.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/lazy_instance.h"
#include "base/memory/singleton.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.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/threading/thread.h"
#include "base/values.h"
#include "chrome/browser/devtools/device/adb/adb_device_provider.h"
#include "chrome/browser/devtools/device/port_forwarding_controller.h"
#include "chrome/browser/devtools/device/tcp_device_provider.h"
#include "chrome/browser/devtools/device/usb/usb_device_provider.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/devtools/remote_debugging_server.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.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"
#include "net/base/host_port_pair.h"
#include "net/base/net_errors.h"
#if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
#include "chrome/browser/devtools/device/cast_device_provider.h"
#endif
BrowserThread;
DevToolsAgentHost;
namespace {
const char kNewPageRequestWithURL[] = …;
const char kChromeDiscoveryURL[] = …;
const char kNodeDiscoveryURL[] = …;
bool BrowserIdFromString(const std::string& browser_id_str,
std::string* serial,
std::string* browser_id) { … }
}
DevToolsAndroidBridge::Factory* DevToolsAndroidBridge::Factory::GetInstance() { … }
DevToolsAndroidBridge* DevToolsAndroidBridge::Factory::GetForProfile(
Profile* profile) { … }
DevToolsAndroidBridge::Factory::Factory()
: … { … }
DevToolsAndroidBridge::Factory::~Factory() { … }
KeyedService* DevToolsAndroidBridge::Factory::BuildServiceInstanceFor(
content::BrowserContext* context) const { … }
void DevToolsAndroidBridge::Shutdown() { … }
scoped_refptr<content::DevToolsAgentHost>
DevToolsAndroidBridge::GetBrowserAgentHost(
scoped_refptr<RemoteBrowser> browser) { … }
void DevToolsAndroidBridge::SendJsonRequest(const std::string& browser_id_str,
const std::string& url,
JsonRequestCallback callback) { … }
void DevToolsAndroidBridge::OpenRemotePage(scoped_refptr<RemoteBrowser> browser,
const std::string& input_url) { … }
DevToolsAndroidBridge::DevToolsAndroidBridge(Profile* profile)
: … { … }
void DevToolsAndroidBridge::AddDeviceListListener(
DeviceListListener* listener) { … }
void DevToolsAndroidBridge::RemoveDeviceListListener(
DeviceListListener* listener) { … }
void DevToolsAndroidBridge::AddDeviceCountListener(
DeviceCountListener* listener) { … }
void DevToolsAndroidBridge::RemoveDeviceCountListener(
DeviceCountListener* listener) { … }
void DevToolsAndroidBridge::AddPortForwardingListener(
PortForwardingListener* listener) { … }
void DevToolsAndroidBridge::RemovePortForwardingListener(
PortForwardingListener* listener) { … }
DevToolsAndroidBridge::~DevToolsAndroidBridge() { … }
void DevToolsAndroidBridge::StartDeviceListPolling() { … }
void DevToolsAndroidBridge::StopDeviceListPolling() { … }
bool DevToolsAndroidBridge::NeedsDeviceListPolling() { … }
void DevToolsAndroidBridge::ReceivedDeviceList(
const CompleteDevices& complete_devices) { … }
void DevToolsAndroidBridge::StartDeviceCountPolling() { … }
void DevToolsAndroidBridge::StopDeviceCountPolling() { … }
void DevToolsAndroidBridge::RequestDeviceCount(
base::RepeatingCallback<void(int)> callback) { … }
void DevToolsAndroidBridge::ReceivedDeviceCount(int count) { … }
static std::set<net::HostPortPair> ParseTargetDiscoveryPreferenceValue(
const base::Value::List* preferenceValue) { … }
static scoped_refptr<TCPDeviceProvider> CreateTCPDeviceProvider(
const base::Value::List* targetDiscoveryConfig) { … }
void DevToolsAndroidBridge::CreateDeviceProviders() { … }
void DevToolsAndroidBridge::set_tcp_provider_callback_for_test(
TCPProviderCallback callback) { … }
void DevToolsAndroidBridge::set_usb_device_manager_for_test(
mojo::PendingRemote<device::mojom::UsbDeviceManager> fake_usb_manager) { … }