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

Side by Side Diff: chrome/browser/gtk/location_bar_view_gtk.cc

Issue 6322001: Remove wstring from TemplateURL and friends.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 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"
11 #include "app/resource_bundle.h" 11 #include "app/resource_bundle.h"
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 std::wstring short_name = profile_->GetTemplateURLModel()-> 986 const string16 short_name = profile_->GetTemplateURLModel()->
987 GetKeywordShortName(keyword, &is_extension_keyword); 987 GetKeywordShortName(WideToUTF16Hack(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 WideToUTF16Hack(short_name)); 991 short_name);
992 string16 partial_name = l10n_util::GetStringFUTF16( 992 string16 partial_name = l10n_util::GetStringFUTF16(
993 message_id, 993 message_id,
994 WideToUTF16Hack(location_bar_util::CalculateMinString(short_name))); 994 WideToUTF16Hack(
995 location_bar_util::CalculateMinString(UTF16ToWideHack(short_name))));
995 gtk_label_set_text(GTK_LABEL(tab_to_search_full_label_), 996 gtk_label_set_text(GTK_LABEL(tab_to_search_full_label_),
996 UTF16ToUTF8(full_name).c_str()); 997 UTF16ToUTF8(full_name).c_str());
997 gtk_label_set_text(GTK_LABEL(tab_to_search_partial_label_), 998 gtk_label_set_text(GTK_LABEL(tab_to_search_partial_label_),
998 UTF16ToUTF8(partial_name).c_str()); 999 UTF16ToUTF8(partial_name).c_str());
999 1000
1000 if (last_keyword_ != keyword) { 1001 if (last_keyword_ != keyword) {
1001 last_keyword_ = keyword; 1002 last_keyword_ = keyword;
1002 1003
1003 if (is_extension_keyword) { 1004 if (is_extension_keyword) {
1004 const TemplateURL* template_url = 1005 const TemplateURL* template_url =
1005 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword); 1006 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(
1007 WideToUTF16Hack(keyword));
1006 const SkBitmap& bitmap = profile_->GetExtensionService()-> 1008 const SkBitmap& bitmap = profile_->GetExtensionService()->
1007 GetOmniboxIcon(template_url->GetExtensionId()); 1009 GetOmniboxIcon(template_url->GetExtensionId());
1008 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); 1010 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap);
1009 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), pixbuf); 1011 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), pixbuf);
1010 g_object_unref(pixbuf); 1012 g_object_unref(pixbuf);
1011 } else { 1013 } else {
1012 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 1014 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
1013 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), 1015 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_),
1014 rb.GetPixbufNamed(IDR_OMNIBOX_SEARCH)); 1016 rb.GetPixbufNamed(IDR_OMNIBOX_SEARCH));
1015 } 1017 }
1016 } 1018 }
1017 } 1019 }
1018 1020
1019 void LocationBarViewGtk::SetKeywordHintLabel(const std::wstring& keyword) { 1021 void LocationBarViewGtk::SetKeywordHintLabel(const std::wstring& keyword) {
1020 if (keyword.empty()) 1022 if (keyword.empty())
1021 return; 1023 return;
1022 1024
1023 DCHECK(profile_); 1025 DCHECK(profile_);
1024 if (!profile_->GetTemplateURLModel()) 1026 if (!profile_->GetTemplateURLModel())
1025 return; 1027 return;
1026 1028
1027 bool is_extension_keyword; 1029 bool is_extension_keyword;
1028 const std::wstring short_name = profile_->GetTemplateURLModel()-> 1030 const string16 short_name = profile_->GetTemplateURLModel()->
1029 GetKeywordShortName(keyword, &is_extension_keyword); 1031 GetKeywordShortName(WideToUTF16Hack(keyword), &is_extension_keyword);
1030 int message_id = is_extension_keyword ? 1032 int message_id = is_extension_keyword ?
1031 IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT; 1033 IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT;
1032 std::vector<size_t> content_param_offsets; 1034 std::vector<size_t> content_param_offsets;
1033 const string16 keyword_hint = l10n_util::GetStringFUTF16( 1035 const string16 keyword_hint = l10n_util::GetStringFUTF16(
1034 message_id, 1036 message_id,
1035 string16(), 1037 string16(),
1036 WideToUTF16Hack(short_name), 1038 short_name,
1037 &content_param_offsets); 1039 &content_param_offsets);
1038 if (content_param_offsets.size() != 2) { 1040 if (content_param_offsets.size() != 2) {
1039 // See comments on an identical NOTREACHED() in search_provider.cc. 1041 // See comments on an identical NOTREACHED() in search_provider.cc.
1040 NOTREACHED(); 1042 NOTREACHED();
1041 return; 1043 return;
1042 } 1044 }
1043 1045
1044 std::string leading(UTF16ToUTF8( 1046 std::string leading(UTF16ToUTF8(
1045 keyword_hint.substr(0, content_param_offsets.front()))); 1047 keyword_hint.substr(0, content_param_offsets.front())));
1046 std::string trailing(UTF16ToUTF8( 1048 std::string trailing(UTF16ToUTF8(
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 1550
1549 std::string badge_text = page_action_->GetBadgeText(tab_id); 1551 std::string badge_text = page_action_->GetBadgeText(tab_id);
1550 if (badge_text.empty()) 1552 if (badge_text.empty())
1551 return FALSE; 1553 return FALSE;
1552 1554
1553 gfx::CanvasSkiaPaint canvas(event, false); 1555 gfx::CanvasSkiaPaint canvas(event, false);
1554 gfx::Rect bounding_rect(widget->allocation); 1556 gfx::Rect bounding_rect(widget->allocation);
1555 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); 1557 page_action_->PaintBadge(&canvas, bounding_rect, tab_id);
1556 return FALSE; 1558 return FALSE;
1557 } 1559 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/keyword_editor_view_unittest.cc ('k') | chrome/browser/gtk/options/general_page_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698