diff --git a/app/vector_icons/BUILD.gn b/app/vector_icons/BUILD.gn new file mode 100644 index 000000000000..059ed08029bb --- /dev/null +++ b/app/vector_icons/BUILD.gn @@ -0,0 +1,24 @@ +# 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/. + +import("//components/vector_icons/vector_icons.gni") + +aggregate_vector_icons("brave_vector_icons") { + icon_directory = "." + + icons = [ + "tor_profile.icon" + ] +} + +source_set("vector_icons") { + sources = get_target_outputs(":brave_vector_icons") + + deps = [ + ":brave_vector_icons", + "//base", + "//skia", + "//ui/gfx", + ] +} \ No newline at end of file diff --git a/app/vector_icons/tor_profile.icon b/app/vector_icons/tor_profile.icon new file mode 100644 index 000000000000..d7ba16452f99 --- /dev/null +++ b/app/vector_icons/tor_profile.icon @@ -0,0 +1,99 @@ +// 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/app/vector_icons/vector_icons.cc.template b/app/vector_icons/vector_icons.cc.template new file mode 100644 index 000000000000..59f6ed1020c1 --- /dev/null +++ b/app/vector_icons/vector_icons.cc.template @@ -0,0 +1,18 @@ +// 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/. + +// vector_icons.cc.template is used to generate vector_icons.cc. Edit the former +// rather than the latter. + +#include "brave/app/vector_icons/vector_icons.h" + +#include "base/logging.h" +#include "ui/gfx/animation/tween.h" +#include "ui/gfx/vector_icon_types.h" + +#include "components/vector_icons/cc_macros.h" + +using namespace gfx; + +TEMPLATE_PLACEHOLDER \ No newline at end of file diff --git a/app/vector_icons/vector_icons.h.template b/app/vector_icons/vector_icons.h.template new file mode 100644 index 000000000000..26b45135e012 --- /dev/null +++ b/app/vector_icons/vector_icons.h.template @@ -0,0 +1,22 @@ +// 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/. + +// vector_icons.h.template is used to generate vector_icons.h. Edit the former +// rather than the latter. + +#ifndef BRAVE_APP_VECTOR_ICONS_VECTOR_ICONS_H_ +#define BRAVE_APP_VECTOR_ICONS_VECTOR_ICONS_H_ + +namespace gfx { +struct VectorIcon; +} + +#define VECTOR_ICON_TEMPLATE_H(icon_name) \ +extern const gfx::VectorIcon icon_name; + +TEMPLATE_PLACEHOLDER + +#undef VECTOR_ICON_TEMPLATE_H + +#endif // BRAVE_APP_VECTOR_ICONS_VECTOR_ICONS_H_ \ No newline at end of file diff --git a/browser/ui/BUILD.gn b/browser/ui/BUILD.gn index cd284375183d..b00698c72bf7 100644 --- a/browser/ui/BUILD.gn +++ b/browser/ui/BUILD.gn @@ -44,6 +44,8 @@ source_set("ui") { "views/importer/brave_import_lock_dialog_view.h", "views/location_bar/brave_location_bar_view.cc", "views/location_bar/brave_location_bar_view.h", + "views/profiles/brave_avatar_toolbar_button.cc", + "views/profiles/brave_avatar_toolbar_button.h", "views/profiles/brave_profile_chooser_view.cc", "views/profiles/brave_profile_chooser_view.h", "views/tabs/brave_new_tab_button.cc", @@ -101,6 +103,7 @@ source_set("ui") { "//brave/app:command_ids", "//brave/app/theme:brave_unscaled_resources", "//brave/app/theme:brave_theme_resources", + "//brave/app/vector_icons:vector_icons", "//brave/components/brave_rewards/browser", "//brave/browser/tor", "//brave/components/resources:brave_components_resources_grit", diff --git a/browser/ui/views/profiles/brave_avatar_toolbar_button.cc b/browser/ui/views/profiles/brave_avatar_toolbar_button.cc new file mode 100644 index 000000000000..72061f02ca1c --- /dev/null +++ b/browser/ui/views/profiles/brave_avatar_toolbar_button.cc @@ -0,0 +1,21 @@ +#include "brave/browser/ui/views/profiles/brave_avatar_toolbar_button.h" + +#include "brave/app/vector_icons/vector_icons.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/themes/theme_properties.h" +#include "chrome/browser/ui/views/profiles/avatar_toolbar_button.h" +#include "ui/base/material_design/material_design_controller.h" +#include "ui/base/theme_provider.h" +#include "ui/gfx/image/image.h" +#include "ui/gfx/paint_vector_icon.h" + +gfx::ImageSkia BraveAvatarToolbarButton::GetAvatarIcon() const { + if (profile_->IsTorProfile()) { + const int icon_size = + ui::MaterialDesignController::IsTouchOptimizedUiEnabled() ? 24 : 20; + const SkColor icon_color = + GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); + return gfx::CreateVectorIcon(kTorProfileIcon, icon_size, icon_color); + } + return AvatarToolbarButton::GetAvatarIcon(); +} \ No newline at end of file diff --git a/browser/ui/views/profiles/brave_avatar_toolbar_button.h b/browser/ui/views/profiles/brave_avatar_toolbar_button.h new file mode 100644 index 000000000000..7b06250124cc --- /dev/null +++ b/browser/ui/views/profiles/brave_avatar_toolbar_button.h @@ -0,0 +1,18 @@ +/* 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/. */ + +#ifndef BRAVE_BROWSER_UI_VIEWS_PROFILES_BRAVE_AVATAR_TOOLBAR_BUTTON_H_ +#define BRAVE_BROWSER_UI_VIEWS_PROFILES_BRAVE_AVATAR_TOOLBAR_BUTTON_H_ + +#include "chrome/browser/ui/views/profiles/avatar_toolbar_button.h" + +class BraveAvatarToolbarButton : public AvatarToolbarButton { + public: + using AvatarToolbarButton::AvatarToolbarButton; + private: + gfx::ImageSkia GetAvatarIcon() const override; + DISALLOW_COPY_AND_ASSIGN(BraveAvatarToolbarButton); +}; + +#endif \ No newline at end of file diff --git a/chromium_src/chrome/browser/ui/views/toolbar/toolbar_view.cc b/chromium_src/chrome/browser/ui/views/toolbar/toolbar_view.cc index 77e32deaeaac..a95b028ee2c6 100644 --- a/chromium_src/chrome/browser/ui/views/toolbar/toolbar_view.cc +++ b/chromium_src/chrome/browser/ui/views/toolbar/toolbar_view.cc @@ -1,6 +1,10 @@ #include "chrome/browser/ui/views/location_bar/location_bar_view.h" #include "brave/browser/ui/views/location_bar/brave_location_bar_view.h" +#include "chrome/browser/ui/views/profiles/avatar_toolbar_button.h" +#include "brave/browser/ui/views/profiles/brave_avatar_toolbar_button.h" #define LocationBarView BraveLocationBarView +#define AvatarToolbarButton BraveAvatarToolbarButton #include "../../../../../../../chrome/browser/ui/views/toolbar/toolbar_view.cc" #undef LocationBarView +#undef AvatarToolbarButton 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 new file mode 100644 index 000000000000..11882a10bfb9 --- /dev/null +++ b/patches/chrome-browser-ui-views-profiles-avatar_toolbar_button.h.patch @@ -0,0 +1,21 @@ +diff --git a/chrome/browser/ui/views/profiles/avatar_toolbar_button.h b/chrome/browser/ui/views/profiles/avatar_toolbar_button.h +index 123fcfa175708b5290df332b0f61af7725f6a597..3f99df509c0336660174401bf52d33e1875ce73f 100644 +--- a/chrome/browser/ui/views/profiles/avatar_toolbar_button.h ++++ b/chrome/browser/ui/views/profiles/avatar_toolbar_button.h +@@ -24,6 +24,7 @@ class AvatarToolbarButton : public ToolbarButton, + public GaiaCookieManagerService::Observer, + public AccountTrackerService::Observer { + public: ++ friend class BraveAvatarToolbarButton; + explicit AvatarToolbarButton(Browser* browser); + ~AvatarToolbarButton() override; + +@@ -65,7 +66,7 @@ class AvatarToolbarButton : public ToolbarButton, + bool IsIncognito() const; + bool ShouldShowGenericIcon() const; + base::string16 GetAvatarTooltipText() const; +- gfx::ImageSkia GetAvatarIcon() const; ++ virtual gfx::ImageSkia GetAvatarIcon() const; + gfx::Image GetIconImageFromProfile() const; + SyncState GetSyncState() const; +