Browse Source

Add patch that allows themes in Incognito windows (#1969)

* Add incognito theme patch

* Update incognito themes patch for 108

* Incognito tab background should be dark

Co-authored-by: Blaise <BlaiseD@GMail.com>
Lucas Bertolini 1 year ago
parent
commit
8a087f8ac2

+ 1 - 0
docs/flags.md

@@ -36,6 +36,7 @@ If a switch requires a value, you must specify it with an `=` sign; e.g. flag `-
   `--close-window-with-last-tab` | Determines whether a window should close once the last tab is closed. Only takes the value `never`.
   `--custom-ntp` | Allows setting a custom URL for the new tab page. Value can be internal (e.g. `about:blank`), external (e.g. `example.com`), or local (e.g. `file:///tmp/startpage.html`). This applies for incognito windows as well when not set to a `chrome://` internal page.
   `--disable-sharing-hub` | Disables the sharing hub button.
+  `--enable-incognito-themes` | Allows themes to change the appearance of Incognito windows.
   `--hide-extensions-menu` | Hides the extensions menu (the puzzle piece icon).
   `--hide-fullscreen-exit-ui` | Hides the "X" that appears when the mouse cursor is moved towards the top of the window in fullscreen mode.
   `--hide-sidepanel-button` | Hides the SidePanel Button.

+ 44 - 0
patches/extra/ungoogled-chromium/add-flag-for-incognito-themes.patch

@@ -0,0 +1,44 @@
+--- a/chrome/browser/ui/views/frame/browser_frame.cc
++++ b/chrome/browser/ui/views/frame/browser_frame.cc
+@@ -252,6 +252,7 @@ BrowserFrame::GetCustomTheme() const {
+   Browser* browser = browser_view_->browser();
+   // If this is an incognito profile, there should never be a custom theme.
+   if (browser->profile()->IsIncognitoProfile())
++   if (!base::CommandLine::ForCurrentProcess()->HasSwitch("enable-incognito-themes"))
+     return nullptr;
+   auto* app_controller = browser->app_controller();
+   // Ignore the system theme for web apps with window-controls-overlay as the
+@@ -385,7 +386,8 @@ void BrowserFrame::SelectNativeTheme() {
+   // Select between regular, dark and Linux toolkit themes.
+   ui::NativeTheme* native_theme = ui::NativeTheme::GetInstanceForNativeUi();
+ 
+-  if (browser_view_->browser()->profile()->IsIncognitoProfile()) {
++  if (browser_view_->browser()->profile()->IsIncognitoProfile() &&
++      !base::CommandLine::ForCurrentProcess()->HasSwitch("enable-incognito-themes")) {
+     // No matter if we are using the default theme or not we always use the dark
+     // ui instance.
+     SetNativeTheme(ui::NativeTheme::GetInstanceForDarkUI());
+--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
++++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+@@ -432,7 +432,9 @@ void NTPResourceCache::CreateNewTabIncog
+       profile_->GetPrefs()->GetString(prefs::kCurrentThemeID);
+ 
+   // Colors.
+-  const ui::ColorProvider& cp = web_contents->GetColorProvider();
++  auto key = native_theme->GetColorProviderKey(nullptr);
++  key.color_mode = ui::ColorProviderManager::ColorMode::kDark;
++  const ui::ColorProvider& cp = *ui::ColorProviderManager::Get().GetColorProviderFor(key);
+   substitutions["colorBackground"] = color_utils::SkColorToRgbaString(
+       GetThemeColor(native_theme, cp, kColorNewTabPageBackground));
+   substitutions["backgroundPosition"] = GetNewTabBackgroundPositionCSS(tp);
+--- a/chrome/browser/ungoogled_flag_entries.h
++++ b/chrome/browser/ungoogled_flag_entries.h
+@@ -120,4 +120,8 @@
+      "Hide Fullscreen Exit UI",
+      "Hides the \"X\" that appears when the mouse cursor is moved towards the top of the window in fullscreen mode. Additionally, this hides the \"Press F11 to exit full screen\" popup. ungoogled-chromium flag.",
+      kOsLinux | kOsWin, SINGLE_VALUE_TYPE("hide-fullscreen-exit-ui")},
++    {"enable-incognito-themes",
++     "Enable themes in Incognito mode",
++     "Allows themes to override Google's built-in Incognito theming. ungoogled-chromium flag.",
++     kOsDesktop, SINGLE_VALUE_TYPE("enable-incognito-themes")},
+ #endif  // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_

+ 1 - 0
patches/series

@@ -102,3 +102,4 @@ extra/ungoogled-chromium/add-flag-to-hide-side-panel-button.patch
 extra/ungoogled-chromium/add-flag-for-disabling-link-drag.patch
 extra/ungoogled-chromium/add-flag-to-hide-extensions-menu.patch
 extra/ungoogled-chromium/add-flag-to-hide-fullscreen-exit-ui.patch
+extra/ungoogled-chromium/add-flag-for-incognito-themes.patch