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

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

Issue 2348853004: Remove non-md code in location bar (Views). (Closed)
Patch Set: images Created 4 years, 3 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/keyword_hint_view.h" 5 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/search_engines/template_url_service_factory.h" 16 #include "chrome/browser/search_engines/template_url_service_factory.h"
17 #include "chrome/browser/ui/layout_constants.h" 17 #include "chrome/browser/ui/layout_constants.h"
18 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" 18 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h"
19 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" 19 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h"
20 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 20 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
21 #include "chrome/grit/generated_resources.h" 21 #include "chrome/grit/generated_resources.h"
22 #include "chrome/grit/theme_resources.h" 22 #include "chrome/grit/theme_resources.h"
23 #include "components/search_engines/template_url_service.h" 23 #include "components/search_engines/template_url_service.h"
24 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/material_design/material_design_controller.h"
26 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/gfx/canvas.h" 26 #include "ui/gfx/canvas.h"
28 #include "ui/gfx/color_palette.h" 27 #include "ui/gfx/color_palette.h"
29 #include "ui/gfx/color_utils.h" 28 #include "ui/gfx/color_utils.h"
30 #include "ui/native_theme/native_theme.h" 29 #include "ui/native_theme/native_theme.h"
31 #include "ui/strings/grit/ui_strings.h" 30 #include "ui/strings/grit/ui_strings.h"
32 #include "ui/views/controls/image_view.h" 31 #include "ui/views/controls/image_view.h"
Peter Kasting 2016/09/19 23:46:45 Nit: Maybe don't need this #include
Evan Stade 2016/09/20 17:37:04 Done.
33 #include "ui/views/controls/label.h" 32 #include "ui/views/controls/label.h"
34 33
35 namespace { 34 namespace {
36 35
37 // This view sort of looks like a tab key. 36 // This view sort of looks like a tab key.
38 class TabKeyBubbleView : public views::Label { 37 class TabKeyBubbleView : public views::Label {
39 public: 38 public:
40 explicit TabKeyBubbleView(const gfx::FontList& font_list); 39 explicit TabKeyBubbleView(const gfx::FontList& font_list);
41 ~TabKeyBubbleView() override; 40 ~TabKeyBubbleView() override;
42 41
(...skipping 28 matching lines...) Expand all
71 int bubble_height, 70 int bubble_height,
72 SkColor text_color, 71 SkColor text_color,
73 SkColor background_color) 72 SkColor background_color)
74 : profile_(profile), 73 : profile_(profile),
75 leading_label_(nullptr), 74 leading_label_(nullptr),
76 tab_key_view_(nullptr), 75 tab_key_view_(nullptr),
77 trailing_label_(nullptr), 76 trailing_label_(nullptr),
78 tab_key_height_(bubble_height) { 77 tab_key_height_(bubble_height) {
79 leading_label_ = 78 leading_label_ =
80 CreateLabel(font_list, text_color, background_color); 79 CreateLabel(font_list, text_color, background_color);
81 if (ui::MaterialDesignController::IsModeMaterial()) { 80 TabKeyBubbleView* tab_key = new TabKeyBubbleView(bubble_font_list);
82 TabKeyBubbleView* tab_key = new TabKeyBubbleView(bubble_font_list); 81 tab_key->SetEnabledColor(text_color);
83 tab_key->SetEnabledColor(text_color); 82 bool inverted = color_utils::IsDark(background_color);
84 bool inverted = color_utils::IsDark(background_color); 83 SkColor tab_bg_color =
85 SkColor tab_bg_color = 84 inverted ? SK_ColorWHITE : SkColorSetA(text_color, 0x13);
86 inverted ? SK_ColorWHITE : SkColorSetA(text_color, 0x13); 85 SkColor tab_border_color = inverted ? SK_ColorWHITE : text_color;
87 SkColor tab_border_color = inverted ? SK_ColorWHITE : text_color; 86 tab_key->SetBackgroundColor(tab_bg_color);
88 tab_key->SetBackgroundColor(tab_bg_color); 87 tab_key->set_background(
89 tab_key->set_background( 88 new BackgroundWith1PxBorder(tab_bg_color, tab_border_color));
90 new BackgroundWith1PxBorder(tab_bg_color, tab_border_color)); 89 tab_key_view_ = tab_key;
91 tab_key_view_ = tab_key;
92 } else {
93 views::ImageView* tab_image = new views::ImageView();
94 tab_image->SetImage(
95 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
96 IDR_OMNIBOX_KEYWORD_HINT_TAB));
97 tab_key_view_ = tab_image;
98 }
99 AddChildView(tab_key_view_); 90 AddChildView(tab_key_view_);
100 trailing_label_ = 91 trailing_label_ =
101 CreateLabel(font_list, text_color, background_color); 92 CreateLabel(font_list, text_color, background_color);
102 } 93 }
103 94
104 KeywordHintView::~KeywordHintView() { 95 KeywordHintView::~KeywordHintView() {
105 } 96 }
106 97
107 void KeywordHintView::SetKeyword(const base::string16& keyword) { 98 void KeywordHintView::SetKeyword(const base::string16& keyword) {
108 keyword_ = keyword; 99 keyword_ = keyword;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 152
162 views::Label* KeywordHintView::CreateLabel(const gfx::FontList& font_list, 153 views::Label* KeywordHintView::CreateLabel(const gfx::FontList& font_list,
163 SkColor text_color, 154 SkColor text_color,
164 SkColor background_color) { 155 SkColor background_color) {
165 views::Label* label = new views::Label(base::string16(), font_list); 156 views::Label* label = new views::Label(base::string16(), font_list);
166 label->SetEnabledColor(text_color); 157 label->SetEnabledColor(text_color);
167 label->SetBackgroundColor(background_color); 158 label->SetBackgroundColor(background_color);
168 AddChildView(label); 159 AddChildView(label);
169 return label; 160 return label;
170 } 161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698