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/gtk/location_bar_view_gtk.h" | 5 #include "chrome/browser/gtk/location_bar_view_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 | 978 |
979 void LocationBarViewGtk::SetKeywordLabel(const std::wstring& keyword) { | 979 void LocationBarViewGtk::SetKeywordLabel(const std::wstring& keyword) { |
980 if (keyword.empty()) | 980 if (keyword.empty()) |
981 return; | 981 return; |
982 | 982 |
983 DCHECK(profile_); | 983 DCHECK(profile_); |
984 if (!profile_->GetTemplateURLModel()) | 984 if (!profile_->GetTemplateURLModel()) |
985 return; | 985 return; |
986 | 986 |
987 bool is_extension_keyword; | 987 bool is_extension_keyword; |
988 const std::wstring short_name = profile_->GetTemplateURLModel()-> | 988 const string16 short_name = profile_->GetTemplateURLModel()-> |
989 GetKeywordShortName(keyword, &is_extension_keyword); | 989 GetKeywordShortName(WideToUTF16Hack(keyword), &is_extension_keyword); |
990 int message_id = is_extension_keyword ? | 990 int message_id = is_extension_keyword ? |
991 IDS_OMNIBOX_EXTENSION_KEYWORD_TEXT : IDS_OMNIBOX_KEYWORD_TEXT; | 991 IDS_OMNIBOX_EXTENSION_KEYWORD_TEXT : IDS_OMNIBOX_KEYWORD_TEXT; |
992 string16 full_name = l10n_util::GetStringFUTF16(message_id, | 992 string16 full_name = l10n_util::GetStringFUTF16(message_id, |
993 WideToUTF16Hack(short_name)); | 993 short_name); |
994 string16 partial_name = l10n_util::GetStringFUTF16( | 994 string16 partial_name = l10n_util::GetStringFUTF16( |
995 message_id, | 995 message_id, |
996 WideToUTF16Hack(location_bar_util::CalculateMinString(short_name))); | 996 WideToUTF16Hack( |
| 997 location_bar_util::CalculateMinString(UTF16ToWideHack(short_name)))); |
997 gtk_label_set_text(GTK_LABEL(tab_to_search_full_label_), | 998 gtk_label_set_text(GTK_LABEL(tab_to_search_full_label_), |
998 UTF16ToUTF8(full_name).c_str()); | 999 UTF16ToUTF8(full_name).c_str()); |
999 gtk_label_set_text(GTK_LABEL(tab_to_search_partial_label_), | 1000 gtk_label_set_text(GTK_LABEL(tab_to_search_partial_label_), |
1000 UTF16ToUTF8(partial_name).c_str()); | 1001 UTF16ToUTF8(partial_name).c_str()); |
1001 | 1002 |
1002 if (last_keyword_ != keyword) { | 1003 if (last_keyword_ != keyword) { |
1003 last_keyword_ = keyword; | 1004 last_keyword_ = keyword; |
1004 | 1005 |
1005 if (is_extension_keyword) { | 1006 if (is_extension_keyword) { |
1006 const TemplateURL* template_url = | 1007 const TemplateURL* template_url = |
1007 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword); | 1008 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword( |
| 1009 WideToUTF16Hack(keyword)); |
1008 const SkBitmap& bitmap = profile_->GetExtensionService()-> | 1010 const SkBitmap& bitmap = profile_->GetExtensionService()-> |
1009 GetOmniboxIcon(template_url->GetExtensionId()); | 1011 GetOmniboxIcon(template_url->GetExtensionId()); |
1010 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); | 1012 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); |
1011 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), pixbuf); | 1013 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), pixbuf); |
1012 g_object_unref(pixbuf); | 1014 g_object_unref(pixbuf); |
1013 } else { | 1015 } else { |
1014 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1016 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
1015 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), | 1017 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), |
1016 rb.GetPixbufNamed(IDR_OMNIBOX_SEARCH)); | 1018 rb.GetPixbufNamed(IDR_OMNIBOX_SEARCH)); |
1017 } | 1019 } |
1018 } | 1020 } |
1019 } | 1021 } |
1020 | 1022 |
1021 void LocationBarViewGtk::SetKeywordHintLabel(const std::wstring& keyword) { | 1023 void LocationBarViewGtk::SetKeywordHintLabel(const std::wstring& keyword) { |
1022 if (keyword.empty()) | 1024 if (keyword.empty()) |
1023 return; | 1025 return; |
1024 | 1026 |
1025 DCHECK(profile_); | 1027 DCHECK(profile_); |
1026 if (!profile_->GetTemplateURLModel()) | 1028 if (!profile_->GetTemplateURLModel()) |
1027 return; | 1029 return; |
1028 | 1030 |
1029 bool is_extension_keyword; | 1031 bool is_extension_keyword; |
1030 const std::wstring short_name = profile_->GetTemplateURLModel()-> | 1032 const string16 short_name = profile_->GetTemplateURLModel()-> |
1031 GetKeywordShortName(keyword, &is_extension_keyword); | 1033 GetKeywordShortName(WideToUTF16Hack(keyword), &is_extension_keyword); |
1032 int message_id = is_extension_keyword ? | 1034 int message_id = is_extension_keyword ? |
1033 IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT; | 1035 IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT; |
1034 std::vector<size_t> content_param_offsets; | 1036 std::vector<size_t> content_param_offsets; |
1035 const string16 keyword_hint = l10n_util::GetStringFUTF16( | 1037 const string16 keyword_hint = l10n_util::GetStringFUTF16( |
1036 message_id, | 1038 message_id, |
1037 string16(), | 1039 string16(), |
1038 WideToUTF16Hack(short_name), | 1040 short_name, |
1039 &content_param_offsets); | 1041 &content_param_offsets); |
1040 if (content_param_offsets.size() != 2) { | 1042 if (content_param_offsets.size() != 2) { |
1041 // See comments on an identical NOTREACHED() in search_provider.cc. | 1043 // See comments on an identical NOTREACHED() in search_provider.cc. |
1042 NOTREACHED(); | 1044 NOTREACHED(); |
1043 return; | 1045 return; |
1044 } | 1046 } |
1045 | 1047 |
1046 std::string leading(UTF16ToUTF8( | 1048 std::string leading(UTF16ToUTF8( |
1047 keyword_hint.substr(0, content_param_offsets.front()))); | 1049 keyword_hint.substr(0, content_param_offsets.front()))); |
1048 std::string trailing(UTF16ToUTF8( | 1050 std::string trailing(UTF16ToUTF8( |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 | 1553 |
1552 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1554 std::string badge_text = page_action_->GetBadgeText(tab_id); |
1553 if (badge_text.empty()) | 1555 if (badge_text.empty()) |
1554 return FALSE; | 1556 return FALSE; |
1555 | 1557 |
1556 gfx::CanvasSkiaPaint canvas(event, false); | 1558 gfx::CanvasSkiaPaint canvas(event, false); |
1557 gfx::Rect bounding_rect(widget->allocation); | 1559 gfx::Rect bounding_rect(widget->allocation); |
1558 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1560 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
1559 return FALSE; | 1561 return FALSE; |
1560 } | 1562 } |
OLD | NEW |