fix: don't propagate GDK_BACKEND to subprocs (#28898)

This commit is contained in:
Shelley Vohr 2021-06-08 16:10:27 +02:00 committed by GitHub
parent b27c5b94f7
commit 7b169c2884
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 0 deletions

View file

@ -155,6 +155,7 @@ std::u16string MediaStringProvider(media::MessageId id) {
}
#if defined(OS_LINUX)
void OverrideLinuxAppDataPath() {
base::FilePath path;
if (base::PathService::Get(DIR_APP_DATA, &path))
@ -375,8 +376,24 @@ void ElectronBrowserMainParts::PostDestroyThreads() {
fake_browser_process_->PostDestroyThreads();
}
#if defined(OS_LINUX)
// static
base::Optional<std::string>& ElectronBrowserMainParts::GetGDKBackend() {
static base::Optional<std::string> gdk_backend;
return gdk_backend;
}
#endif
void ElectronBrowserMainParts::ToolkitInitialized() {
#if defined(OS_LINUX)
// This is set by Chromium here:
// https://chromium-review.googlesource.com/c/chromium/src/+/2586184
// and can detrimentally affect external app behaviors, so we want to
// check if the user has set it so we can use it later.
std::string backend;
if (base::Environment::Create()->GetVar("GDK_BACKEND", &backend))
GetGDKBackend().reset(backend);
auto linux_ui = BuildGtkUi();
linux_ui->Initialize();

View file

@ -88,6 +88,11 @@ class ElectronBrowserMainParts : public content::BrowserMainParts {
Browser* browser() { return browser_.get(); }
BrowserProcessImpl* browser_process() { return fake_browser_process_.get(); }
#if defined(OS_LINUX)
// Used by platform_util to set GDK_BACKEND.
static base::Optional<std::string>& GetGDKBackend();
#endif
protected:
// content::BrowserMainParts:
int PreEarlyInitialization() override;