From 62309ca9be85f9b225fca5ad9448c832607f7072 Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Wed, 21 Oct 2020 17:54:23 +0900 Subject: [PATCH 01/14] Change toolbar/tab color of dark theme, private and tor window --- browser/themes/brave_theme_helper.cc | 10 ++---- browser/themes/brave_theme_helper.h | 6 ++-- browser/themes/brave_theme_service.cc | 12 +++++-- browser/themes/theme_properties.cc | 46 ++++++++++++++++++++++++--- browser/themes/theme_properties.h | 3 +- 5 files changed, 59 insertions(+), 18 deletions(-) diff --git a/browser/themes/brave_theme_helper.cc b/browser/themes/brave_theme_helper.cc index 10f30f01f190..62a60f8bd7f4 100644 --- a/browser/themes/brave_theme_helper.cc +++ b/browser/themes/brave_theme_helper.cc @@ -77,10 +77,6 @@ bool IsUsingSystemTheme(const CustomThemeSupplier* theme_supplier) { BraveThemeHelper::~BraveThemeHelper() = default; -void BraveThemeHelper::SetTorOrGuest() { - is_tor_or_guest_ = true; -} - SkColor BraveThemeHelper::GetDefaultColor( int id, bool incognito, @@ -98,13 +94,13 @@ SkColor BraveThemeHelper::GetDefaultColor( return ThemeHelper::GetDefaultColor(id, incognito, theme_supplier); // Brave Tor profiles are always 'incognito' (for now) - if (!incognito && is_tor_or_guest_) { + if (!incognito && (is_tor_ || is_guest_)) { incognito = true; } const dark_mode::BraveDarkModeType type = dark_mode::GetActiveBraveDarkModeType(); const base::Optional braveColor = - MaybeGetDefaultColorForBraveUi(id, incognito, type); + MaybeGetDefaultColorForBraveUi(id, incognito, is_tor_, type); if (braveColor) { return braveColor.value(); } @@ -136,7 +132,7 @@ base::Optional BraveThemeHelper::GetOmniboxColor( const bool dark = dark_mode::GetActiveBraveDarkModeType() == dark_mode::BraveDarkModeType::BRAVE_DARK_MODE_TYPE_DARK; - incognito = incognito || is_tor_or_guest_; + incognito = incognito || is_tor_ || is_guest_; // TODO(petemill): Get colors from color-pallete and theme constants switch (id) { case ThemeProperties::COLOR_OMNIBOX_BACKGROUND: { diff --git a/browser/themes/brave_theme_helper.h b/browser/themes/brave_theme_helper.h index 92d0cd1362d0..ee0aa4b87e7a 100644 --- a/browser/themes/brave_theme_helper.h +++ b/browser/themes/brave_theme_helper.h @@ -19,7 +19,8 @@ class BraveThemeHelper : public ThemeHelper { BraveThemeHelper(const BraveThemeHelper&) = delete; BraveThemeHelper& operator=(const BraveThemeHelper&) = delete; - void SetTorOrGuest(); + void set_is_tor() { is_tor_ = true; } + void set_is_guest() { is_guest_ = true; } protected: // ThemeHelper overrides: @@ -35,7 +36,8 @@ class BraveThemeHelper : public ThemeHelper { bool* has_custom_color) const override; private: - bool is_tor_or_guest_ = false; + bool is_tor_ = false; + bool is_guest_ = false; }; #endif // BRAVE_BROWSER_THEMES_BRAVE_THEME_HELPER_H_ diff --git a/browser/themes/brave_theme_service.cc b/browser/themes/brave_theme_service.cc index 2545d0a974e8..1bf23c09aea6 100644 --- a/browser/themes/brave_theme_service.cc +++ b/browser/themes/brave_theme_service.cc @@ -22,12 +22,18 @@ const ThemeHelper& GetBraveThemeHelper(Profile* profile) { using BraveThemeHelper = BraveThemeHelperWin; #endif // Because the helper is created as a NoDestructor static, we need separate - // instances for regular vs tor/guest profiles. - if (profile->IsTor() || brave::IsGuestProfile(profile)) { + // instances for regular, tor and guest profiles. + if (profile->IsTor()) { static base::NoDestructor> dark_theme_helper( std::make_unique()); (static_cast(dark_theme_helper.get()->get())) - ->SetTorOrGuest(); + ->set_is_tor(); + return **dark_theme_helper; + } else if (brave::IsGuestProfile(profile)) { + static base::NoDestructor> dark_theme_helper( + std::make_unique()); + (static_cast(dark_theme_helper.get()->get())) + ->set_is_guest(); return **dark_theme_helper; } else { static base::NoDestructor> theme_helper( diff --git a/browser/themes/theme_properties.cc b/browser/themes/theme_properties.cc index 9e5e6147dd72..3ff7928acdf6 100644 --- a/browser/themes/theme_properties.cc +++ b/browser/themes/theme_properties.cc @@ -51,8 +51,8 @@ base::Optional MaybeGetDefaultColorForBraveLightUi(int id) { } } -const SkColor kDarkToolbar = SkColorSetRGB(0x39, 0x39, 0x39); -const SkColor kDarkFrame = SkColorSetRGB(0x22, 0x22, 0x22); +const SkColor kDarkToolbar = SkColorSetRGB(0x30, 0x34, 0x43); +const SkColor kDarkFrame = SkColorSetRGB(0x0C, 0x0C, 0x17); const SkColor kDarkToolbarIcon = SkColorSetRGB(0xed, 0xed, 0xed); base::Optional MaybeGetDefaultColorForBraveDarkUi(int id) { @@ -93,8 +93,8 @@ base::Optional MaybeGetDefaultColorForBraveDarkUi(int id) { } } -const SkColor kPrivateFrame = SkColorSetRGB(0x1b, 0x0e, 0x2c); -const SkColor kPrivateToolbar = SkColorSetRGB(0x3d, 0x28, 0x41); +const SkColor kPrivateFrame = SkColorSetRGB(0x19, 0x16, 0x2F); +const SkColor kPrivateToolbar = SkColorSetRGB(0x32, 0x25, 0x60); base::Optional MaybeGetDefaultColorForPrivateUi(int id) { switch (id) { @@ -133,6 +133,37 @@ base::Optional MaybeGetDefaultColorForPrivateUi(int id) { } } +const SkColor kPrivateTorFrame = SkColorSetRGB(0x19, 0x0E, 0x2A); +const SkColor kPrivateTorToolbar = SkColorSetRGB(0x49, 0x2D, 0x58); +base::Optional MaybeGetDefaultColorForPrivateTorUi(int id) { + switch (id) { + // Applies when the window is active, tabs and also tab bar everywhere + // except active tab + case ThemeProperties::COLOR_FRAME_ACTIVE: + case ThemeProperties::COLOR_TAB_BACKGROUND_INACTIVE_FRAME_ACTIVE: + return kPrivateTorFrame; + // Window when the window is innactive, tabs and also tab bar everywhere + // except active tab + case ThemeProperties::COLOR_FRAME_INACTIVE: + case ThemeProperties::COLOR_TAB_BACKGROUND_INACTIVE_FRAME_INACTIVE: + return color_utils::HSLShift(kPrivateTorFrame, { -1, -1, 0.55 }); + // Active tab and also the URL toolbar + // Parts of this color show up as you hover over innactive tabs too + case ThemeProperties::COLOR_TOOLBAR: + case ThemeProperties::COLOR_TOOLBAR_CONTENT_AREA_SEPARATOR: + case ThemeProperties::COLOR_TAB_BACKGROUND_ACTIVE_FRAME_ACTIVE: + case ThemeProperties::COLOR_TAB_BACKGROUND_ACTIVE_FRAME_INACTIVE: + return kPrivateTorToolbar; + case ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE: + return color_utils::AlphaBlend(kDarkToolbarIcon, + kPrivateTorToolbar, + 0.3f); + // The rest is covered by a private value + default: + return MaybeGetDefaultColorForPrivateUi(id); + } +} + } // namespace namespace BraveThemeProperties { @@ -145,7 +176,8 @@ bool IsBraveThemeProperties(int id) { } // namespace BraveThemeProperties // Returns a |nullopt| if the UI color is not handled by Brave. base::Optional MaybeGetDefaultColorForBraveUi( - int id, bool incognito, dark_mode::BraveDarkModeType dark_mode) { + int id, bool incognito, + bool is_tor, dark_mode::BraveDarkModeType dark_mode) { // Consistent (and stable) values across all themes switch (id) { case ThemeProperties::COLOR_TAB_THROBBER_SPINNING: @@ -154,6 +186,10 @@ base::Optional MaybeGetDefaultColorForBraveUi( break; } + if (is_tor) { + return MaybeGetDefaultColorForPrivateTorUi(id); + } + // Allow Private Window theme to override dark vs light if (incognito) { return MaybeGetDefaultColorForPrivateUi(id); diff --git a/browser/themes/theme_properties.h b/browser/themes/theme_properties.h index b14630b256d8..11e0d2a7cef4 100644 --- a/browser/themes/theme_properties.h +++ b/browser/themes/theme_properties.h @@ -31,6 +31,7 @@ bool IsBraveThemeProperties(int id); } // namespace BraveThemeProperties base::Optional MaybeGetDefaultColorForBraveUi( - int id, bool incognito, dark_mode::BraveDarkModeType dark_mode); + int id, bool incognito, + bool is_tor, dark_mode::BraveDarkModeType dark_mode); #endif // BRAVE_BROWSER_THEMES_THEME_PROPERTIES_H_ From ebca5660c1042cfd3900ef859a78b8c9ed3e0f22 Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Wed, 21 Oct 2020 18:07:23 +0900 Subject: [PATCH 02/14] Adjust tab separator color of private/tor/guest --- browser/ui/views/tabs/brave_tab_strip.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/browser/ui/views/tabs/brave_tab_strip.cc b/browser/ui/views/tabs/brave_tab_strip.cc index 83bdc322035a..8006937cceb4 100644 --- a/browser/ui/views/tabs/brave_tab_strip.cc +++ b/browser/ui/views/tabs/brave_tab_strip.cc @@ -32,8 +32,13 @@ bool BraveTabStrip::ShouldHideCloseButtonForTab(Tab* tab) const { SkColor BraveTabStrip::GetTabSeparatorColor() const { Profile* profile = controller()->GetProfile(); - if (!brave::IsRegularProfile(profile)) - return TabStrip::GetTabSeparatorColor(); + if (!brave::IsRegularProfile(profile)) { + if (brave::IsTorProfile(profile)) + return SkColorSetRGB(0x5A, 0x53, 0x66); + + // For incognito/guest window. + return SkColorSetRGB(0x3F, 0x32, 0x56); + } // If custom theme is used, follow upstream separator color. auto* theme_service = ThemeServiceFactory::GetForProfile(profile); From 58ac2d63556e3f6106d86c36889db50309cbf172 Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Thu, 12 Nov 2020 11:36:13 +0900 Subject: [PATCH 03/14] Cleanup AvatarToolbarButton patches --- .../ui/views/profiles/brave_avatar_toolbar_button.cc | 9 +++++++++ .../ui/views/profiles/brave_avatar_toolbar_button.h | 3 +++ .../ui/views/profiles/avatar_toolbar_button.cc | 7 ------- .../ui/views/profiles/avatar_toolbar_button.h | 6 +++++- ...-ui-views-profiles-avatar_toolbar_button.cc.patch | 12 ------------ ...r-ui-views-profiles-avatar_toolbar_button.h.patch | 8 ++++---- 6 files changed, 21 insertions(+), 24 deletions(-) delete mode 100644 patches/chrome-browser-ui-views-profiles-avatar_toolbar_button.cc.patch diff --git a/browser/ui/views/profiles/brave_avatar_toolbar_button.cc b/browser/ui/views/profiles/brave_avatar_toolbar_button.cc index 309b1f423200..9b84e4822d78 100644 --- a/browser/ui/views/profiles/brave_avatar_toolbar_button.cc +++ b/browser/ui/views/profiles/brave_avatar_toolbar_button.cc @@ -6,11 +6,13 @@ #include "brave/browser/ui/views/profiles/brave_avatar_toolbar_button.h" #include "brave/app/vector_icons/vector_icons.h" +#include "brave/grit/brave_generated_resources.h" #include "chrome/app/vector_icons/vector_icons.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/profiles/avatar_toolbar_button.h" +#include "ui/base/l10n/l10n_util.h" #include "ui/base/pointer/touch_ui_controller.h" #include "ui/base/theme_provider.h" #include "ui/gfx/image/image.h" @@ -40,3 +42,10 @@ ui::ImageModel BraveAvatarToolbarButton::GetAvatarIcon( } return AvatarToolbarButton::GetAvatarIcon(state, gaia_account_image); } + +base::string16 BraveAvatarToolbarButton::GetAvatarTooltipText() const { + if (browser_->profile()->IsTor()) + return l10n_util::GetStringUTF16(IDS_TOR_PROFILE_NAME); + + return AvatarToolbarButton::GetAvatarTooltipText(); +} diff --git a/browser/ui/views/profiles/brave_avatar_toolbar_button.h b/browser/ui/views/profiles/brave_avatar_toolbar_button.h index 81fb85fa3faf..4e244318e66f 100644 --- a/browser/ui/views/profiles/brave_avatar_toolbar_button.h +++ b/browser/ui/views/profiles/brave_avatar_toolbar_button.h @@ -17,9 +17,12 @@ class BraveAvatarToolbarButton : public AvatarToolbarButton { base::Optional highlight_color) override; private: + // AvatarToolbarButton: ui::ImageModel GetAvatarIcon( ButtonState state, const gfx::Image& profile_identity_image) const override; + base::string16 GetAvatarTooltipText() const override; + DISALLOW_COPY_AND_ASSIGN(BraveAvatarToolbarButton); }; diff --git a/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button.cc b/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button.cc index 9467fc11d1b1..78913a8066a0 100644 --- a/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button.cc +++ b/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button.cc @@ -3,15 +3,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.h" -#define GET_AVATAR_TOOLTIP_TEXT_ \ - if (browser_->profile()->IsTor()) \ - return l10n_util::GetStringUTF16(IDS_TOR_PROFILE_NAME); - #define AvatarToolbarButtonDelegate BraveAvatarToolbarButtonDelegate - #include "../../../../../../../chrome/browser/ui/views/profiles/avatar_toolbar_button.cc" #undef AvatarToolbarButtonDelegate -#undef GET_AVATAR_TOOLTIP_TEXT_ diff --git a/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button.h b/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button.h index 60812c0d8568..83a5c7dce8a4 100644 --- a/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button.h +++ b/chromium_src/chrome/browser/ui/views/profiles/avatar_toolbar_button.h @@ -6,11 +6,15 @@ #ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_TOOLBAR_BUTTON_H_ #define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_TOOLBAR_BUTTON_H_ +#define BRAVE_AVATAR_BUTTON_H friend class BraveAvatarToolbarButton; #define GetAvatarIcon virtual GetAvatarIcon +#define GetAvatarTooltipText virtual GetAvatarTooltipText #define AvatarToolbarButtonDelegate BraveAvatarToolbarButtonDelegate #include "../../../../../../../chrome/browser/ui/views/profiles/avatar_toolbar_button.h" -#undef AvatarToolbarButtonDelegate +#undef BRAVE_AVATAR_BUTTON_H #undef GetAvatarIcon +#undef GetAvatarTooltipText +#undef AvatarToolbarButtonDelegate #endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_TOOLBAR_BUTTON_H_ diff --git a/patches/chrome-browser-ui-views-profiles-avatar_toolbar_button.cc.patch b/patches/chrome-browser-ui-views-profiles-avatar_toolbar_button.cc.patch deleted file mode 100644 index 997f0873216e..000000000000 --- a/patches/chrome-browser-ui-views-profiles-avatar_toolbar_button.cc.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/chrome/browser/ui/views/profiles/avatar_toolbar_button.cc b/chrome/browser/ui/views/profiles/avatar_toolbar_button.cc -index 15949d01a13bc8c8449ea22bb31ce8c92a10356b..12a2c45e9ae3038dfca827ca24523498536eb8d8 100644 ---- a/chrome/browser/ui/views/profiles/avatar_toolbar_button.cc -+++ b/chrome/browser/ui/views/profiles/avatar_toolbar_button.cc -@@ -246,6 +246,7 @@ void AvatarToolbarButton::NotifyClick(const ui::Event& event) { - } - - base::string16 AvatarToolbarButton::GetAvatarTooltipText() const { -+ GET_AVATAR_TOOLTIP_TEXT_ - switch (delegate_->GetState()) { - case State::kIncognitoProfile: - return l10n_util::GetStringUTF16(IDS_AVATAR_BUTTON_INCOGNITO_TOOLTIP); diff --git a/patches/chrome-browser-ui-views-profiles-avatar_toolbar_button.h.patch b/patches/chrome-browser-ui-views-profiles-avatar_toolbar_button.h.patch index bd9fd666d55a..e951eb4918e9 100644 --- a/patches/chrome-browser-ui-views-profiles-avatar_toolbar_button.h.patch +++ b/patches/chrome-browser-ui-views-profiles-avatar_toolbar_button.h.patch @@ -1,12 +1,12 @@ diff --git a/chrome/browser/ui/views/profiles/avatar_toolbar_button.h b/chrome/browser/ui/views/profiles/avatar_toolbar_button.h -index 640405468136d45ce52469e64eb02063305741de..ea8dc804e9953458ed435275c1f47860020dc824 100644 +index 640405468136d45ce52469e64eb02063305741de..36d0d4d2dc47790091e89854cdf57a02b4fa0199 100644 --- a/chrome/browser/ui/views/profiles/avatar_toolbar_button.h +++ b/chrome/browser/ui/views/profiles/avatar_toolbar_button.h -@@ -71,6 +71,7 @@ class AvatarToolbarButton : public ToolbarButton, +@@ -70,6 +70,7 @@ class AvatarToolbarButton : public ToolbarButton, + // ToolbarButton: void NotifyClick(const ui::Event& event) override; ++BRAVE_AVATAR_BUTTON_H private: -+ friend class BraveAvatarToolbarButton; FRIEND_TEST_ALL_PREFIXES(AvatarToolbarButtonTest, HighlightMeetsMinimumContrast); - From eda9d5930b311c7087c91e808e0b3b0c6c3e7c8f Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Mon, 16 Nov 2020 11:24:50 +0900 Subject: [PATCH 04/14] Re-style brave avatar button --- app/brave_generated_resources.grd | 6 + app/vector_icons/BUILD.gn | 1 - app/vector_icons/tor_profile.icon | 99 ----------------- .../profiles/brave_avatar_toolbar_button.cc | 103 +++++++++++++++--- .../profiles/brave_avatar_toolbar_button.h | 3 +- .../browser/ui/views/toolbar/toolbar_button.h | 2 + 6 files changed, 100 insertions(+), 114 deletions(-) delete mode 100644 app/vector_icons/tor_profile.icon diff --git a/app/brave_generated_resources.grd b/app/brave_generated_resources.grd index 8ada7008fe2f..fb460166dca2 100644 --- a/app/brave_generated_resources.grd +++ b/app/brave_generated_resources.grd @@ -313,6 +313,12 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U Tor + + Private with Tor + + + This is private window with tor + Open Tor Window diff --git a/app/vector_icons/BUILD.gn b/app/vector_icons/BUILD.gn index 8d310adf8f8c..6db8d39c7de2 100644 --- a/app/vector_icons/BUILD.gn +++ b/app/vector_icons/BUILD.gn @@ -15,7 +15,6 @@ aggregate_vector_icons2("brave_vector_icons") { "speedreader.icon", "speedreader_on_active.icon", "speedreader_on_inactive.icon", - "tor_profile.icon", ] } diff --git a/app/vector_icons/tor_profile.icon b/app/vector_icons/tor_profile.icon deleted file mode 100644 index d7ba16452f99..000000000000 --- a/app/vector_icons/tor_profile.icon +++ /dev/null @@ -1,99 +0,0 @@ -// 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 http://mozilla.org/MPL/2.0/. - -CANVAS_DIMENSIONS, 24, -MOVE_TO, 8.97f, 6.47f, -R_V_LINE_TO, 1.51f, -H_LINE_TO, 6.34f, -V_LINE_TO, 16, -H_LINE_TO, 4.43f, -V_LINE_TO, 7.98f, -R_H_LINE_TO, -2.62f, -V_LINE_TO, 6.47f, -H_LINE_TO, 8.97f, -CLOSE, -R_MOVE_TO, 3.83f, 1.96f, -R_CUBIC_TO, 0.73f, 0, 1.38f, 0.15f, 1.96f, 0.46f, -R_ARC_TO, 3.36f, 3.36f, 0, 0, 1, 1.37f, 1.33f, -R_CUBIC_TO, 0.33f, 0.58f, 0.5f, 1.26f, 0.5f, 2.05f, -R_CUBIC_TO, 0, 0.78f, -0.17f, 1.46f, -0.5f, 2.04f, -R_ARC_TO, 3.42f, 3.42f, 0, 0, 1, -1.37f, 1.33f, -R_CUBIC_TO, -0.58f, 0.31f, -1.24f, 0.47f, -1.96f, 0.47f, -R_CUBIC_TO, -0.73f, 0, -1.38f, -0.16f, -1.96f, -0.47f, -R_ARC_TO, 3.42f, 3.42f, 0, 0, 1, -1.37f, -1.33f, -R_CUBIC_TO, -0.33f, -0.58f, -0.5f, -1.25f, -0.5f, -2.04f, -R_CUBIC_TO, 0, -0.78f, 0.17f, -1.46f, 0.5f, -2.05f, -R_ARC_TO, 3.36f, 3.36f, 0, 0, 1, 1.37f, -1.33f, -R_CUBIC_TO, 0.58f, -0.31f, 1.24f, -0.46f, 1.97f, -0.46f, -CLOSE, -R_MOVE_TO, 0, 1.65f, -R_CUBIC_TO, -0.53f, 0, -0.98f, 0.19f, -1.35f, 0.56f, -R_CUBIC_TO, -0.37f, 0.37f, -0.55f, 0.92f, -0.55f, 1.63f, -R_CUBIC_TO, 0, 0.71f, 0.19f, 1.25f, 0.55f, 1.63f, -R_CUBIC_TO, 0.37f, 0.37f, 0.82f, 0.56f, 1.35f, 0.56f, -R_CUBIC_TO, 0.53f, 0, 0.98f, -0.19f, 1.35f, -0.56f, -R_CUBIC_TO, 0.37f, -0.37f, 0.55f, -0.91f, 0.55f, -1.63f, -R_CUBIC_TO, 0, -0.71f, -0.18f, -1.25f, -0.55f, -1.63f, -R_ARC_TO, 1.83f, 1.83f, 0, 0, 0, -1.35f, -0.56f, -CLOSE, -R_MOVE_TO, 6.41f, -0.12f, -R_ARC_TO, 3.13f, 3.13f, 0, 0, 1, 1.11f, -1.13f, -R_ARC_TO, 2.94f, 2.94f, 0, 0, 1, 1.54f, -0.41f, -R_V_LINE_TO, 2.04f, -R_H_LINE_TO, -0.55f, -R_CUBIC_TO, -1.39f, 0, -2.09f, 0.65f, -2.09f, 1.94f, -V_LINE_TO, 16, -R_H_LINE_TO, -1.9f, -V_LINE_TO, 8.52f, -R_H_LINE_TO, 1.9f, -R_V_LINE_TO, 1.43f, -CLOSE, - -CANVAS_DIMENSIONS, 20, -MOVE_TO, 7.16f, 5.18f, -R_V_LINE_TO, 1.4f, -H_LINE_TO, 4.72f, -V_LINE_TO, 14, -H_LINE_TO, 2.96f, -V_LINE_TO, 6.58f, -H_LINE_TO, 0.53f, -R_V_LINE_TO, -1.4f, -R_H_LINE_TO, 6.63f, -CLOSE, -R_MOVE_TO, 3.55f, 1.81f, -R_CUBIC_TO, 0.68f, 0, 1.28f, 0.14f, 1.82f, 0.42f, -R_CUBIC_TO, 0.54f, 0.28f, 0.96f, 0.69f, 1.27f, 1.23f, -R_CUBIC_TO, 0.31f, 0.54f, 0.46f, 1.17f, 0.46f, 1.89f, -R_CUBIC_TO, 0, 0.73f, -0.15f, 1.36f, -0.46f, 1.89f, -R_ARC_TO, 3.16f, 3.16f, 0, 0, 1, -1.27f, 1.23f, -R_CUBIC_TO, -0.54f, 0.29f, -1.14f, 0.43f, -1.82f, 0.43f, -R_CUBIC_TO, -0.68f, 0, -1.28f, -0.14f, -1.82f, -0.43f, -R_ARC_TO, 3.16f, 3.16f, 0, 0, 1, -1.27f, -1.23f, -R_CUBIC_TO, -0.31f, -0.53f, -0.46f, -1.16f, -0.46f, -1.89f, -R_CUBIC_TO, 0, -0.72f, 0.15f, -1.36f, 0.46f, -1.89f, -R_ARC_TO, 3.11f, 3.11f, 0, 0, 1, 1.27f, -1.23f, -R_CUBIC_TO, 0.54f, -0.28f, 1.14f, -0.42f, 1.82f, -0.42f, -CLOSE, -R_MOVE_TO, 0, 1.52f, -R_ARC_TO, 1.69f, 1.69f, 0, 0, 0, -1.25f, 0.52f, -R_CUBIC_TO, -0.34f, 0.35f, -0.51f, 0.85f, -0.51f, 1.51f, -R_CUBIC_TO, 0, 0.66f, 0.17f, 1.16f, 0.51f, 1.51f, -R_ARC_TO, 1.69f, 1.69f, 0, 0, 0, 1.25f, 0.52f, -R_ARC_TO, 1.69f, 1.69f, 0, 0, 0, 1.25f, -0.52f, -R_CUBIC_TO, 0.34f, -0.35f, 0.51f, -0.85f, 0.51f, -1.51f, -R_CUBIC_TO, 0, -0.66f, -0.17f, -1.16f, -0.51f, -1.51f, -R_ARC_TO, 1.69f, 1.69f, 0, 0, 0, -1.25f, -0.52f, -CLOSE, -R_MOVE_TO, 5.94f, -0.11f, -R_CUBIC_TO, 0.26f, -0.44f, 0.6f, -0.79f, 1.02f, -1.04f, -R_CUBIC_TO, 0.43f, -0.25f, 0.9f, -0.38f, 1.43f, -0.38f, -R_V_LINE_TO, 1.89f, -R_H_LINE_TO, -0.51f, -R_CUBIC_TO, -1.29f, 0, -1.94f, 0.6f, -1.94f, 1.8f, -V_LINE_TO, 14, -H_LINE_TO, 14.88f, -V_LINE_TO, 7.08f, -R_H_LINE_TO, 1.76f, -V_LINE_TO, 8.4f, -CLOSE \ No newline at end of file diff --git a/browser/ui/views/profiles/brave_avatar_toolbar_button.cc b/browser/ui/views/profiles/brave_avatar_toolbar_button.cc index 9b84e4822d78..8ae7ff1c872b 100644 --- a/browser/ui/views/profiles/brave_avatar_toolbar_button.cc +++ b/browser/ui/views/profiles/brave_avatar_toolbar_button.cc @@ -5,47 +5,124 @@ #include "brave/browser/ui/views/profiles/brave_avatar_toolbar_button.h" +#include + #include "brave/app/vector_icons/vector_icons.h" #include "brave/grit/brave_generated_resources.h" #include "chrome/app/vector_icons/vector_icons.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/views/profiles/avatar_toolbar_button.h" +#include "chrome/browser/ui/views/profiles/avatar_toolbar_button_delegate.h" +#include "chrome/browser/ui/views/toolbar/toolbar_ink_drop_util.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/pointer/touch_ui_controller.h" #include "ui/base/theme_provider.h" #include "ui/gfx/image/image.h" #include "ui/gfx/paint_vector_icon.h" +#include "ui/views/background.h" +#include "ui/views/border.h" +#include "ui/views/controls/highlight_path_generator.h" + +namespace { + +constexpr int kHighlightRadius = 36; +constexpr int kBraveAvatarButtonHorizontalSpacing = 10; + +class BraveToolbarButtonHighlightPathGenerator + : public views::HighlightPathGenerator { + public: + // HighlightPathGenerator: + SkPath GetHighlightPath(const views::View* view) override { + gfx::Rect rect(view->size()); + rect.Inset(GetToolbarInkDropInsets(view)); + SkPath path; + path.addRoundRect(gfx::RectToSkRect(rect), + kHighlightRadius, kHighlightRadius); + return path; + } +}; +} // namespace + +BraveAvatarToolbarButton::BraveAvatarToolbarButton(Browser* browser) + : AvatarToolbarButton(browser) { + // Replace ToolbarButton's highlight path generator. + views::HighlightPathGenerator::Install( + this, std::make_unique()); +} void BraveAvatarToolbarButton::SetHighlight( const base::string16& highlight_text, base::Optional highlight_color) { - // We only want the icon for Tor and Guest profiles. - AvatarToolbarButton::SetHighlight((browser_->profile()->IsTor() || - browser_->profile()->IsGuestSession()) - ? base::string16() - : highlight_text, - highlight_color); + base::string16 revised_highlight_text; + if (browser_->profile()->IsTor()) { + revised_highlight_text = + l10n_util::GetStringUTF16(IDS_TOR_AVATAR_BUTTON_LABEL); + } else if (browser_->profile()->IsGuestSession()) { + // We only want the icon for Guest profiles. + revised_highlight_text = base::string16(); + } else { + revised_highlight_text = highlight_text; + } + + AvatarToolbarButton::SetHighlight(revised_highlight_text, highlight_color); +} + +void BraveAvatarToolbarButton::UpdateColorsAndInsets() { + // Use custom bg/border for private/tor window. + const bool is_tor = browser_->profile()->IsTor(); + if (delegate_->GetState() == State::kIncognitoProfile || is_tor) { + constexpr SkColor kPrivateAvatarBGColor = SkColorSetRGB(0x1D, 0x19, 0x35); + constexpr SkColor kPrivateTorAvatarBGColor = + SkColorSetRGB(0x1A, 0x0F, 0x2A); + + const gfx::Insets paint_insets = + gfx::Insets((height() - GetLayoutConstant(LOCATION_BAR_HEIGHT)) / 2) + + *GetProperty(views::kInternalPaddingKey); + SetEnabledTextColors(SK_ColorWHITE); + SetBackground(views::CreateBackgroundFromPainter( + views::Painter::CreateSolidRoundRectPainter( + is_tor ? kPrivateTorAvatarBGColor : kPrivateAvatarBGColor, + kHighlightRadius, + paint_insets))); + + // We give more margins to horizontally. + gfx::Insets target_insets = + GetLayoutInsets(TOOLBAR_BUTTON) + + *GetProperty(views::kInternalPaddingKey) + + gfx::Insets(0, kBraveAvatarButtonHorizontalSpacing); + SetBorder(views::CreateEmptyBorder(target_insets)); + + constexpr int kBraveAvatarImageLabelSpacing = 8; + SetImageLabelSpacing(kBraveAvatarImageLabelSpacing); + return; + } + + AvatarToolbarButton::UpdateColorsAndInsets(); } ui::ImageModel BraveAvatarToolbarButton::GetAvatarIcon( ButtonState state, const gfx::Image& gaia_account_image) const { - if (browser_->profile()->IsTor() || - browser_->profile()->IsGuestSession()) { - const int icon_size = ui::TouchUiController::Get()->touch_ui() ? 24 : 20; - const SkColor icon_color = GetForegroundColor(state); + // We don't use icon for tor avatar button. + if (browser_->profile()->IsTor()) + return ui::ImageModel(); + + if (browser_->profile()->IsGuestSession()) { return ui::ImageModel::FromVectorIcon( - browser_->profile()->IsTor() ? kTorProfileIcon : kUserMenuGuestIcon, - icon_color, icon_size); + kUserMenuGuestIcon, + GetForegroundColor(state), + ui::TouchUiController::Get()->touch_ui() ? 24 : 20); } + return AvatarToolbarButton::GetAvatarIcon(state, gaia_account_image); } base::string16 BraveAvatarToolbarButton::GetAvatarTooltipText() const { if (browser_->profile()->IsTor()) - return l10n_util::GetStringUTF16(IDS_TOR_PROFILE_NAME); + return l10n_util::GetStringUTF16(IDS_TOR_AVATAR_BUTTON_TOOLTIP_TEXT); return AvatarToolbarButton::GetAvatarTooltipText(); } diff --git a/browser/ui/views/profiles/brave_avatar_toolbar_button.h b/browser/ui/views/profiles/brave_avatar_toolbar_button.h index 4e244318e66f..d93d49b25fc2 100644 --- a/browser/ui/views/profiles/brave_avatar_toolbar_button.h +++ b/browser/ui/views/profiles/brave_avatar_toolbar_button.h @@ -10,11 +10,12 @@ class BraveAvatarToolbarButton : public AvatarToolbarButton { public: - using AvatarToolbarButton::AvatarToolbarButton; + explicit BraveAvatarToolbarButton(Browser* browser); // ToolbarButton: void SetHighlight(const base::string16& highlight_text, base::Optional highlight_color) override; + void UpdateColorsAndInsets() override; private: // AvatarToolbarButton: diff --git a/chromium_src/chrome/browser/ui/views/toolbar/toolbar_button.h b/chromium_src/chrome/browser/ui/views/toolbar/toolbar_button.h index 025c9f68ad0c..3cef1ddf5d34 100644 --- a/chromium_src/chrome/browser/ui/views/toolbar/toolbar_button.h +++ b/chromium_src/chrome/browser/ui/views/toolbar/toolbar_button.h @@ -7,7 +7,9 @@ #define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_BUTTON_H_ #define SetHighlight virtual SetHighlight +#define UpdateColorsAndInsets virtual UpdateColorsAndInsets #include "../../../../../../../chrome/browser/ui/views/toolbar/toolbar_button.h" #undef SetHighlight +#undef UpdateColorsAndInsets #endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_BUTTON_H_ From 306be6e6e6d5bf3bc4344838c547a0fa2f01bfe2 Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Mon, 16 Nov 2020 13:36:26 +0900 Subject: [PATCH 05/14] Update location bar focus ring color for non regular --- .../location_bar/brave_location_bar_view.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/browser/ui/views/location_bar/brave_location_bar_view.cc b/browser/ui/views/location_bar/brave_location_bar_view.cc index fc1df2315ff5..5e2f18b17134 100644 --- a/browser/ui/views/location_bar/brave_location_bar_view.cc +++ b/browser/ui/views/location_bar/brave_location_bar_view.cc @@ -41,6 +41,20 @@ class BraveLocationBarViewFocusRingHighlightPathGenerator DISALLOW_COPY_AND_ASSIGN(BraveLocationBarViewFocusRingHighlightPathGenerator); }; +base::Optional GetFocusRingColor(Profile* profile) { + constexpr SkColor kPrivateFocusRingColor = SkColorSetRGB(0xC6, 0xB3, 0xFF); + constexpr SkColor kTorPrivateFocusRingColor = SkColorSetRGB(0xCF, 0xAB, 0xE2); + if (brave::IsRegularProfile(profile) || profile->IsGuestSession()) { + // Don't update color. + return base::nullopt; + } + if (brave::IsTorProfile(profile)) + return kTorPrivateFocusRingColor; + + // Private window. + return kPrivateFocusRingColor; +} + } // namespace void BraveLocationBarView::Init() { @@ -51,6 +65,8 @@ void BraveLocationBarView::Init() { focus_ring_->SetPathGenerator( std::make_unique< BraveLocationBarViewFocusRingHighlightPathGenerator>()); + if (const auto color = GetFocusRingColor(profile())) + focus_ring_->SetColor(color.value()); } #if BUILDFLAG(ENABLE_TOR) onion_location_view_ = new OnionLocationView(browser_->profile()); From 87fe56017230dcad38d4d6ac609893a2b7949f6f Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Mon, 16 Nov 2020 14:38:00 +0900 Subject: [PATCH 06/14] Update location/omnibox color --- browser/themes/brave_theme_helper.cc | 32 +++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/browser/themes/brave_theme_helper.cc b/browser/themes/brave_theme_helper.cc index 62a60f8bd7f4..70acbd341c6f 100644 --- a/browser/themes/brave_theme_helper.cc +++ b/browser/themes/brave_theme_helper.cc @@ -25,20 +25,24 @@ const SkColor kDarkOmniboxText = SkColorSetRGB(0xff, 0xff, 0xff); const SkColor kLightOmniboxText = SkColorSetRGB(0x42, 0x42, 0x42); // Location bar colors -const SkColor kPrivateLocationBarBgBase = SkColorSetRGB(0x1b, 0x0e, 0x2c); +const SkColor kPrivateLocationBarBgBase = SkColorSetRGB(0x0B, 0x07, 0x24); +const SkColor kDarkLocationBarBgBase = SkColorSetRGB(0x18, 0x1A, 0x21); SkColor GetLocationBarBackground(bool dark, bool priv, bool hover) { if (priv) { - return color_utils::HSLShift(kPrivateLocationBarBgBase, - {-1, -1, hover ? 0.54 : 0.52}); + return hover ? color_utils::HSLShift(kPrivateLocationBarBgBase, + {-1, -1, 0.54}) + : kPrivateLocationBarBgBase; } - return dark ? (hover ? SkColorSetRGB(0x44, 0x44, 0x44) - : SkColorSetRGB(0x22, 0x22, 0x22)) - : (hover ? color_utils::AlphaBlend( - SK_ColorWHITE, - SkColorSetRGB(0xf3, 0xf3, 0xf3), 0.7f) - : SK_ColorWHITE); + if (dark) { + return hover ? SkColorSetRGB(0x44, 0x44, 0x44) + : kDarkLocationBarBgBase; + } + + return hover ? color_utils::AlphaBlend(SK_ColorWHITE, + SkColorSetRGB(0xf3, 0xf3, 0xf3), 0.7f) + : SK_ColorWHITE; } // Omnibox result bg colors @@ -55,11 +59,13 @@ SkColor GetOmniboxResultBackground(int id, bool dark, bool priv) { SkColor color; if (priv) { - color = color_utils::HSLShift(kPrivateLocationBarBgBase, - {-1, -1, high_contrast ? 0.45 : 0.56}); + color = high_contrast ? color_utils::HSLShift(kPrivateLocationBarBgBase, + {-1, -1, 0.45}) + : kPrivateLocationBarBgBase; + } else if (dark) { + color = high_contrast ? gfx::kGoogleGrey900 : kDarkLocationBarBgBase; } else { - color = dark ? (high_contrast ? gfx::kGoogleGrey900 : gfx::kGoogleGrey800) - : SK_ColorWHITE; + color = SK_ColorWHITE; } return color_utils::BlendTowardMaxContrast( color, From a71c0a64c4ce1afb77a6617ff657fa5722a657e1 Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Tue, 17 Nov 2020 14:14:15 +0900 Subject: [PATCH 07/14] Paint graphic only on tor window frame --- app/theme/brave_theme_resources.grd | 1 + .../brave/tor_window_frame_graphic.png | Bin 0 -> 28026 bytes .../brave/tor_window_frame_graphic.png | Bin 0 -> 70835 bytes browser/ui/BUILD.gn | 18 ++++++++ .../brave_browser_non_client_frame_view_mac.h | 33 +++++++++++++++ ...brave_browser_non_client_frame_view_mac.mm | 38 +++++++++++++++++ .../frame/brave_glass_browser_frame_view.cc | 37 +++++++++++++++++ .../frame/brave_glass_browser_frame_view.h | 31 ++++++++++++++ .../frame/brave_opaque_browser_frame_view.cc | 39 ++++++++++++++++++ .../frame/brave_opaque_browser_frame_view.h | 33 +++++++++++++++ .../views/frame/brave_window_frame_graphic.cc | 33 +++++++++++++++ .../views/frame/brave_window_frame_graphic.h | 30 ++++++++++++++ ...owser_non_client_frame_view_factory_mac.mm | 12 ++++++ ...ser_non_client_frame_view_factory_views.cc | 22 ++++++++++ 14 files changed, 327 insertions(+) create mode 100644 app/theme/default_100_percent/brave/tor_window_frame_graphic.png create mode 100644 app/theme/default_200_percent/brave/tor_window_frame_graphic.png create mode 100644 browser/ui/views/frame/brave_browser_non_client_frame_view_mac.h create mode 100644 browser/ui/views/frame/brave_browser_non_client_frame_view_mac.mm create mode 100644 browser/ui/views/frame/brave_glass_browser_frame_view.cc create mode 100644 browser/ui/views/frame/brave_glass_browser_frame_view.h create mode 100644 browser/ui/views/frame/brave_opaque_browser_frame_view.cc create mode 100644 browser/ui/views/frame/brave_opaque_browser_frame_view.h create mode 100644 browser/ui/views/frame/brave_window_frame_graphic.cc create mode 100644 browser/ui/views/frame/brave_window_frame_graphic.h create mode 100644 chromium_src/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_mac.mm create mode 100644 chromium_src/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_views.cc diff --git a/app/theme/brave_theme_resources.grd b/app/theme/brave_theme_resources.grd index 92208650aab0..b4e7840aac74 100644 --- a/app/theme/brave_theme_resources.grd +++ b/app/theme/brave_theme_resources.grd @@ -22,6 +22,7 @@ +