chore: update chrome.scripting.execute
logic (#45369)
chore: update chrome.scripting.execute logic Refs: -6123601
-6142377
-6173554
This commit is contained in:
parent
43e328f363
commit
233b99a0a8
2 changed files with 17 additions and 166 deletions
|
@ -15,22 +15,11 @@
|
|||
#include "extensions/browser/extension_function.h"
|
||||
#include "extensions/browser/script_executor.h"
|
||||
#include "extensions/browser/scripting_utils.h"
|
||||
#include "extensions/common/mojom/code_injection.mojom-forward.h"
|
||||
#include "extensions/common/mojom/code_injection.mojom.h"
|
||||
#include "extensions/common/user_script.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
// A simple helper struct to represent a read file (either CSS or JS) to be
|
||||
// injected.
|
||||
struct InjectedFileSource {
|
||||
InjectedFileSource(std::string file_name, std::unique_ptr<std::string> data);
|
||||
InjectedFileSource(InjectedFileSource&&);
|
||||
~InjectedFileSource();
|
||||
|
||||
std::string file_name;
|
||||
std::unique_ptr<std::string> data;
|
||||
};
|
||||
|
||||
class ScriptingExecuteScriptFunction : public ExtensionFunction {
|
||||
public:
|
||||
DECLARE_EXTENSION_FUNCTION("scripting.executeScript", SCRIPTING_EXECUTESCRIPT)
|
||||
|
@ -48,7 +37,7 @@ class ScriptingExecuteScriptFunction : public ExtensionFunction {
|
|||
~ScriptingExecuteScriptFunction() override;
|
||||
|
||||
// Called when the resource files to be injected has been loaded.
|
||||
void DidLoadResources(std::vector<InjectedFileSource> file_sources,
|
||||
void DidLoadResources(std::vector<scripting::InjectedFileSource> file_sources,
|
||||
std::optional<std::string> load_error);
|
||||
|
||||
// Triggers the execution of `sources` in the appropriate context.
|
||||
|
@ -77,7 +66,7 @@ class ScriptingInsertCSSFunction : public ExtensionFunction {
|
|||
~ScriptingInsertCSSFunction() override;
|
||||
|
||||
// Called when the resource files to be injected has been loaded.
|
||||
void DidLoadResources(std::vector<InjectedFileSource> file_sources,
|
||||
void DidLoadResources(std::vector<scripting::InjectedFileSource> file_sources,
|
||||
std::optional<std::string> load_error);
|
||||
|
||||
// Triggers the execution of `sources` in the appropriate context.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue