chromium/third_party/blink/renderer/core/execution_context/execution_context.cc

/*
 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
 * Copyright (C) 2012 Google Inc. All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

#include "third_party/blink/renderer/core/execution_context/execution_context.h"

#include "base/metrics/histogram_functions.h"
#include "base/tracing/protos/chrome_track_event.pbzero.h"
#include "build/build_config.h"
#include "third_party/blink/public/common/permissions_policy/document_policy_features.h"
#include "third_party/blink/public/mojom/devtools/inspector_issue.mojom-blink-forward.h"
#include "third_party/blink/public/mojom/frame/lifecycle.mojom-blink.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom-blink.h"
#include "third_party/blink/public/mojom/permissions_policy/policy_disposition.mojom-blink.h"
#include "third_party/blink/public/mojom/permissions_policy/policy_value.mojom-blink.h"
#include "third_party/blink/public/mojom/v8_cache_options.mojom-blink.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/core/dom/events/event_target.h"
#include "third_party/blink/renderer/core/events/error_event.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_state_observer.h"
#include "third_party/blink/renderer/core/fileapi/public_url_manager.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/csp/execution_context_csp_delegate.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/inspector/inspector_audits_issue.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/origin_trials/origin_trial_context.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/core/workers/worklet_global_scope.h"
#include "third_party/blink/renderer/platform/bindings/dom_wrapper_world.h"
#include "third_party/blink/renderer/platform/bindings/source_location.h"
#include "third_party/blink/renderer/platform/context_lifecycle_notifier.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/loader/fetch/code_cache_host.h"
#include "third_party/blink/renderer/platform/loader/fetch/memory_cache.h"
#include "third_party/blink/renderer/platform/runtime_feature_state/runtime_feature_state_override_context.h"
#include "third_party/blink/renderer/platform/scheduler/public/event_loop.h"
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h"
#include "third_party/blink/renderer/platform/weborigin/security_policy.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_proto.h"

namespace blink {

ExecutionContext::ExecutionContext(v8::Isolate* isolate,
                                   Agent* agent,
                                   bool is_window)
    :{}

ExecutionContext::~ExecutionContext() = default;

// static
ExecutionContext* ExecutionContext::From(const ScriptState* script_state) {}

// static
ExecutionContext* ExecutionContext::From(v8::Local<v8::Context> context) {}

// static
CodeCacheHost* ExecutionContext::GetCodeCacheHostFromContext(
    ExecutionContext* execution_context) {}

void ExecutionContext::SetIsInBackForwardCache(bool value) {}

void ExecutionContext::SetLifecycleState(mojom::FrameLifecycleState state) {}

void ExecutionContext::NotifyContextDestroyed() {}

void ExecutionContext::CountDeprecation(WebFeature feature) {}

HeapObserverSet<ContextLifecycleObserver>&
ExecutionContext::ContextLifecycleObserverSet() {}

unsigned ExecutionContext::ContextLifecycleStateObserverCountForTesting()
    const {}

bool ExecutionContext::SharedArrayBufferTransferAllowed() const {}

bool ExecutionContext::CheckSharedArrayBufferTransferAllowedAndReport() {}

void ExecutionContext::FileSharedArrayBufferCreationIssue() {}

void ExecutionContext::AddConsoleMessageImpl(
    mojom::blink::ConsoleMessageSource source,
    mojom::blink::ConsoleMessageLevel level,
    const String& message,
    bool discard_duplicates,
    std::optional<mojom::ConsoleMessageCategory> category) {}

void ExecutionContext::DispatchErrorEvent(
    ErrorEvent* error_event,
    SanitizeScriptErrors sanitize_script_errors) {}

bool ExecutionContext::DispatchErrorEventInternal(
    ErrorEvent* error_event,
    SanitizeScriptErrors sanitize_script_errors) {}

// TODO(crbug.com/1406134): Review each usage and see if replacing with
// IsContextFrozenOrPaused() makes sense.
bool ExecutionContext::IsContextPaused() const {}

LoaderFreezeMode ExecutionContext::GetLoaderFreezeMode() const {}

bool ExecutionContext::IsContextFrozenOrPaused() const {}

int ExecutionContext::CircularSequentialID() {}

PublicURLManager& ExecutionContext::GetPublicURLManager() {}

ContentSecurityPolicyDelegate&
ExecutionContext::GetContentSecurityPolicyDelegate() {}

const DOMWrapperWorld* ExecutionContext::GetCurrentWorld() const {}

ContentSecurityPolicy*
ExecutionContext::GetContentSecurityPolicyForCurrentWorld() {}

ContentSecurityPolicy* ExecutionContext::GetContentSecurityPolicyForWorld(
    const DOMWrapperWorld* world) {}

const SecurityOrigin* ExecutionContext::GetSecurityOrigin() const {}

SecurityOrigin* ExecutionContext::GetMutableSecurityOrigin() {}

ContentSecurityPolicy* ExecutionContext::GetContentSecurityPolicy() const {}

void ExecutionContext::SetContentSecurityPolicy(
    ContentSecurityPolicy* content_security_policy) {}

void ExecutionContext::SetRequireTrustedTypes() {}

void ExecutionContext::SetRequireTrustedTypesForTesting() {}

network::mojom::blink::WebSandboxFlags ExecutionContext::GetSandboxFlags()
    const {}

bool ExecutionContext::IsSandboxed(
    network::mojom::blink::WebSandboxFlags mask) const {}

const base::UnguessableToken& ExecutionContext::GetAgentClusterID() const {}

void ExecutionContext::AllowWindowInteraction() {}

void ExecutionContext::ConsumeWindowInteraction() {}

bool ExecutionContext::IsWindowInteractionAllowed() const {}

bool ExecutionContext::IsSecureContext(String& error_message) const {}

// https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer
String ExecutionContext::OutgoingReferrer() const {}

void ExecutionContext::ParseAndSetReferrerPolicy(
    const String& policy,
    const ReferrerPolicySource source) {}

network::mojom::ReferrerPolicy ExecutionContext::GetReferrerPolicy() const {}

void ExecutionContext::SetReferrerPolicy(
    network::mojom::ReferrerPolicy referrer_policy) {}

void ExecutionContext::SetPolicyContainer(
    std::unique_ptr<PolicyContainer> container) {}

std::unique_ptr<PolicyContainer> ExecutionContext::TakePolicyContainer() {}

void ExecutionContext::RemoveURLFromMemoryCache(const KURL& url) {}

void ExecutionContext::Trace(Visitor* visitor) const {}

bool ExecutionContext::IsSameAgentCluster(
    const base::UnguessableToken& other_id) const {}

mojom::blink::V8CacheOptions ExecutionContext::GetV8CacheOptions() const {}

v8::MicrotaskQueue* ExecutionContext::GetMicrotaskQueue() const {}

bool ExecutionContext::FeatureEnabled(
    mojom::blink::OriginTrialFeature feature) const {}

bool ExecutionContext::IsFeatureEnabled(
    mojom::blink::PermissionsPolicyFeature feature,
    ReportOptions report_option,
    const String& message) {}

bool ExecutionContext::IsFeatureEnabled(
    mojom::blink::PermissionsPolicyFeature feature) const {}

bool ExecutionContext::IsFeatureEnabled(
    mojom::blink::DocumentPolicyFeature feature) const {}

bool ExecutionContext::IsFeatureEnabled(
    mojom::blink::DocumentPolicyFeature feature,
    PolicyValue threshold_value) const {}

bool ExecutionContext::IsFeatureEnabled(
    mojom::blink::DocumentPolicyFeature feature,
    ReportOptions report_option,
    const String& message,
    const String& source_file) {}

bool ExecutionContext::IsFeatureEnabled(
    mojom::blink::DocumentPolicyFeature feature,
    PolicyValue threshold_value,
    ReportOptions report_option,
    const String& message,
    const String& source_file) {}

bool ExecutionContext::RequireTrustedTypes() const {}

namespace {
ContextType;
ContextType GetContextType(const ExecutionContext& execution_context) {}

WorldType;
WorldType GetWorldType(const ExecutionContext& execution_context) {}
}  // namespace

void ExecutionContext::WriteIntoTrace(
    perfetto::TracedProto<ExecutionContext::Proto> proto) const {}

bool ExecutionContext::CrossOriginIsolatedCapabilityOrDisabledWebSecurity()
    const {}

bool ExecutionContext::IsInjectionMitigatedContext() const {}

}  // namespace blink