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