chromium/extensions/browser/api/user_scripts/user_scripts_api.cc

// Copyright 2023 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/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[] =;

// Returns true if the given `world_id` is valid from the API perspective.
// If invalid, populates `error_out`.
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) {}

// Converts a UserScript object to a api::user_scripts::RegisteredUserScript
// object, used for getScripts.
api::user_scripts::RegisteredUserScript CreateRegisteredUserScriptInfo(
    const UserScript& script) {}

}  // namespace

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() {}

}  // namespace extensions