| 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 <vector> | |
| 8 | |
| 9 #include "base/logging.h" | 7 #include "base/logging.h" |
| 10 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/search_engines/template_url_service.h" | 11 #include "chrome/browser/search_engines/template_url_service.h" |
| 14 #include "chrome/browser/search_engines/template_url_service_factory.h" | 12 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 15 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 16 #include "grit/theme_resources.h" | 14 #include "grit/theme_resources.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 TemplateURLServiceFactory::GetForProfile(profile_); | 58 TemplateURLServiceFactory::GetForProfile(profile_); |
| 61 if (!url_service) | 59 if (!url_service) |
| 62 return; | 60 return; |
| 63 | 61 |
| 64 std::vector<size_t> content_param_offsets; | 62 std::vector<size_t> content_param_offsets; |
| 65 bool is_extension_keyword; | 63 bool is_extension_keyword; |
| 66 string16 short_name = url_service->GetKeywordShortName(keyword, | 64 string16 short_name = url_service->GetKeywordShortName(keyword, |
| 67 &is_extension_keyword); | 65 &is_extension_keyword); |
| 68 int message_id = is_extension_keyword ? | 66 int message_id = is_extension_keyword ? |
| 69 IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT; | 67 IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT; |
| 70 const string16 keyword_hint = l10n_util::GetStringFUTF16( | 68 const std::wstring keyword_hint = |
| 71 message_id, | 69 UTF16ToWide(l10n_util::GetStringFUTF16( |
| 72 string16(), | 70 message_id, |
| 73 short_name, | 71 string16(), |
| 74 &content_param_offsets); | 72 short_name, |
| 73 &content_param_offsets)); |
| 75 if (content_param_offsets.size() == 2) { | 74 if (content_param_offsets.size() == 2) { |
| 76 leading_label_->SetText( | 75 leading_label_->SetText( |
| 77 keyword_hint.substr(0, content_param_offsets.front())); | 76 keyword_hint.substr(0, content_param_offsets.front())); |
| 78 trailing_label_->SetText( | 77 trailing_label_->SetText( |
| 79 keyword_hint.substr(content_param_offsets.front())); | 78 keyword_hint.substr(content_param_offsets.front())); |
| 80 } else { | 79 } else { |
| 81 // See comments on an identical NOTREACHED() in search_provider.cc. | 80 // See comments on an identical NOTREACHED() in search_provider.cc. |
| 82 NOTREACHED(); | 81 NOTREACHED(); |
| 83 } | 82 } |
| 84 } | 83 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 126 |
| 128 if (show_labels) { | 127 if (show_labels) { |
| 129 pref = leading_label_->GetPreferredSize(); | 128 pref = leading_label_->GetPreferredSize(); |
| 130 leading_label_->SetBounds(x, 0, pref.width(), height()); | 129 leading_label_->SetBounds(x, 0, pref.width(), height()); |
| 131 | 130 |
| 132 x += pref.width() + kTabButtonBitmap->width(); | 131 x += pref.width() + kTabButtonBitmap->width(); |
| 133 pref = trailing_label_->GetPreferredSize(); | 132 pref = trailing_label_->GetPreferredSize(); |
| 134 trailing_label_->SetBounds(x, 0, pref.width(), height()); | 133 trailing_label_->SetBounds(x, 0, pref.width(), height()); |
| 135 } | 134 } |
| 136 } | 135 } |
| OLD | NEW |