Skip to content

Commit

Permalink
fix: add support for --ozone-platform-hint flag on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
vially committed Jul 17, 2022
1 parent f1746c8 commit ab3cc3a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
9 changes: 8 additions & 1 deletion chromium_src/BUILD.gn
Expand Up @@ -21,6 +21,7 @@ static_library("chrome") {
"//chrome/browser/browser_features.h",
"//chrome/browser/browser_process.cc",
"//chrome/browser/browser_process.h",
"//chrome/browser/chrome_browser_main_extra_parts.h",
"//chrome/browser/devtools/devtools_contents_resizing_strategy.cc",
"//chrome/browser/devtools/devtools_contents_resizing_strategy.h",
"//chrome/browser/devtools/devtools_embedder_message_dispatcher.cc",
Expand Down Expand Up @@ -117,7 +118,13 @@ static_library("chrome") {
}

if (is_linux) {
sources += [ "//chrome/browser/media/webrtc/window_icon_util_ozone.cc" ]
sources += [
"//chrome/browser/chrome_browser_main_extra_parts_linux.cc",
"//chrome/browser/chrome_browser_main_extra_parts_linux.h",
"//chrome/browser/chrome_browser_main_extra_parts_ozone.cc",
"//chrome/browser/chrome_browser_main_extra_parts_ozone.h",
"//chrome/browser/media/webrtc/window_icon_util_ozone.cc",
]
}

if (use_aura) {
Expand Down
1 change: 1 addition & 0 deletions filenames.gni
Expand Up @@ -25,6 +25,7 @@ filenames = {
"shell/browser/browser_linux.cc",
"shell/browser/lib/power_observer_linux.cc",
"shell/browser/lib/power_observer_linux.h",
"shell/browser/lifetime/application_lifetime_linux.cc",
"shell/browser/linux/unity_service.cc",
"shell/browser/linux/unity_service.h",
"shell/browser/notifications/linux/libnotify_notification.cc",
Expand Down
16 changes: 9 additions & 7 deletions shell/browser/electron_browser_main_parts.cc
Expand Up @@ -68,6 +68,7 @@
#if BUILDFLAG(IS_LINUX)
#include "base/environment.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/chrome_browser_main_extra_parts_linux.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/dbus/dbus_bluez_manager_wrapper_linux.h"
#include "electron/electron_gtk_stubs.h"
Expand Down Expand Up @@ -180,7 +181,11 @@ class DarkThemeObserver : public ui::NativeThemeObserver {
ElectronBrowserMainParts* ElectronBrowserMainParts::self_ = nullptr;

ElectronBrowserMainParts::ElectronBrowserMainParts()
: fake_browser_process_(std::make_unique<BrowserProcessImpl>()),
:
#if BUILDFLAG(IS_LINUX)
main_extra_part_(std::make_unique<ChromeBrowserMainExtraPartsLinux>()),
#endif
fake_browser_process_(std::make_unique<BrowserProcessImpl>()),
browser_(std::make_unique<Browser>()),
node_bindings_(
NodeBindings::Create(NodeBindings::BrowserEnvironment::kBrowser)),
Expand Down Expand Up @@ -217,7 +222,7 @@ int ElectronBrowserMainParts::PreEarlyInitialization() {
HandleSIGCHLD();
#endif
#if BUILDFLAG(IS_LINUX)
ui::OzonePlatform::PreEarlyInitialization();
main_extra_part_->PreEarlyInitialization();
#endif
#if BUILDFLAG(IS_MAC)
screen_ = std::make_unique<display::ScopedNativeScreen>();
Expand Down Expand Up @@ -476,10 +481,7 @@ void ElectronBrowserMainParts::WillRunMainMessageLoop(

void ElectronBrowserMainParts::PostCreateMainMessageLoop() {
#if BUILDFLAG(IS_LINUX)
auto shutdown_cb =
base::BindOnce(base::RunLoop::QuitCurrentWhenIdleClosureDeprecated());
ui::OzonePlatform::GetInstance()->PostCreateMainMessageLoop(
std::move(shutdown_cb));
main_extra_part_->PostCreateMainMessageLoop();
bluez::DBusBluezManagerWrapperLinux::Initialize();

// Set up crypt config. This needs to be done before anything starts the
Expand Down Expand Up @@ -541,7 +543,7 @@ void ElectronBrowserMainParts::PostMainMessageLoopRun() {
content::DevToolsAgentHost::StopRemoteDebuggingPipeHandler();

#if BUILDFLAG(IS_LINUX)
ui::OzonePlatform::GetInstance()->PostMainMessageLoopRun();
main_extra_part_->PostMainMessageLoopRun();
#endif
}

Expand Down
6 changes: 6 additions & 0 deletions shell/browser/electron_browser_main_parts.h
Expand Up @@ -19,6 +19,10 @@
#include "ui/display/screen.h"
#include "ui/views/layout/layout_provider.h"

#if BUILDFLAG(IS_LINUX)
#include "chrome/browser/chrome_browser_main_extra_parts.h"
#endif

class BrowserProcessImpl;
class IconManager;

Expand Down Expand Up @@ -142,6 +146,8 @@ class ElectronBrowserMainParts : public content::BrowserMainParts {
#if BUILDFLAG(IS_LINUX)
// Used to notify the native theme of changes to dark mode.
std::unique_ptr<DarkThemeObserver> dark_theme_observer_;

std::unique_ptr<ChromeBrowserMainExtraParts> main_extra_part_;
#endif

std::unique_ptr<views::LayoutProvider> layout_provider_;
Expand Down
11 changes: 11 additions & 0 deletions shell/browser/lifetime/application_lifetime_linux.cc
@@ -0,0 +1,11 @@
// Copyright (c) 2022 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include "base/run_loop.h"

namespace chrome {
void SessionEnding() {
base::RunLoop::QuitCurrentWhenIdleDeprecated();
}
} // namespace chrome

0 comments on commit ab3cc3a

Please sign in to comment.