Skip to content

Commit

Permalink
[M115 Merge][color] Avoid using the GTK NativeTheme for Incognito bro…
Browse files Browse the repository at this point in the history
…wsers

In crrev.com/c/4542720 we switched from using the dark NativeTheme
instance to falling back to the Widget's ColorMode.

However linux-specific GTK / QT native themes are still forcefully
set if present. This causes light-mode linux themes to render the
incognito browser in a light theme.

This CL forces the native ui instance if running in incognito mode.
With this change incognito mode will fall back to respecting the
Widget's ColorMode, regardless of system theme.

(cherry picked from commit 103c934)

Bug: 1448785
Change-Id: I9c4ebbf8cf24ddd360dc70ac863c91a514b7a1c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4567568
Reviewed-by: Thomas Lukaszewicz <tluk@chromium.org>
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Allen Bauer <kylixrd@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1149404}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4573726
Owners-Override: Prudhvikumar Bommana <pbommana@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Prudhvikumar Bommana <pbommana@google.com>
Cr-Commit-Position: refs/branch-heads/5790@{#135}
Cr-Branched-From: 1d71a33-refs/heads/main@{#1148114}
  • Loading branch information
Thomas Lukaszewicz authored and Chromium LUCI CQ committed May 30, 2023
1 parent ead2543 commit 51b308b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions chrome/browser/ui/views/frame/browser_frame.cc
Expand Up @@ -483,6 +483,13 @@ void BrowserFrame::SelectNativeTheme() {
// Select between regular and Linux toolkit themes.
ui::NativeTheme* native_theme = ui::NativeTheme::GetInstanceForNativeUi();

// Use the regular NativeTheme instance if running incognito mode, regardless
// of system theme (gtk, qt etc).
if (IsIncognitoBrowser()) {
SetNativeTheme(native_theme);
return;
}

#if BUILDFLAG(IS_LINUX)
const auto* linux_ui_theme =
ui::LinuxUiTheme::GetForWindow(GetNativeWindow());
Expand Down

0 comments on commit 51b308b

Please sign in to comment.