From 88cdf50b0a15a95aa9c3491052817ffa0c18596c Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 24 Nov 2025 16:26:45 -0800 Subject: [PATCH] 7159368: update PluginService API for sync GetPlugins Upstream removed async PluginService APIs: - GetPluginsAsync() removed, use synchronous GetPlugins() - RegisterInternalPlugin() now takes single argument (remove add_at_beginning) - RefreshPlugins() removed entirely Updated ElectronPluginInfoHostImpl to use synchronous plugin loading and simplified ElectronBrowserMainParts internal plugin registration. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7159368 Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7159328 Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7159056 --- shell/browser/electron_browser_main_parts.cc | 3 +-- .../browser/electron_plugin_info_host_impl.cc | 26 ++++--------------- .../browser/electron_plugin_info_host_impl.h | 16 ------------ 3 files changed, 6 insertions(+), 39 deletions(-) diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index 139237d3a0..30bdea86cd 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -370,10 +370,9 @@ void ElectronBrowserMainParts::PostCreateThreads() { // Separate the WebPluginInfo registration for these processes. std::vector plugins; auto* plugin_service = content::PluginService::GetInstance(); - plugin_service->RefreshPlugins(); GetInternalPlugins(&plugins); for (const auto& plugin : plugins) - plugin_service->RegisterInternalPlugin(plugin, true); + plugin_service->RegisterInternalPlugin(plugin); #endif } diff --git a/shell/browser/electron_plugin_info_host_impl.cc b/shell/browser/electron_plugin_info_host_impl.cc index 1c1e66beaf..87354896fd 100644 --- a/shell/browser/electron_plugin_info_host_impl.cc +++ b/shell/browser/electron_plugin_info_host_impl.cc @@ -4,16 +4,12 @@ #include "shell/browser/electron_plugin_info_host_impl.h" -#include -#include +#include #include -#include "base/functional/bind.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/plugin_service.h" -#include "content/public/common/content_constants.h" #include "url/gurl.h" -#include "url/origin.h" using content::PluginService; using content::WebPluginInfo; @@ -24,32 +20,20 @@ ElectronPluginInfoHostImpl::ElectronPluginInfoHostImpl() = default; ElectronPluginInfoHostImpl::~ElectronPluginInfoHostImpl() = default; -struct ElectronPluginInfoHostImpl::GetPluginInfo_Params { - GURL url; - url::Origin main_frame_origin; - std::string mime_type; -}; - void ElectronPluginInfoHostImpl::GetPluginInfo(const GURL& url, const url::Origin& origin, const std::string& mime_type, GetPluginInfoCallback callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - GetPluginInfo_Params params = {url, origin, mime_type}; - PluginService::GetInstance()->GetPluginsAsync( - base::BindOnce(&ElectronPluginInfoHostImpl::PluginsLoaded, - weak_factory_.GetWeakPtr(), params, std::move(callback))); -} -void ElectronPluginInfoHostImpl::PluginsLoaded( - const GetPluginInfo_Params& params, - GetPluginInfoCallback callback, - const std::vector& plugins) { + // Ensure plugins are loaded (synchronous, non-blocking on UI thread). + PluginService::GetInstance()->GetPlugins(); + mojom::PluginInfoPtr output = mojom::PluginInfo::New(); std::vector matching_plugins; std::vector mime_types; PluginService::GetInstance()->GetPluginInfoArray( - params.url, params.mime_type, &matching_plugins, &mime_types); + url, mime_type, &matching_plugins, &mime_types); if (!matching_plugins.empty()) { output->plugin = matching_plugins[0]; output->actual_mime_type = mime_types[0]; diff --git a/shell/browser/electron_plugin_info_host_impl.h b/shell/browser/electron_plugin_info_host_impl.h index d3d0c1a62c..6ef9d7af8c 100644 --- a/shell/browser/electron_plugin_info_host_impl.h +++ b/shell/browser/electron_plugin_info_host_impl.h @@ -6,16 +6,11 @@ #define SHELL_BROWSER_ELECTRON_PLUGIN_INFO_HOST_IMPL_H_ #include -#include #include "shell/common/plugin.mojom.h" class GURL; -namespace content { -struct WebPluginInfo; -} // namespace content - namespace url { class Origin; } @@ -25,8 +20,6 @@ namespace electron { // Implements ElectronPluginInfoHost interface. class ElectronPluginInfoHostImpl : public mojom::ElectronPluginInfoHost { public: - struct GetPluginInfo_Params; - ElectronPluginInfoHostImpl(); ElectronPluginInfoHostImpl(const ElectronPluginInfoHostImpl&) = delete; @@ -40,15 +33,6 @@ class ElectronPluginInfoHostImpl : public mojom::ElectronPluginInfoHost { const url::Origin& origin, const std::string& mime_type, GetPluginInfoCallback callback) override; - - private: - // |params| wraps the parameters passed to |OnGetPluginInfo|, because - // |base::Bind| doesn't support the required arity . - void PluginsLoaded(const GetPluginInfo_Params& params, - GetPluginInfoCallback callback, - const std::vector& plugins); - - base::WeakPtrFactory weak_factory_{this}; }; } // namespace electron