chromium/third_party/blink/common/unique_name/unique_name_helper.cc

// Copyright 2017 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/unique_name/unique_name_helper.h"

#include <algorithm>
#include <string_view>
#include <utility>

#include "base/check_op.h"
#include "base/memory/raw_ptr.h"
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/unguessable_token.h"
#include "crypto/sha2.h"

namespace blink {

namespace {

bool g_preserve_stable_unique_name_for_testing =;

FrameAdapter;

class PendingChildFrameAdapter : public UniqueNameHelper::FrameAdapter {};

constexpr char kFramePathPrefix[] =;
constexpr int kFramePathPrefixLength =;
constexpr int kFramePathSuffixLength =;
constexpr char kDynamicFrameMarker[] =;

// 80% of unique names are shorter than this, and it also guarantees that this
// won't ever increase the length of a unique name, as a hashed unique name is
// exactly 80 characters.
constexpr size_t kMaxRequestedNameSize =;

bool IsNameWithFramePath(std::string_view name) {}

std::string GenerateCandidate(const FrameAdapter* frame) {}

std::string GenerateFramePosition(const FrameAdapter* frame) {}

std::string AppendUniqueSuffix(const FrameAdapter* frame,
                               const std::string& prefix,
                               const std::string& likely_unique_suffix) {}

std::string CalculateNameInternal(const FrameAdapter* frame,
                                  std::string_view name) {}

std::string CalculateFrameHash(std::string_view name) {}

std::string CalculateNewName(const FrameAdapter* frame, std::string_view name) {}

}  // namespace

UniqueNameHelper::FrameAdapter::~FrameAdapter() {}

UniqueNameHelper::Replacement::Replacement(std::string old_name,
                                           std::string new_name)
    :{}

UniqueNameHelper::UniqueNameHelper(FrameAdapter* frame) :{}

UniqueNameHelper::~UniqueNameHelper() {}

std::string UniqueNameHelper::GenerateNameForNewChildFrame(
    const std::string& name,
    bool is_created_by_script) const {}

void UniqueNameHelper::UpdateName(const std::string& name) {}

// |replacements| is used for two purposes:
// - when processing a non-frame path unique name that exceeds the max size,
//   this collection records the original name and the hashed name.
// - when processing a frame path unique name, this collection is used to fix up
//   ancestor frames in the frame path with an updated unique name.
//
std::string UniqueNameHelper::UpdateLegacyNameFromV24(
    std::string legacy_name,
    std::vector<Replacement>* replacements) {}

std::string UniqueNameHelper::CalculateLegacyNameForTesting(
    const FrameAdapter* frame,
    const std::string& name) {}

// static
void UniqueNameHelper::PreserveStableUniqueNameForTesting() {}

std::string UniqueNameHelper::ExtractStableNameForTesting(
    std::string_view unique_name) {}

}  // namespace blink