chromium/url/origin.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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/350788890): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "url/origin.h"

#include <stdint.h>

#include <algorithm>
#include <ostream>
#include <string>
#include <string_view>
#include <tuple>
#include <utility>

#include "base/base64.h"
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/debug/crash_logging.h"
#include "base/pickle.h"
#include "base/strings/strcat.h"
#include "base/trace_event/base_tracing.h"
#include "base/trace_event/memory_usage_estimator.h"
#include "base/unguessable_token.h"
#include "url/gurl.h"
#include "url/scheme_host_port.h"
#include "url/url_constants.h"
#include "url/url_features.h"
#include "url/url_util.h"

namespace url {

Origin::Origin() :{}

Origin Origin::Create(const GURL& url) {}

Origin Origin::Resolve(const GURL& url, const Origin& base_origin) {}

Origin::Origin(const Origin&) = default;
Origin& Origin::operator=(const Origin&) = default;
Origin::Origin(Origin&&) noexcept = default;
Origin& Origin::operator=(Origin&&) noexcept = default;
Origin::~Origin() = default;

// static
std::optional<Origin> Origin::UnsafelyCreateTupleOriginWithoutNormalization(
    std::string_view scheme,
    std::string_view host,
    uint16_t port) {}

// static
std::optional<Origin> Origin::UnsafelyCreateOpaqueOriginWithoutNormalization(
    std::string_view precursor_scheme,
    std::string_view precursor_host,
    uint16_t precursor_port,
    const Origin::Nonce& nonce) {}

// static
Origin Origin::CreateFromNormalizedTuple(std::string scheme,
                                         std::string host,
                                         uint16_t port) {}

// static
Origin Origin::CreateOpaqueFromNormalizedPrecursorTuple(
    std::string precursor_scheme,
    std::string precursor_host,
    uint16_t precursor_port,
    const Origin::Nonce& nonce) {}

std::string Origin::Serialize() const {}

GURL Origin::GetURL() const {}

const base::UnguessableToken* Origin::GetNonceForSerialization() const {}

bool Origin::IsSameOriginWith(const Origin& other) const {}

bool Origin::IsSameOriginWith(const GURL& url) const {}

bool Origin::CanBeDerivedFrom(const GURL& url) const {}

bool Origin::DomainIs(std::string_view canonical_domain) const {}

bool Origin::operator<(const Origin& other) const {}

Origin Origin::DeriveNewOpaqueOrigin() const {}

const base::UnguessableToken* Origin::GetNonceForTesting() const {}

std::string Origin::GetDebugString(bool include_nonce) const {}

Origin::Origin(SchemeHostPort tuple) :{}

// Constructs an opaque origin derived from |precursor|.
Origin::Origin(const Nonce& nonce, SchemeHostPort precursor)
    :{}

std::optional<std::string> Origin::SerializeWithNonce() const {}

std::optional<std::string> Origin::SerializeWithNonceAndInitIfNeeded() {}

// The pickle is saved in the following format, in order:
// string - tuple_.GetURL().spec().
// uint64_t (if opaque) - high bits of nonce if opaque. 0 if not initialized.
// uint64_t (if opaque) - low bits of nonce if opaque. 0 if not initialized.
std::optional<std::string> Origin::SerializeWithNonceImpl() const {}

// static
std::optional<Origin> Origin::Deserialize(const std::string& value) {}

void Origin::WriteIntoTrace(perfetto::TracedValue context) const {}

size_t Origin::EstimateMemoryUsage() const {}

std::ostream& operator<<(std::ostream& out, const url::Origin& origin) {}

std::ostream& operator<<(std::ostream& out, const url::Origin::Nonce& nonce) {}

bool IsSameOriginWith(const GURL& a, const GURL& b) {}

Origin::Nonce::Nonce() = default;
Origin::Nonce::Nonce(const base::UnguessableToken& token) :{}

const base::UnguessableToken& Origin::Nonce::token() const {}

const base::UnguessableToken& Origin::Nonce::raw_token() const {}

// Copying a Nonce triggers lazy-generation of the token.
Origin::Nonce::Nonce(const Origin::Nonce& other) :{}

Origin::Nonce& Origin::Nonce::operator=(const Origin::Nonce& other) {}

// Moving a nonce does NOT trigger lazy-generation of the token.
Origin::Nonce::Nonce(Origin::Nonce&& other) noexcept :{}

Origin::Nonce& Origin::Nonce::operator=(Origin::Nonce&& other) noexcept {}

bool Origin::Nonce::operator<(const Origin::Nonce& other) const {}

bool Origin::Nonce::operator==(const Origin::Nonce& other) const {}

bool Origin::Nonce::operator!=(const Origin::Nonce& other) const {}

namespace debug {

ScopedOriginCrashKey::ScopedOriginCrashKey(
    base::debug::CrashKeyString* crash_key,
    const url::Origin* value)
    :{}

ScopedOriginCrashKey::~ScopedOriginCrashKey() = default;

}  // namespace debug

}  // namespace url