#include "extensions/browser/api/user_scripts/user_scripts_api.h"
#include <memory>
#include <string>
#include <vector>
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/notreached.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/types/optional_util.h"
#include "extensions/browser/extension_file_task_runner.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/extension_user_script_loader.h"
#include "extensions/browser/scripting_constants.h"
#include "extensions/browser/scripting_utils.h"
#include "extensions/browser/user_script_manager.h"
#include "extensions/browser/user_script_world_configuration_manager.h"
#include "extensions/common/api/extension_types.h"
#include "extensions/common/api/scripts_internal/script_serialization.h"
#include "extensions/common/api/user_scripts.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/mojom/execution_world.mojom-shared.h"
#include "extensions/common/user_script.h"
#include "extensions/common/utils/content_script_utils.h"
namespace extensions {
namespace {
constexpr char kEmptySourceError[] = …;
constexpr char kInvalidSourceError[] = …;
constexpr char kMatchesMissingError[] = …;
bool IsValidWorldId(const std::optional<std::string>& world_id,
std::string* error_out) { … }
api::scripts_internal::SerializedUserScript
ConvertRegisteredUserScriptToSerializedUserScript(
api::user_scripts::RegisteredUserScript user_script) { … }
std::unique_ptr<UserScript> ParseUserScript(
const Extension& extension,
api::user_scripts::RegisteredUserScript user_script,
bool allowed_in_incognito,
std::u16string* error) { … }
api::user_scripts::RegisteredUserScript CreateRegisteredUserScriptInfo(
const UserScript& script) { … }
}
ExtensionFunction::ResponseAction UserScriptsRegisterFunction::Run() { … }
void UserScriptsRegisterFunction::OnUserScriptFilesValidated(
scripting::ValidateScriptsResult result) { … }
void UserScriptsRegisterFunction::OnUserScriptsRegistered(
const std::optional<std::string>& error) { … }
ExtensionFunction::ResponseAction UserScriptsGetScriptsFunction::Run() { … }
ExtensionFunction::ResponseAction UserScriptsUnregisterFunction::Run() { … }
void UserScriptsUnregisterFunction::OnUserScriptsUnregistered(
const std::optional<std::string>& error) { … }
ExtensionFunction::ResponseAction UserScriptsUpdateFunction::Run() { … }
std::unique_ptr<UserScript> UserScriptsUpdateFunction::ApplyUpdate(
api::user_scripts::RegisteredUserScript& new_script,
api::user_scripts::RegisteredUserScript& original_script,
std::u16string* parse_error) { … }
void UserScriptsUpdateFunction::OnUserScriptFilesValidated(
scripting::ValidateScriptsResult result) { … }
void UserScriptsUpdateFunction::OnUserScriptsUpdated(
const std::optional<std::string>& error) { … }
ExtensionFunction::ResponseAction UserScriptsConfigureWorldFunction::Run() { … }
ExtensionFunction::ResponseAction
UserScriptsGetWorldConfigurationsFunction::Run() { … }
ExtensionFunction::ResponseAction
UserScriptsResetWorldConfigurationFunction::Run() { … }
}