diff options
35 files changed, 622 insertions, 822 deletions
diff --git a/base/json_reader.cc b/base/json_reader.cc index e4dc61c..b5013ef 100644 --- a/base/json_reader.cc +++ b/base/json_reader.cc @@ -277,8 +277,7 @@ Value* JSONReader::BuildValue(bool is_root) { Value* dict_value = BuildValue(false); if (!dict_value) return NULL; - static_cast<DictionaryValue*>(node.get())->Set( - WideToUTF16Hack(dict_key), dict_value); + static_cast<DictionaryValue*>(node.get())->Set(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 bd64162..9153289 100644 --- a/base/json_reader_unittest.cc +++ b/base/json_reader_unittest.cc @@ -5,7 +5,6 @@ #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" @@ -298,14 +297,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(ASCIIToUTF16("number"), &real_val)); + ASSERT_TRUE(dict_val->GetReal(L"number", &real_val)); ASSERT_DOUBLE_EQ(9.87654321, real_val); Value* null_val = NULL; - ASSERT_TRUE(dict_val->Get(ASCIIToUTF16("null"), &null_val)); + ASSERT_TRUE(dict_val->Get(L"null", &null_val)); ASSERT_TRUE(null_val->IsType(Value::TYPE_NULL)); - string16 str16_val; - ASSERT_TRUE(dict_val->GetString(ASCIIToUTF16("S"), &str16_val)); - ASSERT_EQ(ASCIIToUTF16("str"), str16_val); + str_val.clear(); + ASSERT_TRUE(dict_val->GetString(L"S", &str_val)); + ASSERT_EQ(L"str", str_val); root2.reset(JSONReader::Read( "{\"number\":9.87654321, \"null\":null , \"\\x53\" : \"str\", }", true)); @@ -318,15 +317,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(ASCIIToUTF16("inner"), &inner_dict)); + ASSERT_TRUE(dict_val->GetDictionary(L"inner", &inner_dict)); ListValue* inner_array = NULL; - ASSERT_TRUE(inner_dict->GetList(ASCIIToUTF16("array"), &inner_array)); + ASSERT_TRUE(inner_dict->GetList(L"array", &inner_array)); ASSERT_EQ(1U, inner_array->GetSize()); bool_value = true; - ASSERT_TRUE(dict_val->GetBoolean(ASCIIToUTF16("false"), &bool_value)); + ASSERT_TRUE(dict_val->GetBoolean(L"false", &bool_value)); ASSERT_FALSE(bool_value); inner_dict = NULL; - ASSERT_TRUE(dict_val->GetDictionary(ASCIIToUTF16("d"), &inner_dict)); + ASSERT_TRUE(dict_val->GetDictionary(L"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 56efce9..20c533b 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(WideToUTF16Hack(value)); + AppendQuotedString(value); break; } @@ -155,8 +155,8 @@ void JSONWriter::BuildJSONString(const Value* const node, int depth) { } } -void JSONWriter::AppendQuotedString(const string16& str) { - string_escape::JavascriptDoubleQuote(str, true, +void JSONWriter::AppendQuotedString(const std::wstring& str) { + string_escape::JavascriptDoubleQuote(WideToUTF16Hack(str), true, json_string_); } diff --git a/base/json_writer.h b/base/json_writer.h index 330e73c..42232bf 100644 --- a/base/json_writer.h +++ b/base/json_writer.h @@ -5,8 +5,9 @@ #ifndef BASE_JSON_WRITER_H_ #define BASE_JSON_WRITER_H_ +#include <string> + #include "base/basictypes.h" -#include "base/string16.h" class Value; @@ -30,7 +31,7 @@ class JSONWriter { void BuildJSONString(const Value* const node, int depth); // Appends a quoted, escaped, version of str to json_string_. - void AppendQuotedString(const string16& str); + void AppendQuotedString(const std::wstring& str); // Adds space to json_string_ for the indent level. void IndentLine(int depth); @@ -44,3 +45,4 @@ class JSONWriter { }; #endif // BASE_JSON_WRITER_H_ + diff --git a/base/json_writer_unittest.cc b/base/json_writer_unittest.cc index 2c746fd..cddfd4c 100644 --- a/base/json_writer_unittest.cc +++ b/base/json_writer_unittest.cc @@ -4,7 +4,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include "base/json_writer.h" -#include "base/string_util.h" #include "base/values.h" TEST(JSONWriterTest, Writing) { @@ -37,10 +36,10 @@ TEST(JSONWriterTest, Writing) { // list list nesting, etc. DictionaryValue root_dict; ListValue* list = new ListValue; - root_dict.Set(ASCIIToUTF16("list"), list); + root_dict.Set(L"list", list); DictionaryValue* inner_dict = new DictionaryValue; list->Append(inner_dict); - inner_dict->SetInteger(ASCIIToUTF16("inner int"), 10); + inner_dict->SetInteger(L"inner int", 10); ListValue* inner_list = new ListValue; list->Append(inner_list); list->Append(Value::CreateBooleanValue(true)); @@ -55,3 +54,5 @@ TEST(JSONWriterTest, Writing) { "}\r\n", output_js); } + + diff --git a/base/string_util.cc b/base/string_util.cc index 4080b1d..a13f79f 100644 --- a/base/string_util.cc +++ b/base/string_util.cc @@ -1039,10 +1039,6 @@ 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); @@ -1051,10 +1047,6 @@ 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); @@ -1063,10 +1055,6 @@ 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); @@ -1075,10 +1063,6 @@ 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); @@ -1091,10 +1075,6 @@ std::string DoubleToString(double value) { return std::string(buffer); } -string16 DoubleToString16(double value) { - return ASCIIToUTF16(DoubleToString(value)); -} - std::wstring DoubleToWString(double value) { return ASCIIToWide(DoubleToString(value)); } diff --git a/base/string_util.h b/base/string_util.h index fdad6be..26c42e5 100644 --- a/base/string_util.h +++ b/base/string_util.h @@ -189,7 +189,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(WCHAR_T_IS_UTF16) +#if defined(OS_WIN) # define WideToUTF16Hack # define UTF16ToWideHack #else @@ -385,21 +385,16 @@ 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, diff --git a/base/values.cc b/base/values.cc index 29a5896..cf98c0b 100644 --- a/base/values.cc +++ b/base/values.cc @@ -245,13 +245,13 @@ void DictionaryValue::Clear() { dictionary_.clear(); } -bool DictionaryValue::HasKey(const string16& key) const { +bool DictionaryValue::HasKey(const std::wstring& 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 string16& key, +void DictionaryValue::SetInCurrentNode(const std::wstring& 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 string16& key, dictionary_[key] = in_value; } -bool DictionaryValue::Set(const string16& path, Value* in_value) { +bool DictionaryValue::Set(const std::wstring& path, Value* in_value) { DCHECK(in_value); - string16 key = path; + std::wstring key = path; - size_t delimiter_position = path.find_first_of('.', 0); + size_t delimiter_position = path.find_first_of(L".", 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 string16& path, Value* in_value) { entry = static_cast<DictionaryValue*>(dictionary_[key]); } - string16 remaining_path = path.substr(delimiter_position + 1); + std::wstring remaining_path = path.substr(delimiter_position + 1); return entry->Set(remaining_path, in_value); } -bool DictionaryValue::SetBoolean(const string16& path, bool in_value) { +bool DictionaryValue::SetBoolean(const std::wstring& path, bool in_value) { return Set(path, CreateBooleanValue(in_value)); } -bool DictionaryValue::SetInteger(const string16& path, int in_value) { +bool DictionaryValue::SetInteger(const std::wstring& path, int in_value) { return Set(path, CreateIntegerValue(in_value)); } -bool DictionaryValue::SetReal(const string16& path, double in_value) { +bool DictionaryValue::SetReal(const std::wstring& path, double in_value) { return Set(path, CreateRealValue(in_value)); } -bool DictionaryValue::SetString(const string16& path, +bool DictionaryValue::SetString(const std::wstring& path, const std::string& 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::SetString(const std::wstring& path, + const std::wstring& in_value) { + return Set(path, CreateStringValue(in_value)); } -bool DictionaryValue::Get(const string16& path, Value** out_value) const { - string16 key = path; +bool DictionaryValue::Get(const std::wstring& path, Value** out_value) const { + std::wstring key = path; - size_t delimiter_position = path.find_first_of('.', 0); - if (delimiter_position != string16::npos) { + size_t delimiter_position = path.find_first_of(L".", 0); + if (delimiter_position != std::wstring::npos) { key = path.substr(0, delimiter_position); } @@ -325,7 +325,7 @@ bool DictionaryValue::Get(const string16& path, Value** out_value) const { return false; Value* entry = entry_iterator->second; - if (delimiter_position == string16::npos) { + if (delimiter_position == std::wstring::npos) { if (out_value) *out_value = entry; return true; @@ -339,7 +339,7 @@ bool DictionaryValue::Get(const string16& path, Value** out_value) const { return false; } -bool DictionaryValue::GetBoolean(const string16& path, +bool DictionaryValue::GetBoolean(const std::wstring& path, bool* bool_value) const { Value* value; if (!Get(path, &value)) @@ -348,7 +348,7 @@ bool DictionaryValue::GetBoolean(const string16& path, return value->GetAsBoolean(bool_value); } -bool DictionaryValue::GetInteger(const string16& path, +bool DictionaryValue::GetInteger(const std::wstring& path, int* out_value) const { Value* value; if (!Get(path, &value)) @@ -357,7 +357,7 @@ bool DictionaryValue::GetInteger(const string16& path, return value->GetAsInteger(out_value); } -bool DictionaryValue::GetReal(const string16& path, +bool DictionaryValue::GetReal(const std::wstring& path, double* out_value) const { Value* value; if (!Get(path, &value)) @@ -366,7 +366,7 @@ bool DictionaryValue::GetReal(const string16& path, return value->GetAsReal(out_value); } -bool DictionaryValue::GetString(const string16& path, +bool DictionaryValue::GetString(const std::wstring& path, std::string* out_value) const { Value* value; if (!Get(path, &value)) @@ -375,19 +375,16 @@ bool DictionaryValue::GetString(const string16& path, return value->GetAsString(out_value); } -bool DictionaryValue::GetString(const string16& path, - string16* out_value) const { +bool DictionaryValue::GetString(const std::wstring& path, + std::wstring* out_value) const { Value* value; if (!Get(path, &value)) return false; - std::wstring wout_value; - bool success = value->GetAsString(&wout_value); - out_value->assign(WideToUTF16Hack(wout_value)); - return success; + return value->GetAsString(out_value); } -bool DictionaryValue::GetBinary(const string16& path, +bool DictionaryValue::GetBinary(const std::wstring& path, BinaryValue** out_value) const { Value* value; bool result = Get(path, &value); @@ -400,7 +397,7 @@ bool DictionaryValue::GetBinary(const string16& path, return true; } -bool DictionaryValue::GetDictionary(const string16& path, +bool DictionaryValue::GetDictionary(const std::wstring& path, DictionaryValue** out_value) const { Value* value; bool result = Get(path, &value); @@ -413,7 +410,7 @@ bool DictionaryValue::GetDictionary(const string16& path, return true; } -bool DictionaryValue::GetList(const string16& path, +bool DictionaryValue::GetList(const std::wstring& path, ListValue** out_value) const { Value* value; bool result = Get(path, &value); @@ -426,11 +423,11 @@ bool DictionaryValue::GetList(const string16& path, return true; } -bool DictionaryValue::Remove(const string16& path, Value** out_value) { - string16 key = path; +bool DictionaryValue::Remove(const std::wstring& path, Value** out_value) { + std::wstring key = path; - size_t delimiter_position = path.find_first_of('.', 0); - if (delimiter_position != string16::npos) { + size_t delimiter_position = path.find_first_of(L".", 0); + if (delimiter_position != std::wstring::npos) { key = path.substr(0, delimiter_position); } @@ -439,7 +436,7 @@ bool DictionaryValue::Remove(const string16& path, Value** out_value) { return false; Value* entry = entry_iterator->second; - if (delimiter_position == string16::npos) { + if (delimiter_position == std::wstring::npos) { if (out_value) *out_value = entry; else @@ -654,3 +651,4 @@ bool ListValue::Equals(const Value* other) const { return true; } + diff --git a/base/values.h b/base/values.h index 54298d5..cad1311 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<string16, Value*> ValueMap; +typedef std::map<std::wstring, 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 string16& key) const; + bool HasKey(const std::wstring& 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 string16& path, Value* in_value); + bool Set(const std::wstring& 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 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); + 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); // 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 string16& path, Value** out_value) const; + bool Get(const std::wstring& 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 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, + 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, DictionaryValue** out_value) const; - bool GetList(const string16& path, ListValue** out_value) const; + bool GetList(const std::wstring& 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 string16& path, Value** out_value); + bool Remove(const std::wstring& 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 string16> { + : private std::iterator<std::input_iterator_tag, const std::wstring> { public: key_iterator(ValueMap::const_iterator itr) { itr_ = itr; } key_iterator operator++() { ++itr_; return *this; } - const string16& operator*() { return itr_->first; } + const std::wstring& 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 string16& key, Value* in_value); + void SetInCurrentNode(const std::wstring& key, Value* in_value); ValueMap dictionary_; }; diff --git a/base/values_unittest.cc b/base/values_unittest.cc index 63bd65c..dd2121f 100644 --- a/base/values_unittest.cc +++ b/base/values_unittest.cc @@ -6,7 +6,6 @@ #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 { @@ -15,51 +14,46 @@ class ValuesTest: public testing::Test { TEST(ValuesTest, Basic) { // Test basic dictionary getting/setting DictionaryValue settings; - string16 homepage = ASCIIToUTF16("http://google.com"); - ASSERT_FALSE(settings.GetString(ASCIIToUTF16("global.homepage"), &homepage)); - ASSERT_EQ(ASCIIToUTF16("http://google.com"), homepage); - - ASSERT_FALSE(settings.Get(ASCIIToUTF16("global"), NULL)); - ASSERT_TRUE(settings.Set(ASCIIToUTF16("global"), - Value::CreateBooleanValue(true))); - ASSERT_TRUE(settings.Get(ASCIIToUTF16("global"), NULL)); - ASSERT_TRUE(settings.SetString(ASCIIToUTF16("global.homepage"), - ASCIIToUTF16("http://scurvy.com"))); - ASSERT_TRUE(settings.Get(ASCIIToUTF16("global"), NULL)); - homepage = ASCIIToUTF16("http://google.com"); - ASSERT_TRUE(settings.GetString(ASCIIToUTF16("global.homepage"), &homepage)); - ASSERT_EQ(ASCIIToUTF16("http://scurvy.com"), homepage); + 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); // Test storing a dictionary in a list. ListValue* toolbar_bookmarks; ASSERT_FALSE( - settings.GetList(ASCIIToUTF16("global.toolbar.bookmarks"), - &toolbar_bookmarks)); + settings.GetList(L"global.toolbar.bookmarks", &toolbar_bookmarks)); toolbar_bookmarks = new ListValue; - settings.Set(ASCIIToUTF16("global.toolbar.bookmarks"), toolbar_bookmarks); + settings.Set(L"global.toolbar.bookmarks", toolbar_bookmarks); ASSERT_TRUE( - settings.GetList(ASCIIToUTF16("global.toolbar.bookmarks"), - &toolbar_bookmarks)); + settings.GetList(L"global.toolbar.bookmarks", &toolbar_bookmarks)); DictionaryValue* new_bookmark = new DictionaryValue; - new_bookmark->SetString(ASCIIToUTF16("name"), ASCIIToUTF16("Froogle")); - new_bookmark->SetString(ASCIIToUTF16("url"), - ASCIIToUTF16("http://froogle.com")); + new_bookmark->SetString(L"name", L"Froogle"); + new_bookmark->SetString(L"url", L"http://froogle.com"); toolbar_bookmarks->Append(new_bookmark); ListValue* bookmark_list; - ASSERT_TRUE(settings.GetList(ASCIIToUTF16("global.toolbar.bookmarks"), - &bookmark_list)); + ASSERT_TRUE(settings.GetList(L"global.toolbar.bookmarks", &bookmark_list)); DictionaryValue* bookmark; ASSERT_EQ(1U, bookmark_list->GetSize()); ASSERT_TRUE(bookmark_list->GetDictionary(0, &bookmark)); - string16 bookmark_name = ASCIIToUTF16("Unnamed"); - ASSERT_TRUE(bookmark->GetString(ASCIIToUTF16("name"), &bookmark_name)); - ASSERT_EQ(ASCIIToUTF16("Froogle"), bookmark_name); - string16 bookmark_url; - ASSERT_TRUE(bookmark->GetString(ASCIIToUTF16("url"), &bookmark_url)); - ASSERT_EQ(ASCIIToUTF16("http://froogle.com"), bookmark_url); + 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); } TEST(ValuesTest, List) { @@ -240,7 +234,7 @@ TEST(ValuesTest, ListRemoval) { } TEST(ValuesTest, DictionaryDeletion) { - string16 key = ASCIIToUTF16("test"); + std::wstring key = L"test"; bool deletion_flag = true; { @@ -268,7 +262,7 @@ TEST(ValuesTest, DictionaryDeletion) { } TEST(ValuesTest, DictionaryRemoval) { - string16 key = ASCIIToUTF16("test"); + std::wstring key = L"test"; bool deletion_flag = true; Value* removed_item = NULL; @@ -277,7 +271,7 @@ TEST(ValuesTest, DictionaryRemoval) { dict.Set(key, new DeletionTestValue(&deletion_flag)); EXPECT_FALSE(deletion_flag); EXPECT_TRUE(dict.HasKey(key)); - EXPECT_FALSE(dict.Remove(ASCIIToUTF16("absent key"), &removed_item)); + EXPECT_FALSE(dict.Remove(L"absent key", &removed_item)); EXPECT_TRUE(dict.Remove(key, &removed_item)); EXPECT_FALSE(dict.HasKey(key)); ASSERT_TRUE(removed_item); @@ -301,29 +295,29 @@ TEST(ValuesTest, DictionaryRemoval) { TEST(ValuesTest, DeepCopy) { DictionaryValue original_dict; Value* original_null = Value::CreateNullValue(); - original_dict.Set(ASCIIToUTF16("null"), original_null); + original_dict.Set(L"null", original_null); Value* original_bool = Value::CreateBooleanValue(true); - original_dict.Set(ASCIIToUTF16("bool"), original_bool); + original_dict.Set(L"bool", original_bool); Value* original_int = Value::CreateIntegerValue(42); - original_dict.Set(ASCIIToUTF16("int"), original_int); + original_dict.Set(L"int", original_int); Value* original_real = Value::CreateRealValue(3.14); - original_dict.Set(ASCIIToUTF16("real"), original_real); + original_dict.Set(L"real", original_real); Value* original_string = Value::CreateStringValue("hello"); - original_dict.Set(ASCIIToUTF16("string"), original_string); + original_dict.Set(L"string", original_string); Value* original_wstring = Value::CreateStringValue(L"peek-a-boo"); - original_dict.Set(ASCIIToUTF16("wstring"), original_wstring); + original_dict.Set(L"wstring", original_wstring); char* original_buffer = new char[42]; memset(original_buffer, '!', 42); BinaryValue* original_binary = Value::CreateBinaryValue(original_buffer, 42); - original_dict.Set(ASCIIToUTF16("binary"), original_binary); + original_dict.Set(L"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(ASCIIToUTF16("list"), original_list); + original_dict.Set(L"list", original_list); DictionaryValue* copy_dict = static_cast<DictionaryValue*>(original_dict.DeepCopy()); @@ -331,13 +325,13 @@ TEST(ValuesTest, DeepCopy) { ASSERT_NE(copy_dict, &original_dict); Value* copy_null = NULL; - ASSERT_TRUE(copy_dict->Get(ASCIIToUTF16("null"), ©_null)); + ASSERT_TRUE(copy_dict->Get(L"null", ©_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(ASCIIToUTF16("bool"), ©_bool)); + ASSERT_TRUE(copy_dict->Get(L"bool", ©_bool)); ASSERT_TRUE(copy_bool); ASSERT_NE(copy_bool, original_bool); ASSERT_TRUE(copy_bool->IsType(Value::TYPE_BOOLEAN)); @@ -346,7 +340,7 @@ TEST(ValuesTest, DeepCopy) { ASSERT_TRUE(copy_bool_value); Value* copy_int = NULL; - ASSERT_TRUE(copy_dict->Get(ASCIIToUTF16("int"), ©_int)); + ASSERT_TRUE(copy_dict->Get(L"int", ©_int)); ASSERT_TRUE(copy_int); ASSERT_NE(copy_int, original_int); ASSERT_TRUE(copy_int->IsType(Value::TYPE_INTEGER)); @@ -355,7 +349,7 @@ TEST(ValuesTest, DeepCopy) { ASSERT_EQ(42, copy_int_value); Value* copy_real = NULL; - ASSERT_TRUE(copy_dict->Get(ASCIIToUTF16("real"), ©_real)); + ASSERT_TRUE(copy_dict->Get(L"real", ©_real)); ASSERT_TRUE(copy_real); ASSERT_NE(copy_real, original_real); ASSERT_TRUE(copy_real->IsType(Value::TYPE_REAL)); @@ -364,7 +358,7 @@ TEST(ValuesTest, DeepCopy) { ASSERT_EQ(3.14, copy_real_value); Value* copy_string = NULL; - ASSERT_TRUE(copy_dict->Get(ASCIIToUTF16("string"), ©_string)); + ASSERT_TRUE(copy_dict->Get(L"string", ©_string)); ASSERT_TRUE(copy_string); ASSERT_NE(copy_string, original_string); ASSERT_TRUE(copy_string->IsType(Value::TYPE_STRING)); @@ -376,7 +370,7 @@ TEST(ValuesTest, DeepCopy) { ASSERT_EQ(std::wstring(L"hello"), copy_wstring_value); Value* copy_wstring = NULL; - ASSERT_TRUE(copy_dict->Get(ASCIIToUTF16("wstring"), ©_wstring)); + ASSERT_TRUE(copy_dict->Get(L"wstring", ©_wstring)); ASSERT_TRUE(copy_wstring); ASSERT_NE(copy_wstring, original_wstring); ASSERT_TRUE(copy_wstring->IsType(Value::TYPE_STRING)); @@ -386,7 +380,7 @@ TEST(ValuesTest, DeepCopy) { ASSERT_EQ(std::wstring(L"peek-a-boo"), copy_wstring_value); Value* copy_binary = NULL; - ASSERT_TRUE(copy_dict->Get(ASCIIToUTF16("binary"), ©_binary)); + ASSERT_TRUE(copy_dict->Get(L"binary", ©_binary)); ASSERT_TRUE(copy_binary); ASSERT_NE(copy_binary, original_binary); ASSERT_TRUE(copy_binary->IsType(Value::TYPE_BINARY)); @@ -399,7 +393,7 @@ TEST(ValuesTest, DeepCopy) { original_binary->GetSize())); Value* copy_value = NULL; - ASSERT_TRUE(copy_dict->Get(ASCIIToUTF16("list"), ©_value)); + ASSERT_TRUE(copy_dict->Get(L"list", ©_value)); ASSERT_TRUE(copy_value); ASSERT_NE(copy_value, original_list); ASSERT_TRUE(copy_value->IsType(Value::TYPE_LIST)); @@ -438,12 +432,12 @@ TEST(ValuesTest, Equals) { delete boolean; DictionaryValue dv; - dv.SetBoolean(ASCIIToUTF16("a"), false); - dv.SetInteger(ASCIIToUTF16("b"), 2); - dv.SetReal(ASCIIToUTF16("c"), 2.5); - dv.SetString(ASCIIToUTF16("d1"), "string"); - dv.SetString(ASCIIToUTF16("d2"), ASCIIToUTF16("string")); - dv.Set(ASCIIToUTF16("e"), Value::CreateNullValue()); + 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()); DictionaryValue* copy = static_cast<DictionaryValue*>(dv.DeepCopy()); EXPECT_TRUE(dv.Equals(copy)); @@ -451,13 +445,14 @@ TEST(ValuesTest, Equals) { ListValue* list = new ListValue; list->Append(Value::CreateNullValue()); list->Append(new DictionaryValue); - dv.Set(ASCIIToUTF16("f"), list); + dv.Set(L"f", list); EXPECT_FALSE(dv.Equals(copy)); - copy->Set(ASCIIToUTF16("f"), list->DeepCopy()); + copy->Set(L"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 69965f9..23d4407c 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -302,8 +302,7 @@ bool SearchProvider::ParseSuggestResults(Value* root_val) { DictionaryValue* dict_val = static_cast<DictionaryValue*>(optional_val); // Parse Google Suggest specific type extension. - static const string16 kGoogleSuggestType( - ASCIIToUTF16("google:suggesttype")); + static const std::wstring kGoogleSuggestType(L"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 873ef32..dd39fc8 100644 --- a/chrome/browser/bookmarks/bookmark_codec.cc +++ b/chrome/browser/bookmarks/bookmark_codec.cc @@ -36,14 +36,12 @@ Value* BookmarkCodec::Encode(BookmarkModel* model) { Value* BookmarkCodec::Encode(BookmarkNode* bookmark_bar_node, BookmarkNode* other_folder_node) { DictionaryValue* roots = new DictionaryValue(); - roots->Set(WideToUTF16Hack(kRootFolderNameKey), - EncodeNode(bookmark_bar_node)); - roots->Set(WideToUTF16Hack(kOtherBookmarFolderNameKey), - EncodeNode(other_folder_node)); + roots->Set(kRootFolderNameKey, EncodeNode(bookmark_bar_node)); + roots->Set(kOtherBookmarFolderNameKey, EncodeNode(other_folder_node)); DictionaryValue* main = new DictionaryValue(); - main->SetInteger(WideToUTF16Hack(kVersionKey), kCurrentVersion); - main->Set(WideToUTF16Hack(kRootsKey), roots); + main->SetInteger(kVersionKey, kCurrentVersion); + main->Set(kRootsKey, roots); return main; } @@ -54,12 +52,11 @@ bool BookmarkCodec::Decode(BookmarkModel* model, const Value& value) { const DictionaryValue& d_value = static_cast<const DictionaryValue&>(value); int version; - if (!d_value.GetInteger(WideToUTF16Hack(kVersionKey), &version) || - version != kCurrentVersion) + if (!d_value.GetInteger(kVersionKey, &version) || version != kCurrentVersion) return false; // Unknown version. Value* roots; - if (!d_value.Get(WideToUTF16Hack(kRootsKey), &roots)) + if (!d_value.Get(kRootsKey, &roots)) return false; // No roots. if (roots->GetType() != Value::TYPE_DICTIONARY) @@ -68,14 +65,11 @@ 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(WideToUTF16Hack(kRootFolderNameKey), - &root_folder_value) || + if (!roots_d_value->Get(kRootFolderNameKey, &root_folder_value) || root_folder_value->GetType() != Value::TYPE_DICTIONARY || - !roots_d_value->Get(WideToUTF16Hack(kOtherBookmarFolderNameKey), - &other_folder_value) || - other_folder_value->GetType() != Value::TYPE_DICTIONARY) { + !roots_d_value->Get(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()); @@ -95,22 +89,21 @@ bool BookmarkCodec::Decode(BookmarkModel* model, const Value& value) { Value* BookmarkCodec::EncodeNode(BookmarkNode* node) { DictionaryValue* value = new DictionaryValue(); - value->SetString(WideToUTF16Hack(kNameKey), - WideToUTF16Hack(node->GetTitle())); - value->SetString(WideToUTF16Hack(kDateAddedKey), - Int64ToString16(node->date_added().ToInternalValue())); + value->SetString(kNameKey, node->GetTitle()); + value->SetString(kDateAddedKey, + Int64ToWString(node->date_added().ToInternalValue())); if (node->GetType() == history::StarredEntry::URL) { - value->SetString(WideToUTF16Hack(kTypeKey), WideToUTF16Hack(kTypeURL)); - value->SetString(WideToUTF16Hack(kURLKey), - UTF8ToUTF16(node->GetURL().possibly_invalid_spec())); + value->SetString(kTypeKey, kTypeURL); + value->SetString(kURLKey, + UTF8ToWide(node->GetURL().possibly_invalid_spec())); } else { - value->SetString(WideToUTF16Hack(kTypeKey), WideToUTF16Hack(kTypeFolder)); - value->SetString(WideToUTF16Hack(kDateModifiedKey), - Int64ToString16(node->date_group_modified(). + value->SetString(kTypeKey, kTypeFolder); + value->SetString(kDateModifiedKey, + Int64ToWString(node->date_group_modified(). ToInternalValue())); ListValue* child_values = new ListValue(); - value->Set(WideToUTF16Hack(kChildrenKey), child_values); + value->Set(kChildrenKey, child_values); for (int i = 0; i < node->GetChildCount(); ++i) child_values->Append(EncodeNode(node->GetChild(i))); } @@ -140,42 +133,40 @@ bool BookmarkCodec::DecodeNode(BookmarkModel* model, const DictionaryValue& value, BookmarkNode* parent, BookmarkNode* node) { - string16 title; - if (!value.GetString(WideToUTF16Hack(kNameKey), &title)) + std::wstring title; + if (!value.GetString(kNameKey, &title)) return false; // TODO(sky): this should be more flexible. Don't hoark if we can't parse it // all. - string16 date_added_string; - if (!value.GetString(WideToUTF16Hack(kDateAddedKey), &date_added_string)) + std::wstring date_added_string; + if (!value.GetString(kDateAddedKey, &date_added_string)) return false; - string16 type_string; - if (!value.GetString(WideToUTF16Hack(kTypeKey), &type_string)) + std::wstring type_string; + if (!value.GetString(kTypeKey, &type_string)) return false; - if (type_string != WideToUTF16Hack(kTypeURL) && - type_string != WideToUTF16Hack(kTypeFolder)) + if (type_string != kTypeURL && type_string != kTypeFolder) return false; // Unknown type. - if (type_string == WideToUTF16Hack(kTypeURL)) { - string16 url_string; - if (!value.GetString(WideToUTF16Hack(kURLKey), &url_string)) + if (type_string == kTypeURL) { + std::wstring url_string; + if (!value.GetString(kURLKey, &url_string)) return false; // TODO(sky): this should ignore the node if not a valid URL. if (!node) - node = new BookmarkNode(model, GURL(UTF16ToUTF8(url_string))); + node = new BookmarkNode(model, GURL(WideToUTF8(url_string))); if (parent) parent->Add(parent->GetChildCount(), node); node->type_ = history::StarredEntry::URL; } else { - string16 last_modified_date; - if (!value.GetString(WideToUTF16Hack(kDateModifiedKey), - &last_modified_date)) + std::wstring last_modified_date; + if (!value.GetString(kDateModifiedKey, &last_modified_date)) return false; Value* child_values; - if (!value.Get(WideToUTF16Hack(kChildrenKey), &child_values)) + if (!value.Get(kChildrenKey, &child_values)) return false; if (child_values->GetType() != Value::TYPE_LIST) @@ -184,8 +175,8 @@ bool BookmarkCodec::DecodeNode(BookmarkModel* model, if (!node) node = new BookmarkNode(model, GURL()); node->type_ = history::StarredEntry::USER_GROUP; - node->date_group_modified_ = - Time::FromInternalValue(StringToInt64(last_modified_date)); + node->date_group_modified_ = Time::FromInternalValue( + StringToInt64(WideToUTF16Hack(last_modified_date))); if (parent) parent->Add(parent->GetChildCount(), node); @@ -194,8 +185,8 @@ bool BookmarkCodec::DecodeNode(BookmarkModel* model, return false; } - node->SetTitle(UTF16ToWideHack(title)); - node->date_added_ = - Time::FromInternalValue(StringToInt64(date_added_string)); + node->SetTitle(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 4209ab9..5ec7ca0 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( - WideToUTF16Hack(BookmarkCodec::kRootsKey), &roots) || + BookmarkCodec::kRootsKey, &roots) || roots->GetType() != Value::TYPE_DICTIONARY) { NOTREACHED(); return; @@ -94,12 +94,11 @@ 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(WideToUTF16Hack(BookmarkCodec::kRootFolderNameKey), + if (!roots_d_value->Get(BookmarkCodec::kRootFolderNameKey, &root_folder_value) || root_folder_value->GetType() != Value::TYPE_DICTIONARY || - !roots_d_value->Get( - WideToUTF16Hack(BookmarkCodec::kOtherBookmarFolderNameKey), - &other_folder_value) || + !roots_d_value->Get(BookmarkCodec::kOtherBookmarFolderNameKey, + &other_folder_value) || other_folder_value->GetType() != Value::TYPE_DICTIONARY) { NOTREACHED(); return; // Invalid type for root folder and/or other folder. @@ -204,32 +203,29 @@ 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) { - 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))) { + 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)) { NOTREACHED(); return false; } - if (type_string == WideToUTF16Hack(BookmarkCodec::kTypeURL)) { - string16 url_string; - if (!value.GetString(WideToUTF16Hack(BookmarkCodec::kURLKey), - &url_string)) { + if (type_string == BookmarkCodec::kTypeURL) { + std::wstring url_string; + if (!value.GetString(BookmarkCodec::kURLKey, &url_string)) { NOTREACHED(); return false; } if (!WriteIndent() || !Write(kBookmarkStart) || - !Write(UTF16ToWideHack(url_string), ATTRIBUTE_VALUE) || + !Write(url_string, ATTRIBUTE_VALUE) || !Write(kAddDate) || - !WriteTime(UTF16ToWideHack(date_added_string)) || + !WriteTime(date_added_string) || !Write(kBookmarkAttributeEnd) || - !Write(UTF16ToWideHack(title), CONTENT) || + !Write(title, CONTENT) || !Write(kBookmarkEnd) || !Write(kNewline)) { return false; @@ -238,12 +234,11 @@ class Writer : public Task { } // Folder. - string16 last_modified_date; + std::wstring last_modified_date; Value* child_values; - if (!value.GetString(WideToUTF16Hack(BookmarkCodec::kDateModifiedKey), + if (!value.GetString(BookmarkCodec::kDateModifiedKey, &last_modified_date) || - !value.Get(WideToUTF16Hack(BookmarkCodec::kChildrenKey), - &child_values) || + !value.Get(BookmarkCodec::kChildrenKey, &child_values) || child_values->GetType() != Value::TYPE_LIST) { NOTREACHED(); return false; @@ -254,19 +249,19 @@ class Writer : public Task { // bar folder. if (!WriteIndent() || !Write(kFolderStart) || - !WriteTime(UTF16ToWideHack(date_added_string)) || + !WriteTime(date_added_string) || !Write(kLastModified) || - !WriteTime(UTF16ToWideHack(last_modified_date))) { + !WriteTime(last_modified_date)) { return false; } if (folder_type == history::StarredEntry::BOOKMARK_BAR) { if (!Write(kBookmarkBar)) return false; - title = ASCIIToUTF16("Bookmark Bar"); + title = L"Bookmark Bar"; } else if (!Write(kFolderAttributeEnd)) { return false; } - if (!Write(UTF16ToWideHack(title), CONTENT) || + if (!Write(title, CONTENT) || !Write(kFolderEnd) || !Write(kNewline) || !WriteIndent() || diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 1723198f..7f25a60 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -253,9 +253,8 @@ bool BrowserAboutHandler::SupportsURL(GURL* url) { std::string BrowserAboutHandler::AboutVersion() { // Strings used in the JsTemplate file. DictionaryValue localized_strings; - localized_strings.SetString( - ASCIIToUTF16("title"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_TITLE))); + localized_strings.SetString(L"title", + l10n_util::GetString(IDS_ABOUT_VERSION_TITLE)); scoped_ptr<FileVersionInfo> version_info( FileVersionInfo::CreateFileVersionInfoForCurrentModule()); if (version_info == NULL) { @@ -273,36 +272,26 @@ std::string BrowserAboutHandler::AboutVersion() { std::wstring js_engine = L"JavaScriptCore"; #endif - localized_strings.SetString( - ASCIIToUTF16("name"), - WideToUTF16Hack(l10n_util::GetString(IDS_PRODUCT_NAME))); - localized_strings.SetString(ASCIIToUTF16("version"), - WideToUTF16Hack(version_info->file_version())); - localized_strings.SetString(ASCIIToUTF16("js_engine"), - WideToUTF16Hack(js_engine)); - localized_strings.SetString(ASCIIToUTF16("js_version"), - WideToUTF16Hack(js_version)); - localized_strings.SetString(ASCIIToUTF16("webkit_version"), - WideToUTF16Hack(webkit_version)); - localized_strings.SetString( - ASCIIToUTF16("company"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_COMPANY_NAME))); - localized_strings.SetString( - ASCIIToUTF16("copyright"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT))); - localized_strings.SetString(ASCIIToUTF16("cl"), - WideToUTF16Hack(version_info->last_change())); + 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()); if (version_info->is_official_build()) { - localized_strings.SetString( - ASCIIToUTF16("official"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_OFFICIAL))); + localized_strings.SetString(L"official", + l10n_util::GetString(IDS_ABOUT_VERSION_OFFICIAL)); } else { - localized_strings.SetString( - ASCIIToUTF16("official"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_UNOFFICIAL))); + localized_strings.SetString(L"official", + l10n_util::GetString(IDS_ABOUT_VERSION_UNOFFICIAL)); } - localized_strings.SetString(ASCIIToUTF16("useragent"), - UTF8ToUTF16(webkit_glue::GetUserAgent(GURL()))); + localized_strings.SetString(L"useragent", + UTF8ToWide(webkit_glue::GetUserAgent(GURL()))); static const StringPiece version_html( ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -343,37 +332,26 @@ std::string BrowserAboutHandler::AboutTerms() { std::string BrowserAboutHandler::AboutPlugins() { // Strings used in the JsTemplate file. DictionaryValue localized_strings; - localized_strings.SetString( - ASCIIToUTF16("title"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_TITLE))); - localized_strings.SetString( - ASCIIToUTF16("headingPlugs"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_PLUGS))); - localized_strings.SetString( - ASCIIToUTF16("headingNoPlugs"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_NOPLUGS))); - localized_strings.SetString( - ASCIIToUTF16("filename"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_FILENAME_LABEL))); - localized_strings.SetString( - ASCIIToUTF16("mimetype"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_MIMETYPE_LABEL))); - localized_strings.SetString( - ASCIIToUTF16("description"), - WideToUTF16Hack( - l10n_util::GetString(IDS_ABOUT_PLUGINS_DESCRIPTION_LABEL))); - localized_strings.SetString( - ASCIIToUTF16("suffixes"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_SUFFIX_LABEL))); - localized_strings.SetString( - ASCIIToUTF16("enabled"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_LABEL))); - localized_strings.SetString( - ASCIIToUTF16("enabled_yes"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_YES))); - localized_strings.SetString( - ASCIIToUTF16("enabled_no"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_NO))); + 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)); static const StringPiece plugins_html( ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -426,15 +404,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(ASCIIToUTF16("counters"), &counters)) { + if (!root.GetList(L"counters", &counters)) { counters = new ListValue(); - root.Set(ASCIIToUTF16("counters"), counters); + root.Set(L"counters", counters); } ListValue* timers; - if (!root.GetList(ASCIIToUTF16("timers"), &timers)) { + if (!root.GetList(L"timers", &timers)) { timers = new ListValue(); - root.Set(ASCIIToUTF16("timers"), timers); + root.Set(L"timers", timers); } // NOTE: Counters start at index 1. @@ -458,9 +436,9 @@ std::string BrowserAboutHandler::AboutStats() { scan_index < counters->GetSize(); scan_index++) { DictionaryValue* dictionary; if (counters->GetDictionary(scan_index, &dictionary)) { - string16 scan_name; - if (dictionary->GetString(ASCIIToUTF16("name"), &scan_name) && - UTF16ToUTF8(scan_name) == name) { + std::wstring scan_name; + if (dictionary->GetString(L"name", &scan_name) && + WideToASCII(scan_name) == name) { counter = dictionary; } } else { @@ -470,7 +448,7 @@ std::string BrowserAboutHandler::AboutStats() { if (counter == NULL) { counter = new DictionaryValue(); - counter->SetString(ASCIIToUTF16("name"), UTF8ToUTF16(name)); + counter->SetString(L"name", ASCIIToWide(name)); counters->Append(counter); } @@ -480,11 +458,11 @@ std::string BrowserAboutHandler::AboutStats() { int new_value = table->GetRowValue(index); int prior_value = 0; int delta = 0; - if (counter->GetInteger(ASCIIToUTF16("value"), &prior_value)) { + if (counter->GetInteger(L"value", &prior_value)) { delta = new_value - prior_value; } - counter->SetInteger(ASCIIToUTF16("value"), new_value); - counter->SetInteger(ASCIIToUTF16("delta"), delta); + counter->SetInteger(L"value", new_value); + counter->SetInteger(L"delta", delta); } break; case 'm': @@ -495,7 +473,7 @@ std::string BrowserAboutHandler::AboutStats() { case 't': { int time = table->GetRowValue(index); - counter->SetInteger(ASCIIToUTF16("time"), time); + counter->SetInteger(L"time", time); // Store this on the timers list as well. timers->Append(counter); @@ -541,21 +519,16 @@ void AboutMemoryHandler::BindProcessMetrics(DictionaryValue* data, DCHECK(data && info); // Bind metrics to dictionary. - data->SetInteger(ASCIIToUTF16("ws_priv"), - static_cast<int>(info->working_set.priv)); - data->SetInteger(ASCIIToUTF16("ws_shareable"), + data->SetInteger(L"ws_priv", static_cast<int>(info->working_set.priv)); + data->SetInteger(L"ws_shareable", static_cast<int>(info->working_set.shareable)); - data->SetInteger(ASCIIToUTF16("ws_shared"), - static_cast<int>(info->working_set.shared)); - data->SetInteger(ASCIIToUTF16("comm_priv"), - static_cast<int>(info->committed.priv)); - data->SetInteger(ASCIIToUTF16("comm_map"), - static_cast<int>(info->committed.mapped)); - data->SetInteger(ASCIIToUTF16("comm_image"), - static_cast<int>(info->committed.image)); - data->SetInteger(ASCIIToUTF16("pid"), info->pid); - data->SetString(ASCIIToUTF16("version"), WideToUTF16Hack(info->version)); - data->SetInteger(ASCIIToUTF16("processes"), info->num_processes); + 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); } // Helper for AboutMemory to append memory usage information for all @@ -572,9 +545,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(ASCIIToUTF16("child_name"), WideToUTF16Hack(child_label)); + child->SetString(L"child_name", child_label); ListValue* titles = new ListValue(); - child->Set(ASCIIToUTF16("titles"), titles); + child->Set(L"titles", titles); for (size_t i = 0; i < info->titles.size(); ++i) titles->Append(new StringValue(info->titles[i])); } @@ -584,7 +557,7 @@ void AboutMemoryHandler::OnDetailsAvailable() { // the root of the JSON hierarchy for about:memory jstemplate DictionaryValue root; ListValue* browsers = new ListValue(); - root.Set(ASCIIToUTF16("browsers"), browsers); + root.Set(L"browsers", browsers); ProcessData* browser_processes = processes(); @@ -615,8 +588,7 @@ void AboutMemoryHandler::OnDetailsAvailable() { } DictionaryValue* browser_data = new DictionaryValue(); browsers->Append(browser_data); - browser_data->SetString(ASCIIToUTF16("name"), - WideToUTF16Hack(browser_processes[index].name)); + browser_data->SetString(L"name", browser_processes[index].name); BindProcessMetrics(browser_data, &aggregate); @@ -636,9 +608,9 @@ void AboutMemoryHandler::OnDetailsAvailable() { // Set the browser & renderer detailed process data. DictionaryValue* browser_data = new DictionaryValue(); - root.Set(ASCIIToUTF16("browzr_data"), browser_data); + root.Set(L"browzr_data", browser_data); ListValue* child_data = new ListValue(); - root.Set(ASCIIToUTF16("child_data"), child_data); + root.Set(L"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 a3d8dba..d4ec343 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -113,10 +113,8 @@ void SetOverrideHomePage(const CommandLine& command_line, std::wstring new_homepage = URLFixerUpper::FixupRelativeFile( browser_directory, command_line.GetSwitchValue(switches::kHomePage)); - prefs->transient()->SetString(WideToUTF16Hack(prefs::kHomePage), - WideToUTF16Hack(new_homepage)); - prefs->transient()->SetBoolean( - WideToUTF16Hack(prefs::kHomePageIsNewTabPage), false); + prefs->transient()->SetString(prefs::kHomePage, new_homepage); + prefs->transient()->SetBoolean(prefs::kHomePageIsNewTabPage, false); } } @@ -476,8 +474,7 @@ bool BrowserInit::ProcessCommandLine( SetOverrideHomePage(command_line, profile->GetPrefs()); if (command_line.HasSwitch(switches::kBrowserStartRenderersManually)) - prefs->transient()->SetBoolean( - WideToUTF16Hack(prefs::kStartRenderersManually), true); + prefs->transient()->SetBoolean(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 07c87fc..fc4513c 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -144,22 +144,16 @@ void HandleErrorTestParameters(const CommandLine& command_line) { struct LazyDirectoryListerCacher { LazyDirectoryListerCacher() { DictionaryValue value; - value.SetString( - ASCIIToUTF16("header"), - WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_HEADER))); - value.SetString( - ASCIIToUTF16("parentDirText"), - WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_PARENT))); - value.SetString( - ASCIIToUTF16("headerName"), - WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_NAME))); - value.SetString( - ASCIIToUTF16("headerSize"), - WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_SIZE))); - value.SetString( - ASCIIToUTF16("headerDateModified"), - WideToUTF16Hack( - l10n_util::GetString(IDS_DIRECTORY_LISTING_DATE_MODIFIED))); + 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)); html_data = jstemplate_builder::GetTemplateHtml( ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_DIR_HEADER_HTML), @@ -514,8 +508,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( - WideToUTF16Hack(prefs::kMetricsReportingEnabled), false); + local_state->transient()->SetBoolean(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 23ac2c3..b0efcad 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(ASCIIToUTF16("url"), WideToUTF16Hack(wstring_url)); + dictionary->SetString(L"url", 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(ASCIIToUTF16("title"), WideToUTF16Hack(title_to_set)); + dictionary->SetString(L"title", 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 2423458..9bc5d61 100644 --- a/chrome/browser/dom_ui/history_ui.cc +++ b/chrome/browser/dom_ui/history_ui.cc @@ -49,34 +49,32 @@ HistoryUIHTMLSource::HistoryUIHTMLSource() void HistoryUIHTMLSource::StartDataRequest(const std::string& path, int request_id) { DictionaryValue localized_strings; - localized_strings.SetString(ASCIIToUTF16("title"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_TITLE))); - localized_strings.SetString(ASCIIToUTF16("loading"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_LOADING))); - localized_strings.SetString(ASCIIToUTF16("newest"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NEWEST))); - localized_strings.SetString(ASCIIToUTF16("newer"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NEWER))); - localized_strings.SetString(ASCIIToUTF16("older"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_OLDER))); - localized_strings.SetString(ASCIIToUTF16("searchresultsfor"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_SEARCHRESULTSFOR))); - localized_strings.SetString(ASCIIToUTF16("history"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_BROWSERESULTS))); - localized_strings.SetString(ASCIIToUTF16("cont"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_CONTINUED))); - localized_strings.SetString(ASCIIToUTF16("searchbutton"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_SEARCH_BUTTON))); - localized_strings.SetString(ASCIIToUTF16("noresults"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NO_RESULTS))); - localized_strings.SetString(ASCIIToUTF16("noitems"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NO_ITEMS))); - localized_strings.SetString(ASCIIToUTF16("deleteday"), - WideToUTF16Hack( - l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_LINK))); - localized_strings.SetString(ASCIIToUTF16("deletedaywarning"), - WideToUTF16Hack( - l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING))); + 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)); static const StringPiece history_html( ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -228,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(ASCIIToUTF16("time"), + page_value->SetInteger(L"time", static_cast<int>(page.visit_time().ToTimeT())); // Until we get some JS i18n infrastructure, we also need to @@ -248,19 +246,15 @@ void BrowsingHistoryHandler::QueryComplete( IDS_HISTORY_DATE_WITH_RELATIVE_TIME, date_str, base::TimeFormatFriendlyDate(page.visit_time())); } - page_value->SetString(ASCIIToUTF16("dateRelativeDay"), - WideToUTF16Hack(date_str)); - page_value->SetString( - ASCIIToUTF16("dateTimeOfDay"), - WideToUTF16Hack(base::TimeFormatTimeOfDay(page.visit_time()))); + page_value->SetString(L"dateRelativeDay", date_str); + page_value->SetString(L"dateTimeOfDay", + base::TimeFormatTimeOfDay(page.visit_time())); } else { - page_value->SetString( - ASCIIToUTF16("dateShort"), - WideToUTF16Hack(base::TimeFormatShortDate(page.visit_time()))); - page_value->SetString( - ASCIIToUTF16("snippet"), WideToUTF16Hack(page.snippet().text())); + page_value->SetString(L"dateShort", + base::TimeFormatShortDate(page.visit_time())); + page_value->SetString(L"snippet", page.snippet().text()); } - page_value->SetBoolean(ASCIIToUTF16("starred"), + page_value->SetBoolean(L"starred", dom_ui_->get_profile()->GetBookmarkModel()->IsBookmarked(page.url())); results_value.Append(page_value); } diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc index 1195cc9..afb7baa 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) { - string16 string_url = UTF8ToUTF16(gurl.spec()); - dictionary->SetString(ASCIIToUTF16("url"), string_url); + std::wstring wstring_url = UTF8ToWide(gurl.spec()); + dictionary->SetString(L"url", wstring_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 = UTF16ToWideHack(string_url); + title_to_set = wstring_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(ASCIIToUTF16("title"), WideToUTF16Hack(title_to_set)); - dictionary->SetString(ASCIIToUTF16("direction"), WideToUTF16Hack(direction)); + dictionary->SetString(L"title", title_to_set); + dictionary->SetString(L"direction", direction); } } // end anonymous namespace @@ -208,43 +208,35 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path, profile_name); } DictionaryValue localized_strings; - localized_strings.SetString(ASCIIToUTF16("title"), WideToUTF16Hack(title)); - localized_strings.SetString(ASCIIToUTF16("mostvisited"), - WideToUTF16Hack(most_visited)); - localized_strings.SetString(ASCIIToUTF16("searches"), - WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_SEARCHES))); - localized_strings.SetString(ASCIIToUTF16("bookmarks"), - WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_BOOKMARKS))); - localized_strings.SetString(ASCIIToUTF16("showhistory"), - WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_HISTORY_SHOW))); - localized_strings.SetString(ASCIIToUTF16("searchhistory"), - WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_HISTORY_SEARCH))); - localized_strings.SetString(ASCIIToUTF16("recentlyclosed"), - WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED))); - localized_strings.SetString( - ASCIIToUTF16("mostvisitedintro"), - WideToUTF16Hack(l10n_util::GetStringF( - IDS_NEW_TAB_MOST_VISITED_INTRO, - l10n_util::GetString(IDS_WELCOME_PAGE_URL)))); - localized_strings.SetString( - ASCIIToUTF16("closedwindow"), - WideToUTF16Hack( - l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW))); - - localized_strings.SetString( - ASCIIToUTF16("textdirection"), - WideToUTF16Hack( - (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - kRTLHtmlTextDirection : kDefaultHtmlTextDirection)); + 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); // Let the tab know whether it's the first tab being viewed. - localized_strings.SetString(ASCIIToUTF16("firstview"), - first_view_ ? ASCIIToUTF16("true") : string16()); + localized_strings.SetString(L"firstview", + first_view_ ? L"true" : std::wstring()); first_view_ = false; #ifdef CHROME_PERSONALIZATION - localized_strings.SetString(ASCIIToUTF16("p13nsrc"), - Personalization::GetNewTabSource()); + localized_strings.SetString(L"p13nsrc", Personalization::GetNewTabSource()); #endif static const StringPiece new_tab_html( @@ -271,19 +263,15 @@ IncognitoTabHTMLSource::IncognitoTabHTMLSource() void IncognitoTabHTMLSource::StartDataRequest(const std::string& path, int request_id) { DictionaryValue localized_strings; - localized_strings.SetString(ASCIIToUTF16("title"), - WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_TITLE))); - localized_strings.SetString( - ASCIIToUTF16("content"), - WideToUTF16Hack(l10n_util::GetStringF( - IDS_NEW_TAB_OTR_MESSAGE, - l10n_util::GetString(IDS_LEARN_MORE_INCOGNITO_URL)))); - - localized_strings.SetString( - ASCIIToUTF16("textdirection"), - WideToUTF16Hack( - (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - kRTLHtmlTextDirection : kDefaultHtmlTextDirection)); + 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); static const StringPiece incognito_tab_html( ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -493,15 +481,12 @@ void TemplateURLHandler::OnTemplateURLModelChanged() { if (!urlref) continue; DictionaryValue* entry_value = new DictionaryValue; - entry_value->SetString(ASCIIToUTF16("short_name"), - WideToUTF16Hack(urls[i]->short_name())); - entry_value->SetString(ASCIIToUTF16("keyword"), - WideToUTF16Hack(urls[i]->keyword())); + entry_value->SetString(L"short_name", urls[i]->short_name()); + entry_value->SetString(L"keyword", urls[i]->keyword()); const GURL& url = urls[i]->GetFavIconURL(); if (url.is_valid()) - entry_value->SetString(ASCIIToUTF16("favIconURL"), - UTF8ToUTF16(url.spec())); + entry_value->SetString(L"favIconURL", UTF8ToWide(url.spec())); urls_value.Append(entry_value); } @@ -660,7 +645,7 @@ void RecentlyClosedTabsHandler::TabRestoreServiceChanged( (entry->type == TabRestoreService::WINDOW && WindowToValue(*static_cast<TabRestoreService::Window*>(entry), value))) { - value->SetInteger(ASCIIToUTF16("sessionId"), entry->id); + value->SetInteger(L"sessionId", entry->id); list_value.Append(value); added_count++; } else { @@ -688,7 +673,7 @@ bool RecentlyClosedTabsHandler::TabToValue( SetURLTitleAndDirection(dictionary, current_navigation.title(), current_navigation.url()); - dictionary->SetString(ASCIIToUTF16("type"), ASCIIToUTF16("tab")); + dictionary->SetString(L"type", L"tab"); return true; } @@ -713,8 +698,8 @@ bool RecentlyClosedTabsHandler::WindowToValue( return false; } - dictionary->SetString(ASCIIToUTF16("type"), ASCIIToUTF16("window")); - dictionary->Set(ASCIIToUTF16("tabs"), tab_values); + dictionary->SetString(L"type", L"window"); + dictionary->Set(L"tabs", tab_values); return true; } diff --git a/chrome/browser/extensions/extension.cc b/chrome/browser/extensions/extension.cc index 1db97ceb..918268f 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(WideToUTF16Hack(kFormatVersionKey), &format_version) || + if (!source.GetInteger(kFormatVersionKey, &format_version) || static_cast<uint32>(format_version) != kExpectedFormatVersion) { *error = kInvalidFormatVersionError; return false; } // Initialize id. - if (!source.GetString(WideToUTF16Hack(kIdKey), &id_)) { + if (!source.GetString(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(WideToUTF16Hack(kVersionKey), &version_str)) { + if (!source.GetString(kVersionKey, &version_str)) { *error = kInvalidVersionError; return false; } @@ -204,14 +204,14 @@ bool Extension::InitFromValue(const DictionaryValue& source, } // Initialize name. - if (!source.GetString(WideToUTF16Hack(kNameKey), &name_)) { + if (!source.GetString(kNameKey, &name_)) { *error = kInvalidNameError; return false; } // Initialize description (optional). - if (source.HasKey(WideToUTF16Hack(kDescriptionKey))) { - if (!source.GetString(WideToUTF16Hack(kDescriptionKey), &description_)) { + if (source.HasKey(kDescriptionKey)) { + if (!source.GetString(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(WideToUTF16Hack(kZipHashKey))) { - if (!source.GetString(WideToUTF16Hack(kZipHashKey), &zip_hash_)) { + if (source.HasKey(kZipHashKey)) { + if (!source.GetString(kZipHashKey, &zip_hash_)) { *error = kInvalidZipHashError; return false; } } // Initialize plugins dir (optional). - if (source.HasKey(WideToUTF16Hack(kPluginsDirKey))) { + if (source.HasKey(kPluginsDirKey)) { std::string plugins_dir; - if (!source.GetString(WideToUTF16Hack(kPluginsDirKey), &plugins_dir)) { + if (!source.GetString(kPluginsDirKey, &plugins_dir)) { *error = kInvalidPluginsDirError; return false; } @@ -238,9 +238,9 @@ bool Extension::InitFromValue(const DictionaryValue& source, } // Initialize content scripts (optional). - if (source.HasKey(WideToUTF16Hack(kContentScriptsKey))) { + if (source.HasKey(kContentScriptsKey)) { ListValue* list_value; - if (!source.GetList(WideToUTF16Hack(kContentScriptsKey), &list_value)) { + if (!source.GetList(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(WideToUTF16Hack(kMatchesKey), &matches)) { + if (!content_script->GetList(kMatchesKey, &matches)) { *error = FormatErrorMessage(kInvalidMatchesError, IntToString(i)); return false; } - if (!content_script->GetList(WideToUTF16Hack(kJsKey), &js)) { + if (!content_script->GetList(kJsKey, &js)) { *error = FormatErrorMessage(kInvalidJsListError, IntToString(i)); return false; } @@ -277,10 +277,9 @@ bool Extension::InitFromValue(const DictionaryValue& source, } UserScript script; - if (content_script->HasKey(WideToUTF16Hack(kRunAtKey))) { + if (content_script->HasKey(kRunAtKey)) { std::string run_location; - if (!content_script->GetString(WideToUTF16Hack(kRunAtKey), - &run_location)) { + if (!content_script->GetString(kRunAtKey, &run_location)) { *error = FormatErrorMessage(kInvalidRunAtError, IntToString(i)); return false; } @@ -329,3 +328,4 @@ 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 7d41b0c..aa8d791 100644 --- a/chrome/browser/extensions/extension_unittest.cc +++ b/chrome/browser/extensions/extension_unittest.cc @@ -43,65 +43,64 @@ TEST(ExtensionTest, InitFromValueInvalid) { // Test missing and invalid format versions input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->Remove(WideToUTF16Hack(Extension::kFormatVersionKey), NULL); + input_value->Remove(Extension::kFormatVersionKey, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidFormatVersionError, error); - input_value->SetString(WideToUTF16Hack(Extension::kFormatVersionKey), "foo"); + input_value->SetString(Extension::kFormatVersionKey, "foo"); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidFormatVersionError, error); - input_value->SetInteger(WideToUTF16Hack(Extension::kFormatVersionKey), 2); + input_value->SetInteger(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(WideToUTF16Hack(Extension::kIdKey), NULL); + input_value->Remove(Extension::kIdKey, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidIdError, error); - input_value->SetInteger(WideToUTF16Hack(Extension::kIdKey), 42); + input_value->SetInteger(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(WideToUTF16Hack(Extension::kVersionKey), NULL); + input_value->Remove(Extension::kVersionKey, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidVersionError, error); - input_value->SetInteger(WideToUTF16Hack(Extension::kVersionKey), 42); + input_value->SetInteger(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(WideToUTF16Hack(Extension::kNameKey), NULL); + input_value->Remove(Extension::kNameKey, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidNameError, error); - input_value->SetInteger(WideToUTF16Hack(Extension::kNameKey), 42); + input_value->SetInteger(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(WideToUTF16Hack(Extension::kDescriptionKey), 42); + input_value->SetInteger(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(WideToUTF16Hack(Extension::kContentScriptsKey), 42); + input_value->SetInteger(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(WideToUTF16Hack(Extension::kContentScriptsKey), - &content_scripts); + input_value->GetList(Extension::kContentScriptsKey, &content_scripts); ASSERT_FALSE(NULL == content_scripts); content_scripts->Set(0, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); @@ -109,21 +108,19 @@ TEST(ExtensionTest, InitFromValueInvalid) { // Test missing and invalid matches array input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->GetList(WideToUTF16Hack(Extension::kContentScriptsKey), - &content_scripts); + input_value->GetList(Extension::kContentScriptsKey, &content_scripts); DictionaryValue* user_script = NULL; content_scripts->GetDictionary(0, &user_script); - user_script->Remove(WideToUTF16Hack(Extension::kMatchesKey), NULL); + user_script->Remove(Extension::kMatchesKey, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchesError)); - user_script->Set(WideToUTF16Hack(Extension::kMatchesKey), - Value::CreateIntegerValue(42)); + user_script->Set(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(WideToUTF16Hack(Extension::kMatchesKey), matches); + user_script->Set(Extension::kMatchesKey, matches); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchCountError)); @@ -134,20 +131,18 @@ TEST(ExtensionTest, InitFromValueInvalid) { // Test missing and invalid files array input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->GetList(WideToUTF16Hack(Extension::kContentScriptsKey), - &content_scripts); + input_value->GetList(Extension::kContentScriptsKey, &content_scripts); content_scripts->GetDictionary(0, &user_script); - user_script->Remove(WideToUTF16Hack(Extension::kJsKey), NULL); + user_script->Remove(Extension::kJsKey, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsListError)); - user_script->Set(WideToUTF16Hack(Extension::kJsKey), - Value::CreateIntegerValue(42)); + user_script->Set(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(WideToUTF16Hack(Extension::kJsKey), files); + user_script->Set(Extension::kJsKey, files); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsCountError)); @@ -174,14 +169,11 @@ TEST(ExtensionTest, InitFromValueValid) { DictionaryValue input_value; // Test minimal extension - input_value.SetInteger(WideToUTF16Hack(Extension::kFormatVersionKey), 1); - input_value.SetString( - WideToUTF16Hack(Extension::kIdKey), - ASCIIToUTF16("00123456789ABCDEF0123456789ABCDEF0123456")); - input_value.SetString(WideToUTF16Hack(Extension::kVersionKey), - ASCIIToUTF16("1.0.0.0")); - input_value.SetString(WideToUTF16Hack(Extension::kNameKey), - ASCIIToUTF16("my extension")); + input_value.SetInteger(Extension::kFormatVersionKey, 1); + input_value.SetString(Extension::kIdKey, + "00123456789ABCDEF0123456789ABCDEF0123456"); + input_value.SetString(Extension::kVersionKey, "1.0.0.0"); + input_value.SetString(Extension::kNameKey, "my extension"); EXPECT_TRUE(extension.InitFromValue(input_value, &error)); EXPECT_EQ("", error); @@ -201,14 +193,11 @@ TEST(ExtensionTest, GetResourceURLAndPath) { #endif Extension extension(path); DictionaryValue input_value; - input_value.SetInteger(WideToUTF16Hack(Extension::kFormatVersionKey), 1); - input_value.SetString( - WideToUTF16Hack(Extension::kIdKey), - ASCIIToUTF16("00123456789ABCDEF0123456789ABCDEF0123456")); - input_value.SetString(WideToUTF16Hack(Extension::kVersionKey), - ASCIIToUTF16("1.0.0.0")); - input_value.SetString(WideToUTF16Hack(Extension::kNameKey), - ASCIIToUTF16("my extension")); + input_value.SetInteger(Extension::kFormatVersionKey, 1); + input_value.SetString(Extension::kIdKey, + "00123456789ABCDEF0123456789ABCDEF0123456"); + input_value.SetString(Extension::kVersionKey, "1.0.0.0"); + input_value.SetString(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 be6f068..3271920 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -402,15 +402,14 @@ DictionaryValue* ExtensionsServiceBackend::ReadManifest() { // again later, checking it here allows us to skip some potentially expensive // work. std::string id; - if (!manifest->GetString(WideToUTF16Hack(Extension::kIdKey), &id)) { + if (!manifest->GetString(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(WideToUTF16Hack(Extension::kVersionKey), - &version)) { + if (!manifest->GetString(Extension::kVersionKey, &version)) { ReportExtensionInstallError("missing version key"); return NULL; } @@ -422,8 +421,7 @@ DictionaryValue* ExtensionsServiceBackend::ReadManifest() { } std::string zip_hash; - if (!manifest->GetString(WideToUTF16Hack(Extension::kZipHashKey), - &zip_hash)) { + if (!manifest->GetString(Extension::kZipHashKey, &zip_hash)) { ReportExtensionInstallError("missing zip_hash key"); return NULL; } diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index beda4d8..c4d2344 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -30,9 +30,8 @@ ExtensionsUIHTMLSource::ExtensionsUIHTMLSource() void ExtensionsUIHTMLSource::StartDataRequest(const std::string& path, int request_id) { DictionaryValue localized_strings; - localized_strings.SetString( - ASCIIToUTF16("title"), - WideToUTF16Hack(l10n_util::GetString(IDS_EXTENSIONS_TITLE))); + localized_strings.SetString(L"title", + l10n_util::GetString(IDS_EXTENSIONS_TITLE)); static const StringPiece extensions_html( ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -88,3 +87,4 @@ GURL ExtensionsUI::GetBaseURL() { url += kExtensionsHost; return GURL(url); } + diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc index 306dcf6..2d3f924 100644 --- a/chrome/browser/importer/importer.cc +++ b/chrome/browser/importer/importer.cc @@ -658,24 +658,25 @@ void ImporterHost::DetectFirefoxProfiles() { std::wstring source_path; for (int i = 0; ; ++i) { - string16 current_profile = ASCIIToUTF16("Profile") + IntToString16(i); + std::wstring current_profile = L"Profile" + IntToWString(i); if (!root.HasKey(current_profile)) { // Profiles are continuously numbered. So we exit when we can't // find the i-th one. break; } - string16 is_relative, path, profile_path; - if (root.GetString(current_profile + ASCIIToUTF16(".IsRelative"), - &is_relative) && - root.GetString(current_profile + ASCIIToUTF16(".Path"), &path)) { + std::wstring is_relative, path, profile_path; + if (root.GetString(current_profile + L".IsRelative", &is_relative) && + root.GetString(current_profile + L".Path", &path)) { + string16 path16 = WideToUTF16Hack(path); ReplaceSubstringsAfterOffset( - &path, 0, ASCIIToUTF16("/"), ASCIIToUTF16("\\")); + &path16, 0, ASCIIToUTF16("/"), ASCIIToUTF16("\\")); + path.assign(UTF16ToWideHack(path16)); #if defined(OS_WIN) // IsRelative=1 means the folder path would be relative to the // path of profiles.ini. IsRelative=0 refers to a custom profile // location. - if (is_relative == ASCIIToUTF16("1")) { + if (is_relative == L"1") { profile_path = file_util::GetDirectoryFromPath(ini_file); file_util::AppendToPath(&profile_path, path); } else { @@ -686,13 +687,12 @@ void ImporterHost::DetectFirefoxProfiles() { // We only import the default profile when multiple profiles exist, // since the other profiles are used mostly by developers for testing. // Otherwise, Profile0 will be imported. - string16 is_default; - if ((root.GetString(current_profile + ASCIIToUTF16(".Default"), - &is_default) && - is_default == ASCIIToUTF16("1")) || i == 0) { - source_path = UTF16ToWideHack(profile_path); + std::wstring is_default; + if ((root.GetString(current_profile + L".Default", &is_default) && + is_default == L"1") || i == 0) { + source_path = profile_path; // We break out of the loop when we have found the default profile. - if (is_default == ASCIIToUTF16("1")) + if (is_default == L"1") break; } } diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index 9c045d8..a504b11 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -383,28 +383,24 @@ void MetricsLog::WritePluginStabilityElements(PrefService* pref) { } DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter); - string16 plugin_name; - plugin_dict->GetString(WideToUTF16Hack(prefs::kStabilityPluginName), - &plugin_name); + std::wstring plugin_name; + plugin_dict->GetString(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(UTF16ToUTF8(plugin_name))); + WriteAttribute("filename", CreateBase64Hash(WideToUTF8(plugin_name))); int launches = 0; - plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches), - &launches); + plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches); WriteIntAttribute("launchcount", launches); int instances = 0; - plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances), - &instances); + plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances); WriteIntAttribute("instancecount", instances); int crashes = 0; - plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes), - &crashes); + plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes); WriteIntAttribute("crashcount", crashes); } @@ -572,11 +568,10 @@ 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 string16 key_name16 = *i; - const std::wstring& key_name = UTF16ToWideHack(key_name16); + const std::wstring& key_name = *i; if (key_name.compare(0, profile_prefix.size(), profile_prefix) == 0) { DictionaryValue* profile; - if (all_profiles_metrics.GetDictionary(key_name16, &profile)) + if (all_profiles_metrics.GetDictionary(key_name, &profile)) WriteProfileMetrics(key_name.substr(profile_prefix.size()), *profile); } } @@ -590,13 +585,13 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash, i != profile_metrics.end_keys(); ++i) { Value* value; if (profile_metrics.Get(*i, &value)) { - DCHECK(*i != ASCIIToUTF16("id")); + DCHECK(*i != L"id"); switch (value->GetType()) { case Value::TYPE_STRING: { std::string string_value; if (value->GetAsString(&string_value)) { OPEN_ELEMENT_FOR_SCOPE("profileparam"); - WriteAttribute("name", UTF16ToUTF8(*i)); + WriteAttribute("name", WideToUTF8(*i)); WriteAttribute("value", string_value); } break; @@ -606,7 +601,7 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash, bool bool_value; if (value->GetAsBoolean(&bool_value)) { OPEN_ELEMENT_FOR_SCOPE("profileparam"); - WriteAttribute("name", UTF16ToUTF8(*i)); + WriteAttribute("name", WideToUTF8(*i)); WriteIntAttribute("value", bool_value ? 1 : 0); } break; @@ -616,7 +611,7 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash, int int_value; if (value->GetAsInteger(&int_value)) { OPEN_ELEMENT_FOR_SCOPE("profileparam"); - WriteAttribute("name", UTF16ToUTF8(*i)); + WriteAttribute("name", WideToUTF8(*i)); WriteIntAttribute("value", int_value); } break; diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index 8c12373..e081bd9 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -1675,46 +1675,38 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { } DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*value_iter); - string16 plugin_name; - plugin_dict->GetString(WideToUTF16Hack(prefs::kStabilityPluginName), - &plugin_name); + std::wstring plugin_name; + plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); if (plugin_name.empty()) { NOTREACHED(); continue; } - if (child_process_stats_buffer_.find(UTF16ToWideHack(plugin_name)) == + if (child_process_stats_buffer_.find(plugin_name) == child_process_stats_buffer_.end()) continue; - ChildProcessStats stats = - child_process_stats_buffer_[UTF16ToWideHack(plugin_name)]; + ChildProcessStats stats = child_process_stats_buffer_[plugin_name]; if (stats.process_launches) { int launches = 0; - plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches), - &launches); + plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches); launches += stats.process_launches; - plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches), - launches); + plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, launches); } if (stats.process_crashes) { int crashes = 0; - plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes), - &crashes); + plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes); crashes += stats.process_crashes; - plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes), - crashes); + plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, crashes); } if (stats.instances) { int instances = 0; - plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances), - &instances); + plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances); instances += stats.instances; - plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances), - instances); + plugin_dict->SetInteger(prefs::kStabilityPluginInstances, instances); } - child_process_stats_buffer_.erase(UTF16ToWideHack(plugin_name)); + child_process_stats_buffer_.erase(plugin_name); } // Now go through and add dictionaries for plugins that didn't already have @@ -1726,13 +1718,12 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { ChildProcessStats stats = cache_iter->second; DictionaryValue* plugin_dict = new DictionaryValue; - plugin_dict->SetString(WideToUTF16Hack(prefs::kStabilityPluginName), - WideToUTF16Hack(plugin_name)); - plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches), + plugin_dict->SetString(prefs::kStabilityPluginName, plugin_name); + plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, stats.process_launches); - plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes), + plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, stats.process_crashes); - plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances), + plugin_dict->SetInteger(prefs::kStabilityPluginInstances, stats.instances); plugins->Append(plugin_dict); } @@ -1844,7 +1835,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(WideToUTF16Hack(pref_key), value); + prof_prefs->SetInteger(pref_key.c_str(), value); } static bool IsSingleThreaded() { diff --git a/chrome/browser/page_state.cc b/chrome/browser/page_state.cc index c970bbe..827416c 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(UTF8ToUTF16(query_string.substr(keyComp.begin, keyComp.len)), + state_->Set(UTF8ToWide(query_string.substr(keyComp.begin, keyComp.len)), new StringValue(value)); } } @@ -59,12 +59,10 @@ void PageState::GetByteRepresentation(std::string* out) const { void PageState::SetProperty(const std::wstring& key, const std::wstring& value) { - state_->Set(WideToUTF16Hack(key), new StringValue(value)); + state_->Set(key, new StringValue(value)); } -bool PageState::GetProperty(const std::wstring& wkey, - std::wstring* value) const { - string16 key(WideToUTF16(wkey)); +bool PageState::GetProperty(const std::wstring& key, std::wstring* value) const { 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 e8798a2..3735492 100644 --- a/chrome/browser/profile_manager.h +++ b/chrome/browser/profile_manager.h @@ -15,7 +15,6 @@ #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" @@ -34,21 +33,20 @@ class AvailableProfile { // Decodes a DictionaryValue into an AvailableProfile static AvailableProfile* FromValue(DictionaryValue* value) { DCHECK(value); - string16 name, id; + std::wstring name, id; FilePath::StringType directory; - value->GetString(ASCIIToUTF16("name"), &name); - value->GetString(ASCIIToUTF16("id"), &id); - value->GetString(ASCIIToUTF16("directory"), &directory); - return new AvailableProfile(UTF16ToWideHack(name), UTF16ToWideHack(id), - FilePath(directory)); + value->GetString(L"name", &name); + value->GetString(L"id", &id); + value->GetString(L"directory", &directory); + return new AvailableProfile(name, id, FilePath(directory)); } // Encodes this AvailableProfile into a new DictionaryValue DictionaryValue* ToValue() { DictionaryValue* value = new DictionaryValue; - value->SetString(ASCIIToUTF16("name"), WideToUTF16Hack(name_)); - value->SetString(ASCIIToUTF16("id"), WideToUTF16Hack(id_)); - value->SetString(ASCIIToUTF16("directory"), directory_.value()); + value->SetString(L"name", name_); + value->SetString(L"id", id_); + value->SetString(L"directory", directory_.value()); return value; } @@ -185,3 +183,4 @@ 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 c07c750..2eafe9a1 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc @@ -103,14 +103,11 @@ void SafeBrowsingBlockingPage::PopulateStringDictionary( const std::wstring& description1, const std::wstring& description2, const std::wstring& description3) { - strings->SetString(ASCIIToUTF16("title"), WideToUTF16Hack(title)); - strings->SetString(ASCIIToUTF16("headLine"), WideToUTF16Hack(headline)); - strings->SetString(ASCIIToUTF16("description1"), - WideToUTF16Hack(description1)); - strings->SetString(ASCIIToUTF16("description2"), - WideToUTF16Hack(description2)); - strings->SetString(ASCIIToUTF16("description3"), - WideToUTF16Hack(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); } void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary( @@ -118,17 +115,14 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary( bool malware = false; bool phishing = false; - 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)); + 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); ListValue* error_strings = new ListValue; for (UnsafeResourceList::const_iterator iter = unsafe_resources_.begin(); @@ -137,26 +131,20 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary( DictionaryValue* current_error_strings = new DictionaryValue; if (resource.threat_type == SafeBrowsingService::URL_MALWARE) { malware = true; - current_error_strings->SetString(ASCIIToUTF16("type"), - ASCIIToUTF16("malware")); - current_error_strings->SetString(ASCIIToUTF16("typeLabel"), - malware_label); - current_error_strings->SetString(ASCIIToUTF16("errorLink"), malware_link); + current_error_strings->SetString(L"type", L"malware"); + current_error_strings->SetString(L"typeLabel", malware_label); + current_error_strings->SetString(L"errorLink", malware_link); } else { DCHECK(resource.threat_type == SafeBrowsingService::URL_PHISHING); phishing = true; - current_error_strings->SetString(ASCIIToUTF16("type"), - ASCIIToUTF16("phishing")); - current_error_strings->SetString(ASCIIToUTF16("typeLabel"), - phishing_label); - current_error_strings->SetString(ASCIIToUTF16("errorLink"), - phishing_link); + 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(ASCIIToUTF16("url"), - UTF8ToUTF16(resource.url.spec())); + current_error_strings->SetString(L"url", UTF8ToWide(resource.url.spec())); error_strings->Append(current_error_strings); } - strings->Set(ASCIIToUTF16("errors"), error_strings); + strings->Set(L"errors", error_strings); DCHECK(phishing || malware); if (malware && phishing) { @@ -190,18 +178,15 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary( L"", L""); } - strings->SetString(ASCIIToUTF16("confirm_text"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_MALWARE_DESCRIPTION_AGREE))); - strings->SetString(ASCIIToUTF16("continue_button"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON))); - strings->SetString(ASCIIToUTF16("back_button"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON))); - strings->SetString(ASCIIToUTF16("textdirection"), + 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", (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - ASCIIToUTF16("rtl") : ASCIIToUTF16("ltr")); + L"rtl" : L"ltr"); } void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary( @@ -209,7 +194,7 @@ void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary( std::wstring link = StringPrintf(kSbDiagnosticHtml, l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE).c_str()); - strings->SetString(ASCIIToUTF16("badURL"), UTF8ToUTF16(url().host())); + strings->SetString(L"badURL", UTF8ToWide(url().host())); // Check to see if we're blocking the main page, or a sub-resource on the // main page. std::wstring description1, description2; @@ -235,18 +220,15 @@ void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary( description1, description2, l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION3)); - strings->SetString(ASCIIToUTF16("confirm_text"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_MALWARE_DESCRIPTION_AGREE))); - strings->SetString(ASCIIToUTF16("continue_button"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON))); - strings->SetString(ASCIIToUTF16("back_button"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON))); - strings->SetString(ASCIIToUTF16("textdirection"), + 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", (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - ASCIIToUTF16("rtl") : ASCIIToUTF16("ltr")); + L"rtl" : L"ltr"); } void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary( @@ -261,18 +243,15 @@ void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary( UTF8ToWide(url().host())), L""); - strings->SetString(ASCIIToUTF16("continue_button"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_PHISHING_PROCEED_BUTTON))); - strings->SetString(ASCIIToUTF16("back_button"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_PHISHING_BACK_BUTTON))); - strings->SetString(ASCIIToUTF16("report_error"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR))); - strings->SetString(ASCIIToUTF16("textdirection"), + 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", (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - ASCIIToUTF16("rtl") : ASCIIToUTF16("ltr")); + L"rtl" : L"ltr"); } void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) { @@ -456,3 +435,4 @@ 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 1983559..c98975d 100644 --- a/chrome/browser/ssl/ssl_blocking_page.cc +++ b/chrome/browser/ssl/ssl_blocking_page.cc @@ -44,30 +44,23 @@ std::string SSLBlockingPage::GetHTMLContents() { // Let's build the html error page. DictionaryValue strings; SSLErrorInfo error_info = delegate_->GetSSLErrorInfo(error_); - strings.SetString( - ASCIIToUTF16("title"), - WideToUTF16Hack(l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_TITLE))); - strings.SetString(ASCIIToUTF16("headLine"), - WideToUTF16Hack(error_info.title())); - strings.SetString(ASCIIToUTF16("description"), - WideToUTF16Hack(error_info.details())); - - strings.SetString( - ASCIIToUTF16("moreInfoTitle"), - WideToUTF16Hack(l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE))); + 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)); SetExtraInfo(&strings, error_info.extra_information()); - strings.SetString( - ASCIIToUTF16("proceed"), - WideToUTF16Hack(l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_PROCEED))); - strings.SetString( - ASCIIToUTF16("exit"), - WideToUTF16Hack(l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_EXIT))); + 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( - ASCIIToUTF16("textdirection"), + strings.SetString(L"textdirection", (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - ASCIIToUTF16("rtl") : ASCIIToUTF16("ltr")); + L"rtl" : L"ltr"); static const StringPiece html( ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -138,16 +131,15 @@ void SSLBlockingPage::SetExtraInfo( DictionaryValue* strings, const std::vector<std::wstring>& extra_info) { DCHECK(extra_info.size() < 5); // We allow 5 paragraphs max. - const string16 keys[5] = { - ASCIIToUTF16("moreInfo1"), ASCIIToUTF16("moreInfo2"), - ASCIIToUTF16("moreInfo3"), ASCIIToUTF16("moreInfo4"), - ASCIIToUTF16("moreInfo5") + const std::wstring keys[5] = { + L"moreInfo1", L"moreInfo2", L"moreInfo3", L"moreInfo4", L"moreInfo5" }; int i; for (i = 0; i < static_cast<int>(extra_info.size()); i++) { - strings->SetString(keys[i], WideToUTF16Hack(extra_info[i])); + strings->SetString(keys[i], extra_info[i]); } for (;i < 5; i++) { - strings->SetString(keys[i], ASCIIToUTF16("")); + strings->SetString(keys[i], L""); } } + diff --git a/chrome/browser/ssl/ssl_policy.cc b/chrome/browser/ssl/ssl_policy.cc index 49ee40c..4a0fdef 100644 --- a/chrome/browser/ssl/ssl_policy.cc +++ b/chrome/browser/ssl/ssl_policy.cc @@ -76,26 +76,18 @@ static void ShowErrorPage(SSLPolicy* policy, SSLManager::CertError* error) { // Let's build the html error page. DictionaryValue strings; - strings.SetString( - ASCIIToUTF16("title"), - WideToUTF16Hack(l10n_util::GetString(IDS_SSL_ERROR_PAGE_TITLE))); - strings.SetString(ASCIIToUTF16("headLine"), - WideToUTF16Hack(error_info.title())); - strings.SetString(ASCIIToUTF16("description"), - WideToUTF16Hack(error_info.details())); - strings.SetString( - ASCIIToUTF16("moreInfoTitle"), - WideToUTF16Hack(l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE))); + 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)); SSLBlockingPage::SetExtraInfo(&strings, error_info.extra_information()); - strings.SetString( - ASCIIToUTF16("back"), - WideToUTF16Hack(l10n_util::GetString(IDS_SSL_ERROR_PAGE_BACK))); + strings.SetString(L"back", l10n_util::GetString(IDS_SSL_ERROR_PAGE_BACK)); - strings.SetString( - ASCIIToUTF16("textdirection"), + strings.SetString(L"textdirection", (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - ASCIIToUTF16("rtl") : ASCIIToUTF16("ltr")); + L"rtl" : L"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 7504471..1fc9e97 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(ASCIIToUTF16("null"), &null_value)); + ASSERT_TRUE(root_dict->Get(L"null", &null_value)); ASSERT_TRUE(null_value); ASSERT_TRUE(null_value->IsType(Value::TYPE_NULL)); bool bool_value = false; - ASSERT_TRUE(root_dict->GetBoolean(ASCIIToUTF16("bool"), &bool_value)); + ASSERT_TRUE(root_dict->GetBoolean(L"bool", &bool_value)); ASSERT_TRUE(bool_value); int int_value = 0; - ASSERT_TRUE(root_dict->GetInteger(ASCIIToUTF16("int"), &int_value)); + ASSERT_TRUE(root_dict->GetInteger(L"int", &int_value)); ASSERT_EQ(42, int_value); double real_value = 0.0; - ASSERT_TRUE(root_dict->GetReal(ASCIIToUTF16("real"), &real_value)); + ASSERT_TRUE(root_dict->GetReal(L"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(ASCIIToUTF16("all_chars"), WideToUTF16Hack(all_chars)); + valueRoot.SetString(L"all_chars", 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(ASCIIToUTF16("web"), WideToUTF16Hack(test)); + root.SetString(L"web", 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()); - string16 web_value; - ASSERT_TRUE(dict_root->GetString(ASCIIToUTF16("web"), &web_value)); - ASSERT_EQ(test, UTF16ToWideHack(web_value)); + std::wstring web_value; + ASSERT_TRUE(dict_root->GetString(L"web", &web_value)); + ASSERT_EQ(test, web_value); } TEST(JSONValueSerializerTest, HexStrings) { // hex string json -> escaped ascii text DictionaryValue root; std::wstring test(L"\x01\x02"); - root.SetString(ASCIIToUTF16("test"), WideToUTF16Hack(test)); + root.SetString(L"test", 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()); - string16 test_value; - ASSERT_TRUE(dict_root->GetString(ASCIIToUTF16("test"), &test_value)); - ASSERT_EQ(test, UTF16ToWideHack(test_value)); + std::wstring test_value; + ASSERT_TRUE(dict_root->GetString(L"test", &test_value)); + ASSERT_EQ(test, 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(ASCIIToUTF16("test"), &test_value)); - ASSERT_EQ(L"go", UTF16ToWideHack(test_value)); + ASSERT_TRUE(dict_root->GetString(L"test", &test_value)); + ASSERT_EQ(std::wstring(L"go"), 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(ASCIIToUTF16("null"), &null_value)); + ASSERT_TRUE(root_dict->Get(L"null", &null_value)); ASSERT_TRUE(null_value); ASSERT_TRUE(null_value->IsType(Value::TYPE_NULL)); bool bool_value = false; - ASSERT_TRUE(root_dict->GetBoolean(ASCIIToUTF16("bool"), &bool_value)); + ASSERT_TRUE(root_dict->GetBoolean(L"bool", &bool_value)); ASSERT_TRUE(bool_value); int int_value = 0; - ASSERT_TRUE(root_dict->GetInteger(ASCIIToUTF16("int"), &int_value)); + ASSERT_TRUE(root_dict->GetInteger(L"int", &int_value)); ASSERT_EQ(42, int_value); - string16 string_value; - ASSERT_TRUE(root_dict->GetString(ASCIIToUTF16("string"), &string_value)); - ASSERT_EQ(L"hello", UTF16ToWideHack(string_value)); + std::wstring string_value; + ASSERT_TRUE(root_dict->GetString(L"string", &string_value)); + ASSERT_EQ(L"hello", 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 fd27de1..b728a87 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(WideToUTF16Hack(path), &result)) + if (transient_->GetBoolean(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(WideToUTF16Hack(path), &result)) + if (transient_->GetInteger(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(WideToUTF16Hack(path), &result)) + if (transient_->GetReal(path, &result)) return result; const Preference* pref = FindPreference(path); @@ -339,11 +339,10 @@ double PrefService::GetReal(const wchar_t* path) const { std::wstring PrefService::GetString(const wchar_t* path) const { DCHECK(CalledOnValidThread()); - string16 result16; - if (transient_->GetString(WideToUTF16Hack(path), &result16)) - return UTF16ToWideHack(result16); - std::wstring result; + if (transient_->GetString(path, &result)) + return result; + const Preference* pref = FindPreference(path); if (!pref) { #if defined(OS_WIN) @@ -360,8 +359,7 @@ std::wstring PrefService::GetString(const wchar_t* path) const { bool PrefService::HasPrefPath(const wchar_t* path) const { Value* value = NULL; - string16 path16 = WideToUTF16Hack(path); - return (transient_->Get(path16, &value) || persistent_->Get(path16, &value)); + return (transient_->Get(path, &value) || persistent_->Get(path, &value)); } const PrefService::Preference* PrefService::FindPreference( @@ -376,7 +374,7 @@ const DictionaryValue* PrefService::GetDictionary(const wchar_t* path) const { DCHECK(CalledOnValidThread()); DictionaryValue* result = NULL; - if (transient_->GetDictionary(WideToUTF16Hack(path), &result)) + if (transient_->GetDictionary(path, &result)) return result; const Preference* pref = FindPreference(path); @@ -394,7 +392,7 @@ const ListValue* PrefService::GetList(const wchar_t* path) const { DCHECK(CalledOnValidThread()); ListValue* result = NULL; - if (transient_->GetList(WideToUTF16Hack(path), &result)) + if (transient_->GetList(path, &result)) return result; const Preference* pref = FindPreference(path); @@ -475,11 +473,10 @@ void PrefService::ClearPref(const wchar_t* path) { return; } - string16 path16 = WideToUTF16Hack(path); - transient_->Remove(path16, NULL); + transient_->Remove(path, NULL); Value* value; - bool has_old_value = persistent_->Get(path16, &value); - persistent_->Remove(path16, NULL); + bool has_old_value = persistent_->Get(path, &value); + persistent_->Remove(path, NULL); if (has_old_value) FireObservers(path); @@ -499,7 +496,7 @@ void PrefService::SetBoolean(const wchar_t* path, bool value) { } scoped_ptr<Value> old_value(GetPrefCopy(path)); - bool rv = persistent_->SetBoolean(WideToUTF16Hack(path), value); + bool rv = persistent_->SetBoolean(path, value); DCHECK(rv); FireObserversIfChanged(path, old_value.get()); @@ -519,7 +516,7 @@ void PrefService::SetInteger(const wchar_t* path, int value) { } scoped_ptr<Value> old_value(GetPrefCopy(path)); - bool rv = persistent_->SetInteger(WideToUTF16Hack(path), value); + bool rv = persistent_->SetInteger(path, value); DCHECK(rv); FireObserversIfChanged(path, old_value.get()); @@ -539,7 +536,7 @@ void PrefService::SetReal(const wchar_t* path, double value) { } scoped_ptr<Value> old_value(GetPrefCopy(path)); - bool rv = persistent_->SetReal(WideToUTF16Hack(path), value); + bool rv = persistent_->SetReal(path, value); DCHECK(rv); FireObserversIfChanged(path, old_value.get()); @@ -559,8 +556,7 @@ void PrefService::SetString(const wchar_t* path, const std::wstring& value) { } scoped_ptr<Value> old_value(GetPrefCopy(path)); - bool rv = persistent_->SetString(WideToUTF16Hack(path), - WideToUTF16Hack(value)); + bool rv = persistent_->SetString(path, value); DCHECK(rv); FireObserversIfChanged(path, old_value.get()); @@ -580,11 +576,10 @@ DictionaryValue* PrefService::GetMutableDictionary(const wchar_t* path) { } DictionaryValue* dict = NULL; - string16 path16 = WideToUTF16Hack(path); - bool rv = persistent_->GetDictionary(path16, &dict); + bool rv = persistent_->GetDictionary(path, &dict); if (!rv) { dict = new DictionaryValue; - rv = persistent_->Set(path16, dict); + rv = persistent_->Set(path, dict); DCHECK(rv); } return dict; @@ -604,11 +599,10 @@ ListValue* PrefService::GetMutableList(const wchar_t* path) { } ListValue* list = NULL; - string16 path16 = WideToUTF16Hack(path); - bool rv = persistent_->GetList(path16, &list); + bool rv = persistent_->GetList(path, &list); if (!rv) { list = new ListValue; - rv = persistent_->Set(path16, list); + rv = persistent_->Set(path, list); DCHECK(rv); } return list; @@ -625,7 +619,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(WideToUTF16Hack(path), &new_value); + persistent_->Get(path, &new_value); if (!old_value->Equals(new_value)) FireObservers(path); } @@ -678,7 +672,7 @@ const Value* PrefService::Preference::GetValue() const { "Must register pref before getting its value"; Value* temp_value = NULL; - if (root_pref_->Get(WideToUTF16Hack(name_), &temp_value) && + if (root_pref_->Get(name_.c_str(), &temp_value) && temp_value->GetType() == type_) { return temp_value; } diff --git a/chrome/renderer/localized_error.cc b/chrome/renderer/localized_error.cc index b6f6575..af89563 100644 --- a/chrome/renderer/localized_error.cc +++ b/chrome/renderer/localized_error.cc @@ -86,12 +86,10 @@ WebErrorNetErrorMap net_error_options[] = { void GetLocalizedErrorValues(const WebError& error, DictionaryValue* error_strings) { // Grab strings that are applicable to all error pages - error_strings->SetString( - ASCIIToUTF16("detailsLink"), - WideToUTF16Hack(l10n_util::GetString(IDS_ERRORPAGES_DETAILS_LINK))); - error_strings->SetString( - ASCIIToUTF16("detailsHeading"), - WideToUTF16Hack(l10n_util::GetString(IDS_ERRORPAGES_DETAILS_HEADING))); + error_strings->SetString(L"detailsLink", + l10n_util::GetString(IDS_ERRORPAGES_DETAILS_LINK)); + error_strings->SetString(L"detailsHeading", + l10n_util::GetString(IDS_ERRORPAGES_DETAILS_HEADING)); // Grab the strings and settings that depend on the error type. Init // options with default values. @@ -116,49 +114,40 @@ void GetLocalizedErrorValues(const WebError& error, suggestions_heading = l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_HEADING); } - error_strings->SetString(ASCIIToUTF16("suggestionsHeading"), - WideToUTF16Hack(suggestions_heading)); + error_strings->SetString(L"suggestionsHeading", 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( - ASCIIToUTF16("title"), - WideToUTF16Hack(l10n_util::GetStringF(options.title_resource_id, - failed_url))); - error_strings->SetString( - ASCIIToUTF16("heading"), - WideToUTF16Hack(l10n_util::GetString(options.heading_resource_id))); + 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)); DictionaryValue* summary = new DictionaryValue; - summary->SetString( - ASCIIToUTF16("msg"), - WideToUTF16Hack(l10n_util::GetString(options.summary_resource_id))); + summary->SetString(L"msg", + l10n_util::GetString(options.summary_resource_id)); // TODO(tc): we want the unicode url here since it's being displayed - summary->SetString(ASCIIToUTF16("failedUrl"), WideToUTF16Hack(failed_url)); - error_strings->Set(ASCIIToUTF16("summary"), summary); + summary->SetString(L"failedUrl", failed_url); + error_strings->Set(L"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( - ASCIIToUTF16("details"), - WideToUTF16Hack(l10n_util::GetStringF( - IDS_ERRORPAGES_DETAILS_TEMPLATE, - IntToWString(-error_code), - ASCIIToWide(net::ErrorToString(error_code)), - details))); + error_strings->SetString(L"details", + 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( - ASCIIToUTF16("msg"), - WideToUTF16Hack(l10n_util::GetString( - IDS_ERRORPAGES_SUGGESTION_RELOAD))); - suggest_reload->SetString(ASCIIToUTF16("reloadUrl"), - WideToUTF16Hack(failed_url)); - error_strings->Set(ASCIIToUTF16("suggestionsReload"), suggest_reload); + 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); } if (options.suggestions & SUGGEST_HOSTNAME) { @@ -166,21 +155,17 @@ 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( - ASCIIToUTF16("suggestionsHomepageMsg"), - WideToUTF16Hack(l10n_util::GetString( - IDS_ERRORPAGES_SUGGESTION_HOMEPAGE))); + suggest_home_page->SetString(L"suggestionsHomepageMsg", + 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(ASCIIToUTF16("homePage"), - WideToUTF16Hack(homepage)); + suggest_home_page->SetString(L"homePage", homepage); // TODO(tc): we actually want the unicode hostname - suggest_home_page->SetString(ASCIIToUTF16("hostName"), - UTF8ToUTF16(failed_url.host())); - error_strings->Set(ASCIIToUTF16("suggestionsHomepage"), - suggest_home_page); + suggest_home_page->SetString(L"hostName", + ASCIIToWide(failed_url.host())); + error_strings->Set(L"suggestionsHomepage", suggest_home_page); } } @@ -203,14 +188,11 @@ void GetLocalizedErrorValues(const WebError& error, learn_more_url = learn_more_url.ReplaceComponents(repl); DictionaryValue* suggest_learn_more = new DictionaryValue; - suggest_learn_more->SetString( - ASCIIToUTF16("msg"), - WideToUTF16Hack(l10n_util::GetString( - IDS_ERRORPAGES_SUGGESTION_LEARNMORE))); - suggest_learn_more->SetString(ASCIIToUTF16("learnMoreUrl"), - UTF8ToUTF16(learn_more_url.spec())); - error_strings->Set(ASCIIToUTF16("suggestionsLearnMore"), - suggest_learn_more); + 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); } } } @@ -222,18 +204,13 @@ void GetFormRepostErrorValues(const GURL& display_url, if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) l10n_util::WrapStringWithLTRFormatting(&failed_url); error_strings->SetString( - ASCIIToUTF16("title"), - WideToUTF16Hack(l10n_util::GetStringF( - IDS_ERRORPAGES_TITLE_NOT_AVAILABLE, - failed_url.c_str()))); - error_strings->SetString( - ASCIIToUTF16("heading"), - WideToUTF16Hack(l10n_util::GetString(IDS_HTTP_POST_WARNING_TITLE))); - error_strings->SetString(ASCIIToUTF16("suggestionsHeading"), - ASCIIToUTF16("")); + 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""); DictionaryValue* summary = new DictionaryValue; - summary->SetString( - ASCIIToUTF16("msg"), - WideToUTF16Hack(l10n_util::GetString(IDS_ERRORPAGES_HTTP_POST_WARNING))); - error_strings->Set(ASCIIToUTF16("summary"), summary); + summary->SetString(L"msg", + l10n_util::GetString(IDS_ERRORPAGES_HTTP_POST_WARNING)); + error_strings->Set(L"summary", summary); } diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 00da8a6..59ba2c9 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1380,10 +1380,9 @@ void RenderView::LoadNavigationErrorPage(WebFrame* frame, GetLocalizedErrorValues(error, &error_strings); resource_id = IDR_NET_ERROR_HTML; } - error_strings.SetString( - ASCIIToUTF16("textdirection"), - (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - ASCIIToUTF16("rtl") : ASCIIToUTF16("ltr")); + error_strings.SetString(L"textdirection", + (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? + L"rtl" : L"ltr"); alt_html = GetAltHTMLForTemplate(error_strings, resource_id); } else { |