cef/patch/patches/webkit_plugin_info_2015.patch

220 lines
10 KiB
Diff

diff --git third_party/blink/public/mojom/plugins/plugin_registry.mojom third_party/blink/public/mojom/plugins/plugin_registry.mojom
index 92e9cb865204..4628c56882b4 100644
--- third_party/blink/public/mojom/plugins/plugin_registry.mojom
+++ third_party/blink/public/mojom/plugins/plugin_registry.mojom
@@ -34,5 +34,5 @@ interface PluginRegistry {
//
// TODO(crbug.com/850278): We shouldn't rely on the renderer to tell us the main frame origin.
[Sync]
- GetPlugins(bool refresh, url.mojom.Origin main_frame_origin) => (array<PluginInfo> plugins);
+ GetPlugins(bool refresh, bool is_main_frame, url.mojom.Origin main_frame_origin) => (array<PluginInfo> plugins);
};
diff --git third_party/blink/public/platform/platform.h third_party/blink/public/platform/platform.h
index 3e8fae916125..30451122e4a2 100644
--- third_party/blink/public/platform/platform.h
+++ third_party/blink/public/platform/platform.h
@@ -745,6 +745,11 @@ class BLINK_PLATFORM_EXPORT Platform {
// runs during Chromium's build step).
virtual bool IsTakingV8ContextSnapshot() { return false; }
+ // DevTools ------------------------------------------------------------
+
+ virtual void DevToolsAgentAttached() {}
+ virtual void DevToolsAgentDetached() {}
+
protected:
WebThread* main_thread_;
diff --git third_party/blink/renderer/core/dom/dom_implementation.cc third_party/blink/renderer/core/dom/dom_implementation.cc
index c360933eb10f..6295f9d675f7 100644
--- third_party/blink/renderer/core/dom/dom_implementation.cc
+++ third_party/blink/renderer/core/dom/dom_implementation.cc
@@ -243,10 +243,11 @@ Document* DOMImplementation::createDocument(const String& type,
if (init.GetFrame()->IsMainFrame()) {
scoped_refptr<const SecurityOrigin> origin =
SecurityOrigin::Create(init.Url());
- plugin_data = init.GetFrame()->GetPage()->GetPluginData(origin.get());
+ plugin_data = init.GetFrame()->GetPage()->GetPluginData(true,
+ origin.get());
} else {
plugin_data =
- init.GetFrame()->GetPage()->GetPluginData(init.GetFrame()
+ init.GetFrame()->GetPage()->GetPluginData(false, init.GetFrame()
->Tree()
.Top()
.GetSecurityContext()
diff --git third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.cc third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.cc
index 7a7f6e0d88e9..dfa7e007a9fa 100644
--- third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.cc
+++ third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.cc
@@ -325,6 +325,8 @@ WebDevToolsAgentImpl::Session::Session(
&WebDevToolsAgentImpl::Session::Detach, WrapWeakPersistent(this)));
InitializeInspectorSession(std::move(reattach_session_state));
+
+ Platform::Current()->DevToolsAgentAttached();
}
WebDevToolsAgentImpl::Session::~Session() {
@@ -349,6 +351,7 @@ void WebDevToolsAgentImpl::Session::Detach() {
io_session_->DeleteSoon();
io_session_ = nullptr;
inspector_session_->Dispose();
+ Platform::Current()->DevToolsAgentDetached();
}
void WebDevToolsAgentImpl::Session::SendProtocolResponse(
diff --git third_party/blink/renderer/core/frame/local_frame.cc third_party/blink/renderer/core/frame/local_frame.cc
index a7ddc156c2b1..e31496827664 100644
--- third_party/blink/renderer/core/frame/local_frame.cc
+++ third_party/blink/renderer/core/frame/local_frame.cc
@@ -1221,7 +1221,7 @@ FrameResourceCoordinator* LocalFrame::GetFrameResourceCoordinator() {
PluginData* LocalFrame::GetPluginData() const {
if (!Loader().AllowPlugins(kNotAboutToInstantiatePlugin))
return nullptr;
- return GetPage()->GetPluginData(
+ return GetPage()->GetPluginData(IsMainFrame(),
Tree().Top().GetSecurityContext()->GetSecurityOrigin());
}
diff --git third_party/blink/renderer/core/page/page.cc third_party/blink/renderer/core/page/page.cc
index af94b52a5b6e..f5b91fefcda0 100644
--- third_party/blink/renderer/core/page/page.cc
+++ third_party/blink/renderer/core/page/page.cc
@@ -171,7 +171,8 @@ Page::Page(PageClients& page_clients)
overscroll_controller_(
OverscrollController::Create(GetVisualViewport(), GetChromeClient())),
link_highlights_(LinkHighlights::Create(*this)),
- plugin_data_(nullptr),
+ plugin_data_main_frame_(nullptr),
+ plugin_data_sub_frame_(nullptr),
// TODO(pdr): Initialize |validation_message_client_| lazily.
validation_message_client_(ValidationMessageClientImpl::Create(*this)),
opened_by_dom_(false),
@@ -332,21 +333,40 @@ void Page::InitialStyleChanged() {
}
}
-PluginData* Page::GetPluginData(const SecurityOrigin* main_frame_origin) {
- if (!plugin_data_)
- plugin_data_ = PluginData::Create();
+PluginData* Page::GetPluginData(bool is_main_frame,
+ const SecurityOrigin* main_frame_origin) {
+ if (is_main_frame) {
+ if (!plugin_data_main_frame_)
+ plugin_data_main_frame_ = PluginData::Create();
- if (!plugin_data_->Origin() ||
- !main_frame_origin->IsSameSchemeHostPort(plugin_data_->Origin()))
- plugin_data_->UpdatePluginList(main_frame_origin);
+ if (!plugin_data_main_frame_->Origin() ||
+ !main_frame_origin->IsSameSchemeHostPort(
+ plugin_data_main_frame_->Origin())) {
+ plugin_data_main_frame_->UpdatePluginList(true, main_frame_origin);
+ }
+
+ return plugin_data_main_frame_.Get();
+ } else {
+ if (!plugin_data_sub_frame_)
+ plugin_data_sub_frame_ = PluginData::Create();
- return plugin_data_.Get();
+ if (!plugin_data_sub_frame_->Origin() ||
+ !main_frame_origin->IsSameSchemeHostPort(
+ plugin_data_sub_frame_->Origin())) {
+ plugin_data_sub_frame_->UpdatePluginList(false, main_frame_origin);
+ }
+
+ return plugin_data_sub_frame_.Get();
+ }
}
void Page::ResetPluginData() {
for (Page* page : AllPages()) {
- if (page->plugin_data_) {
- page->plugin_data_->ResetPluginData();
+ if (page->plugin_data_main_frame_ || page->plugin_data_sub_frame_) {
+ if (page->plugin_data_main_frame_)
+ page->plugin_data_main_frame_->ResetPluginData();
+ if (page->plugin_data_sub_frame_)
+ page->plugin_data_sub_frame_->ResetPluginData();
page->NotifyPluginsChanged();
}
}
@@ -736,7 +756,8 @@ void Page::Trace(blink::Visitor* visitor) {
visitor->Trace(overscroll_controller_);
visitor->Trace(link_highlights_);
visitor->Trace(main_frame_);
- visitor->Trace(plugin_data_);
+ visitor->Trace(plugin_data_main_frame_);
+ visitor->Trace(plugin_data_sub_frame_);
visitor->Trace(validation_message_client_);
visitor->Trace(plugins_changed_observers_);
visitor->Trace(next_related_page_);
diff --git third_party/blink/renderer/core/page/page.h third_party/blink/renderer/core/page/page.h
index c9ecb33e153f..6ff8e8dc6b67 100644
--- third_party/blink/renderer/core/page/page.h
+++ third_party/blink/renderer/core/page/page.h
@@ -136,7 +136,8 @@ class CORE_EXPORT Page final : public GarbageCollectedFinalized<Page>,
ViewportDescription GetViewportDescription() const;
// Returns the plugin data associated with |main_frame_origin|.
- PluginData* GetPluginData(const SecurityOrigin* main_frame_origin);
+ PluginData* GetPluginData(bool is_main_frame,
+ const SecurityOrigin* main_frame_origin);
// Resets the plugin data for all pages in the renderer process and notifies
// PluginsChangedObservers.
@@ -367,7 +368,8 @@ class CORE_EXPORT Page final : public GarbageCollectedFinalized<Page>,
const Member<OverscrollController> overscroll_controller_;
const Member<LinkHighlights> link_highlights_;
- Member<PluginData> plugin_data_;
+ Member<PluginData> plugin_data_main_frame_;
+ Member<PluginData> plugin_data_sub_frame_;
Member<ValidationMessageClient> validation_message_client_;
diff --git third_party/blink/renderer/platform/plugins/plugin_data.cc third_party/blink/renderer/platform/plugins/plugin_data.cc
index 02d54d5f2dbf..0b2b11e601c6 100644
--- third_party/blink/renderer/platform/plugins/plugin_data.cc
+++ third_party/blink/renderer/platform/plugins/plugin_data.cc
@@ -88,10 +88,12 @@ void PluginData::RefreshBrowserSidePluginCache() {
Platform::Current()->GetInterfaceProvider()->GetInterface(
mojo::MakeRequest(&registry));
Vector<mojom::blink::PluginInfoPtr> plugins;
- registry->GetPlugins(true, SecurityOrigin::CreateUniqueOpaque(), &plugins);
+ registry->GetPlugins(true, true, SecurityOrigin::CreateUniqueOpaque(),
+ &plugins);
}
-void PluginData::UpdatePluginList(const SecurityOrigin* main_frame_origin) {
+void PluginData::UpdatePluginList(bool is_main_frame,
+ const SecurityOrigin* main_frame_origin) {
ResetPluginData();
main_frame_origin_ = main_frame_origin;
@@ -106,7 +108,7 @@ void PluginData::UpdatePluginList(const SecurityOrigin* main_frame_origin) {
Platform::Current()->GetInterfaceProvider()->GetInterface(
mojo::MakeRequest(&registry));
Vector<mojom::blink::PluginInfoPtr> plugins;
- registry->GetPlugins(false, legacy_origin, &plugins);
+ registry->GetPlugins(false, is_main_frame, legacy_origin, &plugins);
for (const auto& plugin : plugins) {
auto* plugin_info =
new PluginInfo(plugin->name, FilePathToWebString(plugin->filename),
diff --git third_party/blink/renderer/platform/plugins/plugin_data.h third_party/blink/renderer/platform/plugins/plugin_data.h
index f1a78d3e0d5f..f6403f5ac018 100644
--- third_party/blink/renderer/platform/plugins/plugin_data.h
+++ third_party/blink/renderer/platform/plugins/plugin_data.h
@@ -101,7 +101,8 @@ class PLATFORM_EXPORT PluginData final
const HeapVector<Member<PluginInfo>>& Plugins() const { return plugins_; }
const HeapVector<Member<MimeClassInfo>>& Mimes() const { return mimes_; }
const SecurityOrigin* Origin() const { return main_frame_origin_.get(); }
- void UpdatePluginList(const SecurityOrigin* main_frame_origin);
+ void UpdatePluginList(bool is_main_frame,
+ const SecurityOrigin* main_frame_origin);
void ResetPluginData();
bool SupportsMimeType(const String& mime_type) const;