chromium/content/browser/site_instance_impl.cc

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

#include "content/browser/site_instance_impl.h"

#include <string>
#include <tuple>

#include "base/containers/contains.h"
#include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h"
#include "base/lazy_instance.h"
#include "base/trace_event/typed_macros.h"
#include "content/browser/bad_message.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/isolated_origin_util.h"
#include "content/browser/isolation_context.h"
#include "content/browser/process_lock.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/site_instance_group.h"
#include "content/browser/storage_partition_impl.h"
#include "content/common/features.h"
#include "content/public/browser/browser_or_resource_context.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/site_isolation_policy.h"
#include "content/public/browser/web_ui_controller_factory.h"
#include "content/public/common/content_client.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/url_utils.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "third_party/blink/public/common/chrome_debug_urls.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"
#include "url/origin.h"

namespace content {

namespace {

// Constant used to mark two call sites that must always agree on whether
// the default SiteInstance is allowed.
constexpr bool kCreateForURLAllowsDefaultSiteInstance =;

// Asks the embedder whether effective URLs should be used when determining if
// |dest_url| should end up in |site_instance|.
// This is used to keep same-site scripting working for hosted apps.
bool ShouldCompareEffectiveURLs(BrowserContext* browser_context,
                                SiteInstanceImpl* site_instance,
                                bool for_outermost_main_frame,
                                const GURL& dest_url) {}

SiteInstanceId::Generator g_site_instance_id_generator;

}  // namespace

// static
const GURL& SiteInstanceImpl::GetDefaultSiteURL() {}

class SiteInstanceImpl::DefaultSiteInstanceState {};

SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance)
    :{}

SiteInstanceImpl::~SiteInstanceImpl() {}

// static
scoped_refptr<SiteInstanceImpl> SiteInstanceImpl::Create(
    BrowserContext* browser_context) {}

// static
scoped_refptr<SiteInstanceImpl> SiteInstanceImpl::CreateForUrlInfo(
    BrowserContext* browser_context,
    const UrlInfo& url_info,
    bool is_guest,
    bool is_fenced,
    bool is_fixed_storage_partition) {}

// static
scoped_refptr<SiteInstanceImpl> SiteInstanceImpl::CreateForServiceWorker(
    BrowserContext* browser_context,
    const UrlInfo& url_info,
    bool can_reuse_process,
    bool is_guest,
    bool is_fenced) {}

// static
scoped_refptr<SiteInstanceImpl> SiteInstanceImpl::CreateForGuest(
    BrowserContext* browser_context,
    const StoragePartitionConfig& partition_config) {}

// static
scoped_refptr<SiteInstanceImpl>
SiteInstanceImpl::CreateForFixedStoragePartition(
    BrowserContext* browser_context,
    const GURL& url,
    const StoragePartitionConfig& partition_config) {}

// static
scoped_refptr<SiteInstanceImpl> SiteInstanceImpl::CreateForFencedFrame(
    SiteInstanceImpl* embedder_site_instance) {}

// static
scoped_refptr<SiteInstanceImpl>
SiteInstanceImpl::CreateReusableInstanceForTesting(
    BrowserContext* browser_context,
    const GURL& url) {}

// static
scoped_refptr<SiteInstanceImpl> SiteInstanceImpl::CreateForTesting(
    BrowserContext* browser_context,
    const GURL& url) {}

// static
bool SiteInstanceImpl::ShouldAssignSiteForUrlInfo(const UrlInfo& url_info) {}

SiteInstanceId SiteInstanceImpl::GetId() {}

BrowsingInstanceId SiteInstanceImpl::GetBrowsingInstanceId() {}

const IsolationContext& SiteInstanceImpl::GetIsolationContext() {}

RenderProcessHost* SiteInstanceImpl::GetSiteInstanceGroupProcessIfAvailable() {}

bool SiteInstanceImpl::IsDefaultSiteInstance() const {}

void SiteInstanceImpl::AddSiteInfoToDefault(const SiteInfo& site_info) {}

bool SiteInstanceImpl::IsSiteInDefaultSiteInstance(const GURL& site_url) const {}

