#include "extensions/renderer/extensions_renderer_client.h"
#include <memory>
#include <ostream>
#include "base/check.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "base/metrics/histogram_functions.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
#include "extensions/buildflags/buildflags.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/mojom/context_type.mojom.h"
#include "extensions/common/switches.h"
#include "extensions/renderer/dispatcher.h"
#include "extensions/renderer/extension_frame_helper.h"
#include "extensions/renderer/extension_web_view_helper.h"
#include "extensions/renderer/extensions_render_frame_observer.h"
#include "extensions/renderer/renderer_extension_registry.h"
#include "extensions/renderer/resource_request_policy.h"
#include "extensions/renderer/script_context.h"
#include "third_party/blink/public/common/security/protocol_handler_security_level.h"
#include "third_party/blink/public/platform/web_url.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_plugin_params.h"
#if BUILDFLAG(ENABLE_GUEST_VIEW)
#include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container_manager.h"
#endif
namespace extensions {
namespace {
ExtensionsRendererClient* g_client = …;
#if BUILDFLAG(ENABLE_GUEST_VIEW)
void IsGuestViewApiAvailableToScriptContext(bool* api_is_available,
ScriptContext* context) { … }
#endif
}
ExtensionsRendererClient::ExtensionsRendererClient() = default;
ExtensionsRendererClient::~ExtensionsRendererClient() = default;
ExtensionsRendererClient* ExtensionsRendererClient::Get() { … }
void ExtensionsRendererClient::Set(ExtensionsRendererClient* client) { … }
void ExtensionsRendererClient::OnExtensionLoaded(const Extension& extension) { … }
void ExtensionsRendererClient::OnExtensionUnloaded(
const ExtensionId& extension_id) { … }
void ExtensionsRendererClient::AddAPIProvider(
std::unique_ptr<ExtensionsRendererAPIProvider> api_provider) { … }
void ExtensionsRendererClient::RenderThreadStarted() { … }
void ExtensionsRendererClient::WebViewCreated(
blink::WebView* web_view,
const url::Origin* outermost_origin) { … }
void ExtensionsRendererClient::RenderFrameCreated(
content::RenderFrame* render_frame,
service_manager::BinderRegistry* registry) { … }
bool ExtensionsRendererClient::OverrideCreatePlugin(
content::RenderFrame* render_frame,
const blink::WebPluginParams& params) { … }
bool ExtensionsRendererClient::AllowPopup() { … }
blink::ProtocolHandlerSecurityLevel
ExtensionsRendererClient::GetProtocolHandlerSecurityLevel() { … }
v8::Local<v8::Object> ExtensionsRendererClient::GetScriptableObject(
const blink::WebElement& plugin_element,
v8::Isolate* isolate) { … }
blink::WebFrame* ExtensionsRendererClient::FindFrame(
blink::WebLocalFrame* relative_to_frame,
const std::string& name) { … }
void ExtensionsRendererClient::RunScriptsAtDocumentStart(
content::RenderFrame* render_frame) { … }
void ExtensionsRendererClient::RunScriptsAtDocumentEnd(
content::RenderFrame* render_frame) { … }
void ExtensionsRendererClient::RunScriptsAtDocumentIdle(
content::RenderFrame* render_frame) { … }
void ExtensionsRendererClient::WillSendRequest(
blink::WebLocalFrame* frame,
ui::PageTransition transition_type,
const blink::WebURL& upstream_url,
const blink::WebURL& target_url,
const net::SiteForCookies& site_for_cookies,
const url::Origin* initiator_origin,
GURL* new_url) { … }
void ExtensionsRendererClient::SetDispatcherForTesting(
std::unique_ptr<Dispatcher> dispatcher) { … }
std::unique_ptr<ResourceRequestPolicy::Delegate>
ExtensionsRendererClient::CreateResourceRequestPolicyDelegate() { … }
}