OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 void KeywordHintView::SetFont(const gfx::Font& font) { | 41 void KeywordHintView::SetFont(const gfx::Font& font) { |
42 leading_label_->SetFont(font); | 42 leading_label_->SetFont(font); |
43 trailing_label_->SetFont(font); | 43 trailing_label_->SetFont(font); |
44 } | 44 } |
45 | 45 |
46 void KeywordHintView::SetColor(const SkColor& color) { | 46 void KeywordHintView::SetColor(const SkColor& color) { |
47 leading_label_->SetColor(color); | 47 leading_label_->SetColor(color); |
48 trailing_label_->SetColor(color); | 48 trailing_label_->SetColor(color); |
49 } | 49 } |
50 | 50 |
51 void KeywordHintView::SetKeyword(const std::wstring& keyword) { | 51 void KeywordHintView::SetKeyword(const string16& keyword) { |
52 keyword_ = keyword; | 52 keyword_ = keyword; |
53 if (keyword_.empty()) | 53 if (keyword_.empty()) |
54 return; | 54 return; |
55 DCHECK(profile_); | 55 DCHECK(profile_); |
56 if (!profile_->GetTemplateURLModel()) | 56 if (!profile_->GetTemplateURLModel()) |
57 return; | 57 return; |
58 | 58 |
59 std::vector<size_t> content_param_offsets; | 59 std::vector<size_t> content_param_offsets; |
60 bool is_extension_keyword; | 60 bool is_extension_keyword; |
61 string16 short_name = profile_->GetTemplateURLModel()-> | 61 string16 short_name = profile_->GetTemplateURLModel()-> |
62 GetKeywordShortName(WideToUTF16Hack(keyword), &is_extension_keyword); | 62 GetKeywordShortName(keyword, &is_extension_keyword); |
63 int message_id = is_extension_keyword ? | 63 int message_id = is_extension_keyword ? |
64 IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT; | 64 IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT; |
65 const std::wstring keyword_hint = | 65 const std::wstring keyword_hint = |
66 UTF16ToWide(l10n_util::GetStringFUTF16( | 66 UTF16ToWide(l10n_util::GetStringFUTF16( |
67 message_id, | 67 message_id, |
68 string16(), | 68 string16(), |
69 short_name, | 69 short_name, |
70 &content_param_offsets)); | 70 &content_param_offsets)); |
71 if (content_param_offsets.size() == 2) { | 71 if (content_param_offsets.size() == 2) { |
72 leading_label_->SetText( | 72 leading_label_->SetText( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 if (show_labels) { | 124 if (show_labels) { |
125 pref = leading_label_->GetPreferredSize(); | 125 pref = leading_label_->GetPreferredSize(); |
126 leading_label_->SetBounds(x, 0, pref.width(), height()); | 126 leading_label_->SetBounds(x, 0, pref.width(), height()); |
127 | 127 |
128 x += pref.width() + kTabButtonBitmap->width(); | 128 x += pref.width() + kTabButtonBitmap->width(); |
129 pref = trailing_label_->GetPreferredSize(); | 129 pref = trailing_label_->GetPreferredSize(); |
130 trailing_label_->SetBounds(x, 0, pref.width(), height()); | 130 trailing_label_->SetBounds(x, 0, pref.width(), height()); |
131 } | 131 } |
132 } | 132 } |
OLD | NEW |