// static
BrowsingInstanceId SiteInstanceImpl::NextBrowsingInstanceId() {}

bool SiteInstanceImpl::HasProcess() {}

RenderProcessHost* SiteInstanceImpl::GetProcess() {}

SiteInstanceGroupId SiteInstanceImpl::GetSiteInstanceGroupId() {}

bool SiteInstanceImpl::ShouldUseProcessPerSite() const {}

void SiteInstanceImpl::ReuseExistingProcessIfPossible(
    RenderProcessHost* existing_process) {}

void SiteInstanceImpl::SetProcessInternal(RenderProcessHost* process) {}

bool SiteInstanceImpl::CanAssociateWithSpareProcess() {}

void SiteInstanceImpl::PreventAssociationWithSpareProcess() {}

void SiteInstanceImpl::SetSite(const UrlInfo& url_info) {}

void SiteInstanceImpl::SetSite(const SiteInfo& site_info) {}

void SiteInstanceImpl::SetSiteInfoToDefault(
    const StoragePartitionConfig& storage_partition_config) {}

void SiteInstanceImpl::SetSiteInfoInternal(const SiteInfo& site_info) {}

void SiteInstanceImpl::ConvertToDefaultOrSetSite(const UrlInfo& url_info) {}

SiteInstanceProcessAssignment
SiteInstanceImpl::GetLastProcessAssignmentOutcome() {}

const GURL& SiteInstanceImpl::GetSiteURL() {}

const SiteInfo& SiteInstanceImpl::GetSiteInfo() {}

SiteInfo SiteInstanceImpl::DeriveSiteInfo(
    const UrlInfo& url_info,
    bool is_related,
    bool disregard_web_exposed_isolation_info) {}

bool SiteInstanceImpl::HasSite() const {}

bool SiteInstanceImpl::HasRelatedSiteInstance(const SiteInfo& site_info) {}

scoped_refptr<SiteInstance> SiteInstanceImpl::GetRelatedSiteInstance(
    const GURL& url) {}

scoped_refptr<SiteInstanceImpl> SiteInstanceImpl::GetRelatedSiteInstanceImpl(
    const UrlInfo& url_info) {}

scoped_refptr<SiteInstanceImpl>
SiteInstanceImpl::GetCoopRelatedSiteInstanceImpl(const UrlInfo& url_info) {}

AgentSchedulingGroupHost& SiteInstanceImpl::GetOrCreateAgentSchedulingGroup() {}

void SiteInstanceImpl::ResetSiteInstanceGroup() {}

bool SiteInstanceImpl::IsRelatedSiteInstance(const SiteInstance* instance) {}

size_t SiteInstanceImpl::GetRelatedActiveContentsCount() {}

namespace {

bool SandboxConfigurationsMatch(const SiteInfo& site_info,
                                const UrlInfo& url_info) {}

}  // namespace

bool SiteInstanceImpl::IsSuitableForUrlInfo(const UrlInfo& url_info) {}

bool SiteInstanceImpl::RequiresDedicatedProcess() {}

bool SiteInstanceImpl::RequiresOriginKeyedProcess() {}

bool SiteInstanceImpl::IsSandboxed() {}

void SiteInstanceImpl::IncrementRelatedActiveContentsCount() {}

void SiteInstanceImpl::DecrementRelatedActiveContentsCount() {}

BrowserContext* SiteInstanceImpl::GetBrowserContext() {}

// static
scoped_refptr<SiteInstance> SiteInstance::Create(
    BrowserContext* browser_context) {}

// static
scoped_refptr<SiteInstance> SiteInstance::CreateForURL(
    BrowserContext* browser_context,
    const GURL& url) {}

// static
scoped_refptr<SiteInstanceImpl> SiteInstanceImpl::CreateForURL(
    BrowserContext* browser_context,
    const GURL& url) {}

// static
scoped_refptr<SiteInstance> SiteInstance::CreateForGuest(
    BrowserContext* browser_context,
    const StoragePartitionConfig& partition_config) {}

// static
scoped_refptr<SiteInstance> SiteInstance::CreateForFixedStoragePartition(
    BrowserContext* browser_context,
    const GURL& url,
    const StoragePartitionConfig& partition_config) {}

