summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 20:21:01 +0000
committerdsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 20:21:01 +0000
commit32c147158f76e19aa22efa2a7b14d3f0e1e23a02 (patch)
treea84b94bc6c2e4e52d009db317ed49a343658634c
parent600a41fb05efe99eb2890e884a7af0541456c365 (diff)
downloadchromium_src-32c147158f76e19aa22efa2a7b14d3f0e1e23a02.zip
chromium_src-32c147158f76e19aa22efa2a7b14d3f0e1e23a02.tar.gz
chromium_src-32c147158f76e19aa22efa2a7b14d3f0e1e23a02.tar.bz2
Port DictionaryValue to use string16 instead of wstring.
Review URL: http://codereview.chromium.org/31014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10818 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/json_reader.cc3
-rw-r--r--base/json_reader_unittest.cc19
-rw-r--r--base/json_writer.cc6
-rw-r--r--base/json_writer.h6
-rw-r--r--base/json_writer_unittest.cc7
-rw-r--r--base/string_util.cc66
-rw-r--r--base/string_util.h26
-rw-r--r--base/values.cc70
-rw-r--r--base/values.h44
-rw-r--r--base/values_unittest.cc107
-rw-r--r--chrome/browser/autocomplete/search_provider.cc2
-rw-r--r--chrome/browser/bookmarks/bookmark_codec.cc76
-rw-r--r--chrome/browser/bookmarks/bookmark_html_writer.cc51
-rw-r--r--chrome/browser/browser_about_handler.cc152
-rw-r--r--chrome/browser/browser_init.cc9
-rw-r--r--chrome/browser/browser_main.cc29
-rw-r--r--chrome/browser/dom_ui/dom_ui.cc4
-rw-r--r--chrome/browser/dom_ui/history_ui.cc70
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc103
-rw-r--r--chrome/browser/extensions/extension.cc34
-rw-r--r--chrome/browser/extensions/extension_unittest.cc61
-rw-r--r--chrome/browser/extensions/extensions_service.cc8
-rw-r--r--chrome/browser/metrics/metrics_log.cc25
-rw-r--r--chrome/browser/metrics/metrics_service.cc37
-rw-r--r--chrome/browser/page_state.cc7
-rw-r--r--chrome/browser/profile_manager.h19
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page.cc106
-rw-r--r--chrome/browser/ssl/ssl_blocking_page.cc42
-rw-r--r--chrome/browser/ssl/ssl_policy.cc23
-rw-r--r--chrome/common/json_value_serializer_unittest.cc42
-rw-r--r--chrome/common/pref_service.cc50
-rw-r--r--chrome/renderer/localized_error.cc104
-rw-r--r--chrome/renderer/render_view.cc7
33 files changed, 818 insertions, 597 deletions
diff --git a/base/json_reader.cc b/base/json_reader.cc
index b5013ef..e4dc61c 100644
--- a/base/json_reader.cc
+++ b/base/json_reader.cc
@@ -277,7 +277,8 @@ Value* JSONReader::BuildValue(bool is_root) {
Value* dict_value = BuildValue(false);
if (!dict_value)
return NULL;
- static_cast<DictionaryValue*>(node.get())->Set(dict_key, dict_value);
+ static_cast<DictionaryValue*>(node.get())->Set(
+ WideToUTF16Hack(dict_key), dict_value);
// After a key/value pair, we expect a comma or the end of the
// object.
diff --git a/base/json_reader_unittest.cc b/base/json_reader_unittest.cc
index 9153289..b77f9d5 100644
--- a/base/json_reader_unittest.cc
+++ b/base/json_reader_unittest.cc
@@ -5,6 +5,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "base/json_reader.h"
#include "base/scoped_ptr.h"
+#include "base/string_util.h"
#include "base/values.h"
#include "build/build_config.h"
@@ -297,14 +298,14 @@ TEST(JSONReaderTest, Reading) {
ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY));
DictionaryValue* dict_val = static_cast<DictionaryValue*>(root.get());
real_val = 0.0;
- ASSERT_TRUE(dict_val->GetReal(L"number", &real_val));
+ ASSERT_TRUE(dict_val->GetReal(LIT16("number"), &real_val));
ASSERT_DOUBLE_EQ(9.87654321, real_val);
Value* null_val = NULL;
- ASSERT_TRUE(dict_val->Get(L"null", &null_val));
+ ASSERT_TRUE(dict_val->Get(LIT16("null"), &null_val));
ASSERT_TRUE(null_val->IsType(Value::TYPE_NULL));
- str_val.clear();
- ASSERT_TRUE(dict_val->GetString(L"S", &str_val));
- ASSERT_EQ(L"str", str_val);
+ string16 str16_val;
+ ASSERT_TRUE(dict_val->GetString(LIT16("S"), &str16_val));
+ ASSERT_EQ(LIT16("str"), str16_val);
root2.reset(JSONReader::Read(
"{\"number\":9.87654321, \"null\":null , \"\\x53\" : \"str\", }", true));
@@ -317,15 +318,15 @@ TEST(JSONReaderTest, Reading) {
ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY));
dict_val = static_cast<DictionaryValue*>(root.get());
DictionaryValue* inner_dict = NULL;
- ASSERT_TRUE(dict_val->GetDictionary(L"inner", &inner_dict));
+ ASSERT_TRUE(dict_val->GetDictionary(LIT16("inner"), &inner_dict));
ListValue* inner_array = NULL;
- ASSERT_TRUE(inner_dict->GetList(L"array", &inner_array));
+ ASSERT_TRUE(inner_dict->GetList(LIT16("array"), &inner_array));
ASSERT_EQ(1U, inner_array->GetSize());
bool_value = true;
- ASSERT_TRUE(dict_val->GetBoolean(L"false", &bool_value));
+ ASSERT_TRUE(dict_val->GetBoolean(LIT16("false"), &bool_value));
ASSERT_FALSE(bool_value);
inner_dict = NULL;
- ASSERT_TRUE(dict_val->GetDictionary(L"d", &inner_dict));
+ ASSERT_TRUE(dict_val->GetDictionary(LIT16("d"), &inner_dict));
root2.reset(JSONReader::Read(
"{\"inner\": {\"array\":[true] , },\"false\":false,\"d\":{},}", true));
diff --git a/base/json_writer.cc b/base/json_writer.cc
index 20c533b..56efce9 100644
--- a/base/json_writer.cc
+++ b/base/json_writer.cc
@@ -76,7 +76,7 @@ void JSONWriter::BuildJSONString(const Value* const node, int depth) {
std::wstring value;
bool result = node->GetAsString(&value);
DCHECK(result);
- AppendQuotedString(value);
+ AppendQuotedString(WideToUTF16Hack(value));
break;
}
@@ -155,8 +155,8 @@ void JSONWriter::BuildJSONString(const Value* const node, int depth) {
}
}
-void JSONWriter::AppendQuotedString(const std::wstring& str) {
- string_escape::JavascriptDoubleQuote(WideToUTF16Hack(str), true,
+void JSONWriter::AppendQuotedString(const string16& str) {
+ string_escape::JavascriptDoubleQuote(str, true,
json_string_);
}
diff --git a/base/json_writer.h b/base/json_writer.h
index 42232bf..330e73c 100644
--- a/base/json_writer.h
+++ b/base/json_writer.h
@@ -5,9 +5,8 @@
#ifndef BASE_JSON_WRITER_H_
#define BASE_JSON_WRITER_H_
-#include <string>
-
#include "base/basictypes.h"
+#include "base/string16.h"
class Value;
@@ -31,7 +30,7 @@ class JSONWriter {
void BuildJSONString(const Value* const node, int depth);
// Appends a quoted, escaped, version of str to json_string_.
- void AppendQuotedString(const std::wstring& str);
+ void AppendQuotedString(const string16& str);
// Adds space to json_string_ for the indent level.
void IndentLine(int depth);
@@ -45,4 +44,3 @@ class JSONWriter {
};
#endif // BASE_JSON_WRITER_H_
-
diff --git a/base/json_writer_unittest.cc b/base/json_writer_unittest.cc
index cddfd4c..a273250 100644
--- a/base/json_writer_unittest.cc
+++ b/base/json_writer_unittest.cc
@@ -4,6 +4,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "base/json_writer.h"
+#include "base/string_util.h"
#include "base/values.h"
TEST(JSONWriterTest, Writing) {
@@ -36,10 +37,10 @@ TEST(JSONWriterTest, Writing) {
// list list nesting, etc.
DictionaryValue root_dict;
ListValue* list = new ListValue;
- root_dict.Set(L"list", list);
+ root_dict.Set(LIT16("list"), list);
DictionaryValue* inner_dict = new DictionaryValue;
list->Append(inner_dict);
- inner_dict->SetInteger(L"inner int", 10);
+ inner_dict->SetInteger(LIT16("inner int"), 10);
ListValue* inner_list = new ListValue;
list->Append(inner_list);
list->Append(Value::CreateBooleanValue(true));
@@ -54,5 +55,3 @@ TEST(JSONWriterTest, Writing) {
"}\r\n",
output_js);
}
-
-
diff --git a/base/string_util.cc b/base/string_util.cc
index a13f79f..b845c45 100644
--- a/base/string_util.cc
+++ b/base/string_util.cc
@@ -1039,6 +1039,10 @@ std::string IntToString(int value) {
return IntToStringT<std::string, int, unsigned int, true>::
IntToString(value);
}
+string16 IntToString16(int value) {
+ return IntToStringT<string16, int, unsigned int, true>::
+ IntToString(value);
+}
std::wstring IntToWString(int value) {
return IntToStringT<std::wstring, int, unsigned int, true>::
IntToString(value);
@@ -1047,6 +1051,10 @@ std::string UintToString(unsigned int value) {
return IntToStringT<std::string, unsigned int, unsigned int, false>::
IntToString(value);
}
+string16 UintToString16(unsigned int value) {
+ return IntToStringT<string16, unsigned int, unsigned int, false>::
+ IntToString(value);
+}
std::wstring UintToWString(unsigned int value) {
return IntToStringT<std::wstring, unsigned int, unsigned int, false>::
IntToString(value);
@@ -1055,6 +1063,10 @@ std::string Int64ToString(int64 value) {
return IntToStringT<std::string, int64, uint64, true>::
IntToString(value);
}
+string16 Int64ToString16(int64 value) {
+ return IntToStringT<string16, int64, uint64, true>::
+ IntToString(value);
+}
std::wstring Int64ToWString(int64 value) {
return IntToStringT<std::wstring, int64, uint64, true>::
IntToString(value);
@@ -1063,6 +1075,10 @@ std::string Uint64ToString(uint64 value) {
return IntToStringT<std::string, uint64, uint64, false>::
IntToString(value);
}
+string16 Uint64ToString16(uint64 value) {
+ return IntToStringT<string16, uint64, uint64, false>::
+ IntToString(value);
+}
std::wstring Uint64ToWString(uint64 value) {
return IntToStringT<std::wstring, uint64, uint64, false>::
IntToString(value);
@@ -1075,6 +1091,10 @@ std::string DoubleToString(double value) {
return std::string(buffer);
}
+string16 DoubleToWString16(double value) {
+ return UTF8ToUTF16(DoubleToString(value));
+}
+
std::wstring DoubleToWString(double value) {
return ASCIIToWide(DoubleToString(value));
}
@@ -1580,6 +1600,52 @@ double StringToDouble(const string16& value) {
return result;
}
+#if !defined(WCHAR_T_IS_UTF16)
+bool StringToInt(const string16& input, int* output) {
+ return StringToInt(UTF16ToWideHack(input), output);
+}
+
+bool StringToInt64(const string16& input, int64* output) {
+ return StringToInt64(UTF16ToWideHack(input), output);
+}
+
+bool HexStringToInt(const string16& input, int* output) {
+ return HexStringToInt(UTF16ToWideHack(input), output);
+}
+
+int StringToInt(const string16& value) {
+ int result;
+ StringToInt(value, &result);
+ return result;
+}
+
+int64 StringToInt64(const string16& value) {
+ int64 result;
+ StringToInt64(value, &result);
+ return result;
+}
+
+int HexStringToInt(const string16& value) {
+ int result;
+ HexStringToInt(value, &result);
+ return result;
+}
+
+bool StringToDouble(const string16& input, double* output) {
+ return StringToDouble(UTF16ToWideHack(input), output);
+}
+
+double StringToDouble(const string16& value) {
+ double result;
+ StringToDouble(value, &result);
+ return result;
+}
+
+bool HexStringToBytes(const string16& input, std::vector<uint8>* output) {
+ return HexStringToBytesT(input, output);
+}
+#endif // !defined(WCHAR_T_IS_UTF16)
+
// The following code is compatible with the OpenBSD lcpy interface. See:
// http://www.gratisoft.us/todd/papers/strlcpy.html
// ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/{wcs,str}lcpy.c
diff --git a/base/string_util.h b/base/string_util.h
index 26c42e5..a775092 100644
--- a/base/string_util.h
+++ b/base/string_util.h
@@ -15,6 +15,13 @@
#include "base/basictypes.h"
#include "base/string16.h"
+// Deal with string literals on different platforms
+#if defined(OS_WIN)
+# define LIT16(s) L##s
+#else
+# define LIT16(s) WideToUTF16(L##s)
+#endif
+
// Safe standard library wrappers for all platforms.
namespace base {
@@ -189,7 +196,7 @@ std::string UTF16ToUTF8(const string16& utf16);
// really should just be passing a string16 around, but we haven't finished
// porting whatever module uses wstring and the conversion is being used as a
// stopcock. This makes it easy to grep for the ones that should be removed.
-#if defined(OS_WIN)
+#if defined(WCHAR_T_IS_UTF16)
# define WideToUTF16Hack
# define UTF16ToWideHack
#else
@@ -385,16 +392,21 @@ void ReplaceSubstringsAfterOffset(std::string* str,
// Specialized string-conversion functions.
std::string IntToString(int value);
+string16 IntToString16(int value);
std::wstring IntToWString(int value);
std::string UintToString(unsigned int value);
+string16 UintToString16(unsigned int value);
std::wstring UintToWString(unsigned int value);
std::string Int64ToString(int64 value);
+string16 Int64ToString16(int64 value);
std::wstring Int64ToWString(int64 value);
std::string Uint64ToString(uint64 value);
+string16 Uint64ToString16(uint64 value);
std::wstring Uint64ToWString(uint64 value);
// The DoubleToString methods convert the double to a string format that
// ignores the locale. If you want to use locale specific formatting, use ICU.
std::string DoubleToString(double value);
+string16 DoubleToString16(double value);
std::wstring DoubleToWString(double value);
// Perform a best-effort conversion of the input string to a numeric type,
@@ -442,6 +454,18 @@ int HexStringToInt(const string16& value);
double StringToDouble(const std::string& value);
double StringToDouble(const string16& value);
+#if !defined(WCHAR_T_IS_UTF16)
+bool StringToInt(const string16& input, int* output);
+bool StringToInt64(const string16& input, int64* output);
+bool HexStringToInt(const string16& input, int* output);
+bool HexStringToBytes(const string16& input, std::vector<uint8>* output);
+bool StringToDouble(const string16& input, double* output);
+int StringToInt(const string16& value);
+int64 StringToInt64(const string16& value);
+int HexStringToInt(const string16& value);
+double StringToDouble(const string16& value);
+#endif
+
// Return a C++ string given printf-like input.
std::string StringPrintf(const char* format, ...);
std::wstring StringPrintf(const wchar_t* format, ...);
diff --git a/base/values.cc b/base/values.cc
index cf98c0b..29a5896 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -245,13 +245,13 @@ void DictionaryValue::Clear() {
dictionary_.clear();
}
-bool DictionaryValue::HasKey(const std::wstring& key) const {
+bool DictionaryValue::HasKey(const string16& key) const {
ValueMap::const_iterator current_entry = dictionary_.find(key);
DCHECK((current_entry == dictionary_.end()) || current_entry->second);
return current_entry != dictionary_.end();
}
-void DictionaryValue::SetInCurrentNode(const std::wstring& key,
+void DictionaryValue::SetInCurrentNode(const string16& key,
Value* in_value) {
// If there's an existing value here, we need to delete it, because
// we own all our children.
@@ -263,12 +263,12 @@ void DictionaryValue::SetInCurrentNode(const std::wstring& key,
dictionary_[key] = in_value;
}
-bool DictionaryValue::Set(const std::wstring& path, Value* in_value) {
+bool DictionaryValue::Set(const string16& path, Value* in_value) {
DCHECK(in_value);
- std::wstring key = path;
+ string16 key = path;
- size_t delimiter_position = path.find_first_of(L".", 0);
+ size_t delimiter_position = path.find_first_of('.', 0);
// If there isn't a dictionary delimiter in the path, we're done.
if (delimiter_position == std::wstring::npos) {
SetInCurrentNode(key, in_value);
@@ -286,37 +286,37 @@ bool DictionaryValue::Set(const std::wstring& path, Value* in_value) {
entry = static_cast<DictionaryValue*>(dictionary_[key]);
}
- std::wstring remaining_path = path.substr(delimiter_position + 1);
+ string16 remaining_path = path.substr(delimiter_position + 1);
return entry->Set(remaining_path, in_value);
}
-bool DictionaryValue::SetBoolean(const std::wstring& path, bool in_value) {
+bool DictionaryValue::SetBoolean(const string16& path, bool in_value) {
return Set(path, CreateBooleanValue(in_value));
}
-bool DictionaryValue::SetInteger(const std::wstring& path, int in_value) {
+bool DictionaryValue::SetInteger(const string16& path, int in_value) {
return Set(path, CreateIntegerValue(in_value));
}
-bool DictionaryValue::SetReal(const std::wstring& path, double in_value) {
+bool DictionaryValue::SetReal(const string16& path, double in_value) {
return Set(path, CreateRealValue(in_value));
}
-bool DictionaryValue::SetString(const std::wstring& path,
+bool DictionaryValue::SetString(const string16& path,
const std::string& in_value) {
return Set(path, CreateStringValue(in_value));
}
-bool DictionaryValue::SetString(const std::wstring& path,
- const std::wstring& in_value) {
- return Set(path, CreateStringValue(in_value));
+bool DictionaryValue::SetString(const string16& path,
+ const string16& in_value) {
+ return Set(path, CreateStringValue(UTF16ToWideHack(in_value)));
}
-bool DictionaryValue::Get(const std::wstring& path, Value** out_value) const {
- std::wstring key = path;
+bool DictionaryValue::Get(const string16& path, Value** out_value) const {
+ string16 key = path;
- size_t delimiter_position = path.find_first_of(L".", 0);
- if (delimiter_position != std::wstring::npos) {
+ size_t delimiter_position = path.find_first_of('.', 0);
+ if (delimiter_position != string16::npos) {
key = path.substr(0, delimiter_position);
}
@@ -325,7 +325,7 @@ bool DictionaryValue::Get(const std::wstring& path, Value** out_value) const {
return false;
Value* entry = entry_iterator->second;
- if (delimiter_position == std::wstring::npos) {
+ if (delimiter_position == string16::npos) {
if (out_value)
*out_value = entry;
return true;
@@ -339,7 +339,7 @@ bool DictionaryValue::Get(const std::wstring& path, Value** out_value) const {
return false;
}
-bool DictionaryValue::GetBoolean(const std::wstring& path,
+bool DictionaryValue::GetBoolean(const string16& path,
bool* bool_value) const {
Value* value;
if (!Get(path, &value))
@@ -348,7 +348,7 @@ bool DictionaryValue::GetBoolean(const std::wstring& path,
return value->GetAsBoolean(bool_value);
}
-bool DictionaryValue::GetInteger(const std::wstring& path,
+bool DictionaryValue::GetInteger(const string16& path,
int* out_value) const {
Value* value;
if (!Get(path, &value))
@@ -357,7 +357,7 @@ bool DictionaryValue::GetInteger(const std::wstring& path,
return value->GetAsInteger(out_value);
}
-bool DictionaryValue::GetReal(const std::wstring& path,
+bool DictionaryValue::GetReal(const string16& path,
double* out_value) const {
Value* value;
if (!Get(path, &value))
@@ -366,7 +366,7 @@ bool DictionaryValue::GetReal(const std::wstring& path,
return value->GetAsReal(out_value);
}
-bool DictionaryValue::GetString(const std::wstring& path,
+bool DictionaryValue::GetString(const string16& path,
std::string* out_value) const {
Value* value;
if (!Get(path, &value))
@@ -375,16 +375,19 @@ bool DictionaryValue::GetString(const std::wstring& path,
return value->GetAsString(out_value);
}
-bool DictionaryValue::GetString(const std::wstring& path,
- std::wstring* out_value) const {
+bool DictionaryValue::GetString(const string16& path,
+ string16* out_value) const {
Value* value;
if (!Get(path, &value))
return false;
- return value->GetAsString(out_value);
+ std::wstring wout_value;
+ bool success = value->GetAsString(&wout_value);
+ out_value->assign(WideToUTF16Hack(wout_value));
+ return success;
}
-bool DictionaryValue::GetBinary(const std::wstring& path,
+bool DictionaryValue::GetBinary(const string16& path,
BinaryValue** out_value) const {
Value* value;
bool result = Get(path, &value);
@@ -397,7 +400,7 @@ bool DictionaryValue::GetBinary(const std::wstring& path,
return true;
}
-bool DictionaryValue::GetDictionary(const std::wstring& path,
+bool DictionaryValue::GetDictionary(const string16& path,
DictionaryValue** out_value) const {
Value* value;
bool result = Get(path, &value);
@@ -410,7 +413,7 @@ bool DictionaryValue::GetDictionary(const std::wstring& path,
return true;
}
-bool DictionaryValue::GetList(const std::wstring& path,
+bool DictionaryValue::GetList(const string16& path,
ListValue** out_value) const {
Value* value;
bool result = Get(path, &value);
@@ -423,11 +426,11 @@ bool DictionaryValue::GetList(const std::wstring& path,
return true;
}
-bool DictionaryValue::Remove(const std::wstring& path, Value** out_value) {
- std::wstring key = path;
+bool DictionaryValue::Remove(const string16& path, Value** out_value) {
+ string16 key = path;
- size_t delimiter_position = path.find_first_of(L".", 0);
- if (delimiter_position != std::wstring::npos) {
+ size_t delimiter_position = path.find_first_of('.', 0);
+ if (delimiter_position != string16::npos) {
key = path.substr(0, delimiter_position);
}
@@ -436,7 +439,7 @@ bool DictionaryValue::Remove(const std::wstring& path, Value** out_value) {
return false;
Value* entry = entry_iterator->second;
- if (delimiter_position == std::wstring::npos) {
+ if (delimiter_position == string16::npos) {
if (out_value)
*out_value = entry;
else
@@ -651,4 +654,3 @@ bool ListValue::Equals(const Value* other) const {
return true;
}
-
diff --git a/base/values.h b/base/values.h
index cad1311..54298d5 100644
--- a/base/values.h
+++ b/base/values.h
@@ -23,10 +23,10 @@
#include <iterator>
#include <map>
-#include <string>
#include <vector>
#include "base/basictypes.h"
+#include "base/string16.h"
class Value;
class FundamentalValue;
@@ -36,7 +36,7 @@ class DictionaryValue;
class ListValue;
typedef std::vector<Value*> ValueVector;
-typedef std::map<std::wstring, Value*> ValueMap;
+typedef std::map<string16, Value*> ValueMap;
// The Value class is the base class for Values. A Value can be
// instantiated via the Create*Value() factory methods, or by directly
@@ -202,7 +202,7 @@ class DictionaryValue : public Value {
virtual bool Equals(const Value* other) const;
// Returns true if the current dictionary has a value for the given key.
- bool HasKey(const std::wstring& key) const;
+ bool HasKey(const string16& key) const;
// Clears any current contents of this dictionary.
void Clear();
@@ -216,15 +216,15 @@ class DictionaryValue : public Value {
// to the path in that location.
// Note that the dictionary takes ownership of the value
// referenced by in_value.
- bool Set(const std::wstring& path, Value* in_value);
+ bool Set(const string16& path, Value* in_value);
// Convenience forms of Set(). These methods will replace any existing
// value at that path, even if it has a different type.
- bool SetBoolean(const std::wstring& path, bool in_value);
- bool SetInteger(const std::wstring& path, int in_value);
- bool SetReal(const std::wstring& path, double in_value);
- bool SetString(const std::wstring& path, const std::string& in_value);
- bool SetString(const std::wstring& path, const std::wstring& in_value);
+ bool SetBoolean(const string16& path, bool in_value);
+ bool SetInteger(const string16& path, int in_value);
+ bool SetReal(const string16& path, double in_value);
+ bool SetString(const string16& path, const std::string& in_value);
+ bool SetString(const string16& path, const string16& in_value);
// Gets the Value associated with the given path starting from this object.
// A path has the form "<key>" or "<key>.<key>.[...]", where "." indexes
@@ -233,20 +233,20 @@ class DictionaryValue : public Value {
// through the "value" parameter, and the function will return true.
// Otherwise, it will return false and "value" will be untouched.
// Note that the dictionary always owns the value that's returned.
- bool Get(const std::wstring& path, Value** out_value) const;
+ bool Get(const string16& path, Value** out_value) const;
// These are convenience forms of Get(). The value will be retrieved
// and the return value will be true if the path is valid and the value at
// the end of the path can be returned in the form specified.
- bool GetBoolean(const std::wstring& path, bool* out_value) const;
- bool GetInteger(const std::wstring& path, int* out_value) const;
- bool GetReal(const std::wstring& path, double* out_value) const;
- bool GetString(const std::wstring& path, std::string* out_value) const;
- bool GetString(const std::wstring& path, std::wstring* out_value) const;
- bool GetBinary(const std::wstring& path, BinaryValue** out_value) const;
- bool GetDictionary(const std::wstring& path,
+ bool GetBoolean(const string16& path, bool* out_value) const;
+ bool GetInteger(const string16& path, int* out_value) const;
+ bool GetReal(const string16& path, double* out_value) const;
+ bool GetString(const string16& path, std::string* out_value) const;
+ bool GetString(const string16& path, string16* out_value) const;
+ bool GetBinary(const string16& path, BinaryValue** out_value) const;
+ bool GetDictionary(const string16& path,
DictionaryValue** out_value) const;
- bool GetList(const std::wstring& path, ListValue** out_value) const;
+ bool GetList(const string16& path, ListValue** out_value) const;
// Removes the Value with the specified path from this dictionary (or one
// of its child dictionaries, if the path is more than just a local key).
@@ -254,16 +254,16 @@ class DictionaryValue : public Value {
// passed out via out_value. If |out_value| is NULL, the removed value will
// be deleted. This method returns true if |path| is a valid path; otherwise
// it will return false and the DictionaryValue object will be unchanged.
- bool Remove(const std::wstring& path, Value** out_value);
+ bool Remove(const string16& path, Value** out_value);
// This class provides an iterator for the keys in the dictionary.
// It can't be used to modify the dictionary.
class key_iterator
- : private std::iterator<std::input_iterator_tag, const std::wstring> {
+ : private std::iterator<std::input_iterator_tag, const string16> {
public:
key_iterator(ValueMap::const_iterator itr) { itr_ = itr; }
key_iterator operator++() { ++itr_; return *this; }
- const std::wstring& operator*() { return itr_->first; }
+ const string16& operator*() { return itr_->first; }
bool operator!=(const key_iterator& other) { return itr_ != other.itr_; }
bool operator==(const key_iterator& other) { return itr_ == other.itr_; }
@@ -280,7 +280,7 @@ class DictionaryValue : public Value {
// Associates the value |in_value| with the |key|. This method should be
// used instead of "dictionary_[key] = foo" so that any previous value can
// be properly deleted.
- void SetInCurrentNode(const std::wstring& key, Value* in_value);
+ void SetInCurrentNode(const string16& key, Value* in_value);
ValueMap dictionary_;
};
diff --git a/base/values_unittest.cc b/base/values_unittest.cc
index dd2121f..2693fcc 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -6,6 +6,7 @@
#include "base/values.h"
#include "base/scoped_ptr.h"
+#include "base/string_util.h"
#include "testing/gtest/include/gtest/gtest.h"
class ValuesTest: public testing::Test {
@@ -14,46 +15,47 @@ class ValuesTest: public testing::Test {
TEST(ValuesTest, Basic) {
// Test basic dictionary getting/setting
DictionaryValue settings;
- std::wstring homepage = L"http://google.com";
- ASSERT_FALSE(
- settings.GetString(L"global.homepage", &homepage));
- ASSERT_EQ(std::wstring(L"http://google.com"), homepage);
-
- ASSERT_FALSE(settings.Get(L"global", NULL));
- ASSERT_TRUE(settings.Set(L"global", Value::CreateBooleanValue(true)));
- ASSERT_TRUE(settings.Get(L"global", NULL));
- ASSERT_TRUE(settings.SetString(L"global.homepage", L"http://scurvy.com"));
- ASSERT_TRUE(settings.Get(L"global", NULL));
- homepage = L"http://google.com";
- ASSERT_TRUE(settings.GetString(L"global.homepage", &homepage));
- ASSERT_EQ(std::wstring(L"http://scurvy.com"), homepage);
+ string16 homepage = LIT16("http://google.com");
+ ASSERT_FALSE(settings.GetString(LIT16("global.homepage"), &homepage));
+ ASSERT_EQ(LIT16("http://google.com"), homepage);
+
+ ASSERT_FALSE(settings.Get(LIT16("global"), NULL));
+ ASSERT_TRUE(settings.Set(LIT16("global"), Value::CreateBooleanValue(true)));
+ ASSERT_TRUE(settings.Get(LIT16("global"), NULL));
+ ASSERT_TRUE(settings.SetString(LIT16("global.homepage"),
+ LIT16("http://scurvy.com")));
+ ASSERT_TRUE(settings.Get(LIT16("global"), NULL));
+ homepage = LIT16("http://google.com");
+ ASSERT_TRUE(settings.GetString(LIT16("global.homepage"), &homepage));
+ ASSERT_EQ(LIT16("http://scurvy.com"), homepage);
// Test storing a dictionary in a list.
ListValue* toolbar_bookmarks;
ASSERT_FALSE(
- settings.GetList(L"global.toolbar.bookmarks", &toolbar_bookmarks));
+ settings.GetList(LIT16("global.toolbar.bookmarks"), &toolbar_bookmarks));
toolbar_bookmarks = new ListValue;
- settings.Set(L"global.toolbar.bookmarks", toolbar_bookmarks);
+ settings.Set(LIT16("global.toolbar.bookmarks"), toolbar_bookmarks);
ASSERT_TRUE(
- settings.GetList(L"global.toolbar.bookmarks", &toolbar_bookmarks));
+ settings.GetList(LIT16("global.toolbar.bookmarks"), &toolbar_bookmarks));
DictionaryValue* new_bookmark = new DictionaryValue;
- new_bookmark->SetString(L"name", L"Froogle");
- new_bookmark->SetString(L"url", L"http://froogle.com");
+ new_bookmark->SetString(LIT16("name"), LIT16("Froogle"));
+ new_bookmark->SetString(LIT16("url"), LIT16("http://froogle.com"));
toolbar_bookmarks->Append(new_bookmark);
ListValue* bookmark_list;
- ASSERT_TRUE(settings.GetList(L"global.toolbar.bookmarks", &bookmark_list));
+ ASSERT_TRUE(settings.GetList(LIT16("global.toolbar.bookmarks"),
+ &bookmark_list));
DictionaryValue* bookmark;
ASSERT_EQ(1U, bookmark_list->GetSize());
ASSERT_TRUE(bookmark_list->GetDictionary(0, &bookmark));
- std::wstring bookmark_name = L"Unnamed";
- ASSERT_TRUE(bookmark->GetString(L"name", &bookmark_name));
- ASSERT_EQ(std::wstring(L"Froogle"), bookmark_name);
- std::wstring bookmark_url;
- ASSERT_TRUE(bookmark->GetString(L"url", &bookmark_url));
- ASSERT_EQ(std::wstring(L"http://froogle.com"), bookmark_url);
+ string16 bookmark_name = LIT16("Unnamed");
+ ASSERT_TRUE(bookmark->GetString(LIT16("name"), &bookmark_name));
+ ASSERT_EQ(LIT16("Froogle"), bookmark_name);
+ string16 bookmark_url;
+ ASSERT_TRUE(bookmark->GetString(LIT16("url"), &bookmark_url));
+ ASSERT_EQ(LIT16("http://froogle.com"), bookmark_url);
}
TEST(ValuesTest, List) {
@@ -234,7 +236,7 @@ TEST(ValuesTest, ListRemoval) {
}
TEST(ValuesTest, DictionaryDeletion) {
- std::wstring key = L"test";
+ string16 key = LIT16("test");
bool deletion_flag = true;
{
@@ -262,7 +264,7 @@ TEST(ValuesTest, DictionaryDeletion) {
}
TEST(ValuesTest, DictionaryRemoval) {
- std::wstring key = L"test";
+ string16 key = LIT16("test");
bool deletion_flag = true;
Value* removed_item = NULL;
@@ -271,7 +273,7 @@ TEST(ValuesTest, DictionaryRemoval) {
dict.Set(key, new DeletionTestValue(&deletion_flag));
EXPECT_FALSE(deletion_flag);
EXPECT_TRUE(dict.HasKey(key));
- EXPECT_FALSE(dict.Remove(L"absent key", &removed_item));
+ EXPECT_FALSE(dict.Remove(LIT16("absent key"), &removed_item));
EXPECT_TRUE(dict.Remove(key, &removed_item));
EXPECT_FALSE(dict.HasKey(key));
ASSERT_TRUE(removed_item);
@@ -295,29 +297,29 @@ TEST(ValuesTest, DictionaryRemoval) {
TEST(ValuesTest, DeepCopy) {
DictionaryValue original_dict;
Value* original_null = Value::CreateNullValue();
- original_dict.Set(L"null", original_null);
+ original_dict.Set(LIT16("null"), original_null);
Value* original_bool = Value::CreateBooleanValue(true);
- original_dict.Set(L"bool", original_bool);
+ original_dict.Set(LIT16("bool"), original_bool);
Value* original_int = Value::CreateIntegerValue(42);
- original_dict.Set(L"int", original_int);
+ original_dict.Set(LIT16("int"), original_int);
Value* original_real = Value::CreateRealValue(3.14);
- original_dict.Set(L"real", original_real);
+ original_dict.Set(LIT16("real"), original_real);
Value* original_string = Value::CreateStringValue("hello");
- original_dict.Set(L"string", original_string);
+ original_dict.Set(LIT16("string"), original_string);
Value* original_wstring = Value::CreateStringValue(L"peek-a-boo");
- original_dict.Set(L"wstring", original_wstring);
+ original_dict.Set(LIT16("wstring"), original_wstring);
char* original_buffer = new char[42];
memset(original_buffer, '!', 42);
BinaryValue* original_binary = Value::CreateBinaryValue(original_buffer, 42);
- original_dict.Set(L"binary", original_binary);
+ original_dict.Set(LIT16("binary"), original_binary);
ListValue* original_list = new ListValue();
Value* original_list_element_0 = Value::CreateIntegerValue(0);
original_list->Append(original_list_element_0);
Value* original_list_element_1 = Value::CreateIntegerValue(1);
original_list->Append(original_list_element_1);
- original_dict.Set(L"list", original_list);
+ original_dict.Set(LIT16("list"), original_list);
DictionaryValue* copy_dict =
static_cast<DictionaryValue*>(original_dict.DeepCopy());
@@ -325,13 +327,13 @@ TEST(ValuesTest, DeepCopy) {
ASSERT_NE(copy_dict, &original_dict);
Value* copy_null = NULL;
- ASSERT_TRUE(copy_dict->Get(L"null", &copy_null));
+ ASSERT_TRUE(copy_dict->Get(LIT16("null"), &copy_null));
ASSERT_TRUE(copy_null);
ASSERT_NE(copy_null, original_null);
ASSERT_TRUE(copy_null->IsType(Value::TYPE_NULL));
Value* copy_bool = NULL;
- ASSERT_TRUE(copy_dict->Get(L"bool", &copy_bool));
+ ASSERT_TRUE(copy_dict->Get(LIT16("bool"), &copy_bool));
ASSERT_TRUE(copy_bool);
ASSERT_NE(copy_bool, original_bool);
ASSERT_TRUE(copy_bool->IsType(Value::TYPE_BOOLEAN));
@@ -340,7 +342,7 @@ TEST(ValuesTest, DeepCopy) {
ASSERT_TRUE(copy_bool_value);
Value* copy_int = NULL;
- ASSERT_TRUE(copy_dict->Get(L"int", &copy_int));
+ ASSERT_TRUE(copy_dict->Get(LIT16("int"), &copy_int));
ASSERT_TRUE(copy_int);
ASSERT_NE(copy_int, original_int);
ASSERT_TRUE(copy_int->IsType(Value::TYPE_INTEGER));
@@ -349,7 +351,7 @@ TEST(ValuesTest, DeepCopy) {
ASSERT_EQ(42, copy_int_value);
Value* copy_real = NULL;
- ASSERT_TRUE(copy_dict->Get(L"real", &copy_real));
+ ASSERT_TRUE(copy_dict->Get(LIT16("real"), &copy_real));
ASSERT_TRUE(copy_real);
ASSERT_NE(copy_real, original_real);
ASSERT_TRUE(copy_real->IsType(Value::TYPE_REAL));
@@ -358,7 +360,7 @@ TEST(ValuesTest, DeepCopy) {
ASSERT_EQ(3.14, copy_real_value);
Value* copy_string = NULL;
- ASSERT_TRUE(copy_dict->Get(L"string", &copy_string));
+ ASSERT_TRUE(copy_dict->Get(LIT16("string"), &copy_string));
ASSERT_TRUE(copy_string);
ASSERT_NE(copy_string, original_string);
ASSERT_TRUE(copy_string->IsType(Value::TYPE_STRING));
@@ -370,7 +372,7 @@ TEST(ValuesTest, DeepCopy) {
ASSERT_EQ(std::wstring(L"hello"), copy_wstring_value);
Value* copy_wstring = NULL;
- ASSERT_TRUE(copy_dict->Get(L"wstring", &copy_wstring));
+ ASSERT_TRUE(copy_dict->Get(LIT16("wstring"), &copy_wstring));
ASSERT_TRUE(copy_wstring);
ASSERT_NE(copy_wstring, original_wstring);
ASSERT_TRUE(copy_wstring->IsType(Value::TYPE_STRING));
@@ -380,7 +382,7 @@ TEST(ValuesTest, DeepCopy) {
ASSERT_EQ(std::wstring(L"peek-a-boo"), copy_wstring_value);
Value* copy_binary = NULL;
- ASSERT_TRUE(copy_dict->Get(L"binary", &copy_binary));
+ ASSERT_TRUE(copy_dict->Get(LIT16("binary"), &copy_binary));
ASSERT_TRUE(copy_binary);
ASSERT_NE(copy_binary, original_binary);
ASSERT_TRUE(copy_binary->IsType(Value::TYPE_BINARY));
@@ -393,7 +395,7 @@ TEST(ValuesTest, DeepCopy) {
original_binary->GetSize()));
Value* copy_value = NULL;
- ASSERT_TRUE(copy_dict->Get(L"list", &copy_value));
+ ASSERT_TRUE(copy_dict->Get(LIT16("list"), &copy_value));
ASSERT_TRUE(copy_value);
ASSERT_NE(copy_value, original_list);
ASSERT_TRUE(copy_value->IsType(Value::TYPE_LIST));
@@ -432,12 +434,12 @@ TEST(ValuesTest, Equals) {
delete boolean;
DictionaryValue dv;
- dv.SetBoolean(L"a", false);
- dv.SetInteger(L"b", 2);
- dv.SetReal(L"c", 2.5);
- dv.SetString(L"d1", "string");
- dv.SetString(L"d2", L"string");
- dv.Set(L"e", Value::CreateNullValue());
+ dv.SetBoolean(LIT16("a"), false);
+ dv.SetInteger(LIT16("b"), 2);
+ dv.SetReal(LIT16("c"), 2.5);
+ dv.SetString(LIT16("d1"), "string");
+ dv.SetString(LIT16("d2"), LIT16("string"));
+ dv.Set(LIT16("e"), Value::CreateNullValue());
DictionaryValue* copy = static_cast<DictionaryValue*>(dv.DeepCopy());
EXPECT_TRUE(dv.Equals(copy));
@@ -445,14 +447,13 @@ TEST(ValuesTest, Equals) {
ListValue* list = new ListValue;
list->Append(Value::CreateNullValue());
list->Append(new DictionaryValue);
- dv.Set(L"f", list);
+ dv.Set(LIT16("f"), list);
EXPECT_FALSE(dv.Equals(copy));
- copy->Set(L"f", list->DeepCopy());
+ copy->Set(LIT16("f"), list->DeepCopy());
EXPECT_TRUE(dv.Equals(copy));
list->Append(Value::CreateBooleanValue(true));
EXPECT_FALSE(dv.Equals(copy));
delete copy;
}
-
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 23d4407c..571217a 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -302,7 +302,7 @@ bool SearchProvider::ParseSuggestResults(Value* root_val) {
DictionaryValue* dict_val = static_cast<DictionaryValue*>(optional_val);
// Parse Google Suggest specific type extension.
- static const std::wstring kGoogleSuggestType(L"google:suggesttype");
+ static const string16 kGoogleSuggestType(LIT16("google:suggesttype"));
if (dict_val->HasKey(kGoogleSuggestType))
dict_val->GetList(kGoogleSuggestType, &type_list);
}
diff --git a/chrome/browser/bookmarks/bookmark_codec.cc b/chrome/browser/bookmarks/bookmark_codec.cc
index dd39fc8..1eba304 100644
--- a/chrome/browser/bookmarks/bookmark_codec.cc
+++ b/chrome/browser/bookmarks/bookmark_codec.cc
@@ -36,12 +36,13 @@ Value* BookmarkCodec::Encode(BookmarkModel* model) {
Value* BookmarkCodec::Encode(BookmarkNode* bookmark_bar_node,
BookmarkNode* other_folder_node) {
DictionaryValue* roots = new DictionaryValue();
- roots->Set(kRootFolderNameKey, EncodeNode(bookmark_bar_node));
- roots->Set(kOtherBookmarFolderNameKey, EncodeNode(other_folder_node));
+ roots->Set(WideToUTF16Hack(kRootFolderNameKey), EncodeNode(bookmark_bar_node));
+ roots->Set(WideToUTF16Hack(kOtherBookmarFolderNameKey),
+ EncodeNode(other_folder_node));
DictionaryValue* main = new DictionaryValue();
- main->SetInteger(kVersionKey, kCurrentVersion);
- main->Set(kRootsKey, roots);
+ main->SetInteger(WideToUTF16Hack(kVersionKey), kCurrentVersion);
+ main->Set(WideToUTF16Hack(kRootsKey), roots);
return main;
}
@@ -52,11 +53,12 @@ bool BookmarkCodec::Decode(BookmarkModel* model, const Value& value) {
const DictionaryValue& d_value = static_cast<const DictionaryValue&>(value);
int version;
- if (!d_value.GetInteger(kVersionKey, &version) || version != kCurrentVersion)
+ if (!d_value.GetInteger(WideToUTF16Hack(kVersionKey), &version) ||
+ version != kCurrentVersion)
return false; // Unknown version.
Value* roots;
- if (!d_value.Get(kRootsKey, &roots))
+ if (!d_value.Get(WideToUTF16Hack(kRootsKey), &roots))
return false; // No roots.
if (roots->GetType() != Value::TYPE_DICTIONARY)
@@ -65,11 +67,14 @@ bool BookmarkCodec::Decode(BookmarkModel* model, const Value& value) {
DictionaryValue* roots_d_value = static_cast<DictionaryValue*>(roots);
Value* root_folder_value;
Value* other_folder_value;
- if (!roots_d_value->Get(kRootFolderNameKey, &root_folder_value) ||
+ if (!roots_d_value->Get(WideToUTF16Hack(kRootFolderNameKey),
+ &root_folder_value) ||
root_folder_value->GetType() != Value::TYPE_DICTIONARY ||
- !roots_d_value->Get(kOtherBookmarFolderNameKey, &other_folder_value) ||
- other_folder_value->GetType() != Value::TYPE_DICTIONARY)
+ !roots_d_value->Get(WideToUTF16Hack(kOtherBookmarFolderNameKey),
+ &other_folder_value) ||
+ other_folder_value->GetType() != Value::TYPE_DICTIONARY) {
return false; // Invalid type for root folder and/or other folder.
+ }
DecodeNode(model, *static_cast<DictionaryValue*>(root_folder_value),
NULL, model->GetBookmarkBarNode());
@@ -89,21 +94,22 @@ bool BookmarkCodec::Decode(BookmarkModel* model, const Value& value) {
Value* BookmarkCodec::EncodeNode(BookmarkNode* node) {
DictionaryValue* value = new DictionaryValue();
- value->SetString(kNameKey, node->GetTitle());
- value->SetString(kDateAddedKey,
- Int64ToWString(node->date_added().ToInternalValue()));
+ value->SetString(WideToUTF16Hack(kNameKey),
+ WideToUTF16Hack(node->GetTitle()));
+ value->SetString(WideToUTF16Hack(kDateAddedKey),
+ Int64ToString16(node->date_added().ToInternalValue()));
if (node->GetType() == history::StarredEntry::URL) {
- value->SetString(kTypeKey, kTypeURL);
- value->SetString(kURLKey,
- UTF8ToWide(node->GetURL().possibly_invalid_spec()));
+ value->SetString(WideToUTF16Hack(kTypeKey), WideToUTF16Hack(kTypeURL));
+ value->SetString(WideToUTF16Hack(kURLKey),
+ UTF8ToUTF16(node->GetURL().possibly_invalid_spec()));
} else {
- value->SetString(kTypeKey, kTypeFolder);
- value->SetString(kDateModifiedKey,
- Int64ToWString(node->date_group_modified().
+ value->SetString(WideToUTF16Hack(kTypeKey), WideToUTF16Hack(kTypeFolder));
+ value->SetString(WideToUTF16Hack(kDateModifiedKey),
+ Int64ToString16(node->date_group_modified().
ToInternalValue()));
ListValue* child_values = new ListValue();
- value->Set(kChildrenKey, child_values);
+ value->Set(WideToUTF16Hack(kChildrenKey), child_values);
for (int i = 0; i < node->GetChildCount(); ++i)
child_values->Append(EncodeNode(node->GetChild(i)));
}
@@ -133,40 +139,42 @@ bool BookmarkCodec::DecodeNode(BookmarkModel* model,
const DictionaryValue& value,
BookmarkNode* parent,
BookmarkNode* node) {
- std::wstring title;
- if (!value.GetString(kNameKey, &title))
+ string16 title;
+ if (!value.GetString(WideToUTF16Hack(kNameKey), &title))
return false;
// TODO(sky): this should be more flexible. Don't hoark if we can't parse it
// all.
- std::wstring date_added_string;
- if (!value.GetString(kDateAddedKey, &date_added_string))
+ string16 date_added_string;
+ if (!value.GetString(WideToUTF16Hack(kDateAddedKey), &date_added_string))
return false;
- std::wstring type_string;
- if (!value.GetString(kTypeKey, &type_string))
+ string16 type_string;
+ if (!value.GetString(WideToUTF16Hack(kTypeKey), &type_string))
return false;
- if (type_string != kTypeURL && type_string != kTypeFolder)
+ if (type_string != WideToUTF16Hack(kTypeURL) &&
+ type_string != WideToUTF16Hack(kTypeFolder))
return false; // Unknown type.
- if (type_string == kTypeURL) {
- std::wstring url_string;
- if (!value.GetString(kURLKey, &url_string))
+ if (type_string == WideToUTF16Hack(kTypeURL)) {
+ string16 url_string;
+ if (!value.GetString(WideToUTF16Hack(kURLKey), &url_string))
return false;
// TODO(sky): this should ignore the node if not a valid URL.
if (!node)
- node = new BookmarkNode(model, GURL(WideToUTF8(url_string)));
+ node = new BookmarkNode(model, GURL(UTF16ToUTF8(url_string)));
if (parent)
parent->Add(parent->GetChildCount(), node);
node->type_ = history::StarredEntry::URL;
} else {
- std::wstring last_modified_date;
- if (!value.GetString(kDateModifiedKey, &last_modified_date))
+ string16 last_modified_date;
+ if (!value.GetString(WideToUTF16Hack(kDateModifiedKey),
+ &last_modified_date))
return false;
Value* child_values;
- if (!value.Get(kChildrenKey, &child_values))
+ if (!value.Get(WideToUTF16Hack(kChildrenKey), &child_values))
return false;
if (child_values->GetType() != Value::TYPE_LIST)
@@ -185,7 +193,7 @@ bool BookmarkCodec::DecodeNode(BookmarkModel* model,
return false;
}
- node->SetTitle(title);
+ node->SetTitle(UTF16ToWideHack(title));
node->date_added_ = Time::FromInternalValue(
StringToInt64(WideToUTF16Hack(date_added_string)));
return true;
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc
index 5ec7ca0..9561543 100644
--- a/chrome/browser/bookmarks/bookmark_html_writer.cc
+++ b/chrome/browser/bookmarks/bookmark_html_writer.cc
@@ -85,7 +85,7 @@ class Writer : public Task {
if (!Write(kHeader) ||
bookmarks_->GetType() != Value::TYPE_DICTIONARY ||
!static_cast<DictionaryValue*>(bookmarks_.get())->Get(
- BookmarkCodec::kRootsKey, &roots) ||
+ WideToUTF16Hack(BookmarkCodec::kRootsKey), &roots) ||
roots->GetType() != Value::TYPE_DICTIONARY) {
NOTREACHED();
return;
@@ -94,11 +94,12 @@ class Writer : public Task {
DictionaryValue* roots_d_value = static_cast<DictionaryValue*>(roots);
Value* root_folder_value;
Value* other_folder_value;
- if (!roots_d_value->Get(BookmarkCodec::kRootFolderNameKey,
+ if (!roots_d_value->Get(WideToUTF16Hack(BookmarkCodec::kRootFolderNameKey),
&root_folder_value) ||
root_folder_value->GetType() != Value::TYPE_DICTIONARY ||
- !roots_d_value->Get(BookmarkCodec::kOtherBookmarFolderNameKey,
- &other_folder_value) ||
+ !roots_d_value->Get(
+ WideToUTF16Hack(BookmarkCodec::kOtherBookmarFolderNameKey),
+ &other_folder_value) ||
other_folder_value->GetType() != Value::TYPE_DICTIONARY) {
NOTREACHED();
return; // Invalid type for root folder and/or other folder.
@@ -203,29 +204,32 @@ class Writer : public Task {
// Writes the node and all its children, returning true on success.
bool WriteNode(const DictionaryValue& value,
history::StarredEntry::Type folder_type) {
- std::wstring title, date_added_string, type_string;
- if (!value.GetString(BookmarkCodec::kNameKey, &title) ||
- !value.GetString(BookmarkCodec::kDateAddedKey, &date_added_string) ||
- !value.GetString(BookmarkCodec::kTypeKey, &type_string) ||
- (type_string != BookmarkCodec::kTypeURL &&
- type_string != BookmarkCodec::kTypeFolder)) {
+ string16 title, date_added_string, type_string;
+ if (!value.GetString(WideToUTF16Hack(BookmarkCodec::kNameKey), &title) ||
+ !value.GetString(WideToUTF16Hack(BookmarkCodec::kDateAddedKey),
+ &date_added_string) ||
+ !value.GetString(WideToUTF16Hack(BookmarkCodec::kTypeKey),
+ &type_string) ||
+ (type_string != WideToUTF16Hack(BookmarkCodec::kTypeURL) &&
+ type_string != WideToUTF16Hack(BookmarkCodec::kTypeFolder))) {
NOTREACHED();
return false;
}
- if (type_string == BookmarkCodec::kTypeURL) {
- std::wstring url_string;
- if (!value.GetString(BookmarkCodec::kURLKey, &url_string)) {
+ if (type_string == WideToUTF16Hack(BookmarkCodec::kTypeURL)) {
+ string16 url_string;
+ if (!value.GetString(WideToUTF16Hack(BookmarkCodec::kURLKey),
+ &url_string)) {
NOTREACHED();
return false;
}
if (!WriteIndent() ||
!Write(kBookmarkStart) ||
- !Write(url_string, ATTRIBUTE_VALUE) ||
+ !Write(UTF16ToWideHack(url_string), ATTRIBUTE_VALUE) ||
!Write(kAddDate) ||
- !WriteTime(date_added_string) ||
+ !WriteTime(UTF16ToWideHack(date_added_string)) ||
!Write(kBookmarkAttributeEnd) ||
- !Write(title, CONTENT) ||
+ !Write(UTF16ToWideHack(title), CONTENT) ||
!Write(kBookmarkEnd) ||
!Write(kNewline)) {
return false;
@@ -234,11 +238,12 @@ class Writer : public Task {
}
// Folder.
- std::wstring last_modified_date;
+ string16 last_modified_date;
Value* child_values;
- if (!value.GetString(BookmarkCodec::kDateModifiedKey,
+ if (!value.GetString(WideToUTF16Hack(BookmarkCodec::kDateModifiedKey),
&last_modified_date) ||
- !value.Get(BookmarkCodec::kChildrenKey, &child_values) ||
+ !value.Get(WideToUTF16Hack(BookmarkCodec::kChildrenKey),
+ &child_values) ||
child_values->GetType() != Value::TYPE_LIST) {
NOTREACHED();
return false;
@@ -249,19 +254,19 @@ class Writer : public Task {
// bar folder.
if (!WriteIndent() ||
!Write(kFolderStart) ||
- !WriteTime(date_added_string) ||
+ !WriteTime(UTF16ToWideHack(date_added_string)) ||
!Write(kLastModified) ||
- !WriteTime(last_modified_date)) {
+ !WriteTime(UTF16ToWideHack(last_modified_date))) {
return false;
}
if (folder_type == history::StarredEntry::BOOKMARK_BAR) {
if (!Write(kBookmarkBar))
return false;
- title = L"Bookmark Bar";
+ title = LIT16("Bookmark Bar");
} else if (!Write(kFolderAttributeEnd)) {
return false;
}
- if (!Write(title, CONTENT) ||
+ if (!Write(UTF16ToWideHack(title), CONTENT) ||
!Write(kFolderEnd) ||
!Write(kNewline) ||
!WriteIndent() ||
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc
index 7f25a60..238804d 100644
--- a/chrome/browser/browser_about_handler.cc
+++ b/chrome/browser/browser_about_handler.cc
@@ -253,8 +253,9 @@ bool BrowserAboutHandler::SupportsURL(GURL* url) {
std::string BrowserAboutHandler::AboutVersion() {
// Strings used in the JsTemplate file.
DictionaryValue localized_strings;
- localized_strings.SetString(L"title",
- l10n_util::GetString(IDS_ABOUT_VERSION_TITLE));
+ localized_strings.SetString(
+ LIT16("title"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_TITLE)));
scoped_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfoForCurrentModule());
if (version_info == NULL) {
@@ -272,26 +273,34 @@ std::string BrowserAboutHandler::AboutVersion() {
std::wstring js_engine = L"JavaScriptCore";
#endif
- localized_strings.SetString(L"name",
- l10n_util::GetString(IDS_PRODUCT_NAME));
- localized_strings.SetString(L"version", version_info->file_version());
- localized_strings.SetString(L"js_engine", js_engine);
- localized_strings.SetString(L"js_version", js_version);
- localized_strings.SetString(L"webkit_version", webkit_version);
- localized_strings.SetString(L"company",
- l10n_util::GetString(IDS_ABOUT_VERSION_COMPANY_NAME));
- localized_strings.SetString(L"copyright",
- l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT));
- localized_strings.SetString(L"cl", version_info->last_change());
+ localized_strings.SetString(
+ LIT16("name"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_PRODUCT_NAME)));
+ localized_strings.SetString(LIT16("version"),
+ WideToUTF16Hack(version_info->file_version()));
+ localized_strings.SetString(LIT16("js_engine"), WideToUTF16Hack(js_engine));
+ localized_strings.SetString(LIT16("js_version"), WideToUTF16Hack(js_version));
+ localized_strings.SetString(LIT16("webkit_version"),
+ WideToUTF16Hack(webkit_version));
+ localized_strings.SetString(
+ LIT16("company"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_COMPANY_NAME)));
+ localized_strings.SetString(
+ LIT16("copyright"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT)));
+ localized_strings.SetString(LIT16("cl"),
+ WideToUTF16Hack(version_info->last_change()));
if (version_info->is_official_build()) {
- localized_strings.SetString(L"official",
- l10n_util::GetString(IDS_ABOUT_VERSION_OFFICIAL));
+ localized_strings.SetString(
+ LIT16("official"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_OFFICIAL)));
} else {
- localized_strings.SetString(L"official",
- l10n_util::GetString(IDS_ABOUT_VERSION_UNOFFICIAL));
+ localized_strings.SetString(
+ LIT16("official"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_UNOFFICIAL)));
}
- localized_strings.SetString(L"useragent",
- UTF8ToWide(webkit_glue::GetUserAgent(GURL())));
+ localized_strings.SetString(LIT16("useragent"),
+ UTF8ToUTF16(webkit_glue::GetUserAgent(GURL())));
static const StringPiece version_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -332,26 +341,36 @@ std::string BrowserAboutHandler::AboutTerms() {
std::string BrowserAboutHandler::AboutPlugins() {
// Strings used in the JsTemplate file.
DictionaryValue localized_strings;
- localized_strings.SetString(L"title",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_TITLE));
- localized_strings.SetString(L"headingPlugs",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_PLUGS));
- localized_strings.SetString(L"headingNoPlugs",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_NOPLUGS));
- localized_strings.SetString(L"filename",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_FILENAME_LABEL));
- localized_strings.SetString(L"mimetype",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_MIMETYPE_LABEL));
- localized_strings.SetString(L"description",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_DESCRIPTION_LABEL));
- localized_strings.SetString(L"suffixes",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_SUFFIX_LABEL));
- localized_strings.SetString(L"enabled",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_LABEL));
- localized_strings.SetString(L"enabled_yes",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_YES));
- localized_strings.SetString(L"enabled_no",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_NO));
+ localized_strings.SetString(
+ LIT16("title"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_TITLE)));
+ localized_strings.SetString(
+ LIT16("headingPlugs"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_PLUGS)));
+ localized_strings.SetString(
+ LIT16("headingNoPlugs"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_NOPLUGS)));
+ localized_strings.SetString(
+ LIT16("filename"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_FILENAME_LABEL)));
+ localized_strings.SetString(
+ LIT16("mimetype"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_MIMETYPE_LABEL)));
+ localized_strings.SetString(
+ LIT16("description"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_DESCRIPTION_LABEL)));
+ localized_strings.SetString(
+ LIT16("suffixes"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_SUFFIX_LABEL)));
+ localized_strings.SetString(
+ LIT16("enabled"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_LABEL)));
+ localized_strings.SetString(
+ LIT16("enabled_yes"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_YES)));
+ localized_strings.SetString(
+ LIT16("enabled_no"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_NO)));
static const StringPiece plugins_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -404,15 +423,15 @@ std::string BrowserAboutHandler::AboutStats() {
// We maintain two lists - one for counters and one for timers.
// Timers actually get stored on both lists.
ListValue* counters;
- if (!root.GetList(L"counters", &counters)) {
+ if (!root.GetList(LIT16("counters"), &counters)) {
counters = new ListValue();
- root.Set(L"counters", counters);
+ root.Set(LIT16("counters"), counters);
}
ListValue* timers;
- if (!root.GetList(L"timers", &timers)) {
+ if (!root.GetList(LIT16("timers"), &timers)) {
timers = new ListValue();
- root.Set(L"timers", timers);
+ root.Set(LIT16("timers"), timers);
}
// NOTE: Counters start at index 1.
@@ -436,9 +455,9 @@ std::string BrowserAboutHandler::AboutStats() {
scan_index < counters->GetSize(); scan_index++) {
DictionaryValue* dictionary;
if (counters->GetDictionary(scan_index, &dictionary)) {
- std::wstring scan_name;
- if (dictionary->GetString(L"name", &scan_name) &&
- WideToASCII(scan_name) == name) {
+ string16 scan_name;
+ if (dictionary->GetString(LIT16("name"), &scan_name) &&
+ UTF16ToUTF8(scan_name) == name) {
counter = dictionary;
}
} else {
@@ -448,7 +467,7 @@ std::string BrowserAboutHandler::AboutStats() {
if (counter == NULL) {
counter = new DictionaryValue();
- counter->SetString(L"name", ASCIIToWide(name));
+ counter->SetString(LIT16("name"), UTF8ToUTF16(name));
counters->Append(counter);
}
@@ -458,11 +477,11 @@ std::string BrowserAboutHandler::AboutStats() {
int new_value = table->GetRowValue(index);
int prior_value = 0;
int delta = 0;
- if (counter->GetInteger(L"value", &prior_value)) {
+ if (counter->GetInteger(LIT16("value"), &prior_value)) {
delta = new_value - prior_value;
}
- counter->SetInteger(L"value", new_value);
- counter->SetInteger(L"delta", delta);
+ counter->SetInteger(LIT16("value"), new_value);
+ counter->SetInteger(LIT16("delta"), delta);
}
break;
case 'm':
@@ -473,7 +492,7 @@ std::string BrowserAboutHandler::AboutStats() {
case 't':
{
int time = table->GetRowValue(index);
- counter->SetInteger(L"time", time);
+ counter->SetInteger(LIT16("time"), time);
// Store this on the timers list as well.
timers->Append(counter);
@@ -519,16 +538,16 @@ void AboutMemoryHandler::BindProcessMetrics(DictionaryValue* data,
DCHECK(data && info);
// Bind metrics to dictionary.
- data->SetInteger(L"ws_priv", static_cast<int>(info->working_set.priv));
- data->SetInteger(L"ws_shareable",
+ data->SetInteger(LIT16("ws_priv"), static_cast<int>(info->working_set.priv));
+ data->SetInteger(LIT16("ws_shareable"),
static_cast<int>(info->working_set.shareable));
- data->SetInteger(L"ws_shared", static_cast<int>(info->working_set.shared));
- data->SetInteger(L"comm_priv", static_cast<int>(info->committed.priv));
- data->SetInteger(L"comm_map", static_cast<int>(info->committed.mapped));
- data->SetInteger(L"comm_image", static_cast<int>(info->committed.image));
- data->SetInteger(L"pid", info->pid);
- data->SetString(L"version", info->version);
- data->SetInteger(L"processes", info->num_processes);
+ data->SetInteger(LIT16("ws_shared"), static_cast<int>(info->working_set.shared));
+ data->SetInteger(LIT16("comm_priv"), static_cast<int>(info->committed.priv));
+ data->SetInteger(LIT16("comm_map"), static_cast<int>(info->committed.mapped));
+ data->SetInteger(LIT16("comm_image"), static_cast<int>(info->committed.image));
+ data->SetInteger(LIT16("pid"), info->pid);
+ data->SetString(LIT16("version"), WideToUTF16Hack(info->version));
+ data->SetInteger(LIT16("processes"), info->num_processes);
}
// Helper for AboutMemory to append memory usage information for all
@@ -545,9 +564,9 @@ void AboutMemoryHandler::AppendProcess(ListValue* child_data,
std::wstring child_label(ChildProcessInfo::GetTypeNameInEnglish(info->type));
if (info->is_diagnostics)
child_label.append(L" (diagnostics)");
- child->SetString(L"child_name", child_label);
+ child->SetString(LIT16("child_name"), WideToUTF16Hack(child_label));
ListValue* titles = new ListValue();
- child->Set(L"titles", titles);
+ child->Set(LIT16("titles"), titles);
for (size_t i = 0; i < info->titles.size(); ++i)
titles->Append(new StringValue(info->titles[i]));
}
@@ -557,7 +576,7 @@ void AboutMemoryHandler::OnDetailsAvailable() {
// the root of the JSON hierarchy for about:memory jstemplate
DictionaryValue root;
ListValue* browsers = new ListValue();
- root.Set(L"browsers", browsers);
+ root.Set(LIT16("browsers"), browsers);
ProcessData* browser_processes = processes();
@@ -588,7 +607,8 @@ void AboutMemoryHandler::OnDetailsAvailable() {
}
DictionaryValue* browser_data = new DictionaryValue();
browsers->Append(browser_data);
- browser_data->SetString(L"name", browser_processes[index].name);
+ browser_data->SetString(LIT16("name"),
+ WideToUTF16Hack(browser_processes[index].name));
BindProcessMetrics(browser_data, &aggregate);
@@ -608,9 +628,9 @@ void AboutMemoryHandler::OnDetailsAvailable() {
// Set the browser & renderer detailed process data.
DictionaryValue* browser_data = new DictionaryValue();
- root.Set(L"browzr_data", browser_data);
+ root.Set(LIT16("browzr_data"), browser_data);
ListValue* child_data = new ListValue();
- root.Set(L"child_data", child_data);
+ root.Set(LIT16("child_data"), child_data);
ProcessData process = browser_processes[0]; // Chrome is the first browser.
for (size_t index = 0; index < process.processes.size(); index++) {
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index d4ec343..a3d8dba 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -113,8 +113,10 @@ void SetOverrideHomePage(const CommandLine& command_line,
std::wstring new_homepage = URLFixerUpper::FixupRelativeFile(
browser_directory,
command_line.GetSwitchValue(switches::kHomePage));
- prefs->transient()->SetString(prefs::kHomePage, new_homepage);
- prefs->transient()->SetBoolean(prefs::kHomePageIsNewTabPage, false);
+ prefs->transient()->SetString(WideToUTF16Hack(prefs::kHomePage),
+ WideToUTF16Hack(new_homepage));
+ prefs->transient()->SetBoolean(
+ WideToUTF16Hack(prefs::kHomePageIsNewTabPage), false);
}
}
@@ -474,7 +476,8 @@ bool BrowserInit::ProcessCommandLine(
SetOverrideHomePage(command_line, profile->GetPrefs());
if (command_line.HasSwitch(switches::kBrowserStartRenderersManually))
- prefs->transient()->SetBoolean(prefs::kStartRenderersManually, true);
+ prefs->transient()->SetBoolean(
+ WideToUTF16Hack(prefs::kStartRenderersManually), true);
bool silent_launch = false;
#if defined(OS_WIN)
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index fc4513c..b2366c1 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -144,16 +144,21 @@ void HandleErrorTestParameters(const CommandLine& command_line) {
struct LazyDirectoryListerCacher {
LazyDirectoryListerCacher() {
DictionaryValue value;
- value.SetString(L"header",
- l10n_util::GetString(IDS_DIRECTORY_LISTING_HEADER));
- value.SetString(L"parentDirText",
- l10n_util::GetString(IDS_DIRECTORY_LISTING_PARENT));
- value.SetString(L"headerName",
- l10n_util::GetString(IDS_DIRECTORY_LISTING_NAME));
- value.SetString(L"headerSize",
- l10n_util::GetString(IDS_DIRECTORY_LISTING_SIZE));
- value.SetString(L"headerDateModified",
- l10n_util::GetString(IDS_DIRECTORY_LISTING_DATE_MODIFIED));
+ value.SetString(
+ LIT16("header"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_HEADER)));
+ value.SetString(
+ LIT16("parentDirText"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_PARENT)));
+ value.SetString(
+ LIT16("headerName"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_NAME)));
+ value.SetString(
+ LIT16("headerSize"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_SIZE)));
+ value.SetString(
+ LIT16("headerDateModified"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_DATE_MODIFIED)));
html_data = jstemplate_builder::GetTemplateHtml(
ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_DIR_HEADER_HTML),
@@ -508,8 +513,8 @@ int BrowserMain(const MainFunctionParams& parameters) {
MetricsService* metrics = NULL;
if (!parsed_command_line.HasSwitch(switches::kDisableMetrics)) {
if (parsed_command_line.HasSwitch(switches::kMetricsRecordingOnly)) {
- local_state->transient()->SetBoolean(prefs::kMetricsReportingEnabled,
- false);
+ local_state->transient()->SetBoolean(
+ WideToUTF16Hack(prefs::kMetricsReportingEnabled), false);
}
metrics = browser_process->metrics_service();
DCHECK(metrics);
diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc
index b0efcad..9a52bdd 100644
--- a/chrome/browser/dom_ui/dom_ui.cc
+++ b/chrome/browser/dom_ui/dom_ui.cc
@@ -111,7 +111,7 @@ void DOMMessageHandler::SetURLAndTitle(DictionaryValue* dictionary,
std::wstring title,
const GURL& gurl) {
std::wstring wstring_url = UTF8ToWide(gurl.spec());
- dictionary->SetString(L"url", wstring_url);
+ dictionary->SetString(LIT16("url"), WideToUTF16Hack(wstring_url));
bool using_url_as_the_title = false;
if (title.empty()) {
@@ -133,7 +133,7 @@ void DOMMessageHandler::SetURLAndTitle(DictionaryValue* dictionary,
DCHECK(success ? (title != title_to_set) : (title == title_to_set));
}
}
- dictionary->SetString(L"title", title_to_set);
+ dictionary->SetString(LIT16("title"), WideToUTF16Hack(title_to_set));
}
bool DOMMessageHandler::ExtractIntegerValue(const Value* value, int* out_int) {
diff --git a/chrome/browser/dom_ui/history_ui.cc b/chrome/browser/dom_ui/history_ui.cc
index 9bc5d61..bbc1602 100644
--- a/chrome/browser/dom_ui/history_ui.cc
+++ b/chrome/browser/dom_ui/history_ui.cc
@@ -49,32 +49,32 @@ HistoryUIHTMLSource::HistoryUIHTMLSource()
void HistoryUIHTMLSource::StartDataRequest(const std::string& path,
int request_id) {
DictionaryValue localized_strings;
- localized_strings.SetString(L"title",
- l10n_util::GetString(IDS_HISTORY_TITLE));
- localized_strings.SetString(L"loading",
- l10n_util::GetString(IDS_HISTORY_LOADING));
- localized_strings.SetString(L"newest",
- l10n_util::GetString(IDS_HISTORY_NEWEST));
- localized_strings.SetString(L"newer",
- l10n_util::GetString(IDS_HISTORY_NEWER));
- localized_strings.SetString(L"older",
- l10n_util::GetString(IDS_HISTORY_OLDER));
- localized_strings.SetString(L"searchresultsfor",
- l10n_util::GetString(IDS_HISTORY_SEARCHRESULTSFOR));
- localized_strings.SetString(L"history",
- l10n_util::GetString(IDS_HISTORY_BROWSERESULTS));
- localized_strings.SetString(L"cont",
- l10n_util::GetString(IDS_HISTORY_CONTINUED));
- localized_strings.SetString(L"searchbutton",
- l10n_util::GetString(IDS_HISTORY_SEARCH_BUTTON));
- localized_strings.SetString(L"noresults",
- l10n_util::GetString(IDS_HISTORY_NO_RESULTS));
- localized_strings.SetString(L"noitems",
- l10n_util::GetString(IDS_HISTORY_NO_ITEMS));
- localized_strings.SetString(L"deleteday",
- l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_LINK));
- localized_strings.SetString(L"deletedaywarning",
- l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING));
+ localized_strings.SetString(LIT16("title"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_TITLE)));
+ localized_strings.SetString(LIT16("loading"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_LOADING)));
+ localized_strings.SetString(LIT16("newest"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NEWEST)));
+ localized_strings.SetString(LIT16("newer"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NEWER)));
+ localized_strings.SetString(LIT16("older"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_OLDER)));
+ localized_strings.SetString(LIT16("searchresultsfor"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_SEARCHRESULTSFOR)));
+ localized_strings.SetString(LIT16("history"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_BROWSERESULTS)));
+ localized_strings.SetString(LIT16("cont"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_CONTINUED)));
+ localized_strings.SetString(LIT16("searchbutton"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_SEARCH_BUTTON)));
+ localized_strings.SetString(LIT16("noresults"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NO_RESULTS)));
+ localized_strings.SetString(LIT16("noitems"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NO_ITEMS)));
+ localized_strings.SetString(LIT16("deleteday"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_LINK)));
+ localized_strings.SetString(LIT16("deletedaywarning"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING)));
static const StringPiece history_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -226,7 +226,7 @@ void BrowsingHistoryHandler::QueryComplete(
SetURLAndTitle(page_value, page.title(), page.url());
// Need to pass the time in epoch time (fastest JS conversion).
- page_value->SetInteger(L"time",
+ page_value->SetInteger(LIT16("time"),
static_cast<int>(page.visit_time().ToTimeT()));
// Until we get some JS i18n infrastructure, we also need to
@@ -246,13 +246,17 @@ void BrowsingHistoryHandler::QueryComplete(
IDS_HISTORY_DATE_WITH_RELATIVE_TIME,
date_str, base::TimeFormatFriendlyDate(page.visit_time()));
}
- page_value->SetString(L"dateRelativeDay", date_str);
- page_value->SetString(L"dateTimeOfDay",
- base::TimeFormatTimeOfDay(page.visit_time()));
+ page_value->SetString(LIT16("dateRelativeDay"),
+ WideToUTF16Hack(date_str));
+ page_value->SetString(
+ LIT16("dateTimeOfDay"),
+ WideToUTF16Hack(base::TimeFormatTimeOfDay(page.visit_time())));
} else {
- page_value->SetString(L"dateShort",
- base::TimeFormatShortDate(page.visit_time()));
- page_value->SetString(L"snippet", page.snippet().text());
+ page_value->SetString(
+ LIT16("dateShort"),
+ WideToUTF16Hack(base::TimeFormatShortDate(page.visit_time())));
+ page_value->SetString(
+ LIT16("snippet"), WideToUTF16Hack(page.snippet().text()));
}
page_value->SetBoolean(L"starred",
dom_ui_->get_profile()->GetBookmarkModel()->IsBookmarked(page.url()));
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index afb7baa..26366f7 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -125,14 +125,14 @@ class PaintTimer : public RenderWidgetHost::PaintObserver {
void SetURLTitleAndDirection(DictionaryValue* dictionary,
const std::wstring& title,
const GURL& gurl) {
- std::wstring wstring_url = UTF8ToWide(gurl.spec());
- dictionary->SetString(L"url", wstring_url);
+ string16 string_url = UTF8ToUTF16(gurl.spec());
+ dictionary->SetString(LIT16("url"), string_url);
bool using_url_as_the_title = false;
std::wstring title_to_set(title);
if (title_to_set.empty()) {
using_url_as_the_title = true;
- title_to_set = wstring_url;
+ title_to_set = UTF16ToWideHack(string_url);
}
// We set the "dir" attribute of the title, so that in RTL locales, a LTR
@@ -168,8 +168,8 @@ void SetURLTitleAndDirection(DictionaryValue* dictionary,
}
}
}
- dictionary->SetString(L"title", title_to_set);
- dictionary->SetString(L"direction", direction);
+ dictionary->SetString(LIT16("title"), WideToUTF16Hack(title_to_set));
+ dictionary->SetString(LIT16("direction"), WideToUTF16Hack(direction));
}
} // end anonymous namespace
@@ -208,35 +208,42 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path,
profile_name);
}
DictionaryValue localized_strings;
- localized_strings.SetString(L"title", title);
- localized_strings.SetString(L"mostvisited", most_visited);
- localized_strings.SetString(L"searches",
- l10n_util::GetString(IDS_NEW_TAB_SEARCHES));
- localized_strings.SetString(L"bookmarks",
- l10n_util::GetString(IDS_NEW_TAB_BOOKMARKS));
- localized_strings.SetString(L"showhistory",
- l10n_util::GetString(IDS_NEW_TAB_HISTORY_SHOW));
- localized_strings.SetString(L"searchhistory",
- l10n_util::GetString(IDS_NEW_TAB_HISTORY_SEARCH));
- localized_strings.SetString(L"recentlyclosed",
- l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED));
- localized_strings.SetString(L"mostvisitedintro",
- l10n_util::GetStringF(IDS_NEW_TAB_MOST_VISITED_INTRO,
- l10n_util::GetString(IDS_WELCOME_PAGE_URL)));
- localized_strings.SetString(L"closedwindow",
- l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW));
-
- localized_strings.SetString(L"textdirection",
- (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- kRTLHtmlTextDirection : kDefaultHtmlTextDirection);
+ localized_strings.SetString(LIT16("title"), WideToUTF16Hack(title));
+ localized_strings.SetString(LIT16("mostvisited"),
+ WideToUTF16Hack(most_visited));
+ localized_strings.SetString(LIT16("searches"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_SEARCHES)));
+ localized_strings.SetString(LIT16("bookmarks"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_BOOKMARKS)));
+ localized_strings.SetString(LIT16("showhistory"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_HISTORY_SHOW)));
+ localized_strings.SetString(LIT16("searchhistory"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_HISTORY_SEARCH)));
+ localized_strings.SetString(LIT16("recentlyclosed"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED)));
+ localized_strings.SetString(
+ LIT16("mostvisitedintro"),
+ WideToUTF16Hack(l10n_util::GetStringF(
+ IDS_NEW_TAB_MOST_VISITED_INTRO,
+ l10n_util::GetString(IDS_WELCOME_PAGE_URL))));
+ localized_strings.SetString(
+ LIT16("closedwindow"),
+ WideToUTF16Hack(
+ l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW)));
+
+ localized_strings.SetString(
+ LIT16("textdirection"),
+ WideToUTF16Hack(
+ (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
+ kRTLHtmlTextDirection : kDefaultHtmlTextDirection));
// Let the tab know whether it's the first tab being viewed.
- localized_strings.SetString(L"firstview",
- first_view_ ? L"true" : std::wstring());
+ localized_strings.SetString(LIT16("firstview"),
+ first_view_ ? LIT16("true") : string16());
first_view_ = false;
#ifdef CHROME_PERSONALIZATION
- localized_strings.SetString(L"p13nsrc", Personalization::GetNewTabSource());
+ localized_strings.SetString(LIT16("p13nsrc"), Personalization::GetNewTabSource());
#endif
static const StringPiece new_tab_html(
@@ -263,15 +270,19 @@ IncognitoTabHTMLSource::IncognitoTabHTMLSource()
void IncognitoTabHTMLSource::StartDataRequest(const std::string& path,
int request_id) {
DictionaryValue localized_strings;
- localized_strings.SetString(L"title",
- l10n_util::GetString(IDS_NEW_TAB_TITLE));
- localized_strings.SetString(L"content",
- l10n_util::GetStringF(IDS_NEW_TAB_OTR_MESSAGE,
- l10n_util::GetString(IDS_LEARN_MORE_INCOGNITO_URL)));
-
- localized_strings.SetString(L"textdirection",
- (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- kRTLHtmlTextDirection : kDefaultHtmlTextDirection);
+ localized_strings.SetString(LIT16("title"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_TITLE)));
+ localized_strings.SetString(
+ LIT16("content"),
+ WideToUTF16Hack(l10n_util::GetStringF(
+ IDS_NEW_TAB_OTR_MESSAGE,
+ l10n_util::GetString(IDS_LEARN_MORE_INCOGNITO_URL))));
+
+ localized_strings.SetString(
+ LIT16("textdirection"),
+ WideToUTF16Hack(
+ (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
+ kRTLHtmlTextDirection : kDefaultHtmlTextDirection));
static const StringPiece incognito_tab_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -481,12 +492,14 @@ void TemplateURLHandler::OnTemplateURLModelChanged() {
if (!urlref)
continue;
DictionaryValue* entry_value = new DictionaryValue;
- entry_value->SetString(L"short_name", urls[i]->short_name());
- entry_value->SetString(L"keyword", urls[i]->keyword());
+ entry_value->SetString(LIT16("short_name"),
+ WideToUTF16Hack(urls[i]->short_name()));
+ entry_value->SetString(LIT16("keyword"),
+ WideToUTF16Hack(urls[i]->keyword()));
const GURL& url = urls[i]->GetFavIconURL();
if (url.is_valid())
- entry_value->SetString(L"favIconURL", UTF8ToWide(url.spec()));
+ entry_value->SetString(LIT16("favIconURL"), UTF8ToUTF16(url.spec()));
urls_value.Append(entry_value);
}
@@ -645,7 +658,7 @@ void RecentlyClosedTabsHandler::TabRestoreServiceChanged(
(entry->type == TabRestoreService::WINDOW &&
WindowToValue(*static_cast<TabRestoreService::Window*>(entry),
value))) {
- value->SetInteger(L"sessionId", entry->id);
+ value->SetInteger(LIT16("sessionId"), entry->id);
list_value.Append(value);
added_count++;
} else {
@@ -673,7 +686,7 @@ bool RecentlyClosedTabsHandler::TabToValue(
SetURLTitleAndDirection(dictionary, current_navigation.title(),
current_navigation.url());
- dictionary->SetString(L"type", L"tab");
+ dictionary->SetString(LIT16("type"), LIT16("tab"));
return true;
}
@@ -698,8 +711,8 @@ bool RecentlyClosedTabsHandler::WindowToValue(
return false;
}
- dictionary->SetString(L"type", L"window");
- dictionary->Set(L"tabs", tab_values);
+ dictionary->SetString(LIT16("type"), LIT16("window"));
+ dictionary->Set(LIT16("tabs"), tab_values);
return true;
}
diff --git a/chrome/browser/extensions/extension.cc b/chrome/browser/extensions/extension.cc
index 918268f..1db97ceb 100644
--- a/chrome/browser/extensions/extension.cc
+++ b/chrome/browser/extensions/extension.cc
@@ -163,14 +163,14 @@ bool Extension::InitFromValue(const DictionaryValue& source,
std::string* error) {
// Check format version.
int format_version = 0;
- if (!source.GetInteger(kFormatVersionKey, &format_version) ||
+ if (!source.GetInteger(WideToUTF16Hack(kFormatVersionKey), &format_version) ||
static_cast<uint32>(format_version) != kExpectedFormatVersion) {
*error = kInvalidFormatVersionError;
return false;
}
// Initialize id.
- if (!source.GetString(kIdKey, &id_)) {
+ if (!source.GetString(WideToUTF16Hack(kIdKey), &id_)) {
*error = kInvalidIdError;
return false;
}
@@ -193,7 +193,7 @@ bool Extension::InitFromValue(const DictionaryValue& source,
// Initialize version.
std::string version_str;
- if (!source.GetString(kVersionKey, &version_str)) {
+ if (!source.GetString(WideToUTF16Hack(kVersionKey), &version_str)) {
*error = kInvalidVersionError;
return false;
}
@@ -204,14 +204,14 @@ bool Extension::InitFromValue(const DictionaryValue& source,
}
// Initialize name.
- if (!source.GetString(kNameKey, &name_)) {
+ if (!source.GetString(WideToUTF16Hack(kNameKey), &name_)) {
*error = kInvalidNameError;
return false;
}
// Initialize description (optional).
- if (source.HasKey(kDescriptionKey)) {
- if (!source.GetString(kDescriptionKey, &description_)) {
+ if (source.HasKey(WideToUTF16Hack(kDescriptionKey))) {
+ if (!source.GetString(WideToUTF16Hack(kDescriptionKey), &description_)) {
*error = kInvalidDescriptionError;
return false;
}
@@ -220,17 +220,17 @@ bool Extension::InitFromValue(const DictionaryValue& source,
// Initialize zip hash (only present in zip)
// There's no need to verify it at this point. If it's in a bogus format
// it won't pass the hash verify step.
- if (source.HasKey(kZipHashKey)) {
- if (!source.GetString(kZipHashKey, &zip_hash_)) {
+ if (source.HasKey(WideToUTF16Hack(kZipHashKey))) {
+ if (!source.GetString(WideToUTF16Hack(kZipHashKey), &zip_hash_)) {
*error = kInvalidZipHashError;
return false;
}
}
// Initialize plugins dir (optional).
- if (source.HasKey(kPluginsDirKey)) {
+ if (source.HasKey(WideToUTF16Hack(kPluginsDirKey))) {
std::string plugins_dir;
- if (!source.GetString(kPluginsDirKey, &plugins_dir)) {
+ if (!source.GetString(WideToUTF16Hack(kPluginsDirKey), &plugins_dir)) {
*error = kInvalidPluginsDirError;
return false;
}
@@ -238,9 +238,9 @@ bool Extension::InitFromValue(const DictionaryValue& source,
}
// Initialize content scripts (optional).
- if (source.HasKey(kContentScriptsKey)) {
+ if (source.HasKey(WideToUTF16Hack(kContentScriptsKey))) {
ListValue* list_value;
- if (!source.GetList(kContentScriptsKey, &list_value)) {
+ if (!source.GetList(WideToUTF16Hack(kContentScriptsKey), &list_value)) {
*error = kInvalidContentScriptsListError;
return false;
}
@@ -255,12 +255,12 @@ bool Extension::InitFromValue(const DictionaryValue& source,
ListValue* matches;
ListValue* js;
- if (!content_script->GetList(kMatchesKey, &matches)) {
+ if (!content_script->GetList(WideToUTF16Hack(kMatchesKey), &matches)) {
*error = FormatErrorMessage(kInvalidMatchesError, IntToString(i));
return false;
}
- if (!content_script->GetList(kJsKey, &js)) {
+ if (!content_script->GetList(WideToUTF16Hack(kJsKey), &js)) {
*error = FormatErrorMessage(kInvalidJsListError, IntToString(i));
return false;
}
@@ -277,9 +277,10 @@ bool Extension::InitFromValue(const DictionaryValue& source,
}
UserScript script;
- if (content_script->HasKey(kRunAtKey)) {
+ if (content_script->HasKey(WideToUTF16Hack(kRunAtKey))) {
std::string run_location;
- if (!content_script->GetString(kRunAtKey, &run_location)) {
+ if (!content_script->GetString(WideToUTF16Hack(kRunAtKey),
+ &run_location)) {
*error = FormatErrorMessage(kInvalidRunAtError, IntToString(i));
return false;
}
@@ -328,4 +329,3 @@ bool Extension::InitFromValue(const DictionaryValue& source,
return true;
}
-
diff --git a/chrome/browser/extensions/extension_unittest.cc b/chrome/browser/extensions/extension_unittest.cc
index aa8d791..259c8db 100644
--- a/chrome/browser/extensions/extension_unittest.cc
+++ b/chrome/browser/extensions/extension_unittest.cc
@@ -43,64 +43,65 @@ TEST(ExtensionTest, InitFromValueInvalid) {
// Test missing and invalid format versions
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->Remove(Extension::kFormatVersionKey, NULL);
+ input_value->Remove(WideToUTF16Hack(Extension::kFormatVersionKey), NULL);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidFormatVersionError, error);
- input_value->SetString(Extension::kFormatVersionKey, "foo");
+ input_value->SetString(WideToUTF16Hack(Extension::kFormatVersionKey), "foo");
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidFormatVersionError, error);
- input_value->SetInteger(Extension::kFormatVersionKey, 2);
+ input_value->SetInteger(WideToUTF16Hack(Extension::kFormatVersionKey), 2);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidFormatVersionError, error);
// Test missing and invalid ids
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->Remove(Extension::kIdKey, NULL);
+ input_value->Remove(WideToUTF16Hack(Extension::kIdKey), NULL);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidIdError, error);
- input_value->SetInteger(Extension::kIdKey, 42);
+ input_value->SetInteger(WideToUTF16Hack(Extension::kIdKey), 42);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidIdError, error);
// Test missing and invalid versions
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->Remove(Extension::kVersionKey, NULL);
+ input_value->Remove(WideToUTF16Hack(Extension::kVersionKey), NULL);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidVersionError, error);
- input_value->SetInteger(Extension::kVersionKey, 42);
+ input_value->SetInteger(WideToUTF16Hack(Extension::kVersionKey), 42);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidVersionError, error);
// Test missing and invalid names
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->Remove(Extension::kNameKey, NULL);
+ input_value->Remove(WideToUTF16Hack(Extension::kNameKey), NULL);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidNameError, error);
- input_value->SetInteger(Extension::kNameKey, 42);
+ input_value->SetInteger(WideToUTF16Hack(Extension::kNameKey), 42);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidNameError, error);
// Test invalid description
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->SetInteger(Extension::kDescriptionKey, 42);
+ input_value->SetInteger(WideToUTF16Hack(Extension::kDescriptionKey), 42);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidDescriptionError, error);
// Test invalid user scripts list
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->SetInteger(Extension::kContentScriptsKey, 42);
+ input_value->SetInteger(WideToUTF16Hack(Extension::kContentScriptsKey), 42);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidContentScriptsListError, error);
// Test invalid user script item
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
ListValue* content_scripts = NULL;
- input_value->GetList(Extension::kContentScriptsKey, &content_scripts);
+ input_value->GetList(WideToUTF16Hack(Extension::kContentScriptsKey),
+ &content_scripts);
ASSERT_FALSE(NULL == content_scripts);
content_scripts->Set(0, Value::CreateIntegerValue(42));
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
@@ -108,19 +109,21 @@ TEST(ExtensionTest, InitFromValueInvalid) {
// Test missing and invalid matches array
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->GetList(Extension::kContentScriptsKey, &content_scripts);
+ input_value->GetList(WideToUTF16Hack(Extension::kContentScriptsKey),
+ &content_scripts);
DictionaryValue* user_script = NULL;
content_scripts->GetDictionary(0, &user_script);
- user_script->Remove(Extension::kMatchesKey, NULL);
+ user_script->Remove(WideToUTF16Hack(Extension::kMatchesKey), NULL);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchesError));
- user_script->Set(Extension::kMatchesKey, Value::CreateIntegerValue(42));
+ user_script->Set(WideToUTF16Hack(Extension::kMatchesKey),
+ Value::CreateIntegerValue(42));
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchesError));
ListValue* matches = new ListValue;
- user_script->Set(Extension::kMatchesKey, matches);
+ user_script->Set(WideToUTF16Hack(Extension::kMatchesKey), matches);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchCountError));
@@ -131,18 +134,20 @@ TEST(ExtensionTest, InitFromValueInvalid) {
// Test missing and invalid files array
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->GetList(Extension::kContentScriptsKey, &content_scripts);
+ input_value->GetList(WideToUTF16Hack(Extension::kContentScriptsKey),
+ &content_scripts);
content_scripts->GetDictionary(0, &user_script);
- user_script->Remove(Extension::kJsKey, NULL);
+ user_script->Remove(WideToUTF16Hack(Extension::kJsKey), NULL);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsListError));
- user_script->Set(Extension::kJsKey, Value::CreateIntegerValue(42));
+ user_script->Set(WideToUTF16Hack(Extension::kJsKey),
+ Value::CreateIntegerValue(42));
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsListError));
ListValue* files = new ListValue;
- user_script->Set(Extension::kJsKey, files);
+ user_script->Set(WideToUTF16Hack(Extension::kJsKey), files);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsCountError));
@@ -169,11 +174,11 @@ TEST(ExtensionTest, InitFromValueValid) {
DictionaryValue input_value;
// Test minimal extension
- input_value.SetInteger(Extension::kFormatVersionKey, 1);
- input_value.SetString(Extension::kIdKey,
+ input_value.SetInteger(WideToUTF16Hack(Extension::kFormatVersionKey), 1);
+ input_value.SetString(WideToUTF16Hack(Extension::kIdKey),
"00123456789ABCDEF0123456789ABCDEF0123456");
- input_value.SetString(Extension::kVersionKey, "1.0.0.0");
- input_value.SetString(Extension::kNameKey, "my extension");
+ input_value.SetString(WideToUTF16Hack(Extension::kVersionKey), "1.0.0.0");
+ input_value.SetString(WideToUTF16Hack(Extension::kNameKey), "my extension");
EXPECT_TRUE(extension.InitFromValue(input_value, &error));
EXPECT_EQ("", error);
@@ -193,11 +198,11 @@ TEST(ExtensionTest, GetResourceURLAndPath) {
#endif
Extension extension(path);
DictionaryValue input_value;
- input_value.SetInteger(Extension::kFormatVersionKey, 1);
- input_value.SetString(Extension::kIdKey,
+ input_value.SetInteger(WideToUTF16Hack(Extension::kFormatVersionKey), 1);
+ input_value.SetString(WideToUTF16Hack(Extension::kIdKey),
"00123456789ABCDEF0123456789ABCDEF0123456");
- input_value.SetString(Extension::kVersionKey, "1.0.0.0");
- input_value.SetString(Extension::kNameKey, "my extension");
+ input_value.SetString(WideToUTF16Hack(Extension::kVersionKey), "1.0.0.0");
+ input_value.SetString(WideToUTF16Hack(Extension::kNameKey), "my extension");
EXPECT_TRUE(extension.InitFromValue(input_value, NULL));
EXPECT_EQ(extension.url().spec() + "bar/baz.js",
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 3271920..be6f068 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -402,14 +402,15 @@ DictionaryValue* ExtensionsServiceBackend::ReadManifest() {
// again later, checking it here allows us to skip some potentially expensive
// work.
std::string id;
- if (!manifest->GetString(Extension::kIdKey, &id)) {
+ if (!manifest->GetString(WideToUTF16Hack(Extension::kIdKey), &id)) {
ReportExtensionInstallError("missing id key");
return NULL;
}
FilePath dest_dir = install_directory_.AppendASCII(id.c_str());
if (file_util::PathExists(dest_dir)) {
std::string version;
- if (!manifest->GetString(Extension::kVersionKey, &version)) {
+ if (!manifest->GetString(WideToUTF16Hack(Extension::kVersionKey),
+ &version)) {
ReportExtensionInstallError("missing version key");
return NULL;
}
@@ -421,7 +422,8 @@ DictionaryValue* ExtensionsServiceBackend::ReadManifest() {
}
std::string zip_hash;
- if (!manifest->GetString(Extension::kZipHashKey, &zip_hash)) {
+ if (!manifest->GetString(WideToUTF16Hack(Extension::kZipHashKey),
+ &zip_hash)) {
ReportExtensionInstallError("missing zip_hash key");
return NULL;
}
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index a504b11..57da551 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -383,24 +383,24 @@ void MetricsLog::WritePluginStabilityElements(PrefService* pref) {
}
DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter);
- std::wstring plugin_name;
- plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name);
+ string16 plugin_name;
+ plugin_dict->GetString(WideToUTF16Hack(prefs::kStabilityPluginName), &plugin_name);
OPEN_ELEMENT_FOR_SCOPE("pluginstability");
// Use "filename" instead of "name", otherwise we need to update the
// UMA servers.
- WriteAttribute("filename", CreateBase64Hash(WideToUTF8(plugin_name)));
+ WriteAttribute("filename", CreateBase64Hash(UTF16ToUTF8(plugin_name)));
int launches = 0;
- plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches);
+ plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches), &launches);
WriteIntAttribute("launchcount", launches);
int instances = 0;
- plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances);
+ plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances), &instances);
WriteIntAttribute("instancecount", instances);
int crashes = 0;
- plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes);
+ plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes), &crashes);
WriteIntAttribute("crashcount", crashes);
}
@@ -568,10 +568,11 @@ void MetricsLog::WriteAllProfilesMetrics(
const std::wstring profile_prefix(prefs::kProfilePrefix);
for (DictionaryValue::key_iterator i = all_profiles_metrics.begin_keys();
i != all_profiles_metrics.end_keys(); ++i) {
- const std::wstring& key_name = *i;
+ const string16 key_name16 = *i;
+ const std::wstring& key_name = UTF16ToWideHack(key_name16);
if (key_name.compare(0, profile_prefix.size(), profile_prefix) == 0) {
DictionaryValue* profile;
- if (all_profiles_metrics.GetDictionary(key_name, &profile))
+ if (all_profiles_metrics.GetDictionary(key_name16, &profile))
WriteProfileMetrics(key_name.substr(profile_prefix.size()), *profile);
}
}
@@ -585,13 +586,13 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash,
i != profile_metrics.end_keys(); ++i) {
Value* value;
if (profile_metrics.Get(*i, &value)) {
- DCHECK(*i != L"id");
+ DCHECK(*i != LIT16("id"));
switch (value->GetType()) {
case Value::TYPE_STRING: {
std::string string_value;
if (value->GetAsString(&string_value)) {
OPEN_ELEMENT_FOR_SCOPE("profileparam");
- WriteAttribute("name", WideToUTF8(*i));
+ WriteAttribute("name", UTF16ToUTF8(*i));
WriteAttribute("value", string_value);
}
break;
@@ -601,7 +602,7 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash,
bool bool_value;
if (value->GetAsBoolean(&bool_value)) {
OPEN_ELEMENT_FOR_SCOPE("profileparam");
- WriteAttribute("name", WideToUTF8(*i));
+ WriteAttribute("name", UTF16ToUTF8(*i));
WriteIntAttribute("value", bool_value ? 1 : 0);
}
break;
@@ -611,7 +612,7 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash,
int int_value;
if (value->GetAsInteger(&int_value)) {
OPEN_ELEMENT_FOR_SCOPE("profileparam");
- WriteAttribute("name", WideToUTF8(*i));
+ WriteAttribute("name", UTF16ToUTF8(*i));
WriteIntAttribute("value", int_value);
}
break;
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index e081bd9..db92b9c 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -1675,13 +1675,15 @@ void MetricsService::RecordPluginChanges(PrefService* pref) {
}
DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*value_iter);
- std::wstring plugin_name;
- plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name);
- if (plugin_name.empty()) {
+ string16 plugin_name16;
+ plugin_dict->GetString(WideToUTF16Hack(prefs::kStabilityPluginName),
+ &plugin_name16);
+ if (plugin_name16.empty()) {
NOTREACHED();
continue;
}
+ std::wstring plugin_name = UTF16ToWideHack(plugin_name16);
if (child_process_stats_buffer_.find(plugin_name) ==
child_process_stats_buffer_.end())
continue;
@@ -1689,21 +1691,27 @@ void MetricsService::RecordPluginChanges(PrefService* pref) {
ChildProcessStats stats = child_process_stats_buffer_[plugin_name];
if (stats.process_launches) {
int launches = 0;
- plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches);
+ plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches),
+ &launches);
launches += stats.process_launches;
- plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, launches);
+ plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches),
+ launches);
}
if (stats.process_crashes) {
int crashes = 0;
- plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes);
+ plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes),
+ &crashes);
crashes += stats.process_crashes;
- plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, crashes);
+ plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes),
+ crashes);
}
if (stats.instances) {
int instances = 0;
- plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances);
+ plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances),
+ &instances);
instances += stats.instances;
- plugin_dict->SetInteger(prefs::kStabilityPluginInstances, instances);
+ plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances),
+ instances);
}
child_process_stats_buffer_.erase(plugin_name);
@@ -1718,12 +1726,13 @@ void MetricsService::RecordPluginChanges(PrefService* pref) {
ChildProcessStats stats = cache_iter->second;
DictionaryValue* plugin_dict = new DictionaryValue;
- plugin_dict->SetString(prefs::kStabilityPluginName, plugin_name);
- plugin_dict->SetInteger(prefs::kStabilityPluginLaunches,
+ plugin_dict->SetString(WideToUTF16Hack(prefs::kStabilityPluginName),
+ WideToUTF16Hack(plugin_name));
+ plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches),
stats.process_launches);
- plugin_dict->SetInteger(prefs::kStabilityPluginCrashes,
+ plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes),
stats.process_crashes);
- plugin_dict->SetInteger(prefs::kStabilityPluginInstances,
+ plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances),
stats.instances);
plugins->Append(plugin_dict);
}
@@ -1835,7 +1844,7 @@ void MetricsService::AddProfileMetric(Profile* profile,
DCHECK(prof_prefs);
const std::wstring pref_key = std::wstring(prefs::kProfilePrefix) + id_hash +
L"." + key;
- prof_prefs->SetInteger(pref_key.c_str(), value);
+ prof_prefs->SetInteger(WideToUTF16Hack(pref_key), value);
}
static bool IsSingleThreaded() {
diff --git a/chrome/browser/page_state.cc b/chrome/browser/page_state.cc
index 827416c..3e013f2 100644
--- a/chrome/browser/page_state.cc
+++ b/chrome/browser/page_state.cc
@@ -28,7 +28,7 @@ void PageState::InitWithURL(const GURL& url) {
// We know that the query string is UTF-8 since it's an internal URL.
std::wstring value = UTF8ToWide(
UnescapeURLComponent(escaped, UnescapeRule::REPLACE_PLUS_WITH_SPACE));
- state_->Set(UTF8ToWide(query_string.substr(keyComp.begin, keyComp.len)),
+ state_->Set(UTF8ToUTF16(query_string.substr(keyComp.begin, keyComp.len)),
new StringValue(value));
}
}
@@ -59,10 +59,11 @@ void PageState::GetByteRepresentation(std::string* out) const {
void PageState::SetProperty(const std::wstring& key,
const std::wstring& value) {
- state_->Set(key, new StringValue(value));
+ state_->Set(WideToUTF16Hack(key), new StringValue(value));
}
-bool PageState::GetProperty(const std::wstring& key, std::wstring* value) const {
+bool PageState::GetProperty(const std::wstring& wkey, std::wstring* value) const {
+ string16 key(WideToUTF16(wkey));
if (state_->HasKey(key)) {
Value* v;
state_->Get(key, &v);
diff --git a/chrome/browser/profile_manager.h b/chrome/browser/profile_manager.h
index 3735492..ba8581d 100644
--- a/chrome/browser/profile_manager.h
+++ b/chrome/browser/profile_manager.h
@@ -15,6 +15,7 @@
#include "base/file_path.h"
#include "base/message_loop.h"
#include "base/non_thread_safe.h"
+#include "base/string_util.h"
#include "base/system_monitor.h"
#include "base/values.h"
#include "chrome/browser/profile.h"
@@ -33,20 +34,21 @@ class AvailableProfile {
// Decodes a DictionaryValue into an AvailableProfile
static AvailableProfile* FromValue(DictionaryValue* value) {
DCHECK(value);
- std::wstring name, id;
+ string16 name, id;
FilePath::StringType directory;
- value->GetString(L"name", &name);
- value->GetString(L"id", &id);
- value->GetString(L"directory", &directory);
- return new AvailableProfile(name, id, FilePath(directory));
+ value->GetString(LIT16("name"), &name);
+ value->GetString(LIT16("id"), &id);
+ value->GetString(LIT16("directory"), &directory);
+ return new AvailableProfile(UTF16ToWideHack(name), UTF16ToWideHack(id),
+ FilePath(directory));
}
// Encodes this AvailableProfile into a new DictionaryValue
DictionaryValue* ToValue() {
DictionaryValue* value = new DictionaryValue;
- value->SetString(L"name", name_);
- value->SetString(L"id", id_);
- value->SetString(L"directory", directory_.value());
+ value->SetString(LIT16("name"), WideToUTF16Hack(name_));
+ value->SetString(LIT16("id"), WideToUTF16Hack(id_));
+ value->SetString(LIT16("directory"), directory_.value());
return value;
}
@@ -183,4 +185,3 @@ class ProfileManager : public NonThreadSafe,
};
#endif // CHROME_BROWSER_PROFILE_MANAGER_H__
-
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
index 2eafe9a1..2590556 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
@@ -103,11 +103,11 @@ void SafeBrowsingBlockingPage::PopulateStringDictionary(
const std::wstring& description1,
const std::wstring& description2,
const std::wstring& description3) {
- strings->SetString(L"title", title);
- strings->SetString(L"headLine", headline);
- strings->SetString(L"description1", description1);
- strings->SetString(L"description2", description2);
- strings->SetString(L"description3", description3);
+ strings->SetString(LIT16("title"), WideToUTF16Hack(title));
+ strings->SetString(LIT16("headLine"), WideToUTF16Hack(headline));
+ strings->SetString(LIT16("description1"), WideToUTF16Hack(description1));
+ strings->SetString(LIT16("description2"), WideToUTF16Hack(description2));
+ strings->SetString(LIT16("description3"), WideToUTF16Hack(description3));
}
void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary(
@@ -115,14 +115,17 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary(
bool malware = false;
bool phishing = false;
- std::wstring phishing_label =
- l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_LABEL);
- std::wstring phishing_link =
- l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR);
- std::wstring malware_label =
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_LABEL);
- std::wstring malware_link =
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE);
+ string16 phishing_label =
+ WideToUTF16Hack(l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_LABEL));
+ string16 phishing_link =
+ WideToUTF16Hack(
+ l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR));
+ string16 malware_label =
+ WideToUTF16Hack(
+ l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_LABEL));
+ string16 malware_link =
+ WideToUTF16Hack(
+ l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE));
ListValue* error_strings = new ListValue;
for (UnsafeResourceList::const_iterator iter = unsafe_resources_.begin();
@@ -131,20 +134,21 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary(
DictionaryValue* current_error_strings = new DictionaryValue;
if (resource.threat_type == SafeBrowsingService::URL_MALWARE) {
malware = true;
- current_error_strings->SetString(L"type", L"malware");
- current_error_strings->SetString(L"typeLabel", malware_label);
- current_error_strings->SetString(L"errorLink", malware_link);
+ current_error_strings->SetString(LIT16("type"), LIT16("malware"));
+ current_error_strings->SetString(LIT16("typeLabel"), malware_label);
+ current_error_strings->SetString(LIT16("errorLink"), malware_link);
} else {
DCHECK(resource.threat_type == SafeBrowsingService::URL_PHISHING);
phishing = true;
- current_error_strings->SetString(L"type", L"phishing");
- current_error_strings->SetString(L"typeLabel", phishing_label);
- current_error_strings->SetString(L"errorLink", phishing_link);
+ current_error_strings->SetString(LIT16("type"), LIT16("phishing"));
+ current_error_strings->SetString(LIT16("typeLabel"), phishing_label);
+ current_error_strings->SetString(LIT16("errorLink"), phishing_link);
}
- current_error_strings->SetString(L"url", UTF8ToWide(resource.url.spec()));
+ current_error_strings->SetString(LIT16("url"),
+ UTF8ToUTF16(resource.url.spec()));
error_strings->Append(current_error_strings);
}
- strings->Set(L"errors", error_strings);
+ strings->Set(LIT16("errors"), error_strings);
DCHECK(phishing || malware);
if (malware && phishing) {
@@ -178,15 +182,18 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary(
L"", L"");
}
- strings->SetString(L"confirm_text",
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION_AGREE));
- strings->SetString(L"continue_button",
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON));
- strings->SetString(L"back_button",
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON));
- strings->SetString(L"textdirection",
+ strings->SetString(LIT16("confirm_text"),
+ WideToUTF16Hack(l10n_util::GetString(
+ IDS_SAFE_BROWSING_MALWARE_DESCRIPTION_AGREE)));
+ strings->SetString(LIT16("continue_button"),
+ WideToUTF16Hack(l10n_util::GetString(
+ IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON)));
+ strings->SetString(LIT16("back_button"),
+ WideToUTF16Hack(l10n_util::GetString(
+ IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)));
+ strings->SetString(LIT16("textdirection"),
(l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- L"rtl" : L"ltr");
+ LIT16("rtl") : LIT16("ltr"));
}
void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary(
@@ -194,7 +201,7 @@ void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary(
std::wstring link = StringPrintf(kSbDiagnosticHtml,
l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE).c_str());
- strings->SetString(L"badURL", UTF8ToWide(url().host()));
+ strings->SetString(LIT16("badURL"), UTF8ToUTF16(url().host()));
// Check to see if we're blocking the main page, or a sub-resource on the
// main page.
std::wstring description1, description2;
@@ -220,15 +227,18 @@ void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary(
description1, description2,
l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION3));
- strings->SetString(L"confirm_text",
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION_AGREE));
- strings->SetString(L"continue_button",
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON));
- strings->SetString(L"back_button",
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON));
- strings->SetString(L"textdirection",
+ strings->SetString(LIT16("confirm_text"),
+ WideToUTF16Hack(l10n_util::GetString(
+ IDS_SAFE_BROWSING_MALWARE_DESCRIPTION_AGREE)));
+ strings->SetString(LIT16("continue_button"),
+ WideToUTF16Hack(l10n_util::GetString(
+ IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON)));
+ strings->SetString(LIT16("back_button"),
+ WideToUTF16Hack(l10n_util::GetString(
+ IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)));
+ strings->SetString(LIT16("textdirection"),
(l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- L"rtl" : L"ltr");
+ LIT16("rtl") : LIT16("ltr"));
}
void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary(
@@ -243,15 +253,18 @@ void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary(
UTF8ToWide(url().host())),
L"");
- strings->SetString(L"continue_button",
- l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_PROCEED_BUTTON));
- strings->SetString(L"back_button",
- l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_BACK_BUTTON));
- strings->SetString(L"report_error",
- l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR));
- strings->SetString(L"textdirection",
+ strings->SetString(LIT16("continue_button"),
+ WideToUTF16Hack(l10n_util::GetString(
+ IDS_SAFE_BROWSING_PHISHING_PROCEED_BUTTON)));
+ strings->SetString(LIT16("back_button"),
+ WideToUTF16Hack(l10n_util::GetString(
+ IDS_SAFE_BROWSING_PHISHING_BACK_BUTTON)));
+ strings->SetString(LIT16("report_error"),
+ WideToUTF16Hack(l10n_util::GetString(
+ IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR)));
+ strings->SetString(LIT16("textdirection"),
(l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- L"rtl" : L"ltr");
+ LIT16("rtl") : LIT16("ltr"));
}
void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
@@ -435,4 +448,3 @@ bool SafeBrowsingBlockingPage::IsMainPage(
return unsafe_resources.size() == 1 &&
unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME;
}
-
diff --git a/chrome/browser/ssl/ssl_blocking_page.cc b/chrome/browser/ssl/ssl_blocking_page.cc
index c98975d..966b514 100644
--- a/chrome/browser/ssl/ssl_blocking_page.cc
+++ b/chrome/browser/ssl/ssl_blocking_page.cc
@@ -44,23 +44,29 @@ std::string SSLBlockingPage::GetHTMLContents() {
// Let's build the html error page.
DictionaryValue strings;
SSLErrorInfo error_info = delegate_->GetSSLErrorInfo(error_);
- strings.SetString(L"title",
- l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_TITLE));
- strings.SetString(L"headLine", error_info.title());
- strings.SetString(L"description", error_info.details());
-
- strings.SetString(L"moreInfoTitle",
- l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE));
+ strings.SetString(
+ LIT16("title"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_TITLE)));
+ strings.SetString(LIT16("headLine"), WideToUTF16Hack(error_info.title()));
+ strings.SetString(LIT16("description"),
+ WideToUTF16Hack(error_info.details()));
+
+ strings.SetString(
+ LIT16("moreInfoTitle"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE)));
SetExtraInfo(&strings, error_info.extra_information());
- strings.SetString(L"proceed",
- l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_PROCEED));
- strings.SetString(L"exit",
- l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_EXIT));
+ strings.SetString(
+ LIT16("proceed"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_PROCEED)));
+ strings.SetString(
+ LIT16("exit"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_EXIT)));
- strings.SetString(L"textdirection",
+ strings.SetString(
+ LIT16("textdirection"),
(l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- L"rtl" : L"ltr");
+ LIT16("rtl") : LIT16("ltr"));
static const StringPiece html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -131,15 +137,15 @@ void SSLBlockingPage::SetExtraInfo(
DictionaryValue* strings,
const std::vector<std::wstring>& extra_info) {
DCHECK(extra_info.size() < 5); // We allow 5 paragraphs max.
- const std::wstring keys[5] = {
- L"moreInfo1", L"moreInfo2", L"moreInfo3", L"moreInfo4", L"moreInfo5"
+ const string16 keys[5] = {
+ LIT16("moreInfo1"), LIT16("moreInfo2"), LIT16("moreInfo3"),
+ LIT16("moreInfo4"), LIT16("moreInfo5")
};
int i;
for (i = 0; i < static_cast<int>(extra_info.size()); i++) {
- strings->SetString(keys[i], extra_info[i]);
+ strings->SetString(keys[i], WideToUTF16Hack(extra_info[i]));
}
for (;i < 5; i++) {
- strings->SetString(keys[i], L"");
+ strings->SetString(keys[i], LIT16(""));
}
}
-
diff --git a/chrome/browser/ssl/ssl_policy.cc b/chrome/browser/ssl/ssl_policy.cc
index 4a0fdef..7b18048 100644
--- a/chrome/browser/ssl/ssl_policy.cc
+++ b/chrome/browser/ssl/ssl_policy.cc
@@ -76,18 +76,25 @@ static void ShowErrorPage(SSLPolicy* policy, SSLManager::CertError* error) {
// Let's build the html error page.
DictionaryValue strings;
- strings.SetString(L"title", l10n_util::GetString(IDS_SSL_ERROR_PAGE_TITLE));
- strings.SetString(L"headLine", error_info.title());
- strings.SetString(L"description", error_info.details());
- strings.SetString(L"moreInfoTitle",
- l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE));
+ strings.SetString(
+ LIT16("title"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_SSL_ERROR_PAGE_TITLE)));
+ strings.SetString(LIT16("headLine"), WideToUTF16Hack(error_info.title()));
+ strings.SetString(LIT16("description"),
+ WideToUTF16Hack(error_info.details()));
+ strings.SetString(
+ LIT16("moreInfoTitle"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE)));
SSLBlockingPage::SetExtraInfo(&strings, error_info.extra_information());
- strings.SetString(L"back", l10n_util::GetString(IDS_SSL_ERROR_PAGE_BACK));
+ strings.SetString(
+ LIT16("back"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_SSL_ERROR_PAGE_BACK)));
- strings.SetString(L"textdirection",
+ strings.SetString(
+ LIT16("textdirection"),
(l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- L"rtl" : L"ltr");
+ LIT16("rtl") : LIT16("ltr"));
static const StringPiece html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
diff --git a/chrome/common/json_value_serializer_unittest.cc b/chrome/common/json_value_serializer_unittest.cc
index 1fc9e97..f09f8d3 100644
--- a/chrome/common/json_value_serializer_unittest.cc
+++ b/chrome/common/json_value_serializer_unittest.cc
@@ -24,20 +24,20 @@ TEST(JSONValueSerializerTest, Roundtrip) {
DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get());
Value* null_value = NULL;
- ASSERT_TRUE(root_dict->Get(L"null", &null_value));
+ ASSERT_TRUE(root_dict->Get(LIT16("null"), &null_value));
ASSERT_TRUE(null_value);
ASSERT_TRUE(null_value->IsType(Value::TYPE_NULL));
bool bool_value = false;
- ASSERT_TRUE(root_dict->GetBoolean(L"bool", &bool_value));
+ ASSERT_TRUE(root_dict->GetBoolean(LIT16("bool"), &bool_value));
ASSERT_TRUE(bool_value);
int int_value = 0;
- ASSERT_TRUE(root_dict->GetInteger(L"int", &int_value));
+ ASSERT_TRUE(root_dict->GetInteger(LIT16("int"), &int_value));
ASSERT_EQ(42, int_value);
double real_value = 0.0;
- ASSERT_TRUE(root_dict->GetReal(L"real", &real_value));
+ ASSERT_TRUE(root_dict->GetReal(LIT16("real"), &real_value));
ASSERT_DOUBLE_EQ(3.14, real_value);
// We shouldn't be able to write using this serializer, since it was
@@ -92,7 +92,7 @@ TEST(JSONValueSerializerTest, StringEscape) {
// Test JSONWriter interface
std::string output_js;
DictionaryValue valueRoot;
- valueRoot.SetString(L"all_chars", all_chars);
+ valueRoot.SetString(LIT16("all_chars"), WideToUTF16Hack(all_chars));
JSONWriter::Write(&valueRoot, false, &output_js);
ASSERT_EQ(expected_output, output_js);
@@ -106,7 +106,7 @@ TEST(JSONValueSerializerTest, UnicodeStrings) {
// unicode string json -> escaped ascii text
DictionaryValue root;
std::wstring test(L"\x7F51\x9875");
- root.SetString(L"web", test);
+ root.SetString(LIT16("web"), WideToUTF16Hack(test));
std::string expected = "{\"web\":\"\\u7F51\\u9875\"}";
@@ -121,16 +121,16 @@ TEST(JSONValueSerializerTest, UnicodeStrings) {
ASSERT_TRUE(deserial_root.get());
DictionaryValue* dict_root =
static_cast<DictionaryValue*>(deserial_root.get());
- std::wstring web_value;
- ASSERT_TRUE(dict_root->GetString(L"web", &web_value));
- ASSERT_EQ(test, web_value);
+ string16 web_value;
+ ASSERT_TRUE(dict_root->GetString(LIT16("web"), &web_value));
+ ASSERT_EQ(test, UTF16ToWideHack(web_value));
}
TEST(JSONValueSerializerTest, HexStrings) {
// hex string json -> escaped ascii text
DictionaryValue root;
std::wstring test(L"\x01\x02");
- root.SetString(L"test", test);
+ root.SetString(LIT16("test"), WideToUTF16Hack(test));
std::string expected = "{\"test\":\"\\x01\\x02\"}";
@@ -145,9 +145,9 @@ TEST(JSONValueSerializerTest, HexStrings) {
ASSERT_TRUE(deserial_root.get());
DictionaryValue* dict_root =
static_cast<DictionaryValue*>(deserial_root.get());
- std::wstring test_value;
- ASSERT_TRUE(dict_root->GetString(L"test", &test_value));
- ASSERT_EQ(test, test_value);
+ string16 test_value;
+ ASSERT_TRUE(dict_root->GetString(LIT16("test"), &test_value));
+ ASSERT_EQ(test, UTF16ToWideHack(test_value));
// Test converting escaped regular chars
std::string escaped_chars = "{\"test\":\"\\x67\\x6f\"}";
@@ -155,8 +155,8 @@ TEST(JSONValueSerializerTest, HexStrings) {
deserial_root.reset(deserializer2.Deserialize(NULL));
ASSERT_TRUE(deserial_root.get());
dict_root = static_cast<DictionaryValue*>(deserial_root.get());
- ASSERT_TRUE(dict_root->GetString(L"test", &test_value));
- ASSERT_EQ(std::wstring(L"go"), test_value);
+ ASSERT_TRUE(dict_root->GetString(LIT16("test"), &test_value));
+ ASSERT_EQ(L"go", UTF16ToWideHack(test_value));
}
TEST(JSONValueSerializerTest, AllowTrailingComma) {
@@ -260,21 +260,21 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) {
DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get());
Value* null_value = NULL;
- ASSERT_TRUE(root_dict->Get(L"null", &null_value));
+ ASSERT_TRUE(root_dict->Get(LIT16("null"), &null_value));
ASSERT_TRUE(null_value);
ASSERT_TRUE(null_value->IsType(Value::TYPE_NULL));
bool bool_value = false;
- ASSERT_TRUE(root_dict->GetBoolean(L"bool", &bool_value));
+ ASSERT_TRUE(root_dict->GetBoolean(LIT16("bool"), &bool_value));
ASSERT_TRUE(bool_value);
int int_value = 0;
- ASSERT_TRUE(root_dict->GetInteger(L"int", &int_value));
+ ASSERT_TRUE(root_dict->GetInteger(LIT16("int"), &int_value));
ASSERT_EQ(42, int_value);
- std::wstring string_value;
- ASSERT_TRUE(root_dict->GetString(L"string", &string_value));
- ASSERT_EQ(L"hello", string_value);
+ string16 string_value;
+ ASSERT_TRUE(root_dict->GetString(LIT16("string"), &string_value));
+ ASSERT_EQ(L"hello", UTF16ToWideHack(string_value));
// Now try writing.
std::wstring written_file_path = test_dir_;
diff --git a/chrome/common/pref_service.cc b/chrome/common/pref_service.cc
index b728a87..fd27de1 100644
--- a/chrome/common/pref_service.cc
+++ b/chrome/common/pref_service.cc
@@ -289,7 +289,7 @@ bool PrefService::GetBoolean(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
bool result = false;
- if (transient_->GetBoolean(path, &result))
+ if (transient_->GetBoolean(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -306,7 +306,7 @@ int PrefService::GetInteger(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
int result = 0;
- if (transient_->GetInteger(path, &result))
+ if (transient_->GetInteger(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -323,7 +323,7 @@ double PrefService::GetReal(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
double result = 0.0;
- if (transient_->GetReal(path, &result))
+ if (transient_->GetReal(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -339,10 +339,11 @@ double PrefService::GetReal(const wchar_t* path) const {
std::wstring PrefService::GetString(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
- std::wstring result;
- if (transient_->GetString(path, &result))
- return result;
+ string16 result16;
+ if (transient_->GetString(WideToUTF16Hack(path), &result16))
+ return UTF16ToWideHack(result16);
+ std::wstring result;
const Preference* pref = FindPreference(path);
if (!pref) {
#if defined(OS_WIN)
@@ -359,7 +360,8 @@ std::wstring PrefService::GetString(const wchar_t* path) const {
bool PrefService::HasPrefPath(const wchar_t* path) const {
Value* value = NULL;
- return (transient_->Get(path, &value) || persistent_->Get(path, &value));
+ string16 path16 = WideToUTF16Hack(path);
+ return (transient_->Get(path16, &value) || persistent_->Get(path16, &value));
}
const PrefService::Preference* PrefService::FindPreference(
@@ -374,7 +376,7 @@ const DictionaryValue* PrefService::GetDictionary(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
DictionaryValue* result = NULL;
- if (transient_->GetDictionary(path, &result))
+ if (transient_->GetDictionary(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -392,7 +394,7 @@ const ListValue* PrefService::GetList(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
ListValue* result = NULL;
- if (transient_->GetList(path, &result))
+ if (transient_->GetList(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -473,10 +475,11 @@ void PrefService::ClearPref(const wchar_t* path) {
return;
}
- transient_->Remove(path, NULL);
+ string16 path16 = WideToUTF16Hack(path);
+ transient_->Remove(path16, NULL);
Value* value;
- bool has_old_value = persistent_->Get(path, &value);
- persistent_->Remove(path, NULL);
+ bool has_old_value = persistent_->Get(path16, &value);
+ persistent_->Remove(path16, NULL);
if (has_old_value)
FireObservers(path);
@@ -496,7 +499,7 @@ void PrefService::SetBoolean(const wchar_t* path, bool value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetBoolean(path, value);
+ bool rv = persistent_->SetBoolean(WideToUTF16Hack(path), value);
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -516,7 +519,7 @@ void PrefService::SetInteger(const wchar_t* path, int value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetInteger(path, value);
+ bool rv = persistent_->SetInteger(WideToUTF16Hack(path), value);
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -536,7 +539,7 @@ void PrefService::SetReal(const wchar_t* path, double value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetReal(path, value);
+ bool rv = persistent_->SetReal(WideToUTF16Hack(path), value);
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -556,7 +559,8 @@ void PrefService::SetString(const wchar_t* path, const std::wstring& value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetString(path, value);
+ bool rv = persistent_->SetString(WideToUTF16Hack(path),
+ WideToUTF16Hack(value));
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -576,10 +580,11 @@ DictionaryValue* PrefService::GetMutableDictionary(const wchar_t* path) {
}
DictionaryValue* dict = NULL;
- bool rv = persistent_->GetDictionary(path, &dict);
+ string16 path16 = WideToUTF16Hack(path);
+ bool rv = persistent_->GetDictionary(path16, &dict);
if (!rv) {
dict = new DictionaryValue;
- rv = persistent_->Set(path, dict);
+ rv = persistent_->Set(path16, dict);
DCHECK(rv);
}
return dict;
@@ -599,10 +604,11 @@ ListValue* PrefService::GetMutableList(const wchar_t* path) {
}
ListValue* list = NULL;
- bool rv = persistent_->GetList(path, &list);
+ string16 path16 = WideToUTF16Hack(path);
+ bool rv = persistent_->GetList(path16, &list);
if (!rv) {
list = new ListValue;
- rv = persistent_->Set(path, list);
+ rv = persistent_->Set(path16, list);
DCHECK(rv);
}
return list;
@@ -619,7 +625,7 @@ Value* PrefService::GetPrefCopy(const wchar_t* path) {
void PrefService::FireObserversIfChanged(const wchar_t* path,
const Value* old_value) {
Value* new_value = NULL;
- persistent_->Get(path, &new_value);
+ persistent_->Get(WideToUTF16Hack(path), &new_value);
if (!old_value->Equals(new_value))
FireObservers(path);
}
@@ -672,7 +678,7 @@ const Value* PrefService::Preference::GetValue() const {
"Must register pref before getting its value";
Value* temp_value = NULL;
- if (root_pref_->Get(name_.c_str(), &temp_value) &&
+ if (root_pref_->Get(WideToUTF16Hack(name_), &temp_value) &&
temp_value->GetType() == type_) {
return temp_value;
}
diff --git a/chrome/renderer/localized_error.cc b/chrome/renderer/localized_error.cc
index af89563..a9abbac 100644
--- a/chrome/renderer/localized_error.cc
+++ b/chrome/renderer/localized_error.cc
@@ -86,10 +86,12 @@ WebErrorNetErrorMap net_error_options[] = {
void GetLocalizedErrorValues(const WebError& error,
DictionaryValue* error_strings) {
// Grab strings that are applicable to all error pages
- error_strings->SetString(L"detailsLink",
- l10n_util::GetString(IDS_ERRORPAGES_DETAILS_LINK));
- error_strings->SetString(L"detailsHeading",
- l10n_util::GetString(IDS_ERRORPAGES_DETAILS_HEADING));
+ error_strings->SetString(
+ LIT16("detailsLink"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ERRORPAGES_DETAILS_LINK)));
+ error_strings->SetString(
+ LIT16("detailsHeading"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ERRORPAGES_DETAILS_HEADING)));
// Grab the strings and settings that depend on the error type. Init
// options with default values.
@@ -114,40 +116,49 @@ void GetLocalizedErrorValues(const WebError& error,
suggestions_heading =
l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_HEADING);
}
- error_strings->SetString(L"suggestionsHeading", suggestions_heading);
+ error_strings->SetString(LIT16("suggestionsHeading"),
+ WideToUTF16Hack(suggestions_heading));
std::wstring failed_url(ASCIIToWide(error.GetFailedURL().spec()));
// URLs are always LTR.
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
l10n_util::WrapStringWithLTRFormatting(&failed_url);
- error_strings->SetString(L"title",
- l10n_util::GetStringF(options.title_resource_id,
- failed_url));
- error_strings->SetString(L"heading",
- l10n_util::GetString(options.heading_resource_id));
+ error_strings->SetString(
+ LIT16("title"),
+ WideToUTF16Hack(l10n_util::GetStringF(options.title_resource_id,
+ failed_url)));
+ error_strings->SetString(
+ LIT16("heading"),
+ WideToUTF16Hack(l10n_util::GetString(options.heading_resource_id)));
DictionaryValue* summary = new DictionaryValue;
- summary->SetString(L"msg",
- l10n_util::GetString(options.summary_resource_id));
+ summary->SetString(
+ LIT16("msg"),
+ WideToUTF16Hack(l10n_util::GetString(options.summary_resource_id)));
// TODO(tc): we want the unicode url here since it's being displayed
- summary->SetString(L"failedUrl", failed_url);
- error_strings->Set(L"summary", summary);
+ summary->SetString(LIT16("failedUrl"), WideToUTF16Hack(failed_url));
+ error_strings->Set(LIT16("summary"), summary);
// Error codes are expected to be negative
DCHECK(error_code < 0);
std::wstring details = l10n_util::GetString(options.details_resource_id);
- error_strings->SetString(L"details",
- l10n_util::GetStringF(IDS_ERRORPAGES_DETAILS_TEMPLATE,
- IntToWString(-error_code),
- ASCIIToWide(net::ErrorToString(error_code)),
- details));
+ error_strings->SetString(
+ LIT16("details"),
+ WideToUTF16Hack(l10n_util::GetStringF(
+ IDS_ERRORPAGES_DETAILS_TEMPLATE,
+ IntToWString(-error_code),
+ ASCIIToWide(net::ErrorToString(error_code)),
+ details)));
if (options.suggestions & SUGGEST_RELOAD) {
DictionaryValue* suggest_reload = new DictionaryValue;
- suggest_reload->SetString(L"msg",
- l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_RELOAD));
- suggest_reload->SetString(L"reloadUrl", failed_url);
- error_strings->Set(L"suggestionsReload", suggest_reload);
+ suggest_reload->SetString(
+ LIT16("msg"),
+ WideToUTF16Hack(l10n_util::GetString(
+ IDS_ERRORPAGES_SUGGESTION_RELOAD)));
+ suggest_reload->SetString(LIT16("reloadUrl"),
+ WideToUTF16Hack(failed_url));
+ error_strings->Set(LIT16("suggestionsReload"), suggest_reload);
}
if (options.suggestions & SUGGEST_HOSTNAME) {
@@ -155,17 +166,20 @@ void GetLocalizedErrorValues(const WebError& error,
const GURL& failed_url = error.GetFailedURL();
if (std::string() == failed_url.path()) {
DictionaryValue* suggest_home_page = new DictionaryValue;
- suggest_home_page->SetString(L"suggestionsHomepageMsg",
- l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_HOMEPAGE));
+ suggest_home_page->SetString(
+ LIT16("suggestionsHomepageMsg"),
+ WideToUTF16Hack(l10n_util::GetString(
+ IDS_ERRORPAGES_SUGGESTION_HOMEPAGE)));
std::wstring homepage(ASCIIToWide(failed_url.GetWithEmptyPath().spec()));
// URLs are always LTR.
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
l10n_util::WrapStringWithLTRFormatting(&homepage);
- suggest_home_page->SetString(L"homePage", homepage);
+ suggest_home_page->SetString(LIT16("homePage"),
+ WideToUTF16Hack(homepage));
// TODO(tc): we actually want the unicode hostname
- suggest_home_page->SetString(L"hostName",
- ASCIIToWide(failed_url.host()));
- error_strings->Set(L"suggestionsHomepage", suggest_home_page);
+ suggest_home_page->SetString(LIT16("hostName"),
+ UTF8ToUTF16(failed_url.host()));
+ error_strings->Set(LIT16("suggestionsHomepage"), suggest_home_page);
}
}
@@ -188,11 +202,13 @@ void GetLocalizedErrorValues(const WebError& error,
learn_more_url = learn_more_url.ReplaceComponents(repl);
DictionaryValue* suggest_learn_more = new DictionaryValue;
- suggest_learn_more->SetString(L"msg",
- l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_LEARNMORE));
- suggest_learn_more->SetString(L"learnMoreUrl",
- ASCIIToWide(learn_more_url.spec()));
- error_strings->Set(L"suggestionsLearnMore", suggest_learn_more);
+ suggest_learn_more->SetString(
+ LIT16("msg"),
+ WideToUTF16Hack(l10n_util::GetString(
+ IDS_ERRORPAGES_SUGGESTION_LEARNMORE)));
+ suggest_learn_more->SetString(LIT16("learnMoreUrl"),
+ UTF8ToUTF16(learn_more_url.spec()));
+ error_strings->Set(LIT16("suggestionsLearnMore"), suggest_learn_more);
}
}
}
@@ -204,13 +220,17 @@ void GetFormRepostErrorValues(const GURL& display_url,
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
l10n_util::WrapStringWithLTRFormatting(&failed_url);
error_strings->SetString(
- L"title", l10n_util::GetStringF(IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
- failed_url.c_str()));
- error_strings->SetString(L"heading",
- l10n_util::GetString(IDS_HTTP_POST_WARNING_TITLE));
- error_strings->SetString(L"suggestionsHeading", L"");
+ LIT16("title"),
+ WideToUTF16Hack(l10n_util::GetStringF(
+ IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
+ failed_url.c_str())));
+ error_strings->SetString(
+ LIT16("heading"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_HTTP_POST_WARNING_TITLE)));
+ error_strings->SetString(LIT16("suggestionsHeading"), LIT16(""));
DictionaryValue* summary = new DictionaryValue;
- summary->SetString(L"msg",
- l10n_util::GetString(IDS_ERRORPAGES_HTTP_POST_WARNING));
- error_strings->Set(L"summary", summary);
+ summary->SetString(
+ LIT16("msg"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ERRORPAGES_HTTP_POST_WARNING)));
+ error_strings->Set(LIT16("summary"), summary);
}
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 59ba2c9..c7d3a72 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1380,9 +1380,10 @@ void RenderView::LoadNavigationErrorPage(WebFrame* frame,
GetLocalizedErrorValues(error, &error_strings);
resource_id = IDR_NET_ERROR_HTML;
}
- error_strings.SetString(L"textdirection",
- (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- L"rtl" : L"ltr");
+ error_strings.SetString(
+ LIT16("textdirection"),
+ (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
+ LIT16("rtl") : LIT16("ltr"));
alt_html = GetAltHTMLForTemplate(error_strings, resource_id);
} else {