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

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

Issue 1421683002: Update search chip icon for MD, vectorize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 2 months 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/selected_keyword_view.h" 5 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search_engines/template_url_service_factory.h" 10 #include "chrome/browser/search_engines/template_url_service_factory.h"
11 #include "chrome/browser/ui/location_bar/location_bar_util.h" 11 #include "chrome/browser/ui/location_bar/location_bar_util.h"
12 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" 12 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h"
13 #include "chrome/grit/generated_resources.h" 13 #include "chrome/grit/generated_resources.h"
14 #include "components/search_engines/template_url_service.h" 14 #include "components/search_engines/template_url_service.h"
15 #include "grit/components_scaled_resources.h"
15 #include "grit/theme_resources.h" 16 #include "grit/theme_resources.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/material_design/material_design_controller.h" 18 #include "ui/base/resource/material_design/material_design_controller.h"
19 #include "ui/base/theme_provider.h"
20 #include "ui/gfx/color_palette.h"
21 #include "ui/gfx/paint_vector_icon.h"
22 #include "ui/gfx/vector_icons_public.h"
23 #include "ui/native_theme/native_theme.h"
24 #include "ui/views/controls/image_view.h"
Peter Kasting 2015/10/23 23:44:09 Are all these needed? It kinda surprises me that
Evan Stade 2015/10/26 19:29:19 a couple were not necessary
18 #include "ui/views/painter.h" 25 #include "ui/views/painter.h"
19 26
20 SelectedKeywordView::SelectedKeywordView(const gfx::FontList& font_list, 27 SelectedKeywordView::SelectedKeywordView(const gfx::FontList& font_list,
21 SkColor text_color, 28 SkColor text_color,
22 SkColor parent_background_color, 29 SkColor parent_background_color,
23 Profile* profile) 30 Profile* profile)
24 : IconLabelBubbleView(IDR_KEYWORD_SEARCH_MAGNIFIER, 31 : IconLabelBubbleView(0,
Evan Stade 2015/10/23 21:49:40 this was actually never visible because it got ove
25 font_list, 32 font_list,
26 text_color, 33 text_color,
27 parent_background_color, 34 parent_background_color,
28 false), 35 false),
29 profile_(profile) { 36 profile_(profile) {
30 if (ui::MaterialDesignController::IsModeMaterial()) { 37 if (ui::MaterialDesignController::IsModeMaterial()) {
31 // The inset for IDR_OMNIBOX_SELECTED_KEYWORD_BUBBLE for which to perfom 38 // The inset for IDR_OMNIBOX_SELECTED_KEYWORD_BUBBLE for which to perfom
32 // nine-slicing. 39 // nine-slicing.
33 static const int kImageInset = 4; 40 static const int kImageInset = 4;
34 gfx::Insets insets(kImageInset, kImageInset, kImageInset, kImageInset); 41 gfx::Insets insets(kImageInset, kImageInset, kImageInset, kImageInset);
35 SetBackgroundImageWithInsets(IDR_OMNIBOX_SELECTED_KEYWORD_BUBBLE, insets); 42 SetBackgroundImageWithInsets(IDR_OMNIBOX_SELECTED_KEYWORD_BUBBLE, insets);
36 } else { 43 } else {
37 static const int kBackgroundImages[] = 44 static const int kBackgroundImages[] =
38 IMAGE_GRID(IDR_OMNIBOX_SELECTED_KEYWORD_BUBBLE); 45 IMAGE_GRID(IDR_OMNIBOX_SELECTED_KEYWORD_BUBBLE);
39 SetBackgroundImageGrid(kBackgroundImages); 46 SetBackgroundImageGrid(kBackgroundImages);
40 } 47 }
41 full_label_.SetFontList(font_list); 48 full_label_.SetFontList(font_list);
42 full_label_.SetVisible(false); 49 full_label_.SetVisible(false);
43 partial_label_.SetFontList(font_list); 50 partial_label_.SetFontList(font_list);
44 partial_label_.SetVisible(false); 51 partial_label_.SetVisible(false);
45 } 52 }
46 53
47 SelectedKeywordView::~SelectedKeywordView() { 54 SelectedKeywordView::~SelectedKeywordView() {
48 } 55 }
49 56
57 void SelectedKeywordView::ResetImage() {
58 if (ui::MaterialDesignController::IsModeMaterial()) {
59 SkColor link_color =
60 GetNativeTheme()->GetSystemColor(ui::NativeTheme::kColorId_LinkEnabled);
Peter Kasting 2015/10/23 23:44:09 Huh. Are we sure we want the magnifier to be the
Evan Stade 2015/10/26 19:29:19 The magnifier is set in a chip and the border of t
Peter Kasting 2015/10/26 19:57:41 GetSystemColor() probably isn't right, then, since
Evan Stade 2015/10/26 20:19:36 NativeTheme does not necessarily draw from system
Peter Kasting 2015/10/26 20:34:01 At least on Windows, where there is a concept of a
Evan Stade 2015/10/26 21:29:42 Perhaps that was the original intent, but right no
Peter Kasting 2015/10/26 22:21:19 I haven't studied Linux in detail, but last time I
61 SetImage(gfx::CreateVectorIcon(gfx::VectorIconId::SEARCH_CHIP_ICON, 16,
62 link_color));
63 } else {
64 SetImage(*GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH));
65 }
66 }
67
50 gfx::Size SelectedKeywordView::GetPreferredSize() const { 68 gfx::Size SelectedKeywordView::GetPreferredSize() const {
51 // Height will be ignored by the LocationBarView. 69 // Height will be ignored by the LocationBarView.
52 return GetSizeForLabelWidth(full_label_.GetPreferredSize().width()); 70 return GetSizeForLabelWidth(full_label_.GetPreferredSize().width());
53 } 71 }
54 72
55 gfx::Size SelectedKeywordView::GetMinimumSize() const { 73 gfx::Size SelectedKeywordView::GetMinimumSize() const {
56 // Height will be ignored by the LocationBarView. 74 // Height will be ignored by the LocationBarView.
57 return GetSizeForLabelWidth(partial_label_.GetMinimumSize().width()); 75 return GetSizeForLabelWidth(partial_label_.GetMinimumSize().width());
58 } 76 }
59 77
(...skipping 26 matching lines...) Expand all
86 const base::string16 partial_name = is_extension_keyword ? 104 const base::string16 partial_name = is_extension_keyword ?
87 min_string : 105 min_string :
88 l10n_util::GetStringFUTF16(IDS_OMNIBOX_KEYWORD_TEXT, min_string); 106 l10n_util::GetStringFUTF16(IDS_OMNIBOX_KEYWORD_TEXT, min_string);
89 partial_label_.SetText(min_string.empty() ? 107 partial_label_.SetText(min_string.empty() ?
90 full_label_.text() : partial_name); 108 full_label_.text() : partial_name);
91 } 109 }
92 110
93 const char* SelectedKeywordView::GetClassName() const { 111 const char* SelectedKeywordView::GetClassName() const {
94 return "SelectedKeywordView"; 112 return "SelectedKeywordView";
95 } 113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698