Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc |
| diff --git a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc |
| index f6a1d472cd322f17b5624c34bfb4c41aacb2e132..42fad880720294ea4089ea99a98d9954f79a8150 100644 |
| --- a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc |
| +++ b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc |
| @@ -11,6 +11,7 @@ |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/gfx/canvas.h" |
| #include "ui/gfx/color_utils.h" |
| +#include "ui/native_theme/native_theme.h" |
| #include "ui/views/controls/image_view.h" |
| #include "ui/views/painter.h" |
| @@ -122,8 +123,7 @@ void IconLabelBubbleView::OnNativeThemeChanged( |
| label_->SetEnabledColor(GetTextColor()); |
| - bool inverted = |
| - color_utils::GetLuminanceForColor(parent_background_color_) < 128; |
| + bool inverted = IsInvertedColorScheme(); |
| SkColor border_color = inverted ? SK_ColorWHITE : GetBorderColor(); |
| SkColor background_color = |
| inverted ? SK_ColorWHITE : SkColorSetA(border_color, 0x13); |
| @@ -132,6 +132,11 @@ void IconLabelBubbleView::OnNativeThemeChanged( |
| SetLabelBackgroundColor(background_color); |
| } |
| +bool IconLabelBubbleView::IsInvertedColorScheme() const { |
| + return color_utils::IsDark(GetNativeTheme()->GetSystemColor( |
| + ui::NativeTheme::kColorId_TextfieldDefaultBackground)); |
|
Peter Kasting
2015/11/17 21:27:03
The code to get this background color is repeated
Evan Stade
2015/11/17 22:57:21
Done.
|
| +} |
| + |
| gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const { |
| gfx::Size size(image_->GetPreferredSize()); |
| if (ShouldShowBackground()) { |
| @@ -165,17 +170,22 @@ int IconLabelBubbleView::GetBubbleOuterPaddingMd(bool leading) const { |
| } |
| void IconLabelBubbleView::SetLabelBackgroundColor( |
| - SkColor background_image_color) { |
| + SkColor chip_background_color) { |
| + SkColor parent_background_color = |
| + ui::MaterialDesignController::IsModeMaterial() |
| + ? GetNativeTheme()->GetSystemColor( |
| + ui::NativeTheme::kColorId_TextfieldDefaultBackground) |
| + : parent_background_color_; |
| // The background images are painted atop |parent_background_color_|. |
| - // Alpha-blend |background_image_color| with |parent_background_color_| to |
| + // Alpha-blend |chip_background_color| with |parent_background_color_| to |
| // determine the actual color the label text will sit atop. |
| - // Tricky bit: We alpha blend an opaque version of |background_image_color| |
| + // Tricky bit: We alpha blend an opaque version of |chip_background_color| |
| // against |parent_background_color_| using the original image grid color's |
| // alpha. This is because AlphaBlend(a, b, 255) always returns |a| unchanged |
| // even if |a| is a color with non-255 alpha. |
| label_->SetBackgroundColor(color_utils::AlphaBlend( |
| - SkColorSetA(background_image_color, 255), parent_background_color_, |
| - SkColorGetA(background_image_color))); |
| + SkColorSetA(chip_background_color, 255), parent_background_color, |
| + SkColorGetA(chip_background_color))); |
| } |
| const char* IconLabelBubbleView::GetClassName() const { |