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

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

Issue 869453002: Define class names for views class in c/b/ui/views (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: inline class name strings Created 5 years, 11 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 <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/search_engines/template_url_service_factory.h" 13 #include "chrome/browser/search_engines/template_url_service_factory.h"
14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
15 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
16 #include "components/search_engines/template_url_service.h" 16 #include "components/search_engines/template_url_service.h"
17 #include "grit/theme_resources.h" 17 #include "grit/theme_resources.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
21 #include "ui/views/controls/image_view.h" 21 #include "ui/views/controls/image_view.h"
22 #include "ui/views/controls/label.h" 22 #include "ui/views/controls/label.h"
23 23
24
Peter Kasting 2015/01/23 07:28:10 Nit: Don't remove this (I generally try to separat
oshima 2015/01/24 01:23:07 Done.
25 KeywordHintView::KeywordHintView(Profile* profile, 24 KeywordHintView::KeywordHintView(Profile* profile,
26 const gfx::FontList& font_list, 25 const gfx::FontList& font_list,
27 SkColor text_color, 26 SkColor text_color,
28 SkColor background_color) 27 SkColor background_color)
29 : profile_(profile), 28 : profile_(profile),
30 tab_image_(new views::ImageView()) { 29 tab_image_(new views::ImageView()) {
31 leading_label_ = 30 leading_label_ =
32 CreateLabel(font_list, text_color, background_color); 31 CreateLabel(font_list, text_color, background_color);
33 tab_image_->SetImage( 32 tab_image_->SetImage(
34 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 33 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
(...skipping 23 matching lines...) Expand all
58 int message_id = is_extension_keyword ? 57 int message_id = is_extension_keyword ?
59 IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT; 58 IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT;
60 const base::string16 keyword_hint = l10n_util::GetStringFUTF16( 59 const base::string16 keyword_hint = l10n_util::GetStringFUTF16(
61 message_id, base::string16(), short_name, &content_param_offsets); 60 message_id, base::string16(), short_name, &content_param_offsets);
62 DCHECK_EQ(2U, content_param_offsets.size()); 61 DCHECK_EQ(2U, content_param_offsets.size());
63 leading_label_->SetText( 62 leading_label_->SetText(
64 keyword_hint.substr(0, content_param_offsets.front())); 63 keyword_hint.substr(0, content_param_offsets.front()));
65 trailing_label_->SetText(keyword_hint.substr(content_param_offsets.front())); 64 trailing_label_->SetText(keyword_hint.substr(content_param_offsets.front()));
66 } 65 }
67 66
67 const char* KeywordHintView::GetClassName() const {
68 return "KeywordHintView";
69 }
70
68 gfx::Size KeywordHintView::GetPreferredSize() const { 71 gfx::Size KeywordHintView::GetPreferredSize() const {
69 // Height will be ignored by the LocationBarView. 72 // Height will be ignored by the LocationBarView.
70 return gfx::Size(leading_label_->GetPreferredSize().width() + 73 return gfx::Size(leading_label_->GetPreferredSize().width() +
71 tab_image_->GetPreferredSize().width() + 74 tab_image_->GetPreferredSize().width() +
72 trailing_label_->GetPreferredSize().width(), 75 trailing_label_->GetPreferredSize().width(),
73 0); 76 0);
74 } 77 }
75 78
76 gfx::Size KeywordHintView::GetMinimumSize() const { 79 gfx::Size KeywordHintView::GetMinimumSize() const {
77 // Height will be ignored by the LocationBarView. 80 // Height will be ignored by the LocationBarView.
(...skipping 16 matching lines...) Expand all
94 97
95 views::Label* KeywordHintView::CreateLabel(const gfx::FontList& font_list, 98 views::Label* KeywordHintView::CreateLabel(const gfx::FontList& font_list,
96 SkColor text_color, 99 SkColor text_color,
97 SkColor background_color) { 100 SkColor background_color) {
98 views::Label* label = new views::Label(base::string16(), font_list); 101 views::Label* label = new views::Label(base::string16(), font_list);
99 label->SetEnabledColor(text_color); 102 label->SetEnabledColor(text_color);
100 label->SetBackgroundColor(background_color); 103 label->SetBackgroundColor(background_color);
101 AddChildView(label); 104 AddChildView(label);
102 return label; 105 return label;
103 } 106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698