summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-14 19:31:09 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-14 19:31:09 +0000
commit2674971542ef049b13ddad5dc1ac77fa9b16f498 (patch)
treefaae032905d7fafbedeee45b440ac3b9be678b56 /chrome/common
parentf06c262be1375eb6fc880dc044186653f873f665 (diff)
downloadchromium_src-2674971542ef049b13ddad5dc1ac77fa9b16f498.zip
chromium_src-2674971542ef049b13ddad5dc1ac77fa9b16f498.tar.gz
chromium_src-2674971542ef049b13ddad5dc1ac77fa9b16f498.tar.bz2
Switch ResourceBundle::GetLocalizedString to return a string16 instead
of a wstring. This saves us a conversion to wstring on linux when getting utf8 strings. BUG=9911 Review URL: http://codereview.chromium.org/67134 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13692 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/l10n_util.cc12
-rw-r--r--chrome/common/resource_bundle.h2
-rw-r--r--chrome/common/resource_bundle_linux.cc8
-rw-r--r--chrome/common/resource_bundle_mac.mm8
-rw-r--r--chrome/common/resource_bundle_win.cc8
5 files changed, 19 insertions, 19 deletions
diff --git a/chrome/common/l10n_util.cc b/chrome/common/l10n_util.cc
index cdb65d7..2b47e5f 100644
--- a/chrome/common/l10n_util.cc
+++ b/chrome/common/l10n_util.cc
@@ -293,12 +293,13 @@ std::wstring GetLocalName(const std::string& locale_code_str,
}
std::wstring GetString(int message_id) {
- ResourceBundle &rb = ResourceBundle::GetSharedInstance();
- return rb.GetLocalizedString(message_id);
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ return UTF16ToWide(rb.GetLocalizedString(message_id));
}
std::string GetStringUTF8(int message_id) {
- return WideToUTF8(GetString(message_id));
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ return UTF16ToUTF8(rb.GetLocalizedString(message_id));
}
static string16 GetStringF(int message_id,
@@ -307,9 +308,8 @@ static string16 GetStringF(int message_id,
const string16& c,
const string16& d,
std::vector<size_t>* offsets) {
- // TODO(tc): ResourceBundle::GetLocalizedString should return a string16
- // so we can avoid this conversion on linux/mac.
- const string16& format_string = WideToUTF16(GetString(message_id));
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ const string16& format_string = rb.GetLocalizedString(message_id);
string16 formatted = ReplaceStringPlaceholders(format_string, a, b, c, d,
offsets);
return formatted;
diff --git a/chrome/common/resource_bundle.h b/chrome/common/resource_bundle.h
index 76b9252..6fa3a7e 100644
--- a/chrome/common/resource_bundle.h
+++ b/chrome/common/resource_bundle.h
@@ -100,7 +100,7 @@ class ResourceBundle {
// Get a localized string given a message id. Returns an empty
// string if the message_id is not found.
- std::wstring GetLocalizedString(int message_id);
+ string16 GetLocalizedString(int message_id);
// Returns the font for the specified style.
ChromeFont GetFont(FontStyle style);
diff --git a/chrome/common/resource_bundle_linux.cc b/chrome/common/resource_bundle_linux.cc
index 009b5d3..870d817 100644
--- a/chrome/common/resource_bundle_linux.cc
+++ b/chrome/common/resource_bundle_linux.cc
@@ -97,12 +97,12 @@ StringPiece ResourceBundle::GetRawDataResource(int resource_id) {
return data;
}
-std::wstring ResourceBundle::GetLocalizedString(int message_id) {
+string16 ResourceBundle::GetLocalizedString(int message_id) {
// If for some reason we were unable to load a resource dll, return an empty
// string (better than crashing).
if (!locale_resources_data_) {
LOG(WARNING) << "locale resources are not loaded";
- return std::wstring();
+ return string16();
}
StringPiece data;
@@ -112,14 +112,14 @@ std::wstring ResourceBundle::GetLocalizedString(int message_id) {
data = GetRawDataResource(message_id);
if (data.empty()) {
NOTREACHED() << "unable to find resource: " << message_id;
- return std::wstring();
+ return string16();
}
}
// Data pack encodes strings as UTF16.
string16 msg(reinterpret_cast<const char16*>(data.data()),
data.length() / 2);
- return UTF16ToWide(msg);
+ return msg;
}
#if defined(TOOLKIT_GTK)
diff --git a/chrome/common/resource_bundle_mac.mm b/chrome/common/resource_bundle_mac.mm
index 3059d62..0a6664f 100644
--- a/chrome/common/resource_bundle_mac.mm
+++ b/chrome/common/resource_bundle_mac.mm
@@ -94,12 +94,12 @@ StringPiece ResourceBundle::GetRawDataResource(int resource_id) {
return data;
}
-std::wstring ResourceBundle::GetLocalizedString(int message_id) {
+string16 ResourceBundle::GetLocalizedString(int message_id) {
// If for some reason we were unable to load a resource dll, return an empty
// string (better than crashing).
if (!locale_resources_data_) {
LOG(WARNING) << "locale resources are not loaded";
- return std::wstring();
+ return string16();
}
StringPiece data;
@@ -109,12 +109,12 @@ std::wstring ResourceBundle::GetLocalizedString(int message_id) {
data = GetRawDataResource(message_id);
if (data.empty()) {
NOTREACHED() << "unable to find resource: " << message_id;
- return std::wstring();
+ return string16();
}
}
// Data pack encodes strings as UTF16.
string16 msg(reinterpret_cast<const char16*>(data.data()),
data.length() / 2);
- return UTF16ToWide(msg);
+ return msg;
}
diff --git a/chrome/common/resource_bundle_win.cc b/chrome/common/resource_bundle_win.cc
index 27b0b36..532193d 100644
--- a/chrome/common/resource_bundle_win.cc
+++ b/chrome/common/resource_bundle_win.cc
@@ -135,12 +135,12 @@ HCURSOR ResourceBundle::LoadCursor(int cursor_id) {
MAKEINTRESOURCE(cursor_id));
}
-std::wstring ResourceBundle::GetLocalizedString(int message_id) {
+string16 ResourceBundle::GetLocalizedString(int message_id) {
// If for some reason we were unable to load a resource dll, return an empty
// string (better than crashing).
if (!locale_resources_data_) {
LOG(WARNING) << "locale resources are not loaded";
- return std::wstring();
+ return string16();
}
DCHECK(IS_INTRESOURCE(message_id));
@@ -159,6 +159,6 @@ std::wstring ResourceBundle::GetLocalizedString(int message_id) {
return std::wstring();
}
}
- // Copy into a wstring and return.
- return std::wstring(image->achString, image->nLength);
+ // Copy into a string16 and return.
+ return string16(image->achString, image->nLength);
}