#ifndef EXTENSIONS_BROWSER_SCRIPTING_UTILS_H_
#define EXTENSIONS_BROWSER_SCRIPTING_UTILS_H_
#include <string>
#include "base/containers/contains.h"
#include "base/functional/callback_forward.h"
#include "base/strings/utf_string_conversions.h"
#include "extensions/browser/extension_user_script_loader.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/extension_resource.h"
#include "extensions/common/url_pattern_set.h"
#include "extensions/common/user_script.h"
namespace content {
class BrowserContext;
}
namespace extensions::scripting {
std::string AddPrefixToDynamicScriptId(const std::string& script_id,
UserScript::Source source);
bool IsScriptIdValid(const std::string& script_id, std::string* error);
bool ScriptsShouldBeAllowedInIncognito(
const ExtensionId& extension_id,
content::BrowserContext* browser_context);
template <typename Script>
std::set<std::string> CreateDynamicScriptIds(
std::vector<Script>& scripts,
UserScript::Source source,
const std::set<std::string>& existing_script_ids,
std::string* error) { … }
template <typename Script>
UserScriptList UpdateScripts(
std::vector<Script>& scripts_to_update,
UserScript::Source source,
ExtensionUserScriptLoader& loader,
base::RepeatingCallback<Script(const UserScript& script)>
create_script_metadata_callback,
base::RepeatingCallback<std::unique_ptr<UserScript>(
Script& new_script,
Script& existent_script,
std::u16string* parse_error)> apply_update_callback,
std::string* error) { … }
bool RemoveScripts(
const std::optional<std::vector<std::string>>& ids,
UserScript::Source source,
content::BrowserContext* browser_context,
const ExtensionId& extension_id,
ExtensionUserScriptLoader::DynamicScriptsModifiedCallback remove_callback,
std::string* error);
URLPatternSet GetPersistentScriptURLPatterns(
content::BrowserContext* browser_context,
const ExtensionId& extension_id);
void SetPersistentScriptURLPatterns(content::BrowserContext* browser_context,
const ExtensionId& extension_id,
const URLPatternSet& patterns);
void ClearPersistentScriptURLPatterns(content::BrowserContext* browser_context,
const ExtensionId& extension_id);
ValidateScriptsResult;
ValidateScriptsResult ValidateParsedScriptsOnFileThread(
ExtensionResource::SymlinkPolicy symlink_policy,
UserScriptList scripts);
}
#endif