#include "chrome/browser/devtools/devtools_targets_ui.h"
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/timer/timer.h"
#include "base/values.h"
#include "base/version.h"
#include "chrome/browser/devtools/device/devtools_android_bridge.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/devtools/serialize_host_descriptions.h"
#include "chrome/browser/profiles/profile.h"
#include "components/media_router/browser/presentation/local_presentation_manager.h"
#include "components/media_router/browser/presentation/local_presentation_manager_factory.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/devtools_agent_host_observer.h"
BrowserThread;
DevToolsAgentHost;
namespace {
const char kTargetSourceField[] = …;
const char kTargetSourceLocal[] = …;
const char kTargetSourceRemote[] = …;
const char kTargetIdField[] = …;
const char kTargetTypeField[] = …;
const char kAttachedField[] = …;
const char kUrlField[] = …;
const char kNameField[] = …;
const char kFaviconUrlField[] = …;
const char kDescriptionField[] = …;
const char kGuestList[] = …;
const char kAdbModelField[] = …;
const char kAdbConnectedField[] = …;
const char kAdbSerialField[] = …;
const char kAdbBrowsersList[] = …;
const char kAdbDeviceIdFormat[] = …;
const char kAdbBrowserNameField[] = …;
const char kAdbBrowserUserField[] = …;
const char kAdbBrowserVersionField[] = …;
const char kAdbBrowserChromeVersionField[] = …;
const char kAdbPagesList[] = …;
const char kAdbScreenWidthField[] = …;
const char kAdbScreenHeightField[] = …;
const char kPortForwardingPorts[] = …;
const char kPortForwardingBrowserId[] = …;
class LocalTargetsUIHandler : public DevToolsTargetsUIHandler,
public content::DevToolsAgentHostObserver { … };
LocalTargetsUIHandler::LocalTargetsUIHandler(const Callback& callback,
Profile* profile)
: … { … }
LocalTargetsUIHandler::~LocalTargetsUIHandler() { … }
bool LocalTargetsUIHandler::ShouldForceDevToolsAgentHostCreation() { … }
void LocalTargetsUIHandler::DevToolsAgentHostCreated(DevToolsAgentHost*) { … }
void LocalTargetsUIHandler::DevToolsAgentHostDestroyed(DevToolsAgentHost*) { … }
void LocalTargetsUIHandler::ForceUpdate() { … }
void LocalTargetsUIHandler::ScheduleUpdate() { … }
void LocalTargetsUIHandler::UpdateTargets() { … }
bool LocalTargetsUIHandler::AllowDevToolsFor(DevToolsAgentHost* host) { … }
class AdbTargetsUIHandler
: public DevToolsTargetsUIHandler,
public DevToolsAndroidBridge::DeviceListListener { … };
AdbTargetsUIHandler::AdbTargetsUIHandler(const Callback& callback,
Profile* profile)
: … { … }
AdbTargetsUIHandler::~AdbTargetsUIHandler() { … }
void AdbTargetsUIHandler::Open(const std::string& browser_id,
const std::string& url) { … }
scoped_refptr<DevToolsAgentHost>
AdbTargetsUIHandler::GetBrowserAgentHost(
const std::string& browser_id) { … }
void AdbTargetsUIHandler::DeviceListChanged(
const DevToolsAndroidBridge::RemoteDevices& devices) { … }
}
DevToolsTargetsUIHandler::DevToolsTargetsUIHandler(const std::string& source_id,
Callback callback)
: … { … }
DevToolsTargetsUIHandler::~DevToolsTargetsUIHandler() = default;
std::unique_ptr<DevToolsTargetsUIHandler>
DevToolsTargetsUIHandler::CreateForLocal(
DevToolsTargetsUIHandler::Callback callback,
Profile* profile) { … }
std::unique_ptr<DevToolsTargetsUIHandler>
DevToolsTargetsUIHandler::CreateForAdb(
DevToolsTargetsUIHandler::Callback callback,
Profile* profile) { … }
scoped_refptr<DevToolsAgentHost> DevToolsTargetsUIHandler::GetTarget(
const std::string& target_id) { … }
void DevToolsTargetsUIHandler::Open(const std::string& browser_id,
const std::string& url) { … }
scoped_refptr<DevToolsAgentHost>
DevToolsTargetsUIHandler::GetBrowserAgentHost(const std::string& browser_id) { … }
base::Value::Dict DevToolsTargetsUIHandler::Serialize(DevToolsAgentHost* host) { … }
void DevToolsTargetsUIHandler::SendSerializedTargets(const base::Value& list) { … }
void DevToolsTargetsUIHandler::ForceUpdate() { … }
PortForwardingStatusSerializer::PortForwardingStatusSerializer(
const Callback& callback, Profile* profile)
: … { … }
PortForwardingStatusSerializer::~PortForwardingStatusSerializer() { … }
void PortForwardingStatusSerializer::PortStatusChanged(
const ForwardingStatus& status) { … }