123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: Jeremy Apthorp <[email protected]>
- Date: Wed, 15 Jan 2020 16:35:18 -0800
- Subject: add DidInstallConditionalFeatures
- This adds a hook on script context creation _after conditional features
- have been installed_. Electron uses this to run preload scripts and
- various other initialization. This is necessary because at the time
- DidCreateScriptContext is called, not all JS APIs are available in the
- context, which can cause some preload scripts to trip.
- diff --git a/content/public/renderer/render_frame_observer.h b/content/public/renderer/render_frame_observer.h
- index a92e09dc651a5f1a9bbae2572fad32233afcd46c..f99b652dda817b62615d2b3f00b4ae4b438ec44d 100644
- --- a/content/public/renderer/render_frame_observer.h
- +++ b/content/public/renderer/render_frame_observer.h
- @@ -129,6 +129,8 @@ class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener,
- virtual void DidHandleOnloadEvents() {}
- virtual void DidCreateScriptContext(v8::Local<v8::Context> context,
- int32_t world_id) {}
- + virtual void DidInstallConditionalFeatures(v8::Local<v8::Context> context,
- + int32_t world_id) {}
- virtual void WillReleaseScriptContext(v8::Local<v8::Context> context,
- int32_t world_id) {}
- virtual void DidClearWindowObject() {}
- diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
- index fea269ba08af3296e2e304bb94610508ecd01b02..59e48882aba9b0431ddaa0b48f896866833f3376 100644
- --- a/content/renderer/render_frame_impl.cc
- +++ b/content/renderer/render_frame_impl.cc
- @@ -4453,6 +4453,12 @@ void RenderFrameImpl::DidCreateScriptContext(v8::Local<v8::Context> context,
- observer.DidCreateScriptContext(context, world_id);
- }
-
- +void RenderFrameImpl::DidInstallConditionalFeatures(
- + v8::Local<v8::Context> context, int world_id) {
- + for (auto& observer : observers_)
- + observer.DidInstallConditionalFeatures(context, world_id);
- +}
- +
- void RenderFrameImpl::WillReleaseScriptContext(v8::Local<v8::Context> context,
- int world_id) {
- for (auto& observer : observers_)
- diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h
- index 4e5d10d32272d5617c7475f58b57ea73d3cf0a65..6ac30bdb5cbc81274e26fd74f3332f0e5c3fb1dc 100644
- --- a/content/renderer/render_frame_impl.h
- +++ b/content/renderer/render_frame_impl.h
- @@ -597,6 +597,8 @@ class CONTENT_EXPORT RenderFrameImpl
- blink::WebLocalFrameClient::LazyLoadBehavior lazy_load_behavior) override;
- void DidCreateScriptContext(v8::Local<v8::Context> context,
- int world_id) override;
- + void DidInstallConditionalFeatures(v8::Local<v8::Context> context,
- + int world_id) override;
- void WillReleaseScriptContext(v8::Local<v8::Context> context,
- int world_id) override;
- void DidChangeScrollOffset() override;
- diff --git a/third_party/blink/public/web/web_local_frame_client.h b/third_party/blink/public/web/web_local_frame_client.h
- index 507efab2cc79422cc58b1459de8e84a9b7992195..0948dd92c89db566317df7b352d9f5967a3ae86b 100644
- --- a/third_party/blink/public/web/web_local_frame_client.h
- +++ b/third_party/blink/public/web/web_local_frame_client.h
- @@ -598,6 +598,9 @@ class BLINK_EXPORT WebLocalFrameClient {
- virtual void DidCreateScriptContext(v8::Local<v8::Context>,
- int32_t world_id) {}
-
- + virtual void DidInstallConditionalFeatures(v8::Local<v8::Context>,
- + int32_t world_id) {}
- +
- // WebKit is about to release its reference to a v8 context for a frame.
- virtual void WillReleaseScriptContext(v8::Local<v8::Context>,
- int32_t world_id) {}
- diff --git a/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc b/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
- index aa4b510137d60e6fb924f4f1a6554fe06c19ad75..816b6260020a6cbb6880b0eed197743ccd9002f5 100644
- --- a/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
- +++ b/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
- @@ -205,6 +205,7 @@ void LocalWindowProxy::Initialize() {
- }
-
- InstallConditionalFeatures();
- + GetFrame()->Client()->DidInstallConditionalFeatures(context, world_->GetWorldId());
-
- if (World().IsMainWorld()) {
- GetFrame()->Loader().DispatchDidClearWindowObjectInMainWorld();
- diff --git a/third_party/blink/renderer/core/frame/local_frame_client.h b/third_party/blink/renderer/core/frame/local_frame_client.h
- index cf6f792bb68df3a15a74a61921f50f790817b3ca..8a922b95064909d750b041e3e36ab6ebf0375284 100644
- --- a/third_party/blink/renderer/core/frame/local_frame_client.h
- +++ b/third_party/blink/renderer/core/frame/local_frame_client.h
- @@ -309,6 +309,8 @@ class CORE_EXPORT LocalFrameClient : public FrameClient {
-
- virtual void DidCreateScriptContext(v8::Local<v8::Context>,
- int32_t world_id) = 0;
- + virtual void DidInstallConditionalFeatures(v8::Local<v8::Context>,
- + int32_t world_id) = 0;
- virtual void WillReleaseScriptContext(v8::Local<v8::Context>,
- int32_t world_id) = 0;
- virtual bool AllowScriptExtensions() = 0;
- diff --git a/third_party/blink/renderer/core/frame/local_frame_client_impl.cc b/third_party/blink/renderer/core/frame/local_frame_client_impl.cc
- index ba2d1beff9d4fe7b0eca90a274b8bd95a76446c1..3056ae4d9b6d1604b14f2626122a78a9f916d265 100644
- --- a/third_party/blink/renderer/core/frame/local_frame_client_impl.cc
- +++ b/third_party/blink/renderer/core/frame/local_frame_client_impl.cc
- @@ -274,6 +274,13 @@ void LocalFrameClientImpl::DidCreateScriptContext(
- web_frame_->Client()->DidCreateScriptContext(context, world_id);
- }
-
- +void LocalFrameClientImpl::DidInstallConditionalFeatures(
- + v8::Local<v8::Context> context,
- + int32_t world_id) {
- + if (web_frame_->Client())
- + web_frame_->Client()->DidInstallConditionalFeatures(context, world_id);
- +}
- +
- void LocalFrameClientImpl::WillReleaseScriptContext(
- v8::Local<v8::Context> context,
- int32_t world_id) {
- diff --git a/third_party/blink/renderer/core/frame/local_frame_client_impl.h b/third_party/blink/renderer/core/frame/local_frame_client_impl.h
- index 2d9517cb12b4debe28694f54bcaa0ad0af62a44a..09c9486bbbf789e9367fdbb3655f431f5a1ae199 100644
- --- a/third_party/blink/renderer/core/frame/local_frame_client_impl.h
- +++ b/third_party/blink/renderer/core/frame/local_frame_client_impl.h
- @@ -78,6 +78,8 @@ class CORE_EXPORT LocalFrameClientImpl final : public LocalFrameClient {
-
- void DidCreateScriptContext(v8::Local<v8::Context>,
- int32_t world_id) override;
- + void DidInstallConditionalFeatures(v8::Local<v8::Context>,
- + int32_t world_id) override;
- void WillReleaseScriptContext(v8::Local<v8::Context>,
- int32_t world_id) override;
-
- diff --git a/third_party/blink/renderer/core/loader/empty_clients.h b/third_party/blink/renderer/core/loader/empty_clients.h
- index 094de359d6831e656f0666732fb1c80f8f316fa7..65d2a6a279b2b4009b19494af54e194e8c9b626a 100644
- --- a/third_party/blink/renderer/core/loader/empty_clients.h
- +++ b/third_party/blink/renderer/core/loader/empty_clients.h
- @@ -356,6 +356,8 @@ class CORE_EXPORT EmptyLocalFrameClient : public LocalFrameClient {
-
- void DidCreateScriptContext(v8::Local<v8::Context>,
- int32_t world_id) override {}
- + void DidInstallConditionalFeatures(v8::Local<v8::Context>,
- + int32_t world_id) override {}
- void WillReleaseScriptContext(v8::Local<v8::Context>,
- int32_t world_id) override {}
- bool AllowScriptExtensions() override { return false; }
|