summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-05 00:07:51 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-05 00:07:51 +0000
commit68bf60380800cbd4210f32433ec0310aa8646da2 (patch)
tree8e1854974d25404dea3ab2e72baef9f43bc6a60d /webkit
parentfc296c02aa9de1d144779944f4d0081e273329f2 (diff)
downloadchromium_src-68bf60380800cbd4210f32433ec0310aa8646da2.zip
chromium_src-68bf60380800cbd4210f32433ec0310aa8646da2.tar.gz
chromium_src-68bf60380800cbd4210f32433ec0310aa8646da2.tar.bz2
Convert webkit_glue::GetLocalizedString to return a string16
instead of a wstring. Convert the linux data pack files to pack message strings as utf16 instead of utf8. Review URL: http://codereview.chromium.org/20060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9193 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/glue_util.cc5
-rw-r--r--webkit/glue/glue_util.h1
-rw-r--r--webkit/glue/localized_strings.cc9
-rw-r--r--webkit/glue/webkit_glue.h2
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc6
-rw-r--r--webkit/tools/test_shell/test_shell_mac.mm5
-rw-r--r--webkit/tools/test_shell/test_shell_win.cc4
7 files changed, 21 insertions, 11 deletions
diff --git a/webkit/glue/glue_util.cc b/webkit/glue/glue_util.cc
index 997af01..3759b2b 100644
--- a/webkit/glue/glue_util.cc
+++ b/webkit/glue/glue_util.cc
@@ -48,6 +48,11 @@ string16 StringToString16(const WebCore::String& str) {
return string16(chars ? chars : (UChar *)L"", str.length());
}
+WebCore::String String16ToString(const string16& str) {
+ return WebCore::String(reinterpret_cast<const UChar*>(str.data()),
+ str.length());
+}
+
std::string StringToStdString(const WebCore::String& str) {
if (str.length() == 0)
return std::string();
diff --git a/webkit/glue/glue_util.h b/webkit/glue/glue_util.h
index ace448b..b9ebf41 100644
--- a/webkit/glue/glue_util.h
+++ b/webkit/glue/glue_util.h
@@ -36,6 +36,7 @@ WebCore::String StdWStringToString(const std::wstring& str);
// WebCore::String -> string16. This is a direct copy of UTF-16 characters.
string16 StringToString16(const WebCore::String& str);
+WebCore::String String16ToString(const string16& str);
// WebCore::String <-> std::string. We assume the WebCore::String is UTF-16 and
// the std::string is UTF-8, and convert as necessary.
diff --git a/webkit/glue/localized_strings.cc b/webkit/glue/localized_strings.cc
index 957b42ed..148252a 100644
--- a/webkit/glue/localized_strings.cc
+++ b/webkit/glue/localized_strings.cc
@@ -30,20 +30,21 @@
#undef LOG
-#include "webkit/glue/glue_util.h"
-#include "webkit/glue/webkit_glue.h"
#include "base/logging.h"
#include "base/file_util.h"
+#include "base/string16.h"
#include "base/string_util.h"
#include "build/build_config.h"
#include "webkit/glue/glue_util.h"
+#include "webkit/glue/webkit_glue.h"
+
#include "webkit_strings.h"
using namespace WebCore;
inline String GetLocalizedString(int message_id) {
- const std::wstring& str(webkit_glue::GetLocalizedString(message_id));
- return webkit_glue::StdWStringToString(str);
+ const string16& str = webkit_glue::GetLocalizedString(message_id);
+ return webkit_glue::String16ToString(str);
}
String WebCore::searchableIndexIntroduction() {
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index 820d569..1826876 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -177,7 +177,7 @@ void NotifyCacheStats();
// Gets 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 raw data for a resource. This resource must have been
// specified as BINDATA in the relevant .rc file.
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index 7cdca4b..1fa1d20 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -16,6 +16,7 @@
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/path_service.h"
+#include "base/string16.h"
#include "base/string_piece.h"
#include "base/string_util.h"
#include "net/base/mime_util.h"
@@ -632,13 +633,14 @@ StringPiece TestShell::NetResourceProvider(int key) {
namespace webkit_glue {
-std::wstring GetLocalizedString(int message_id) {
+string16 GetLocalizedString(int message_id) {
StringPiece res;
if (!g_resource_data_pack->Get(message_id, &res)) {
LOG(FATAL) << "failed to load webkit string with id " << message_id;
}
- return UTF8ToWide(res.as_string());
+ return string16(reinterpret_cast<const char16*>(res.data()),
+ res.length() / 2);
}
std::string GetDataResource(int resource_id) {
diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm
index cbf1794..0f9db5c 100644
--- a/webkit/tools/test_shell/test_shell_mac.mm
+++ b/webkit/tools/test_shell/test_shell_mac.mm
@@ -21,6 +21,7 @@
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/stats_table.h"
+#include "base/string16.h"
#include "base/string_piece.h"
#include "base/string_util.h"
#include "net/base/mime_util.h"
@@ -634,11 +635,11 @@ StringPiece TestShell::NetResourceProvider(int key) {
namespace webkit_glue {
-std::wstring GetLocalizedString(int message_id) {
+string16 GetLocalizedString(int message_id) {
NSString* idString = [NSString stringWithFormat:@"%d", message_id];
NSString* localString = NSLocalizedString(idString, @"");
- return UTF8ToWide([localString UTF8String]);
+ return UTF8ToUTF16([localString UTF8String]);
}
std::string GetDataResource(int resource_id) {
diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc
index 0ca8490..57dc592 100644
--- a/webkit/tools/test_shell/test_shell_win.cc
+++ b/webkit/tools/test_shell/test_shell_win.cc
@@ -683,7 +683,7 @@ StringPiece TestShell::NetResourceProvider(int key) {
namespace webkit_glue {
-std::wstring GetLocalizedString(int message_id) {
+string16 GetLocalizedString(int message_id) {
const ATLSTRINGRESOURCEIMAGE* image =
AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(),
message_id);
@@ -691,7 +691,7 @@ std::wstring GetLocalizedString(int message_id) {
NOTREACHED();
return L"No string for this identifier!";
}
- return std::wstring(image->achString, image->nLength);
+ return string16(image->achString, image->nLength);
}
// TODO(tc): Convert this to using resources from test_shell.rc.