Commit 94e20f2e authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Make more location bar-related colors respond correctly to theme changes.

Bug: 1033922
Change-Id: I8c8efc7cae25c2308d8f5289f3f124b0fa4782d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1983539Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728633}
parent 4a27784c
......@@ -77,6 +77,10 @@ void IconLabelBubbleView::SeparatorView::OnPaint(gfx::Canvas* canvas) {
gfx::PointF(x, GetLocalBounds().bottom()), separator_color);
}
void IconLabelBubbleView::SeparatorView::OnThemeChanged() {
SchedulePaint();
}
void IconLabelBubbleView::SeparatorView::UpdateOpacity() {
if (!GetVisible())
return;
......@@ -183,10 +187,6 @@ void IconLabelBubbleView::SetLabel(const base::string16& label_text) {
separator_view_->UpdateOpacity();
}
void IconLabelBubbleView::SetImage(const gfx::ImageSkia& image_skia) {
LabelButton::SetImage(STATE_NORMAL, image_skia);
}
void IconLabelBubbleView::SetFontList(const gfx::FontList& font_list) {
label()->SetFontList(font_list);
}
......@@ -394,6 +394,10 @@ void IconLabelBubbleView::OnTouchUiChanged() {
PreferredSizeChanged();
}
void IconLabelBubbleView::SetImage(const gfx::ImageSkia& image_skia) {
LabelButton::SetImage(STATE_NORMAL, image_skia);
}
gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int label_width) const {
gfx::Size image_size = image()->GetPreferredSize();
image_size.Enlarge(GetInsets().left() + GetWidthBetweenIconAndSeparator() +
......
......@@ -72,7 +72,6 @@ class IconLabelBubbleView : public views::InkDropObserver,
virtual bool ShouldShowLabel() const;
void SetLabel(const base::string16& label);
void SetImage(const gfx::ImageSkia& image);
void SetFontList(const gfx::FontList& font_list);
const views::ImageView* GetImageView() const { return image(); }
......@@ -142,6 +141,8 @@ class IconLabelBubbleView : public views::InkDropObserver,
const gfx::FontList& font_list() const { return label()->font_list(); }
void SetImage(const gfx::ImageSkia& image);
gfx::Size GetSizeForLabelWidth(int label_width) const;
// Set up for icons that animate their labels in. Animating out is initiated
......@@ -189,6 +190,7 @@ class IconLabelBubbleView : public views::InkDropObserver,
// views::View:
void OnPaint(gfx::Canvas* canvas) override;
void OnThemeChanged() override;
// Updates the opacity based on the ink drop's state.
void UpdateOpacity();
......
......@@ -428,7 +428,7 @@ gfx::Size LocationBarView::CalculatePreferredSize() const {
}
void LocationBarView::OnKeywordFaviconFetched(const gfx::Image& icon) {
selected_keyword_view_->SetImage(icon.AsImageSkia());
selected_keyword_view_->SetCustomImage(icon.AsImageSkia());
}
void LocationBarView::Layout() {
......@@ -506,7 +506,7 @@ void LocationBarView::Layout() {
gfx::Image image =
extensions::OmniboxAPI::Get(profile_)->GetOmniboxIcon(
template_url->GetExtensionId());
selected_keyword_view_->SetImage(image.AsImageSkia());
selected_keyword_view_->SetCustomImage(image.AsImageSkia());
} else if (template_url && template_url->type() == TemplateURL::NORMAL &&
OmniboxFieldTrial::IsExperimentalKeywordModeEnabled()) {
gfx::Image image =
......@@ -518,7 +518,7 @@ void LocationBarView::Layout() {
base::BindOnce(&LocationBarView::OnKeywordFaviconFetched,
base::Unretained(this)));
if (!image.IsEmpty())
selected_keyword_view_->SetImage(image.AsImageSkia());
selected_keyword_view_->SetCustomImage(image.AsImageSkia());
else
selected_keyword_view_->ResetImage();
} else {
......
......@@ -34,10 +34,16 @@ SelectedKeywordView::SelectedKeywordView(LocationBarView* location_bar,
SelectedKeywordView::~SelectedKeywordView() {}
void SelectedKeywordView::SetCustomImage(const gfx::ImageSkia& image) {
IconLabelBubbleView::SetImage(image);
using_custom_image_ = true;
}
void SelectedKeywordView::ResetImage() {
SetImage(gfx::CreateVectorIcon(vector_icons::kSearchIcon,
GetLayoutConstant(LOCATION_BAR_ICON_SIZE),
GetForegroundColor()));
IconLabelBubbleView::SetImage(gfx::CreateVectorIcon(
vector_icons::kSearchIcon, GetLayoutConstant(LOCATION_BAR_ICON_SIZE),
GetForegroundColor()));
using_custom_image_ = false;
}
void SelectedKeywordView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
......@@ -58,6 +64,12 @@ gfx::Size SelectedKeywordView::GetMinimumSize() const {
return GetSizeForLabelWidth(0);
}
void SelectedKeywordView::OnThemeChanged() {
IconLabelBubbleView::OnThemeChanged();
if (!using_custom_image_)
ResetImage();
}
void SelectedKeywordView::SetKeyword(const base::string16& keyword) {
if (keyword_ != keyword) {
keyword_ = keyword;
......
......@@ -29,13 +29,16 @@ class SelectedKeywordView : public IconLabelBubbleView {
Profile* profile);
~SelectedKeywordView() override;
// Resets the icon for this chip to its default (it may have been changed
// for an extension).
// Sets the icon for this chip to |image|.
void SetCustomImage(const gfx::ImageSkia& image);
// Resets the icon for this chip to its default.
void ResetImage();
// IconLabelBubbleView:
gfx::Size CalculatePreferredSize() const override;
gfx::Size GetMinimumSize() const override;
void OnThemeChanged() override;
SkColor GetForegroundColor() const override;
// The current keyword, or an empty string if no keyword is displayed.
......@@ -68,6 +71,9 @@ class SelectedKeywordView : public IconLabelBubbleView {
Profile* profile_;
// True when the chip icon has been changed via SetCustomImage().
bool using_custom_image_ = false;
DISALLOW_COPY_AND_ASSIGN(SelectedKeywordView);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment