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

Side by Side Diff: chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc

Issue 1421683002: Update search chip icon for MD, vectorize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pkasting review 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" 5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/ui/views/layout_constants.h" 8 #include "chrome/browser/ui/views/layout_constants.h"
9 #include "ui/base/resource/material_design/material_design_controller.h"
9 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/color_utils.h" 12 #include "ui/gfx/color_utils.h"
12 #include "ui/views/controls/image_view.h" 13 #include "ui/views/controls/image_view.h"
13 #include "ui/views/painter.h" 14 #include "ui/views/painter.h"
14 15
15 namespace { 16 namespace {
16 17
17 SkColor CalculateImageColor(gfx::ImageSkia* image) { 18 SkColor CalculateImageColor(gfx::ImageSkia* image) {
18 // We grab the color of the middle pixel of the image, which we treat as 19 // We grab the color of the middle pixel of the image, which we treat as
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 double IconLabelBubbleView::WidthMultiplier() const { 94 double IconLabelBubbleView::WidthMultiplier() const {
94 return 1.0; 95 return 1.0;
95 } 96 }
96 97
97 gfx::Size IconLabelBubbleView::GetPreferredSize() const { 98 gfx::Size IconLabelBubbleView::GetPreferredSize() const {
98 // Height will be ignored by the LocationBarView. 99 // Height will be ignored by the LocationBarView.
99 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); 100 return GetSizeForLabelWidth(label_->GetPreferredSize().width());
100 } 101 }
101 102
102 void IconLabelBubbleView::Layout() { 103 void IconLabelBubbleView::Layout() {
104 // In MD mode, both extension icons and Chrome-provided icons are 16px,
105 // so it's not necessary to handle them differently. TODO(estade): clean
106 // this up when MD is on by default.
107 bool icon_needs_extra_padding =
108 !is_extension_icon_ && !ui::MaterialDesignController::IsModeMaterial();
103 const int image_width = image()->GetPreferredSize().width(); 109 const int image_width = image()->GetPreferredSize().width();
104 image_->SetBounds(std::min((width() - image_width) / 2, 110 image_->SetBounds(std::min((width() - image_width) / 2,
105 GetBubbleOuterPadding(!is_extension_icon_)), 111 GetBubbleOuterPadding(icon_needs_extra_padding)),
106 0, image_->GetPreferredSize().width(), height()); 112 0, image_->GetPreferredSize().width(), height());
107 113
108 const int padding = GetLayoutConstant(ICON_LABEL_VIEW_INTERNAL_PADDING); 114 const int padding = GetLayoutConstant(ICON_LABEL_VIEW_INTERNAL_PADDING);
109 int pre_label_width = 115 int pre_label_width =
110 GetBubbleOuterPadding(true) + (image_width ? (image_width + padding) : 0); 116 GetBubbleOuterPadding(true) + (image_width ? (image_width + padding) : 0);
111 label_->SetBounds(pre_label_width, 0, 117 label_->SetBounds(pre_label_width, 0,
112 width() - pre_label_width - GetBubbleOuterPadding(false), 118 width() - pre_label_width - GetBubbleOuterPadding(false),
113 height()); 119 height());
114 } 120 }
115 121
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 const char* IconLabelBubbleView::GetClassName() const { 158 const char* IconLabelBubbleView::GetClassName() const {
153 return "IconLabelBubbleView"; 159 return "IconLabelBubbleView";
154 } 160 }
155 161
156 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { 162 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) {
157 if (!ShouldShowBackground()) 163 if (!ShouldShowBackground())
158 return; 164 return;
159 if (background_painter_) 165 if (background_painter_)
160 background_painter_->Paint(canvas, size()); 166 background_painter_->Paint(canvas, size());
161 } 167 }
OLDNEW
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | chrome/browser/ui/views/location_bar/location_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698