chromium/third_party/blink/common/storage_key/storage_key.cc

// Copyright 2021 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/public/common/storage_key/storage_key.h"

#include <memory>
#include <ostream>
#include <string>
#include <string_view>
#include <tuple>

#include "base/feature_list.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/types/optional_util.h"
#include "net/base/features.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "third_party/abseil-cpp/absl/strings/ascii.h"
#include "url/gurl.h"

namespace {

// This enum represents the different type of encodable partitioning
// attributes. These values are persisted to disk. Entries should not be
// renumbered and numeric values should never be reused.
enum class EncodedAttribute : uint8_t {};

// Converts the attribute type into the separator + uint8_t byte
// serialization. E.x.: kTopLevelSite becomes "^0"
std::string SerializeAttributeSeparator(const EncodedAttribute type) {}

// Converts the serialized separator into an EncodedAttribute enum.
// E.x.: "^0" becomes kTopLevelSite.
// Expects `in` to have a length of 2.
std::optional<EncodedAttribute> DeserializeAttributeSeparator(
    const std::string_view& in) {}

// Returns true if there are at least 2 chars after the '^' in `in` and the
// second char is not '^'. Meaning that the substring is syntactically valid.
// This is to indicate that there is a valid separator with both a '^' and a
// uint8_t and some amount of encoded data. I.e.: "^09" has both a "^0" as the
// separator and '9' as the encoded data.
bool ValidSeparatorWithData(std::string_view in, size_t pos_of_caret) {}

}  // namespace

namespace blink {

// static
std::optional<StorageKey> StorageKey::Deserialize(std::string_view in) {}

// static
std::optional<StorageKey> StorageKey::DeserializeForLocalStorage(
    std::string_view in) {}

// static
StorageKey StorageKey::CreateFromStringForTesting(const std::string& origin) {}

// static
// Keep consistent with BlinkStorageKey::FromWire().
bool StorageKey::FromWire(
    const url::Origin& origin,
    const net::SchemefulSite& top_level_site,
    const net::SchemefulSite& top_level_site_if_third_party_enabled,
    const std::optional<base::UnguessableToken>& nonce,
    blink::mojom::AncestorChainBit ancestor_chain_bit,
    blink::mojom::AncestorChainBit ancestor_chain_bit_if_third_party_enabled,
    StorageKey& out) {}

// static
bool StorageKey::IsThirdPartyStoragePartitioningEnabled() {}

// static
StorageKey StorageKey::CreateFirstParty(const url::Origin& origin) {}

// static
StorageKey StorageKey::CreateWithNonce(const url::Origin& origin,
                                       const base::UnguessableToken& nonce) {}

// static
StorageKey StorageKey::Create(const url::Origin& origin,
                              const net::SchemefulSite& top_level_site,
                              blink::mojom::AncestorChainBit ancestor_chain_bit,
                              bool third_party_partitioning_allowed) {}

// static
StorageKey StorageKey::CreateFromOriginAndIsolationInfo(
    const url::Origin& origin,
    const net::IsolationInfo& isolation_info) {}

StorageKey StorageKey::WithOrigin(const url::Origin& origin) const {}

StorageKey::StorageKey(const url::Origin& origin,
                       const net::SchemefulSite& top_level_site,
                       const base::UnguessableToken* nonce,
                       blink::mojom::AncestorChainBit ancestor_chain_bit,
                       bool third_party_partitioning_allowed)
    :{}

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

std::string StorageKey::SerializeForLocalStorage() const {}

std::string StorageKey::GetDebugString() const {}

std::string StorageKey::GetMemoryDumpString(size_t max_length) const {}

const net::SiteForCookies StorageKey::ToNetSiteForCookies() const {}

const net::IsolationInfo StorageKey::ToPartialNetIsolationInfo() const {}

// static
bool StorageKey::ShouldSkipKeyDueToPartitioning(
    const std::string& reg_key_string) {}

const std::optional<net::CookiePartitionKey> StorageKey::ToCookiePartitionKey()
    const {}

bool StorageKey::MatchesOriginForTrustedStorageDeletion(
    const url::Origin& origin) const {}

bool StorageKey::MatchesRegistrableDomainForTrustedStorageDeletion(
    std::string_view domain) const {}

bool StorageKey::ExactMatchForTesting(const StorageKey& other) const {}

bool operator==(const StorageKey& lhs, const StorageKey& rhs) {}

bool operator!=(const StorageKey& lhs, const StorageKey& rhs) {}

bool operator<(const StorageKey& lhs, const StorageKey& rhs) {}

std::ostream& operator<<(std::ostream& ostream, const StorageKey& sk) {}

bool StorageKey::IsValid() const {}

}  // namespace blink