#include "extensions/renderer/user_script_set.h"
#include <stddef.h>
#include <memory>
#include <string_view>
#include <utility>
#include "base/containers/span.h"
#include "base/debug/alias.h"
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "base/pickle.h"
#include "base/strings/strcat.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/extensions_client.h"
#include "extensions/common/mojom/host_id.mojom.h"
#include "extensions/renderer/extension_injection_host.h"
#include "extensions/renderer/extensions_renderer_client.h"
#include "extensions/renderer/injection_host.h"
#include "extensions/renderer/script_context.h"
#include "extensions/renderer/script_injection.h"
#include "extensions/renderer/user_script_injector.h"
#include "extensions/renderer/web_ui_injection_host.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "url/gurl.h"
namespace extensions {
namespace {
const char kUserScriptHead[] = …;
const char kUserScriptTail[] = …;
const uint32_t kNumScriptsArbitraryMax = …;
GURL GetDocumentUrlForFrame(blink::WebLocalFrame* frame) { … }
}
UserScriptSet::UserScriptSet(mojom::HostID host_id)
: … { … }
UserScriptSet::~UserScriptSet() { … }
void UserScriptSet::AddObserver(Observer* observer) { … }
void UserScriptSet::RemoveObserver(Observer* observer) { … }
void UserScriptSet::GetInjections(
std::vector<std::unique_ptr<ScriptInjection>>* injections,
content::RenderFrame* render_frame,
int tab_id,
mojom::RunLocation run_location,
bool log_activity) { … }
bool UserScriptSet::UpdateUserScripts(
base::ReadOnlySharedMemoryRegion shared_memory) { … }
void UserScriptSet::ClearUserScripts() { … }
std::unique_ptr<ScriptInjection> UserScriptSet::GetDeclarativeScriptInjection(
const std::string& script_id,
content::RenderFrame* render_frame,
int tab_id,
mojom::RunLocation run_location,
const GURL& document_url,
bool log_activity) { … }
std::unique_ptr<ScriptInjection> UserScriptSet::GetInjectionForScript(
const UserScript* script,
content::RenderFrame* render_frame,
int tab_id,
mojom::RunLocation run_location,
const GURL& document_url,
bool is_declarative,
bool log_activity) { … }
blink::WebString UserScriptSet::GetJsSource(const UserScript::Content& file,
bool emulate_greasemonkey) { … }
blink::WebString UserScriptSet::GetCssSource(const UserScript::Content& file) { … }
}