// static
bool SiteInstance::ShouldAssignSiteForURL(const GURL& url) {}

bool SiteInstanceImpl::IsSameSiteWithURL(const GURL& url) {}

bool SiteInstanceImpl::IsSameSiteWithURLInfo(const UrlInfo& url_info) {}

bool SiteInstanceImpl::IsGuest() {}

bool SiteInstanceImpl::IsFixedStoragePartition() {}

bool SiteInstanceImpl::IsJitDisabled() {}

bool SiteInstanceImpl::AreV8OptimizationsDisabled() {}

bool SiteInstanceImpl::IsPdf() {}

const StoragePartitionConfig& SiteInstanceImpl::GetStoragePartitionConfig() {}

std::string SiteInstanceImpl::GetPartitionDomain(
    StoragePartitionImpl* storage_partition) {}

bool SiteInstanceImpl::IsOriginalUrlSameSite(
    const UrlInfo& dest_url_info,
    bool should_compare_effective_urls) {}

bool SiteInstanceImpl::IsNavigationSameSite(
    const GURL& last_successful_url,
    const url::Origin& last_committed_origin,
    bool for_outermost_main_frame,
    const UrlInfo& dest_url_info) {}

bool SiteInstanceImpl::IsNavigationAllowedToStayInSameProcessDueToEffectiveURLs(
    BrowserContext* browser_context,
    bool for_outermost_main_frame,
    const GURL& dest_url) {}

// static
bool SiteInstanceImpl::IsSameSite(const IsolationContext& isolation_context,
                                  const UrlInfo& real_src_url_info,
                                  const UrlInfo& real_dest_url_info,
                                  bool should_compare_effective_urls) {}

bool SiteInstanceImpl::DoesSiteInfoForURLMatch(const UrlInfo& url_info) {}

void SiteInstanceImpl::RegisterAsDefaultOriginIsolation(
    const url::Origin& previously_visited_origin) {}

// static
bool SiteInstanceImpl::CanBePlacedInDefaultSiteInstance(
    const IsolationContext& isolation_context,
    const GURL& url,
    const SiteInfo& site_info) {}

// static
GURL SiteInstanceImpl::GetEffectiveURL(BrowserContext* browser_context,
                                       const GURL& url) {}

// static
bool SiteInstanceImpl::HasEffectiveURL(BrowserContext* browser_context,
                                       const GURL& url) {}

void SiteInstanceImpl::LockProcessIfNeeded() {}

const WebExposedIsolationInfo& SiteInstanceImpl::GetWebExposedIsolationInfo()
    const {}

bool SiteInstanceImpl::IsCrossOriginIsolated() const {}

const std::optional<url::Origin>& SiteInstanceImpl::GetCommonCoopOrigin()
    const {}

// static
void SiteInstance::StartIsolatingSite(
    BrowserContext* context,
    const GURL& url,
    ChildProcessSecurityPolicy::IsolatedOriginSource source,
    bool should_persist) {}

void SiteInstanceImpl::WriteIntoTrace(
    perfetto::TracedProto<perfetto::protos::pbzero::SiteInstance> proto) {}

int SiteInstanceImpl::EstimateOriginAgentClusterOverheadForMetrics() {}

scoped_refptr<SiteInstanceImpl>
SiteInstanceImpl::GetCompatibleSandboxedSiteInstance(
    const UrlInfo& url_info,
    const url::Origin& parent_origin) {}

RenderProcessHost* SiteInstanceImpl::GetDefaultProcessForBrowsingInstance() {}

bool SiteInstanceImpl::IsCoopRelatedSiteInstance(
    const SiteInstanceImpl* instance) const {}

void SiteInstanceImpl::SetProcessForTesting(RenderProcessHost* process) {}

void SiteInstanceImpl::IncrementActiveDocumentCount(
    const SiteInfo& url_derived_site_info) {}

void SiteInstanceImpl::DecrementActiveDocumentCount(
    const SiteInfo& url_derived_site_info) {}

size_t SiteInstanceImpl::GetActiveDocumentCount(
    const SiteInfo& url_derived_site_info) {}

}  // namespace content