#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 {
const size_t kIDPrefixLength = …;
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 extensions {
enum { … };
std::string UserScript::GenerateUserScriptID() { … }
std::string UserScript::TrimPrefixFromScriptID(const std::string& script_id) { … }
UserScript::Source UserScript::GetSourceForScriptID(
const std::string& script_id) { … }
bool UserScript::IsURLUserScript(const GURL& url,
const std::string& mime_type) { … }
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)
: … { … }
std::unique_ptr<UserScript::Content> UserScript::Content::CreateFile(
const base::FilePath& extension_root,
const base::FilePath& relative_path,
const GURL& url) { … }
std::unique_ptr<UserScript::Content> UserScript::Content::CreateInlineCode(
const GURL& url) { … }
UserScript::Content::Content() = default;
UserScript::Content::Content(const Content& other)
: … { … }
UserScript::Content::~Content() = default;
UserScript::UserScript() = default;
UserScript::~UserScript() = default;
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) { … }
}