#include "chrome/browser/extensions/chrome_content_browser_client_extensions_part.h"
#include <stddef.h>
#include <algorithm>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/auto_reset.h"
#include "base/check_deref.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_selections.h"
#include "chrome/browser/sync_file_system/local/sync_file_system_backend.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/url_constants.h"
#include "components/dom_distiller/core/url_constants.h"
#include "components/download/public/common/quarantine_connection.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browser_url_handler.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/vpn_service_proxy.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "extensions/browser/api/web_request/web_request_api.h"
#include "extensions/browser/api/web_request/web_request_api_helpers.h"
#include "extensions/browser/bad_message.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_map.h"
#include "extensions/browser/renderer_startup_helper.h"
#include "extensions/browser/service_worker/service_worker_task_queue.h"
#include "extensions/browser/url_loader_factory_manager.h"
#include "extensions/browser/url_request_util.h"
#include "extensions/browser/view_type_utils.h"
#include "extensions/common/api/sockets/sockets_manifest_data.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/background_info.h"
#include "extensions/common/manifest_handlers/mime_types_handler.h"
#include "extensions/common/manifest_handlers/sandboxed_page_info.h"
#include "extensions/common/mojom/manifest.mojom-shared.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/switches.h"
#include "pdf/buildflags.h"
#include "third_party/blink/public/common/features_generated.h"
#include "url/origin.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/component_loader.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_web_ui.h"
#include "chrome/browser/extensions/extension_webkit_preferences.h"
#include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h"
#endif
#if BUILDFLAG(ENABLE_GUEST_VIEW)
#include "components/guest_view/common/guest_view.mojom.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
#endif
#if BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/chromeos/extensions/vpn_provider/vpn_service_factory.h"
#include "chromeos/constants/chromeos_features.h"
#endif
#if BUILDFLAG(ENABLE_PDF)
#include "pdf/pdf_features.h"
#endif
WebPreferences;
BrowserContext;
BrowserThread;
BrowserURLHandler;
RenderViewHost;
SiteInstance;
WebContents;
namespace extensions {
namespace {
const GURL* g_allow_service_worker_unregistration_scope = …;
const Extension* GetEnabledExtensionFromSiteURL(BrowserContext* context,
const GURL& site_url) { … }
bool HasEffectiveUrl(content::BrowserContext* browser_context,
const GURL& url) { … }
bool AllowServiceWorker(const GURL& scope,
const GURL& script_url,
const Extension* extension) { … }
const Extension* GetServiceWorkerBasedExtensionForScope(
const GURL& scope,
BrowserContext* browser_context) { … }
size_t GetExtensionBackgroundProcessCount() { … }
}
ChromeContentBrowserClientExtensionsPart::
ChromeContentBrowserClientExtensionsPart() = default;
ChromeContentBrowserClientExtensionsPart::
~ChromeContentBrowserClientExtensionsPart() = default;
GURL ChromeContentBrowserClientExtensionsPart::GetEffectiveURL(
Profile* profile,
const GURL& url) { … }
bool ChromeContentBrowserClientExtensionsPart::
ShouldCompareEffectiveURLsForSiteInstanceSelection(
content::BrowserContext* browser_context,
content::SiteInstance* candidate_site_instance,
bool is_outermost_main_frame,
const GURL& candidate_url,
const GURL& destination_url) { … }
bool ChromeContentBrowserClientExtensionsPart::ShouldUseProcessPerSite(
Profile* profile,
const GURL& site_url) { … }
bool ChromeContentBrowserClientExtensionsPart::ShouldUseSpareRenderProcessHost(
Profile* profile,
const GURL& site_url) { … }
bool ChromeContentBrowserClientExtensionsPart::DoesSiteRequireDedicatedProcess(
content::BrowserContext* browser_context,
const GURL& effective_site_url) { … }
bool ChromeContentBrowserClientExtensionsPart::
ShouldAllowCrossProcessSandboxedFrameForPrecursor(
content::BrowserContext* browser_context,
const GURL& precursor,
const GURL& url) { … }
bool ChromeContentBrowserClientExtensionsPart::CanCommitURL(
content::RenderProcessHost* process_host,
const GURL& url) { … }
bool ChromeContentBrowserClientExtensionsPart::IsSuitableHost(
Profile* profile,
content::RenderProcessHost* process_host,
const GURL& site_url) { … }
size_t
ChromeContentBrowserClientExtensionsPart::GetProcessCountToIgnoreForLimit() { … }
bool ChromeContentBrowserClientExtensionsPart::
ShouldEmbeddedFramesTryToReuseExistingProcess(
content::RenderFrameHost* outermost_main_frame) { … }
bool ChromeContentBrowserClientExtensionsPart::
ShouldSwapBrowsingInstancesForNavigation(
SiteInstance* site_instance,
const GURL& current_effective_url,
const GURL& destination_effective_url) { … }
bool ChromeContentBrowserClientExtensionsPart::AllowServiceWorker(
const GURL& scope,
const GURL& first_party_url,
const GURL& script_url,
content::BrowserContext* context) { … }
bool ChromeContentBrowserClientExtensionsPart::
MayDeleteServiceWorkerRegistration(
const GURL& scope,
content::BrowserContext* browser_context) { … }
bool ChromeContentBrowserClientExtensionsPart::
ShouldTryToUpdateServiceWorkerRegistration(
const GURL& scope,
content::BrowserContext* browser_context) { … }
std::vector<url::Origin> ChromeContentBrowserClientExtensionsPart::
GetOriginsRequiringDedicatedProcess() { … }
std::unique_ptr<content::VpnServiceProxy>
ChromeContentBrowserClientExtensionsPart::GetVpnServiceProxy(
content::BrowserContext* browser_context) { … }
void ChromeContentBrowserClientExtensionsPart::OverrideURLLoaderFactoryParams(
content::BrowserContext* browser_context,
const url::Origin& origin,
bool is_for_isolated_world,
network::mojom::URLLoaderFactoryParams* factory_params) { … }
bool ChromeContentBrowserClientExtensionsPart::IsBuiltinComponent(
content::BrowserContext* browser_context,
const url::Origin& origin) { … }
bool ChromeContentBrowserClientExtensionsPart::AreExtensionsDisabledForProfile(
content::BrowserContext* browser_context) { … }
base::AutoReset<const GURL*> ChromeContentBrowserClientExtensionsPart::
AllowServiceWorkerUnregistrationForScopeForTesting(const GURL* scope) { … }
void ChromeContentBrowserClientExtensionsPart::SiteInstanceGotProcessAndSite(
SiteInstance* site_instance) { … }
bool ChromeContentBrowserClientExtensionsPart::
OverrideWebPreferencesAfterNavigation(WebContents* web_contents,
WebPreferences* web_prefs) { … }
void ChromeContentBrowserClientExtensionsPart::OverrideWebkitPrefs(
WebContents* web_contents,
WebPreferences* web_prefs) { … }
void ChromeContentBrowserClientExtensionsPart::BrowserURLHandlerCreated(
BrowserURLHandler* handler) { … }
void ChromeContentBrowserClientExtensionsPart::
GetAdditionalAllowedSchemesForFileSystem(
std::vector<std::string>* additional_allowed_schemes) { … }
void ChromeContentBrowserClientExtensionsPart::GetURLRequestAutoMountHandlers(
std::vector<storage::URLRequestAutoMountHandler>* handlers) { … }
void ChromeContentBrowserClientExtensionsPart::GetAdditionalFileSystemBackends(
content::BrowserContext* browser_context,
const base::FilePath& storage_partition_path,
download::QuarantineConnectionCallback quarantine_connection_callback,
std::vector<std::unique_ptr<storage::FileSystemBackend>>*
additional_backends) { … }
void ChromeContentBrowserClientExtensionsPart::
AppendExtraRendererCommandLineSwitches(
base::CommandLine* command_line,
content::RenderProcessHost& process) { … }
}