Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc

Issue 1423263004: [MD] Use programmatic rendering for omnibox chips (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 3331425aa198acba98ac154106d97e7fbe914074..73d899010f58dbf103a1df6139232110b35d6f34 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
@@ -6,6 +6,7 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/views/layout_constants.h"
+#include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h"
#include "ui/base/resource/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
@@ -69,16 +70,6 @@ void IconLabelBubbleView::SetBackgroundImageGrid(
SetLabelBackgroundColor(CalculateImageColor(background_image));
}
-void IconLabelBubbleView::SetBackgroundImageWithInsets(int background_image_id,
- gfx::Insets& insets) {
- gfx::ImageSkia* background_image =
- ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
- background_image_id);
- background_painter_.reset(
- views::Painter::CreateImagePainter(*background_image, insets));
- SetLabelBackgroundColor(CalculateImageColor(background_image));
-}
-
void IconLabelBubbleView::SetLabel(const base::string16& label) {
label_->SetText(label);
}
@@ -119,6 +110,19 @@ void IconLabelBubbleView::Layout() {
height());
}
+void IconLabelBubbleView::OnNativeThemeChanged(
+ const ui::NativeTheme* native_theme) {
+ if (!ui::MaterialDesignController::IsModeMaterial())
+ return;
+
+ label_->SetEnabledColor(GetTextColor());
+ SkColor border_color = GetBorderColor();
+ SkColor background_color = SkColorSetA(border_color, 0x13);
+ set_background(
+ new BackgroundWith1PxBorder(background_color, border_color, false));
+ SetLabelBackgroundColor(background_color);
+}
+
gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const {
gfx::Size size(image_->GetPreferredSize());
if (ShouldShowBackground()) {
@@ -129,7 +133,8 @@ gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const {
(image_width ? (image_width + padding) : 0) +
GetBubbleOuterPadding(false);
size = gfx::Size(WidthMultiplier() * (width + non_label_width), 0);
- size.SetToMax(background_painter_->GetMinimumSize());
+ if (!ui::MaterialDesignController::IsModeMaterial())
+ size.SetToMax(background_painter_->GetMinimumSize());
}
return size;
@@ -164,4 +169,6 @@ void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) {
return;
if (background_painter_)
background_painter_->Paint(canvas, size());
+ if (background())
+ background()->Paint(canvas, this);
}

Powered by Google App Engine
This is Rietveld 408576698