chromium/extensions/common/user_script.cc

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

#include "extensions/common/user_script.h"

#include <stddef.h>
#include <stdint.h>

#include <memory>
#include <utility>

#include "base/atomic_sequence_num.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/memory/ptr_util.h"
#include "base/notreached.h"
#include "base/pickle.h"
#include "base/strings/pattern.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "extensions/common/mojom/host_id.mojom.h"
#include "extensions/common/switches.h"

namespace {

// The length of all internally appended prefixes for a UserScript's ID.
const size_t kIDPrefixLength =;

// This cannot be a plain int or int64_t because we need to generate unique IDs
// from multiple threads.
base::AtomicSequenceNumber g_user_script_id_generator;

bool UrlMatchesGlobs(const std::vector<std::string>* globs,
                     const GURL& url) {}

constexpr const char* kAllPrefixes[] =;

constexpr bool ValidatePrefixes() {}

static_assert;

}  // namespace

namespace extensions {

// The bitmask for valid user script injectable schemes used by URLPattern.
enum {};

// static
std::string UserScript::GenerateUserScriptID() {}

// static
std::string UserScript::TrimPrefixFromScriptID(const std::string& script_id) {}

// static
UserScript::Source UserScript::GetSourceForScriptID(
    const std::string& script_id) {}

// static
bool UserScript::IsURLUserScript(const GURL& url,
                                 const std::string& mime_type) {}

// static
int UserScript::ValidUserScriptSchemes(bool can_execute_script_everywhere) {}

UserScript::Content::Content(Source source,
                             const base::FilePath& extension_root,
                             const base::FilePath& relative_path,
                             const GURL& url)
    :{}

// static
std::unique_ptr<UserScript::Content> UserScript::Content::CreateFile(
    const base::FilePath& extension_root,
    const base::FilePath& relative_path,
    const GURL& url) {}

// static
std::unique_ptr<UserScript::Content> UserScript::Content::CreateInlineCode(
    const GURL& url) {}

UserScript::Content::Content() = default;

// File content is not copied.
UserScript::Content::Content(const Content& other)
    :{}

UserScript::Content::~Content() = default;

UserScript::UserScript() = default;
UserScript::~UserScript() = default;

// static.
std::unique_ptr<UserScript> UserScript::CopyMetadataFrom(
    const UserScript& other) {}

void UserScript::add_url_pattern(const URLPattern& pattern) {}

void UserScript::add_exclude_url_pattern(const URLPattern& pattern) {}

std::string UserScript::GetIDWithoutPrefix() const {}

UserScript::Source UserScript::GetSource() const {}

bool UserScript::MatchesURL(const GURL& url) const {}

bool UserScript::MatchesDocument(const GURL& effective_document_url,
                                 bool is_subframe) const {}

void UserScript::Content::Pickle(base::Pickle* pickle) const {}

void UserScript::Content::Unpickle(const base::Pickle& pickle,
                                   base::PickleIterator* iter) {}

void UserScript::Pickle(base::Pickle* pickle) const {}

void UserScript::PickleGlobs(base::Pickle* pickle,
                             const std::vector<std::string>& globs) const {}

void UserScript::PickleHostID(base::Pickle* pickle,
                              const mojom::HostID& host_id) const {}

void UserScript::PickleURLPatternSet(base::Pickle* pickle,
                                     const URLPatternSet& pattern_list) const {}

void UserScript::PickleScripts(base::Pickle* pickle,
                               const ContentList& scripts) const {}

void UserScript::Unpickle(const base::Pickle& pickle,
                          base::PickleIterator* iter) {}

void UserScript::UnpickleGlobs(const base::Pickle& pickle,
                               base::PickleIterator* iter,
                               std::vector<std::string>* globs) {}

void UserScript::UnpickleHostID(const base::Pickle& pickle,
                                base::PickleIterator* iter,
                                mojom::HostID* host_id) {}

void UserScript::UnpickleURLPatternSet(const base::Pickle& pickle,
                                       base::PickleIterator* iter,
                                       URLPatternSet* pattern_list) {}

void UserScript::UnpickleScripts(const base::Pickle& pickle,
                                 base::PickleIterator* iter,
                                 ContentList* scripts) {}

}  // namespace extensions