diff --git a/DEPS b/DEPS index 394e664b08ad..e99480851085 100644 --- a/DEPS +++ b/DEPS @@ -5,7 +5,7 @@ deps = { "vendor/tracking-protection": "https://github.com/brave/tracking-protection.git@e67738e656244f7ab6e0ed9815071ca744f5468f", "vendor/hashset-cpp": "https://github.com/brave/hashset-cpp.git@4b55fe39bb25bb0d8b11a43d547d75f00c6c46fb", "vendor/bloom-filter-cpp": "https://github.com/brave/bloom-filter-cpp.git@9be5c63b14e094156e00c8b28f205e7794f0b92c", - "vendor/brave-extension": "https://github.com/brave/brave-extension.git@038a43af5294150d48ce94a326290f70aa001cd0", + "vendor/brave-extension": "https://github.com/brave/brave-extension.git@70550a1619139459119f472c18a03dc12c3ed5f2", "vendor/requests": "https://github.com/kennethreitz/requests@e4d59bedfd3c7f4f254f4f5d036587bcd8152458", "vendor/boto": "https://github.com/boto/boto@f7574aa6cc2c819430c1f05e9a1a1a666ef8169b", "vendor/python-patch": "https://github.com/svn2github/python-patch@a336a458016ced89aba90dfc3f4c8222ae3b1403", diff --git a/browser/resources/brave_extension.grd b/browser/resources/brave_extension.grd index c5081258cecf..927e73e31b26 100644 --- a/browser/resources/brave_extension.grd +++ b/browser/resources/brave_extension.grd @@ -19,8 +19,12 @@ - - + + + + + + diff --git a/browser/ui/BUILD.gn b/browser/ui/BUILD.gn index 7c5a1d7956fd..82846ad875fb 100644 --- a/browser/ui/BUILD.gn +++ b/browser/ui/BUILD.gn @@ -35,6 +35,8 @@ source_set("ui") { "toolbar/brave_toolbar_actions_model.h", "views/brave_layout_provider.cc", "views/brave_layout_provider.h", + "views/brave_actions/brave_action_view.cc", + "views/brave_actions/brave_action_view.h", "views/brave_actions/brave_actions_container.cc", "views/brave_actions/brave_actions_container.h", "views/download/brave_download_item_view.cc", @@ -49,6 +51,8 @@ source_set("ui") { "views/profiles/brave_avatar_toolbar_button.h", "views/profiles/brave_profile_chooser_view.cc", "views/profiles/brave_profile_chooser_view.h", + "views/rounded_separator.cc", + "views/rounded_separator.h", "views/tabs/brave_new_tab_button.cc", "views/tabs/brave_new_tab_button.h", "views/toolbar/bookmark_button.cc", diff --git a/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.cc b/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.cc index cf9857847515..82be8dec6724 100644 --- a/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.cc +++ b/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.cc @@ -5,6 +5,7 @@ #include "brave/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.h" #include "base/strings/utf_string_conversions.h" +#include "brave/browser/ui/brave_actions/constants.h" #include "cc/paint/paint_flags.h" #include "chrome/browser/extensions/extension_action.h" #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" @@ -19,6 +20,24 @@ #include "ui/gfx/image/image_skia_operations.h" #include "ui/gfx/skia_paint_util.h" +using namespace brave_actions; + +base::Optional BraveActionIconWithBadgeImageSource::GetCustomGraphicSize() { + return kBraveActionGraphicSize; +} + +base::Optional BraveActionIconWithBadgeImageSource::GetCustomGraphicXOffset() { + return std::floor( + (size().width() - kBraveActionRightMargin - kBraveActionGraphicSize) / 2.0 + ); +} + +base::Optional BraveActionIconWithBadgeImageSource::GetCustomGraphicYOffset() { + return std::floor( + (size().height() - kBraveActionGraphicSize) / 2.0 + ); +} + void BraveActionIconWithBadgeImageSource::PaintBadge(gfx::Canvas* canvas) { if (!badge_ || badge_->text.empty()) return; @@ -35,6 +54,7 @@ void BraveActionIconWithBadgeImageSource::PaintBadge(gfx::Canvas* canvas) { constexpr int kBadgeHeight = 12; constexpr int kBadgeMaxWidth = 14; constexpr int kVPadding = 1; + constexpr int kVMarginTop = 2; const int kTextHeightTarget = kBadgeHeight - (kVPadding * 2); int h_padding = 2; int text_max_width = kBadgeMaxWidth - (h_padding * 2); @@ -113,10 +133,9 @@ void BraveActionIconWithBadgeImageSource::PaintBadge(gfx::Canvas* canvas) { if (icon_area.width() != 0 && (badge_width % 2 != icon_area.width() % 2)) badge_width += 1; - // Calculate the badge background rect. It is usually right-aligned, but it - // can also be center-aligned if it is large. - const int badge_offset_x = icon_area.width() - badge_width; - const int badge_offset_y = 0; + // Calculate the badge background rect. It is anchored to a specific position + const int badge_offset_x = icon_area.width() - kBadgeMaxWidth; + const int badge_offset_y = kVMarginTop; gfx::Rect rect(icon_area.x() + badge_offset_x, icon_area.y() + badge_offset_y, badge_width, kBadgeHeight); cc::PaintFlags rect_flags; diff --git a/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.h b/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.h index d87aa1ae0d6e..39656536b24b 100644 --- a/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.h +++ b/browser/ui/brave_actions/brave_action_icon_with_badge_image_source.h @@ -19,6 +19,9 @@ class BraveActionIconWithBadgeImageSource : public IconWithBadgeImageSource { public: using IconWithBadgeImageSource::IconWithBadgeImageSource; private: + base::Optional GetCustomGraphicSize() override; + base::Optional GetCustomGraphicXOffset() override; + base::Optional GetCustomGraphicYOffset() override; void PaintBadge(gfx::Canvas* canvas) override; gfx::Rect GetIconAreaRect() const override; DISALLOW_COPY_AND_ASSIGN(BraveActionIconWithBadgeImageSource); diff --git a/browser/ui/brave_actions/constants.h b/browser/ui/brave_actions/constants.h new file mode 100644 index 000000000000..9dc5d3007478 --- /dev/null +++ b/browser/ui/brave_actions/constants.h @@ -0,0 +1,10 @@ +/* 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/. */ + +namespace brave_actions { + + const int kBraveActionGraphicSize = 18; + const int kBraveActionRightMargin = 2; + +} \ No newline at end of file diff --git a/browser/ui/views/brave_actions/brave_action_view.cc b/browser/ui/views/brave_actions/brave_action_view.cc new file mode 100644 index 000000000000..f194fe0dd3ae --- /dev/null +++ b/browser/ui/views/brave_actions/brave_action_view.cc @@ -0,0 +1,36 @@ +/* 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/. */ + +#include "brave/browser/ui/views/brave_actions/brave_action_view.h" + +#include "brave/browser/ui/brave_actions/constants.h" +#include "chrome/browser/themes/theme_properties.h" +#include "chrome/browser/ui/layout_constants.h" +#include "chrome/browser/ui/views/chrome_layout_provider.h" +#include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" +#include "chrome/browser/ui/views/toolbar/toolbar_ink_drop_util.h" +#include "third_party/skia/include/core/SkPath.h" +#include "ui/gfx/geometry/insets.h" +#include "ui/gfx/geometry/rect.h" +#include "ui/gfx/geometry/size.h" +#include "ui/views/controls/button/menu_button.h" +#include "ui/views/view.h" +#include "ui/views/view_properties.h" + +void BraveActionView::OnBoundsChanged(const gfx::Rect& previous_bounds) { + // Set the highlight path for the toolbar button, + // making it inset so that the badge can show outside it in the + // fake margin on the right that we are creating. + gfx::Insets highlight_insets(0, 0, 0, brave_actions::kBraveActionRightMargin); + gfx::Rect rect(size()); + rect.Inset(highlight_insets); + const int radii = ChromeLayoutProvider::Get()->GetCornerRadiusMetric( + views::EMPHASIS_MAXIMUM, rect.size()); + + auto path = std::make_unique(); + path->addRoundRect(gfx::RectToSkRect(rect), radii, radii); + SetProperty(views::kHighlightPathKey, path.release()); + + MenuButton::OnBoundsChanged(previous_bounds); +} diff --git a/browser/ui/views/brave_actions/brave_action_view.h b/browser/ui/views/brave_actions/brave_action_view.h new file mode 100644 index 000000000000..583fe96e871f --- /dev/null +++ b/browser/ui/views/brave_actions/brave_action_view.h @@ -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/. */ + +#ifndef BRAVE_BROWSER_UI_VIEWS_BRAVE_ACTIONS_BRAVE_ACTION_VIEW_H_ +#define BRAVE_BROWSER_UI_VIEWS_BRAVE_ACTIONS_BRAVE_ACTION_VIEW_H_ + +#include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" + +namespace gfx { + class Rect; +} + +// Subclasses ToolbarActionViewc so that the notification badge can be painted +// outside the highlight bubble. +class BraveActionView : public ToolbarActionView { + public: + using ToolbarActionView::ToolbarActionView; + // views::MenuButton: + void OnBoundsChanged(const gfx::Rect& previous_bounds) override; + DISALLOW_COPY_AND_ASSIGN(BraveActionView); +}; + +#endif diff --git a/browser/ui/views/brave_actions/brave_actions_container.cc b/browser/ui/views/brave_actions/brave_actions_container.cc index f9de0748fca9..2b4903dc65e6 100644 --- a/browser/ui/views/brave_actions/brave_actions_container.cc +++ b/browser/ui/views/brave_actions/brave_actions_container.cc @@ -7,6 +7,8 @@ #include #include "brave/browser/ui/brave_actions/brave_action_view_controller.h" +#include "brave/browser/ui/views/brave_actions/brave_action_view.h" +#include "brave/browser/ui/views/rounded_separator.h" #include "brave/common/extensions/extension_constants.h" #include "chrome/browser/extensions/extension_action_manager.h" #include "chrome/browser/profiles/profile.h" @@ -18,7 +20,6 @@ #include "extensions/browser/extension_registry_observer.h" #include "extensions/browser/extension_system.h" #include "extensions/common/one_shot_event.h" -#include "ui/views/controls/separator.h" #include "ui/views/layout/box_layout.h" #include "ui/views/layout/grid_layout.h" #include "ui/views/view.h" @@ -68,11 +69,21 @@ void BraveActionsContainer::Init() { SetLayoutManager(std::move(vertical_container_layout)); // children - views::Separator* brave_button_separator_ = new views::Separator(); + RoundedSeparator* brave_button_separator_ = new RoundedSeparator(); // TODO: theme color brave_button_separator_->SetColor(SkColorSetRGB(0xb2, 0xb5, 0xb7)); - brave_button_separator_->SetPreferredSize(gfx::Size(2, - GetLayoutConstant(LOCATION_BAR_ICON_SIZE))); + constexpr int kSeparatorRightMargin = 2; + constexpr int kSeparatorWidth = 1; + brave_button_separator_->SetPreferredSize(gfx::Size( + kSeparatorWidth + kSeparatorRightMargin, + GetLayoutConstant(LOCATION_BAR_ICON_SIZE))); + // separator right margin + brave_button_separator_->SetBorder(views::CreateEmptyBorder( + 0, + 0, + 0, + kSeparatorRightMargin + )); // Just in case the extensions load before this function does (not likely!) // make sure separator is at index 0 AddChildViewAt(brave_button_separator_, 0); @@ -98,12 +109,12 @@ void BraveActionsContainer::AddAction(const extensions::Extension* extension, // do not require that logic. // If we do require notifications when popups are open or closed, // then we should inherit and pass |this| through. - actions_[id].view_controller_ = + actions_[id].view_controller_ = std::make_unique( extension, browser_, extension_action_manager_->GetExtensionAction(*extension), nullptr); // The button view - actions_[id].view_ = std::make_unique( + actions_[id].view_ = std::make_unique( actions_[id].view_controller_.get(), this); // Add extension view after separator view // `AddChildView` should be called first, so that changes that modify @@ -118,7 +129,7 @@ void BraveActionsContainer::AddAction(const extensions::Extension* extension, actions_[id].view_->set_owned_by_client(); // Sets overall size of button but not image graphic. We set a large width // in order to give space for the bubble. - actions_[id].view_->SetPreferredSize(gfx::Size(32, 24)); + actions_[id].view_->SetPreferredSize(gfx::Size(34, 24)); Update(); } } diff --git a/browser/ui/views/rounded_separator.cc b/browser/ui/views/rounded_separator.cc new file mode 100644 index 000000000000..c6b0a8a4e847 --- /dev/null +++ b/browser/ui/views/rounded_separator.cc @@ -0,0 +1,73 @@ +/* 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/. */ + +#include "brave/browser/ui/views/rounded_separator.h" + +#include "ui/accessibility/ax_node_data.h" +#include "ui/gfx/canvas.h" +#include "ui/native_theme/native_theme.h" + +// static +const char RoundedSeparator::kViewClassName[] = "RoundedSeparator"; + +// static +const int RoundedSeparator::kThickness = 1; + +RoundedSeparator::RoundedSeparator() {} + +RoundedSeparator::~RoundedSeparator() {} + +void RoundedSeparator::SetColor(SkColor color) { + overridden_color_ = color; + SchedulePaint(); +} + +void RoundedSeparator::SetPreferredHeight(int height) { + preferred_height_ = height; + PreferredSizeChanged(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Separator, View overrides: + +gfx::Size RoundedSeparator::CalculatePreferredSize() const { + gfx::Size size(kThickness, preferred_height_); + gfx::Insets insets = GetInsets(); + size.Enlarge(insets.width(), insets.height()); + return size; +} + +void RoundedSeparator::GetAccessibleNodeData(ui::AXNodeData* node_data) { + node_data->role = ax::mojom::Role::kSplitter; +} + +void RoundedSeparator::OnPaint(gfx::Canvas* canvas) { + SkColor color = overridden_color_ + ? *overridden_color_ + : GetNativeTheme()->GetSystemColor( + ui::NativeTheme::kColorId_SeparatorColor); + + float dsf = canvas->UndoDeviceScaleFactor(); + + // The separator fills its bounds, but avoid filling partial pixels. + gfx::Rect aligned = gfx::ScaleToEnclosedRect(GetContentsBounds(), dsf, dsf); + + + // At least 1 pixel should be drawn to make the separator visible. + aligned.set_width(std::max(1, aligned.width())); + aligned.set_height(std::max(1, aligned.height())); + + const int separator_radius = aligned.width() / 2; + + cc::PaintFlags flags; + flags.setAntiAlias(true); + flags.setColor(color); + canvas->DrawRoundRect(aligned, separator_radius, flags); + + View::OnPaint(canvas); +} + +const char* RoundedSeparator::GetClassName() const { + return kViewClassName; +} diff --git a/browser/ui/views/rounded_separator.h b/browser/ui/views/rounded_separator.h new file mode 100644 index 000000000000..0bbbd4f6639b --- /dev/null +++ b/browser/ui/views/rounded_separator.h @@ -0,0 +1,44 @@ +/* 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_ROUNDED_SEPARATOR_H_ +#define BRAVE_BROWSER_UI_VIEWS_ROUNDED_SEPARATOR_H_ + +#include + +#include "base/macros.h" +#include "base/optional.h" +#include "ui/views/view.h" + +// The RoundedSeparator class is a view that shows a line used to visually separate +// other views. +class RoundedSeparator : public views::View { + public: + // The separator's class name. + static const char kViewClassName[]; + + // The separator's thickness in dip. + static const int kThickness; + + RoundedSeparator(); + ~RoundedSeparator() override; + + void SetColor(SkColor color); + + void SetPreferredHeight(int height); + + // Overridden from View: + gfx::Size CalculatePreferredSize() const override; + void GetAccessibleNodeData(ui::AXNodeData* node_data) override; + void OnPaint(gfx::Canvas* canvas) override; + const char* GetClassName() const override; + + private: + int preferred_height_ = kThickness; + base::Optional overridden_color_; + + DISALLOW_COPY_AND_ASSIGN(RoundedSeparator); +}; + +#endif diff --git a/chromium_src/chrome/browser/ui/extensions/icon_with_badge_image_source.cc b/chromium_src/chrome/browser/ui/extensions/icon_with_badge_image_source.cc new file mode 100644 index 000000000000..803b94838bad --- /dev/null +++ b/chromium_src/chrome/browser/ui/extensions/icon_with_badge_image_source.cc @@ -0,0 +1,14 @@ +#include "../../../../../../chrome/browser/ui/extensions/icon_with_badge_image_source.cc" + +// Implement default virtual methods +base::Optional IconWithBadgeImageSource::GetCustomGraphicSize() { + return base::nullopt; +} + +base::Optional IconWithBadgeImageSource::GetCustomGraphicXOffset() { + return base::nullopt; +} + +base::Optional IconWithBadgeImageSource::GetCustomGraphicYOffset() { + return base::nullopt; +} \ No newline at end of file diff --git a/components/brave_rewards/resources/extension/brave_rewards/BUILD.gn b/components/brave_rewards/resources/extension/brave_rewards/BUILD.gn index 5ed0fec3353c..b05e235e7a6e 100644 --- a/components/brave_rewards/resources/extension/brave_rewards/BUILD.gn +++ b/components/brave_rewards/resources/extension/brave_rewards/BUILD.gn @@ -24,6 +24,12 @@ transpile_web_ui("brave_rewards_panel") { "components/app.tsx", "components/panel.tsx", "constants/rewards_panel_types.ts", + "img/rewards-off.png", + "img/rewards-off@2x.png", + "img/rewards-off@3x.png", + "img/rewards-on.png", + "img/rewards-on@2x.png", + "img/rewards-on@3x.png", "utils.ts", ] diff --git a/components/brave_rewards/resources/extension/brave_rewards/background.ts b/components/brave_rewards/resources/extension/brave_rewards/background.ts index 47fed8cbbedb..8129e1e2f942 100644 --- a/components/brave_rewards/resources/extension/brave_rewards/background.ts +++ b/components/brave_rewards/resources/extension/brave_rewards/background.ts @@ -5,8 +5,32 @@ import './background/store' import './background/events/rewardsEvents' import './background/events/tabEvents' +import batIconOn18Url from './img/rewards-on.png' +import batIconOn36Url from './img/rewards-on@2x.png' +import batIconOn54Url from './img/rewards-on@3x.png' +// TODO: display 'off' icon at appropriate time +// import batIconOff18Url from './img/rewards-off.png' +// import batIconOff36Url from './img/rewards-off@2x.png' +// import batIconOff54Url from './img/rewards-off@3x.png' -chrome.browserAction.setBadgeBackgroundColor({ color: '#FF0000' }) +const iconOn = { + path: { + 18: batIconOn18Url, + 36: batIconOn36Url, + 54: batIconOn54Url + } +} + +// const iconOff = { +// path: { +// 18: batIconOff18Url, +// 36: batIconOff36Url, +// 54: batIconOff54Url +// } +// } + +chrome.browserAction.setBadgeBackgroundColor({ color: '#FB542B' }) +chrome.browserAction.setIcon(iconOn) chrome.runtime.onInstalled.addListener(function (details) { if (details.reason === 'install') { diff --git a/components/brave_rewards/resources/extension/brave_rewards/img/rewards-off.png b/components/brave_rewards/resources/extension/brave_rewards/img/rewards-off.png new file mode 100644 index 000000000000..6ef1990ae440 Binary files /dev/null and b/components/brave_rewards/resources/extension/brave_rewards/img/rewards-off.png differ diff --git a/components/brave_rewards/resources/extension/brave_rewards/img/rewards-off@2x.png b/components/brave_rewards/resources/extension/brave_rewards/img/rewards-off@2x.png new file mode 100644 index 000000000000..e017d3077ea6 Binary files /dev/null and b/components/brave_rewards/resources/extension/brave_rewards/img/rewards-off@2x.png differ diff --git a/components/brave_rewards/resources/extension/brave_rewards/img/rewards-off@3x.png b/components/brave_rewards/resources/extension/brave_rewards/img/rewards-off@3x.png new file mode 100644 index 000000000000..8f0b903b808d Binary files /dev/null and b/components/brave_rewards/resources/extension/brave_rewards/img/rewards-off@3x.png differ diff --git a/components/brave_rewards/resources/extension/brave_rewards/img/rewards-on.png b/components/brave_rewards/resources/extension/brave_rewards/img/rewards-on.png new file mode 100644 index 000000000000..0260a61645ea Binary files /dev/null and b/components/brave_rewards/resources/extension/brave_rewards/img/rewards-on.png differ diff --git a/components/brave_rewards/resources/extension/brave_rewards/img/rewards-on@2x.png b/components/brave_rewards/resources/extension/brave_rewards/img/rewards-on@2x.png new file mode 100644 index 000000000000..cd20bb58902b Binary files /dev/null and b/components/brave_rewards/resources/extension/brave_rewards/img/rewards-on@2x.png differ diff --git a/components/brave_rewards/resources/extension/brave_rewards/img/rewards-on@3x.png b/components/brave_rewards/resources/extension/brave_rewards/img/rewards-on@3x.png new file mode 100644 index 000000000000..e5d0ae21a96f Binary files /dev/null and b/components/brave_rewards/resources/extension/brave_rewards/img/rewards-on@3x.png differ diff --git a/patches/chrome-browser-ui-extensions-icon_with_badge_image_source.cc.patch b/patches/chrome-browser-ui-extensions-icon_with_badge_image_source.cc.patch new file mode 100644 index 000000000000..b1e1ece7b682 --- /dev/null +++ b/patches/chrome-browser-ui-extensions-icon_with_badge_image_source.cc.patch @@ -0,0 +1,24 @@ +diff --git a/chrome/browser/ui/extensions/icon_with_badge_image_source.cc b/chrome/browser/ui/extensions/icon_with_badge_image_source.cc +index d3c8759bc0eab046ca895e11247d65611f53620b..092c87d894ab15911050556b0fd55df97597595a 100644 +--- a/chrome/browser/ui/extensions/icon_with_badge_image_source.cc ++++ b/chrome/browser/ui/extensions/icon_with_badge_image_source.cc +@@ -79,14 +79,18 @@ void IconWithBadgeImageSource::Draw(gfx::Canvas* canvas) { + gfx::ImageSkiaRep rep = skia.GetRepresentation(canvas->image_scale()); + if (rep.scale() != canvas->image_scale()) { + skia.AddRepresentation(ScaleImageSkiaRep( +- rep, ExtensionAction::ActionIconSize(), canvas->image_scale())); ++ rep, GetCustomGraphicSize().value_or(ExtensionAction::ActionIconSize()), canvas->image_scale())); + } + if (grayscale_) + skia = gfx::ImageSkiaOperations::CreateHSLShiftedImage(skia, {-1, 0, 0.75}); + + int x_offset = ++ GetCustomGraphicXOffset().has_value() ? ++ GetCustomGraphicXOffset().value() : + std::floor((size().width() - ExtensionAction::ActionIconSize()) / 2.0); + int y_offset = ++ GetCustomGraphicYOffset().has_value() ? ++ GetCustomGraphicYOffset().value() : + std::floor((size().height() - ExtensionAction::ActionIconSize()) / 2.0); + canvas->DrawImageInt(skia, x_offset, y_offset); + diff --git a/patches/chrome-browser-ui-extensions-icon_with_badge_image_source.h.patch b/patches/chrome-browser-ui-extensions-icon_with_badge_image_source.h.patch index 249a392ab432..ee00d57d1e5d 100644 --- a/patches/chrome-browser-ui-extensions-icon_with_badge_image_source.h.patch +++ b/patches/chrome-browser-ui-extensions-icon_with_badge_image_source.h.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/ui/extensions/icon_with_badge_image_source.h b/chrome/browser/ui/extensions/icon_with_badge_image_source.h -index addf0c4d1cd795eab24e538fbb136dcccd92f957..33577a779c5a038e9c32ce3d7a83797a75df6606 100644 +index addf0c4d1cd795eab24e538fbb136dcccd92f957..db769d55edbba9b7b3fdc579f91986f99cc161b7 100644 --- a/chrome/browser/ui/extensions/icon_with_badge_image_source.h +++ b/chrome/browser/ui/extensions/icon_with_badge_image_source.h @@ -13,6 +13,7 @@ @@ -18,7 +18,16 @@ index addf0c4d1cd795eab24e538fbb136dcccd92f957..33577a779c5a038e9c32ce3d7a83797a // The data representing a badge to be painted over the base image. struct Badge { Badge(const std::string& text, -@@ -60,7 +62,7 @@ class IconWithBadgeImageSource : public gfx::CanvasImageSource { +@@ -56,11 +58,16 @@ class IconWithBadgeImageSource : public gfx::CanvasImageSource { + } + + private: ++ // Custom values for Brave Action Icons ++ virtual base::Optional GetCustomGraphicSize(); ++ virtual base::Optional GetCustomGraphicXOffset(); ++ virtual base::Optional GetCustomGraphicYOffset(); ++ + // gfx::CanvasImageSource: void Draw(gfx::Canvas* canvas) override; // Paints |badge_|, if any, on |canvas|. @@ -27,7 +36,7 @@ index addf0c4d1cd795eab24e538fbb136dcccd92f957..33577a779c5a038e9c32ce3d7a83797a // Paints a decoration over the base icon to indicate that the action wants to // run. -@@ -75,7 +77,7 @@ class IconWithBadgeImageSource : public gfx::CanvasImageSource { +@@ -75,7 +82,7 @@ class IconWithBadgeImageSource : public gfx::CanvasImageSource { // all cases, our badges and decorations should be positions at the corners of // the area where the icon exists (ignoring all the paddings). // https://crbug.com/831946. diff --git a/patches/chrome-browser-ui-views-location_bar-location_bar_view.cc.patch b/patches/chrome-browser-ui-views-location_bar-location_bar_view.cc.patch index ca0321e05b19..633c05b1f280 100644 --- a/patches/chrome-browser-ui-views-location_bar-location_bar_view.cc.patch +++ b/patches/chrome-browser-ui-views-location_bar-location_bar_view.cc.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc -index 16a2d97dab9ffead2178e61cb3b9c65ea8f222c4..4098108819f3f49fbccafb034421628da38ef36b 100644 +index 16a2d97dab9ffead2178e61cb3b9c65ea8f222c4..103eeb6bb91c60c57598cc49e33b1213a2bc61ad 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -412,7 +412,7 @@ gfx::Size LocationBarView::CalculatePreferredSize() const { @@ -18,7 +18,7 @@ index 16a2d97dab9ffead2178e61cb3b9c65ea8f222c4..4098108819f3f49fbccafb034421628d + if (right_most && right_most->visible()) + trailing_decorations.AddDecoration(0, + height(), -+ false, 0, edge_padding, right_most); ++ false, 0, 0, right_most); + if (star_view_) add_trailing_decoration(star_view_);