#include "extensions/renderer/user_script_injector.h"
#include <tuple>
#include <vector>
#include "base/check.h"
#include "base/lazy_instance.h"
#include "content/public/common/url_constants.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
#include "extensions/common/extension.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/grit/extensions_renderer_resources.h"
#include "extensions/renderer/extension_frame_helper.h"
#include "extensions/renderer/injection_host.h"
#include "extensions/renderer/script_context.h"
#include "extensions/renderer/scripts_run_info.h"
#include "ipc/ipc_sync_channel.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.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"
#include "ui/base/resource/resource_bundle.h"
#include "url/gurl.h"
#if BUILDFLAG(ENABLE_GUEST_VIEW)
#include "extensions/common/mojom/guest_view.mojom.h"
#endif
namespace extensions {
namespace {
#if BUILDFLAG(ENABLE_GUEST_VIEW)
struct RoutingInfoKey { … };
RoutingInfoMap;
base::LazyInstance<RoutingInfoMap>::DestructorAtExit g_routing_info_map = …;
#endif
struct GreasemonkeyApiJsString { … };
GreasemonkeyApiJsString::GreasemonkeyApiJsString() { … }
blink::WebScriptSource GreasemonkeyApiJsString::GetSource() const { … }
base::LazyInstance<GreasemonkeyApiJsString>::Leaky g_greasemonkey_api = …;
bool ShouldInjectScripts(const UserScript::ContentList& script_contents,
const std::set<std::string>& injected_files) { … }
}
UserScriptInjector::UserScriptInjector(const UserScript* script,
UserScriptSet* script_list,
bool is_declarative)
: … { … }
UserScriptInjector::~UserScriptInjector() { … }
void UserScriptInjector::OnUserScriptsUpdated() { … }
void UserScriptInjector::OnUserScriptSetDestroyed() { … }
mojom::InjectionType UserScriptInjector::script_type() const { … }
blink::mojom::UserActivationOption UserScriptInjector::IsUserGesture() const { … }
mojom::ExecutionWorld UserScriptInjector::GetExecutionWorld() const { … }
const std::optional<std::string>& UserScriptInjector::GetExecutionWorldId()
const { … }
blink::mojom::WantResultOption UserScriptInjector::ExpectsResults() const { … }
blink::mojom::PromiseResultOption UserScriptInjector::ShouldWaitForPromise()
const { … }
mojom::CSSOrigin UserScriptInjector::GetCssOrigin() const { … }
mojom::CSSInjection::Operation UserScriptInjector::GetCSSInjectionOperation()
const { … }
bool UserScriptInjector::ShouldInjectJs(
mojom::RunLocation run_location,
const std::set<std::string>& executing_scripts) const { … }
bool UserScriptInjector::ShouldInjectOrRemoveCss(
mojom::RunLocation run_location,
const std::set<std::string>& injected_stylesheets) const { … }
PermissionsData::PageAccess UserScriptInjector::CanExecuteOnFrame(
const InjectionHost* injection_host,
blink::WebLocalFrame* web_frame,
int tab_id) { … }
std::vector<blink::WebScriptSource> UserScriptInjector::GetJsSources(
mojom::RunLocation run_location,
std::set<std::string>* executing_scripts,
size_t* num_injected_js_scripts) const { … }
std::vector<ScriptInjector::CSSSource> UserScriptInjector::GetCssSources(
mojom::RunLocation run_location,
std::set<std::string>* injected_stylesheets,
size_t* num_injected_stylesheets) const { … }
void UserScriptInjector::OnInjectionComplete(
std::optional<base::Value> execution_result,
mojom::RunLocation run_location) { … }
void UserScriptInjector::OnWillNotInject(InjectFailureReason reason) { … }
}