chromium/third_party/blink/renderer/core/origin_trials/origin_trial_context.cc

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

#include "third_party/blink/renderer/core/origin_trials/origin_trial_context.h"

#include <ostream>
#include <vector>

#include "base/feature_list.h"
#include "base/time/time.h"
#include "components/attribution_reporting/features.h"
#include "services/network/public/cpp/features.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/features_generated.h"
#include "third_party/blink/public/common/origin_trials/origin_trials.h"
#include "third_party/blink/public/common/origin_trials/trial_token.h"
#include "third_party/blink/public/common/origin_trials/trial_token_result.h"
#include "third_party/blink/public/common/origin_trials/trial_token_validator.h"
#include "third_party/blink/public/mojom/origin_trial_feature/origin_trial_feature.mojom-shared.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_security_origin.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/window_proxy.h"
#include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/workers/worklet_global_scope.h"
#include "third_party/blink/renderer/platform/bindings/origin_trial_features.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/runtime_feature_state/runtime_feature_state_override_context.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "v8/include/v8.h"

namespace blink {

namespace {

constexpr char kDefaultTrialName[] =;

bool IsWhitespace(UChar chr) {}

bool SkipWhiteSpace(const String& str, unsigned& pos) {}

// Extracts a quoted or unquoted token from an HTTP header. If the token was a
// quoted string, this also removes the quotes and unescapes any escaped
// characters. Also skips all whitespace before and after the token.
String ExtractTokenOrQuotedString(const String& header_value, unsigned& pos) {}

// Returns whether the given feature can be activated across navigations. Only
// features reviewed and approved by security reviewers can be activated across
// navigations.
bool IsCrossNavigationFeature(mojom::blink::OriginTrialFeature feature) {}

std::ostream& operator<<(std::ostream& stream, OriginTrialTokenStatus status) {}

// Merges `OriginTrialStatus` from different tokens for the same trial.
// Some combinations of status should never occur, such as
// s1 == kOSNotSupported && s2 == kEnabled.
OriginTrialStatus MergeOriginTrialStatus(OriginTrialStatus s1,
                                         OriginTrialStatus s2) {}

}  // namespace

// TODO(crbug.com/607555): Mark `TrialToken` as copyable.
OriginTrialTokenResult::OriginTrialTokenResult(
    const String& raw_token,
    OriginTrialTokenStatus status,
    const std::optional<TrialToken>& parsed_token)
    :{}

OriginTrialContext::OriginTrialContext(ExecutionContext* context)
    :{}

void OriginTrialContext::SetTrialTokenValidatorForTesting(
    std::unique_ptr<TrialTokenValidator> validator) {}

// static
std::unique_ptr<Vector<String>> OriginTrialContext::ParseHeaderValue(
    const String& header_value) {}

// static
void OriginTrialContext::AddTokensFromHeader(ExecutionContext* context,
                                             const String& header_value) {}

// static
void OriginTrialContext::AddTokens(ExecutionContext* context,
                                   const Vector<String>* tokens) {}

// static
void OriginTrialContext::ActivateWorkerInheritedFeatures(
    ExecutionContext* context,
    const Vector<mojom::blink::OriginTrialFeature>* features) {}

// static
void OriginTrialContext::ActivateNavigationFeaturesFromInitiator(
    ExecutionContext* context,
    const Vector<mojom::blink::OriginTrialFeature>* features) {}

// static
std::unique_ptr<Vector<String>> OriginTrialContext::GetTokens(
    ExecutionContext* execution_context) {}

// static
std::unique_ptr<Vector<mojom::blink::OriginTrialFeature>>
OriginTrialContext::GetInheritedTrialFeatures(
    ExecutionContext* execution_context) {}

// static
std::unique_ptr<Vector<mojom::blink::OriginTrialFeature>>
OriginTrialContext::GetEnabledNavigationFeatures(
    ExecutionContext* execution_context) {}

std::unique_ptr<Vector<mojom::blink::OriginTrialFeature>>
OriginTrialContext::GetInheritedTrialFeatures() const {}

std::unique_ptr<Vector<mojom::blink::OriginTrialFeature>>
OriginTrialContext::GetEnabledNavigationFeatures() const {}

void OriginTrialContext::AddToken(const String& token) {}

void OriginTrialContext::AddTokenFromExternalScript(
    const String& token,
    const Vector<scoped_refptr<SecurityOrigin>>& external_origins) {}

void OriginTrialContext::AddTokenInternal(
    const String& token,
    const OriginInfo origin,
    const Vector<OriginInfo>* script_origins) {}

void OriginTrialContext::AddTokens(const Vector<String>& tokens) {}

void OriginTrialContext::ActivateWorkerInheritedFeatures(
    const Vector<mojom::blink::OriginTrialFeature>& features) {}

void OriginTrialContext::ActivateNavigationFeaturesFromInitiator(
    const Vector<mojom::blink::OriginTrialFeature>& features) {}

void OriginTrialContext::InitializePendingFeatures() {}

bool OriginTrialContext::InstallFeatures(
    const HashSet<mojom::blink::OriginTrialFeature>& features,
    Document& document,
    ScriptState* script_state) {}

bool OriginTrialContext::InstallSettingFeature(
    Document& document,
    mojom::blink::OriginTrialFeature enabled_feature) {}

void OriginTrialContext::AddFeature(mojom::blink::OriginTrialFeature feature) {}

bool OriginTrialContext::IsFeatureEnabled(
    mojom::blink::OriginTrialFeature feature) const {}

base::Time OriginTrialContext::GetFeatureExpiry(
    mojom::blink::OriginTrialFeature feature) {}

bool OriginTrialContext::IsNavigationFeatureActivated(
    mojom::blink::OriginTrialFeature feature) const {}

void OriginTrialContext::AddForceEnabledTrials(
    const Vector<String>& trial_names) {}

bool OriginTrialContext::CanEnableTrialFromName(const StringView& trial_name) {}

OriginTrialFeaturesEnabled OriginTrialContext::EnableTrialFromName(
    const String& trial_name,
    base::Time expiry_time) {}

bool OriginTrialContext::EnableTrialFromToken(const String& token,
                                              const OriginInfo origin_info) {}

bool OriginTrialContext::EnableTrialFromToken(
    const String& token,
    const OriginInfo origin_info,
    const Vector<OriginInfo>* script_origins) {}

void OriginTrialContext::CacheToken(const String& raw_token,
                                    const TrialTokenResult& token_result,
                                    OriginTrialStatus trial_status) {}

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

const SecurityOrigin* OriginTrialContext::GetSecurityOrigin() {}

bool OriginTrialContext::IsSecureContext() {}

OriginTrialContext::OriginInfo OriginTrialContext::GetCurrentOriginInfo() {}

void OriginTrialContext::SendTokenToBrowser(
    const OriginInfo& origin_info,
    const TrialToken& parsed_token,
    const String& raw_token,
    const Vector<OriginInfo>* script_origin_info) {}

}  // namespace blink