#include "extensions/renderer/programmatic_script_injector.h"
#include <utility>
#include <vector>
#include "base/values.h"
#include "content/public/common/url_constants.h"
#include "content/public/renderer/render_frame.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/mojom/host_id.mojom.h"
#include "extensions/common/permissions/api_permission.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/script_constants.h"
#include "extensions/renderer/injection_host.h"
#include "extensions/renderer/renderer_extension_registry.h"
#include "extensions/renderer/script_context.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_script_source.h"
namespace extensions {
ProgrammaticScriptInjector::ProgrammaticScriptInjector(
mojom::ExecuteCodeParamsPtr params,
mojom::LocalFrame::ExecuteCodeCallback callback)
: … { … }
ProgrammaticScriptInjector::~ProgrammaticScriptInjector() { … }
mojom::InjectionType ProgrammaticScriptInjector::script_type() const { … }
blink::mojom::UserActivationOption ProgrammaticScriptInjector::IsUserGesture()
const { … }
mojom::ExecutionWorld ProgrammaticScriptInjector::GetExecutionWorld() const { … }
const std::optional<std::string>&
ProgrammaticScriptInjector::GetExecutionWorldId() const { … }
mojom::CSSOrigin ProgrammaticScriptInjector::GetCssOrigin() const { … }
mojom::CSSInjection::Operation
ProgrammaticScriptInjector::GetCSSInjectionOperation() const { … }
blink::mojom::WantResultOption ProgrammaticScriptInjector::ExpectsResults()
const { … }
blink::mojom::PromiseResultOption
ProgrammaticScriptInjector::ShouldWaitForPromise() const { … }
bool ProgrammaticScriptInjector::ShouldInjectJs(
mojom::RunLocation run_location,
const std::set<std::string>& executing_scripts) const { … }
bool ProgrammaticScriptInjector::ShouldInjectOrRemoveCss(
mojom::RunLocation run_location,
const std::set<std::string>& injected_stylesheets) const { … }
PermissionsData::PageAccess ProgrammaticScriptInjector::CanExecuteOnFrame(
const InjectionHost* injection_host,
blink::WebLocalFrame* frame,
int tab_id) { … }
std::vector<blink::WebScriptSource> ProgrammaticScriptInjector::GetJsSources(
mojom::RunLocation run_location,
std::set<std::string>* executing_scripts,
size_t* num_injected_js_scripts) const { … }
std::vector<ScriptInjector::CSSSource>
ProgrammaticScriptInjector::GetCssSources(
mojom::RunLocation run_location,
std::set<std::string>* injected_stylesheets,
size_t* num_injected_stylesheets) const { … }
void ProgrammaticScriptInjector::OnInjectionComplete(
std::optional<base::Value> execution_result,
mojom::RunLocation run_location) { … }
void ProgrammaticScriptInjector::OnWillNotInject(InjectFailureReason reason) { … }
bool ProgrammaticScriptInjector::CanShowUrlInError() const { … }
void ProgrammaticScriptInjector::Finish(const std::string& error) { … }
}