#include "chrome/browser/devtools/chrome_devtools_manager_delegate.h"
#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/not_fatal_until.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_features.h"
#include "chrome/browser/devtools/chrome_devtools_session.h"
#include "chrome/browser/devtools/device/android_device_manager.h"
#include "chrome/browser/devtools/device/tcp_device_provider.h"
#include "chrome/browser/devtools/devtools_browser_context_manager.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/devtools/protocol/target_handler.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/policy/developer_tools_policy_handler.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/keep_alive/profile_keep_alive_types.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/browser/web_applications/web_app_tab_helper.h"
#include "chrome/browser/web_applications/web_app_utils.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/browser_resources.h"
#include "components/guest_view/browser/guest_view_base.h"
#include "components/keep_alive_registry/keep_alive_types.h"
#include "components/keep_alive_registry/scoped_keep_alive.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/devtools_agent_host_client_channel.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/view_type_utils.h"
#include "extensions/common/manifest.h"
#include "extensions/common/mojom/view_type.mojom.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/switches.h"
#include "ui/views/controls/webview/webview.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/constants/pref_names.h"
#include "components/prefs/pref_service.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/constants/ash_switches.h"
#endif
DevToolsAgentHost;
const char ChromeDevToolsManagerDelegate::kTypeApp[] = …;
const char ChromeDevToolsManagerDelegate::kTypeBackgroundPage[] = …;
const char ChromeDevToolsManagerDelegate::kTypePage[] = …;
namespace {
std::optional<std::string> GetIsolatedWebAppName(
content::WebContents* web_contents) { … }
bool GetExtensionInfo(content::WebContents* wc,
std::string* name,
std::string* type) { … }
policy::DeveloperToolsPolicyHandler::Availability GetDevToolsAvailability(
Profile* profile) { … }
ChromeDevToolsManagerDelegate* g_instance;
}
ChromeDevToolsManagerDelegate* ChromeDevToolsManagerDelegate::GetInstance() { … }
ChromeDevToolsManagerDelegate::ChromeDevToolsManagerDelegate() { … }
ChromeDevToolsManagerDelegate::~ChromeDevToolsManagerDelegate() { … }
void ChromeDevToolsManagerDelegate::Inspect(
content::DevToolsAgentHost* agent_host) { … }
void ChromeDevToolsManagerDelegate::Activate(
content::DevToolsAgentHost* agent_host) { … }
void ChromeDevToolsManagerDelegate::HandleCommand(
content::DevToolsAgentHostClientChannel* channel,
base::span<const uint8_t> message,
NotHandledCallback callback) { … }
std::string ChromeDevToolsManagerDelegate::GetTargetType(
content::WebContents* web_contents) { … }
std::string ChromeDevToolsManagerDelegate::GetTargetTitle(
content::WebContents* web_contents) { … }
bool ChromeDevToolsManagerDelegate::AllowInspectingRenderFrameHost(
content::RenderFrameHost* rfh) { … }
bool ChromeDevToolsManagerDelegate::AllowInspection(
Profile* profile,
content::WebContents* web_contents) { … }
bool ChromeDevToolsManagerDelegate::AllowInspection(
Profile* profile,
const extensions::Extension* extension) { … }
bool ChromeDevToolsManagerDelegate::AllowInspection(
Profile* profile,
const web_app::WebApp* web_app) { … }
void ChromeDevToolsManagerDelegate::ClientAttached(
content::DevToolsAgentHostClientChannel* channel) { … }
void ChromeDevToolsManagerDelegate::ClientDetached(
content::DevToolsAgentHostClientChannel* channel) { … }
scoped_refptr<DevToolsAgentHost> ChromeDevToolsManagerDelegate::CreateNewTarget(
const GURL& url,
DevToolsManagerDelegate::TargetType target_type) { … }
std::vector<content::BrowserContext*>
ChromeDevToolsManagerDelegate::GetBrowserContexts() { … }
content::BrowserContext*
ChromeDevToolsManagerDelegate::GetDefaultBrowserContext() { … }
content::BrowserContext* ChromeDevToolsManagerDelegate::CreateBrowserContext() { … }
void ChromeDevToolsManagerDelegate::DisposeBrowserContext(
content::BrowserContext* context,
DisposeCallback callback) { … }
bool ChromeDevToolsManagerDelegate::HasBundledFrontendResources() { … }
void ChromeDevToolsManagerDelegate::DevicesAvailable(
const DevToolsDeviceDiscovery::CompleteDevices& devices) { … }
void ChromeDevToolsManagerDelegate::UpdateDeviceDiscovery() { … }
void ChromeDevToolsManagerDelegate::ResetAndroidDeviceManagerForTesting() { … }
void ChromeDevToolsManagerDelegate::CloseBrowserSoon() { … }
void ChromeDevToolsManagerDelegate::AllowBrowserToClose() { … }