From 52326a5ec76cb3f3a27646f6d73796100198e077 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 10 Jul 2024 15:35:17 +0200 Subject: [PATCH] refactor: run Windows `SelectFileDialog` out of process (#42826) refactor: run Windows SelectFileDialog out of process --- chromium_src/BUILD.gn | 5 +++++ shell/browser/electron_browser_main_parts.cc | 6 ++++++ shell/utility/electron_content_utility_client.cc | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/chromium_src/BUILD.gn b/chromium_src/BUILD.gn index 9b50f1fbdea..37bafeb8b8c 100644 --- a/chromium_src/BUILD.gn +++ b/chromium_src/BUILD.gn @@ -152,9 +152,13 @@ static_library("chrome") { "//chrome/browser/ui/frame/window_frame_util.h", "//chrome/browser/win/chrome_process_finder.cc", "//chrome/browser/win/chrome_process_finder.h", + "//chrome/browser/win/chrome_select_file_dialog_factory.cc", + "//chrome/browser/win/chrome_select_file_dialog_factory.h", "//chrome/browser/win/titlebar_config.cc", "//chrome/browser/win/titlebar_config.h", "//chrome/browser/win/titlebar_config.h", + "//chrome/browser/win/util_win_service.cc", + "//chrome/browser/win/util_win_service.h", "//chrome/child/v8_crashpad_support_win.cc", "//chrome/child/v8_crashpad_support_win.h", ] @@ -233,6 +237,7 @@ static_library("chrome") { "//chrome/services/util_win:lib", "//components/webapps/common:mojo_bindings", ] + deps += [ "//chrome/services/util_win/public/mojom" ] } if (is_mac) { diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index 727c489e2bf..546368be903 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -95,6 +95,7 @@ #endif #if BUILDFLAG(IS_WIN) +#include "chrome/browser/win/chrome_select_file_dialog_factory.h" #include "ui/base/l10n/l10n_util_win.h" #include "ui/gfx/system_fonts_win.h" #include "ui/strings/grit/app_locale_settings.h" @@ -483,6 +484,11 @@ int ElectronBrowserMainParts::PreMainMessageLoopRun() { fake_browser_process_->PreMainMessageLoopRun(); +#if BUILDFLAG(IS_WIN) + ui::SelectFileDialog::SetFactory( + std::make_unique()); +#endif + return GetExitCode(); } diff --git a/shell/utility/electron_content_utility_client.cc b/shell/utility/electron_content_utility_client.cc index 83c385b2d6c..85b3c7bcef8 100644 --- a/shell/utility/electron_content_utility_client.cc +++ b/shell/utility/electron_content_utility_client.cc @@ -20,7 +20,9 @@ #if BUILDFLAG(IS_WIN) #include "chrome/services/util_win/public/mojom/util_read_icon.mojom.h" +#include "chrome/services/util_win/public/mojom/util_win.mojom.h" #include "chrome/services/util_win/util_read_icon.h" +#include "chrome/services/util_win/util_win_impl.h" #endif // BUILDFLAG(IS_WIN) #if BUILDFLAG(ENABLE_PRINTING) @@ -55,6 +57,9 @@ auto RunWindowsIconReader( mojo::PendingReceiver receiver) { return std::make_unique(std::move(receiver)); } +auto RunWindowsUtility(mojo::PendingReceiver receiver) { + return std::make_unique(std::move(receiver)); +} #endif #if BUILDFLAG(ENABLE_PRINTING) @@ -109,6 +114,7 @@ void ElectronContentUtilityClient::RegisterMainThreadServices( mojo::ServiceFactory& services) { #if BUILDFLAG(IS_WIN) services.Add(RunWindowsIconReader); + services.Add(RunWindowsUtility); #endif #if BUILDFLAG(ENABLE_PRINTING)