Skip to content

Commit

Permalink
WebUI tab strip: fix new tab button does not change color OnThemeChange
Browse files Browse the repository at this point in the history
Bug: 1225079
Change-Id: I0cab1dd657a29d765dec19fd1754377d0e8e92aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2994870
Commit-Queue: Yuheng Huang <yuhengh@chromium.org>
Reviewed-by: Collin Baker <collinbaker@chromium.org>
Reviewed-by: Thomas Lukaszewicz <tluk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#897144}
  • Loading branch information
Yuheng Huang authored and Chromium LUCI CQ committed Jun 29, 2021
1 parent 83b51e4 commit b831eab
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions chrome/browser/ui/views/frame/webui_tab_strip_container_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,29 @@ class WebUITabStripWebView : public views::WebView {
BEGIN_METADATA(WebUITabStripWebView, views::WebView)
END_METADATA

class WebUINewTabButton : public ToolbarButton {
public:
METADATA_HEADER(WebUINewTabButton);
explicit WebUINewTabButton(PressedCallback pressed_callback)
: ToolbarButton(pressed_callback) {
SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_NEW_TAB));
const int button_height = GetLayoutConstant(TOOLBAR_BUTTON_HEIGHT);
SetPreferredSize(gfx::Size(button_height, button_height));
SetHorizontalAlignment(gfx::ALIGN_CENTER);
}

void OnThemeChanged() override {
ToolbarButton::OnThemeChanged();
const SkColor normal_color = GetThemeProvider()->GetColor(
ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
SetImage(views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(kNewTabToolbarButtonIcon, normal_color));
}
};

BEGIN_METADATA(WebUINewTabButton, ToolbarButton)
END_METADATA

} // namespace

// When enabled, closes the container for taps in either the web content
Expand Down Expand Up @@ -587,24 +610,11 @@ views::NativeViewHost* WebUITabStripContainerView::GetNativeViewHost() {

std::unique_ptr<views::View> WebUITabStripContainerView::CreateNewTabButton() {
DCHECK_EQ(nullptr, new_tab_button_);
auto new_tab_button = std::make_unique<ToolbarButton>(
auto new_tab_button = std::make_unique<WebUINewTabButton>(
base::BindRepeating(&WebUITabStripContainerView::NewTabButtonPressed,
base::Unretained(this)));
new_tab_button->SetTooltipText(
l10n_util::GetStringUTF16(IDS_TOOLTIP_NEW_TAB));
const SkColor normal_color =
GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
new_tab_button->SetImage(
views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(kNewTabToolbarButtonIcon, normal_color));

const int button_height = GetLayoutConstant(TOOLBAR_BUTTON_HEIGHT);
new_tab_button->SetPreferredSize(gfx::Size(button_height, button_height));
new_tab_button->SetHorizontalAlignment(gfx::ALIGN_CENTER);

new_tab_button_ = new_tab_button.get();
view_observations_.AddObservation(new_tab_button_);

return new_tab_button;
}

Expand Down

0 comments on commit b831eab

Please sign in to comment.