Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Nala]: Remove redundant overrides, to improve theming support. #25337

Merged
merged 10 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions browser/resources/settings/brave_overrides/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ import './site_settings_page.js'
import './sync_account_control.js'
import './sync_controls.js'
import './system_page.js'
import './theme_color_picker.js'
13 changes: 13 additions & 0 deletions browser/resources/settings/brave_overrides/theme_color_picker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) 2024 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

import { ThemeColorPickerElement } from '//resources/cr_components/theme_color_picker/theme_color_picker.js'

import { css } from '//resources/lit/v3_0/lit.rollup.js'
import { injectStyle } from '//resources/brave/lit_overriding.js'

injectStyle(ThemeColorPickerElement, css`
#defaultColor { display: none; }
`)
1 change: 1 addition & 0 deletions browser/resources/settings/sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ brave_settings_non_web_component_files = [
"brave_overrides/import_data_dialog.ts",
"brave_overrides/index.ts",
"brave_overrides/iron_icon.ts",
"brave_overrides/theme_color_picker.ts",
"brave_overrides/page_visibility.ts",
"brave_overrides/passwords_section.ts",
"brave_overrides/payments_section.ts",
Expand Down
6 changes: 6 additions & 0 deletions browser/themes/brave_theme_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ BraveThemeService::BraveThemeService(Profile* profile,

BraveThemeService::~BraveThemeService() = default;

// We replace the baseline theme with the grayscale theme - the default theme is
// blue ish while ours is gray.
bool BraveThemeService::GetIsGrayscale() const {
return ThemeService::GetIsGrayscale() || GetIsBaseline();
}

void BraveThemeService::SetBraveThemeEventRouterForTesting(
extensions::BraveThemeEventRouter* mock_router) {
brave_theme_event_router_.reset(mock_router);
Expand Down
3 changes: 3 additions & 0 deletions browser/themes/brave_theme_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class BraveThemeService : public ThemeService {
explicit BraveThemeService(Profile* profile, const ThemeHelper& theme_helper);
~BraveThemeService() override;

// ThemeService:
bool GetIsGrayscale() const override;

private:
FRIEND_TEST_ALL_PREFIXES(BraveThemeEventRouterBrowserTest, ThemeChangeTest);

Expand Down
37 changes: 3 additions & 34 deletions browser/themes/brave_theme_service_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,44 +209,13 @@ IN_PROC_BROWSER_TEST_F(BraveThemeServiceTest, SystemThemeChangeTest) {
}
}

IN_PROC_BROWSER_TEST_F(BraveThemeServiceTest, OmniboxColorTest) {
auto* browser_view = BrowserView::GetBrowserViewForBrowser(browser());

// Change to light.
dark_mode::SetBraveDarkModeType(
dark_mode::BraveDarkModeType::BRAVE_DARK_MODE_TYPE_LIGHT);
bool dark = false;
auto* color_provider = browser_view->GetColorProvider();
EXPECT_EQ(GetLocationBarBackground(dark, false /* incognito */),
color_provider->GetColor(kColorToolbarBackgroundSubtleEmphasis));
EXPECT_EQ(GetOmniboxResultBackground(kColorOmniboxResultsBackground, dark,
false /* incognito */),
color_provider->GetColor(kColorOmniboxResultsBackground));

// Change to dark.
dark_mode::SetBraveDarkModeType(
dark_mode::BraveDarkModeType::BRAVE_DARK_MODE_TYPE_DARK);
dark = true;
color_provider = browser_view->GetColorProvider();
EXPECT_EQ(GetLocationBarBackground(dark, false /* incognito */),
color_provider->GetColor(kColorToolbarBackgroundSubtleEmphasis));
// Check color is different on dark mode and incognito mode.
EXPECT_NE(GetLocationBarBackground(dark, true /* incognito */),
color_provider->GetColor(kColorToolbarBackgroundSubtleEmphasis));

EXPECT_EQ(GetOmniboxResultBackground(kColorOmniboxResultsBackground, dark,
false /* incognito */),
color_provider->GetColor(kColorOmniboxResultsBackground));
}

// Check some colors from color provider pipeline.
IN_PROC_BROWSER_TEST_F(BraveThemeServiceTest, ColorProviderTest) {
auto* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
auto* cp = browser_view->GetColorProvider();
SkColor frame_active_color = cp->GetColor(ui::kColorFrameActive);
SkColor nala_frame_color =
cp->GetColor(nala::kColorDesktopbrowserTabbarBackground);
EXPECT_EQ(nala_frame_color, frame_active_color);
SkColor material_frame_color = cp->GetColor(ui::kColorSysHeader);
EXPECT_EQ(material_frame_color, frame_active_color);

#if BUILDFLAG(ENABLE_EXTENSIONS)
// Check frame color is not ours when theme extension is installed.
Expand All @@ -261,7 +230,7 @@ IN_PROC_BROWSER_TEST_F(BraveThemeServiceTest, ColorProviderTest) {

cp = browser_view->GetColorProvider();
frame_active_color = cp->GetColor(ui::kColorFrameActive);
EXPECT_NE(nala_frame_color, frame_active_color);
EXPECT_NE(material_frame_color, frame_active_color);
#endif

auto* private_browser = CreateIncognitoBrowser();
Expand Down
Loading
Loading