#include "third_party/blink/renderer/core/speculation_rules/speculation_rule_set.h"
#include "base/containers/contains.h"
#include "base/not_fatal_until.h"
#include "services/network/public/mojom/no_vary_search.mojom-shared.h"
#include "services/network/public/mojom/referrer_policy.mojom-shared.h"
#include "third_party/blink/public/mojom/speculation_rules/speculation_rules.mojom-shared.h"
#include "third_party/blink/renderer/core/css/style_rule.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/web_feature.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/inspector/identifiers_factory.h"
#include "third_party/blink/renderer/core/loader/resource/speculation_rules_resource.h"
#include "third_party/blink/renderer/core/script/script_element_base.h"
#include "third_party/blink/renderer/core/speculation_rules/document_rule_predicate.h"
#include "third_party/blink/renderer/core/speculation_rules/speculation_rules_metrics.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.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/json/json_parser.h"
#include "third_party/blink/renderer/platform/json/json_values.h"
#include "third_party/blink/renderer/platform/network/http_parsers.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/weborigin/security_policy.h"
#include "third_party/blink/renderer/platform/wtf/text/string_view.h"
namespace blink {
namespace {
void AddConsoleMessageForSpeculationRuleSetValidation(
SpeculationRuleSet& speculation_rule_set,
Document& element_document,
ScriptElementBase* script_element,
SpeculationRulesResource* resource) { … }
bool IsValidContextName(const String& name_or_keyword) { … }
bool IsValidBrowsingContextNameOrKeyword(const String& name_or_keyword) { … }
void SetParseErrorMessage(String* out_error, String message) { … }
SpeculationRule* ParseSpeculationRule(JSONObject* input,
const KURL& base_url,
ExecutionContext* context,
bool is_browser_injected,
String* out_error,
Vector<String>& out_warnings) { … }
}
SpeculationRuleSet::Source::Source(base::PassKey<SpeculationRuleSet::Source>,
const String& source_text,
Document* document,
std::optional<DOMNodeId> node_id,
std::optional<KURL> base_url,
std::optional<uint64_t> request_id,
bool ignore_opt_out)
: … { … }
SpeculationRuleSet::Source* SpeculationRuleSet::Source::FromInlineScript(
const String& source_text,
Document& document,
DOMNodeId node_id) { … }
SpeculationRuleSet::Source* SpeculationRuleSet::Source::FromRequest(
const String& source_text,
const KURL& base_url,
uint64_t request_id) { … }
SpeculationRuleSet::Source* SpeculationRuleSet::Source::FromBrowserInjected(
const String& source_text,
const KURL& base_url,
BrowserInjectedSpeculationRuleOptOut opt_out) { … }
bool SpeculationRuleSet::Source::IsFromInlineScript() const { … }
bool SpeculationRuleSet::Source::IsFromRequest() const { … }
bool SpeculationRuleSet::Source::IsFromBrowserInjected() const { … }
bool SpeculationRuleSet::Source::IsFromBrowserInjectedAndRespectsOptOut()
const { … }
const String& SpeculationRuleSet::Source::GetSourceText() const { … }
const std::optional<DOMNodeId>& SpeculationRuleSet::Source::GetNodeId() const { … }
const std::optional<KURL> SpeculationRuleSet::Source::GetSourceURL() const { … }
const std::optional<uint64_t>& SpeculationRuleSet::Source::GetRequestId()
const { … }
KURL SpeculationRuleSet::Source::GetBaseURL() const { … }
void SpeculationRuleSet::Source::Trace(Visitor* visitor) const { … }
SpeculationRuleSet::SpeculationRuleSet(base::PassKey<SpeculationRuleSet>,
Source* source)
: … { … }
void SpeculationRuleSet::SetError(SpeculationRuleSetErrorType error_type,
String error_message) { … }
void SpeculationRuleSet::AddWarnings(
base::span<const String> warning_messages) { … }
SpeculationRuleSet* SpeculationRuleSet::Parse(Source* source,
ExecutionContext* context) { … }
bool SpeculationRuleSet::HasError() const { … }
bool SpeculationRuleSet::HasWarnings() const { … }
bool SpeculationRuleSet::ShouldReportUMAForError() const { … }
mojom::blink::SpeculationTargetHint
SpeculationRuleSet::SpeculationTargetHintFromString(
const StringView& target_hint_str) { … }
void SpeculationRuleSet::Trace(Visitor* visitor) const { … }
void SpeculationRuleSet::AddConsoleMessageForValidation(
ScriptElementBase& script_element) { … }
void SpeculationRuleSet::AddConsoleMessageForValidation(
Document& document,
SpeculationRulesResource& resource) { … }
}