#include "extensions/renderer/script_context_set.h"
#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "content/public/common/url_constants.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/worker_thread.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/mojom/context_type.mojom.h"
#include "extensions/common/mojom/host_id.mojom.h"
#include "extensions/common/utils/extension_utils.h"
#include "extensions/renderer/extension_frame_helper.h"
#include "extensions/renderer/extensions_renderer_client.h"
#include "extensions/renderer/isolated_world_manager.h"
#include "extensions/renderer/renderer_frame_context_data.h"
#include "extensions/renderer/script_context.h"
#include "pdf/buildflags.h"
#include "third_party/blink/public/platform/scheduler/web_agent_group_scheduler.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "v8/include/v8-isolate.h"
#include "v8/include/v8-object.h"
namespace extensions {
namespace {
ScriptContextSet* g_context_set = …;
}
ScriptContextSet::ScriptContextSet(ExtensionIdSet* active_extension_ids)
: … { … }
ScriptContextSet::~ScriptContextSet() { … }
ScriptContext* ScriptContextSet::Register(
blink::WebLocalFrame* frame,
const v8::Local<v8::Context>& v8_context,
int32_t world_id,
bool is_webview) { … }
void ScriptContextSet::Remove(ScriptContext* context) { … }
ScriptContext* ScriptContextSet::GetCurrent() const { … }
ScriptContext* ScriptContextSet::GetByV8Context(
const v8::Local<v8::Context>& v8_context) const { … }
ScriptContext* ScriptContextSet::GetContextByObject(
const v8::Local<v8::Object>& object) { … }
ScriptContext* ScriptContextSet::GetContextByV8Context(
const v8::Local<v8::Context>& v8_context) { … }
ScriptContext* ScriptContextSet::GetMainWorldContextForFrame(
content::RenderFrame* render_frame) { … }
void ScriptContextSet::ForEach(
const mojom::HostID& host_id,
content::RenderFrame* render_frame,
const base::RepeatingCallback<void(ScriptContext*)>& callback) { … }
void ScriptContextSet::ExecuteCallbackWithContext(
ScriptContext* context,
content::RenderFrame* render_frame,
const base::RepeatingCallback<void(ScriptContext*)>& callback) { … }
void ScriptContextSet::OnExtensionUnloaded(const ExtensionId& extension_id) { … }
void ScriptContextSet::AddForTesting(std::unique_ptr<ScriptContext> context) { … }
const Extension* ScriptContextSet::GetExtensionFromFrameAndWorld(
blink::WebLocalFrame* frame,
int32_t world_id,
bool use_effective_url) { … }
mojom::ContextType ScriptContextSet::ClassifyJavaScriptContext(
const Extension* extension,
int32_t world_id,
const GURL& url,
const blink::WebSecurityOrigin& origin,
mojom::ViewType view_type,
bool is_webview) { … }
}