summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/search_provider.cc3
-rw-r--r--chrome/browser/bookmarks/bookmark_codec.cc85
-rw-r--r--chrome/browser/bookmarks/bookmark_html_writer.cc51
-rw-r--r--chrome/browser/browser_about_handler.cc160
-rw-r--r--chrome/browser/browser_init.cc9
-rw-r--r--chrome/browser/browser_main.cc30
-rw-r--r--chrome/browser/dom_ui/dom_ui.cc4
-rw-r--r--chrome/browser/dom_ui/history_ui.cc74
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc105
-rw-r--r--chrome/browser/extensions/extension.cc34
-rw-r--r--chrome/browser/extensions/extension_unittest.cc71
-rw-r--r--chrome/browser/extensions/extensions_service.cc8
-rw-r--r--chrome/browser/extensions/extensions_ui.cc6
-rw-r--r--chrome/browser/importer/importer.cc26
-rw-r--r--chrome/browser/metrics/metrics_log.cc29
-rw-r--r--chrome/browser/metrics/metrics_service.cc41
-rw-r--r--chrome/browser/page_state.cc8
-rw-r--r--chrome/browser/profile_manager.h19
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page.cc114
-rw-r--r--chrome/browser/ssl/ssl_blocking_page.cc44
-rw-r--r--chrome/browser/ssl/ssl_policy.cc24
-rw-r--r--chrome/common/json_value_serializer_unittest.cc42
-rw-r--r--chrome/common/pref_service.cc50
-rw-r--r--chrome/renderer/localized_error.cc107
-rw-r--r--chrome/renderer/render_view.cc7
25 files changed, 660 insertions, 491 deletions
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 23d4407c..69965f9 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -302,7 +302,8 @@ bool SearchProvider::ParseSuggestResults(Value* root_val) {
DictionaryValue* dict_val = static_cast<DictionaryValue*>(optional_val);
// Parse Google Suggest specific type extension.
- static const std::wstring kGoogleSuggestType(L"google:suggesttype");
+ static const string16 kGoogleSuggestType(
+ ASCIIToUTF16("google:suggesttype"));
if (dict_val->HasKey(kGoogleSuggestType))
dict_val->GetList(kGoogleSuggestType, &type_list);
}
diff --git a/chrome/browser/bookmarks/bookmark_codec.cc b/chrome/browser/bookmarks/bookmark_codec.cc
index dd39fc8..873ef32 100644
--- a/chrome/browser/bookmarks/bookmark_codec.cc
+++ b/chrome/browser/bookmarks/bookmark_codec.cc
@@ -36,12 +36,14 @@ Value* BookmarkCodec::Encode(BookmarkModel* model) {
Value* BookmarkCodec::Encode(BookmarkNode* bookmark_bar_node,
BookmarkNode* other_folder_node) {
DictionaryValue* roots = new DictionaryValue();
- roots->Set(kRootFolderNameKey, EncodeNode(bookmark_bar_node));
- roots->Set(kOtherBookmarFolderNameKey, EncodeNode(other_folder_node));
+ roots->Set(WideToUTF16Hack(kRootFolderNameKey),
+ EncodeNode(bookmark_bar_node));
+ roots->Set(WideToUTF16Hack(kOtherBookmarFolderNameKey),
+ EncodeNode(other_folder_node));
DictionaryValue* main = new DictionaryValue();
- main->SetInteger(kVersionKey, kCurrentVersion);
- main->Set(kRootsKey, roots);
+ main->SetInteger(WideToUTF16Hack(kVersionKey), kCurrentVersion);
+ main->Set(WideToUTF16Hack(kRootsKey), roots);
return main;
}
@@ -52,11 +54,12 @@ bool BookmarkCodec::Decode(BookmarkModel* model, const Value& value) {
const DictionaryValue& d_value = static_cast<const DictionaryValue&>(value);
int version;
- if (!d_value.GetInteger(kVersionKey, &version) || version != kCurrentVersion)
+ if (!d_value.GetInteger(WideToUTF16Hack(kVersionKey), &version) ||
+ version != kCurrentVersion)
return false; // Unknown version.
Value* roots;
- if (!d_value.Get(kRootsKey, &roots))
+ if (!d_value.Get(WideToUTF16Hack(kRootsKey), &roots))
return false; // No roots.
if (roots->GetType() != Value::TYPE_DICTIONARY)
@@ -65,11 +68,14 @@ bool BookmarkCodec::Decode(BookmarkModel* model, const Value& value) {
DictionaryValue* roots_d_value = static_cast<DictionaryValue*>(roots);
Value* root_folder_value;
Value* other_folder_value;
- if (!roots_d_value->Get(kRootFolderNameKey, &root_folder_value) ||
+ if (!roots_d_value->Get(WideToUTF16Hack(kRootFolderNameKey),
+ &root_folder_value) ||
root_folder_value->GetType() != Value::TYPE_DICTIONARY ||
- !roots_d_value->Get(kOtherBookmarFolderNameKey, &other_folder_value) ||
- other_folder_value->GetType() != Value::TYPE_DICTIONARY)
+ !roots_d_value->Get(WideToUTF16Hack(kOtherBookmarFolderNameKey),
+ &other_folder_value) ||
+ other_folder_value->GetType() != Value::TYPE_DICTIONARY) {
return false; // Invalid type for root folder and/or other folder.
+ }
DecodeNode(model, *static_cast<DictionaryValue*>(root_folder_value),
NULL, model->GetBookmarkBarNode());
@@ -89,21 +95,22 @@ bool BookmarkCodec::Decode(BookmarkModel* model, const Value& value) {
Value* BookmarkCodec::EncodeNode(BookmarkNode* node) {
DictionaryValue* value = new DictionaryValue();
- value->SetString(kNameKey, node->GetTitle());
- value->SetString(kDateAddedKey,
- Int64ToWString(node->date_added().ToInternalValue()));
+ value->SetString(WideToUTF16Hack(kNameKey),
+ WideToUTF16Hack(node->GetTitle()));
+ value->SetString(WideToUTF16Hack(kDateAddedKey),
+ Int64ToString16(node->date_added().ToInternalValue()));
if (node->GetType() == history::StarredEntry::URL) {
- value->SetString(kTypeKey, kTypeURL);
- value->SetString(kURLKey,
- UTF8ToWide(node->GetURL().possibly_invalid_spec()));
+ value->SetString(WideToUTF16Hack(kTypeKey), WideToUTF16Hack(kTypeURL));
+ value->SetString(WideToUTF16Hack(kURLKey),
+ UTF8ToUTF16(node->GetURL().possibly_invalid_spec()));
} else {
- value->SetString(kTypeKey, kTypeFolder);
- value->SetString(kDateModifiedKey,
- Int64ToWString(node->date_group_modified().
+ value->SetString(WideToUTF16Hack(kTypeKey), WideToUTF16Hack(kTypeFolder));
+ value->SetString(WideToUTF16Hack(kDateModifiedKey),
+ Int64ToString16(node->date_group_modified().
ToInternalValue()));
ListValue* child_values = new ListValue();
- value->Set(kChildrenKey, child_values);
+ value->Set(WideToUTF16Hack(kChildrenKey), child_values);
for (int i = 0; i < node->GetChildCount(); ++i)
child_values->Append(EncodeNode(node->GetChild(i)));
}
@@ -133,40 +140,42 @@ bool BookmarkCodec::DecodeNode(BookmarkModel* model,
const DictionaryValue& value,
BookmarkNode* parent,
BookmarkNode* node) {
- std::wstring title;
- if (!value.GetString(kNameKey, &title))
+ string16 title;
+ if (!value.GetString(WideToUTF16Hack(kNameKey), &title))
return false;
// TODO(sky): this should be more flexible. Don't hoark if we can't parse it
// all.
- std::wstring date_added_string;
- if (!value.GetString(kDateAddedKey, &date_added_string))
+ string16 date_added_string;
+ if (!value.GetString(WideToUTF16Hack(kDateAddedKey), &date_added_string))
return false;
- std::wstring type_string;
- if (!value.GetString(kTypeKey, &type_string))
+ string16 type_string;
+ if (!value.GetString(WideToUTF16Hack(kTypeKey), &type_string))
return false;
- if (type_string != kTypeURL && type_string != kTypeFolder)
+ if (type_string != WideToUTF16Hack(kTypeURL) &&
+ type_string != WideToUTF16Hack(kTypeFolder))
return false; // Unknown type.
- if (type_string == kTypeURL) {
- std::wstring url_string;
- if (!value.GetString(kURLKey, &url_string))
+ if (type_string == WideToUTF16Hack(kTypeURL)) {
+ string16 url_string;
+ if (!value.GetString(WideToUTF16Hack(kURLKey), &url_string))
return false;
// TODO(sky): this should ignore the node if not a valid URL.
if (!node)
- node = new BookmarkNode(model, GURL(WideToUTF8(url_string)));
+ node = new BookmarkNode(model, GURL(UTF16ToUTF8(url_string)));
if (parent)
parent->Add(parent->GetChildCount(), node);
node->type_ = history::StarredEntry::URL;
} else {
- std::wstring last_modified_date;
- if (!value.GetString(kDateModifiedKey, &last_modified_date))
+ string16 last_modified_date;
+ if (!value.GetString(WideToUTF16Hack(kDateModifiedKey),
+ &last_modified_date))
return false;
Value* child_values;
- if (!value.Get(kChildrenKey, &child_values))
+ if (!value.Get(WideToUTF16Hack(kChildrenKey), &child_values))
return false;
if (child_values->GetType() != Value::TYPE_LIST)
@@ -175,8 +184,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(WideToUTF16Hack(last_modified_date)));
+ node->date_group_modified_ =
+ Time::FromInternalValue(StringToInt64(last_modified_date));
if (parent)
parent->Add(parent->GetChildCount(), node);
@@ -185,8 +194,8 @@ bool BookmarkCodec::DecodeNode(BookmarkModel* model,
return false;
}
- node->SetTitle(title);
- node->date_added_ = Time::FromInternalValue(
- StringToInt64(WideToUTF16Hack(date_added_string)));
+ node->SetTitle(UTF16ToWideHack(title));
+ node->date_added_ =
+ Time::FromInternalValue(StringToInt64(date_added_string));
return true;
}
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc
index 5ec7ca0..4209ab9 100644
--- a/chrome/browser/bookmarks/bookmark_html_writer.cc
+++ b/chrome/browser/bookmarks/bookmark_html_writer.cc
@@ -85,7 +85,7 @@ class Writer : public Task {
if (!Write(kHeader) ||
bookmarks_->GetType() != Value::TYPE_DICTIONARY ||
!static_cast<DictionaryValue*>(bookmarks_.get())->Get(
- BookmarkCodec::kRootsKey, &roots) ||
+ WideToUTF16Hack(BookmarkCodec::kRootsKey), &roots) ||
roots->GetType() != Value::TYPE_DICTIONARY) {
NOTREACHED();
return;
@@ -94,11 +94,12 @@ class Writer : public Task {
DictionaryValue* roots_d_value = static_cast<DictionaryValue*>(roots);
Value* root_folder_value;
Value* other_folder_value;
- if (!roots_d_value->Get(BookmarkCodec::kRootFolderNameKey,
+ if (!roots_d_value->Get(WideToUTF16Hack(BookmarkCodec::kRootFolderNameKey),
&root_folder_value) ||
root_folder_value->GetType() != Value::TYPE_DICTIONARY ||
- !roots_d_value->Get(BookmarkCodec::kOtherBookmarFolderNameKey,
- &other_folder_value) ||
+ !roots_d_value->Get(
+ WideToUTF16Hack(BookmarkCodec::kOtherBookmarFolderNameKey),
+ &other_folder_value) ||
other_folder_value->GetType() != Value::TYPE_DICTIONARY) {
NOTREACHED();
return; // Invalid type for root folder and/or other folder.
@@ -203,29 +204,32 @@ class Writer : public Task {
// Writes the node and all its children, returning true on success.
bool WriteNode(const DictionaryValue& value,
history::StarredEntry::Type folder_type) {
- std::wstring title, date_added_string, type_string;
- if (!value.GetString(BookmarkCodec::kNameKey, &title) ||
- !value.GetString(BookmarkCodec::kDateAddedKey, &date_added_string) ||
- !value.GetString(BookmarkCodec::kTypeKey, &type_string) ||
- (type_string != BookmarkCodec::kTypeURL &&
- type_string != BookmarkCodec::kTypeFolder)) {
+ string16 title, date_added_string, type_string;
+ if (!value.GetString(WideToUTF16Hack(BookmarkCodec::kNameKey), &title) ||
+ !value.GetString(WideToUTF16Hack(BookmarkCodec::kDateAddedKey),
+ &date_added_string) ||
+ !value.GetString(WideToUTF16Hack(BookmarkCodec::kTypeKey),
+ &type_string) ||
+ (type_string != WideToUTF16Hack(BookmarkCodec::kTypeURL) &&
+ type_string != WideToUTF16Hack(BookmarkCodec::kTypeFolder))) {
NOTREACHED();
return false;
}
- if (type_string == BookmarkCodec::kTypeURL) {
- std::wstring url_string;
- if (!value.GetString(BookmarkCodec::kURLKey, &url_string)) {
+ if (type_string == WideToUTF16Hack(BookmarkCodec::kTypeURL)) {
+ string16 url_string;
+ if (!value.GetString(WideToUTF16Hack(BookmarkCodec::kURLKey),
+ &url_string)) {
NOTREACHED();
return false;
}
if (!WriteIndent() ||
!Write(kBookmarkStart) ||
- !Write(url_string, ATTRIBUTE_VALUE) ||
+ !Write(UTF16ToWideHack(url_string), ATTRIBUTE_VALUE) ||
!Write(kAddDate) ||
- !WriteTime(date_added_string) ||
+ !WriteTime(UTF16ToWideHack(date_added_string)) ||
!Write(kBookmarkAttributeEnd) ||
- !Write(title, CONTENT) ||
+ !Write(UTF16ToWideHack(title), CONTENT) ||
!Write(kBookmarkEnd) ||
!Write(kNewline)) {
return false;
@@ -234,11 +238,12 @@ class Writer : public Task {
}
// Folder.
- std::wstring last_modified_date;
+ string16 last_modified_date;
Value* child_values;
- if (!value.GetString(BookmarkCodec::kDateModifiedKey,
+ if (!value.GetString(WideToUTF16Hack(BookmarkCodec::kDateModifiedKey),
&last_modified_date) ||
- !value.Get(BookmarkCodec::kChildrenKey, &child_values) ||
+ !value.Get(WideToUTF16Hack(BookmarkCodec::kChildrenKey),
+ &child_values) ||
child_values->GetType() != Value::TYPE_LIST) {
NOTREACHED();
return false;
@@ -249,19 +254,19 @@ class Writer : public Task {
// bar folder.
if (!WriteIndent() ||
!Write(kFolderStart) ||
- !WriteTime(date_added_string) ||
+ !WriteTime(UTF16ToWideHack(date_added_string)) ||
!Write(kLastModified) ||
- !WriteTime(last_modified_date)) {
+ !WriteTime(UTF16ToWideHack(last_modified_date))) {
return false;
}
if (folder_type == history::StarredEntry::BOOKMARK_BAR) {
if (!Write(kBookmarkBar))
return false;
- title = L"Bookmark Bar";
+ title = ASCIIToUTF16("Bookmark Bar");
} else if (!Write(kFolderAttributeEnd)) {
return false;
}
- if (!Write(title, CONTENT) ||
+ if (!Write(UTF16ToWideHack(title), CONTENT) ||
!Write(kFolderEnd) ||
!Write(kNewline) ||
!WriteIndent() ||
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc
index 7f25a60..1723198f 100644
--- a/chrome/browser/browser_about_handler.cc
+++ b/chrome/browser/browser_about_handler.cc
@@ -253,8 +253,9 @@ bool BrowserAboutHandler::SupportsURL(GURL* url) {
std::string BrowserAboutHandler::AboutVersion() {
// Strings used in the JsTemplate file.
DictionaryValue localized_strings;
- localized_strings.SetString(L"title",
- l10n_util::GetString(IDS_ABOUT_VERSION_TITLE));
+ localized_strings.SetString(
+ ASCIIToUTF16("title"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_TITLE)));
scoped_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfoForCurrentModule());
if (version_info == NULL) {
@@ -272,26 +273,36 @@ std::string BrowserAboutHandler::AboutVersion() {
std::wstring js_engine = L"JavaScriptCore";
#endif
- localized_strings.SetString(L"name",
- l10n_util::GetString(IDS_PRODUCT_NAME));
- localized_strings.SetString(L"version", version_info->file_version());
- localized_strings.SetString(L"js_engine", js_engine);
- localized_strings.SetString(L"js_version", js_version);
- localized_strings.SetString(L"webkit_version", webkit_version);
- localized_strings.SetString(L"company",
- l10n_util::GetString(IDS_ABOUT_VERSION_COMPANY_NAME));
- localized_strings.SetString(L"copyright",
- l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT));
- localized_strings.SetString(L"cl", version_info->last_change());
+ localized_strings.SetString(
+ 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()));
if (version_info->is_official_build()) {
- localized_strings.SetString(L"official",
- l10n_util::GetString(IDS_ABOUT_VERSION_OFFICIAL));
+ localized_strings.SetString(
+ ASCIIToUTF16("official"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_OFFICIAL)));
} else {
- localized_strings.SetString(L"official",
- l10n_util::GetString(IDS_ABOUT_VERSION_UNOFFICIAL));
+ localized_strings.SetString(
+ ASCIIToUTF16("official"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_UNOFFICIAL)));
}
- localized_strings.SetString(L"useragent",
- UTF8ToWide(webkit_glue::GetUserAgent(GURL())));
+ localized_strings.SetString(ASCIIToUTF16("useragent"),
+ UTF8ToUTF16(webkit_glue::GetUserAgent(GURL())));
static const StringPiece version_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -332,26 +343,37 @@ std::string BrowserAboutHandler::AboutTerms() {
std::string BrowserAboutHandler::AboutPlugins() {
// Strings used in the JsTemplate file.
DictionaryValue localized_strings;
- localized_strings.SetString(L"title",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_TITLE));
- localized_strings.SetString(L"headingPlugs",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_PLUGS));
- localized_strings.SetString(L"headingNoPlugs",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_NOPLUGS));
- localized_strings.SetString(L"filename",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_FILENAME_LABEL));
- localized_strings.SetString(L"mimetype",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_MIMETYPE_LABEL));
- localized_strings.SetString(L"description",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_DESCRIPTION_LABEL));
- localized_strings.SetString(L"suffixes",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_SUFFIX_LABEL));
- localized_strings.SetString(L"enabled",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_LABEL));
- localized_strings.SetString(L"enabled_yes",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_YES));
- localized_strings.SetString(L"enabled_no",
- l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_NO));
+ localized_strings.SetString(
+ 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)));
static const StringPiece plugins_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -404,15 +426,15 @@ std::string BrowserAboutHandler::AboutStats() {
// We maintain two lists - one for counters and one for timers.
// Timers actually get stored on both lists.
ListValue* counters;
- if (!root.GetList(L"counters", &counters)) {
+ if (!root.GetList(ASCIIToUTF16("counters"), &counters)) {
counters = new ListValue();
- root.Set(L"counters", counters);
+ root.Set(ASCIIToUTF16("counters"), counters);
}
ListValue* timers;
- if (!root.GetList(L"timers", &timers)) {
+ if (!root.GetList(ASCIIToUTF16("timers"), &timers)) {
timers = new ListValue();
- root.Set(L"timers", timers);
+ root.Set(ASCIIToUTF16("timers"), timers);
}
// NOTE: Counters start at index 1.
@@ -436,9 +458,9 @@ std::string BrowserAboutHandler::AboutStats() {
scan_index < counters->GetSize(); scan_index++) {
DictionaryValue* dictionary;
if (counters->GetDictionary(scan_index, &dictionary)) {
- std::wstring scan_name;
- if (dictionary->GetString(L"name", &scan_name) &&
- WideToASCII(scan_name) == name) {
+ string16 scan_name;
+ if (dictionary->GetString(ASCIIToUTF16("name"), &scan_name) &&
+ UTF16ToUTF8(scan_name) == name) {
counter = dictionary;
}
} else {
@@ -448,7 +470,7 @@ std::string BrowserAboutHandler::AboutStats() {
if (counter == NULL) {
counter = new DictionaryValue();
- counter->SetString(L"name", ASCIIToWide(name));
+ counter->SetString(ASCIIToUTF16("name"), UTF8ToUTF16(name));
counters->Append(counter);
}
@@ -458,11 +480,11 @@ std::string BrowserAboutHandler::AboutStats() {
int new_value = table->GetRowValue(index);
int prior_value = 0;
int delta = 0;
- if (counter->GetInteger(L"value", &prior_value)) {
+ if (counter->GetInteger(ASCIIToUTF16("value"), &prior_value)) {
delta = new_value - prior_value;
}
- counter->SetInteger(L"value", new_value);
- counter->SetInteger(L"delta", delta);
+ counter->SetInteger(ASCIIToUTF16("value"), new_value);
+ counter->SetInteger(ASCIIToUTF16("delta"), delta);
}
break;
case 'm':
@@ -473,7 +495,7 @@ std::string BrowserAboutHandler::AboutStats() {
case 't':
{
int time = table->GetRowValue(index);
- counter->SetInteger(L"time", time);
+ counter->SetInteger(ASCIIToUTF16("time"), time);
// Store this on the timers list as well.
timers->Append(counter);
@@ -519,16 +541,21 @@ void AboutMemoryHandler::BindProcessMetrics(DictionaryValue* data,
DCHECK(data && info);
// Bind metrics to dictionary.
- data->SetInteger(L"ws_priv", static_cast<int>(info->working_set.priv));
- data->SetInteger(L"ws_shareable",
+ data->SetInteger(ASCIIToUTF16("ws_priv"),
+ static_cast<int>(info->working_set.priv));
+ data->SetInteger(ASCIIToUTF16("ws_shareable"),
static_cast<int>(info->working_set.shareable));
- data->SetInteger(L"ws_shared", static_cast<int>(info->working_set.shared));
- data->SetInteger(L"comm_priv", static_cast<int>(info->committed.priv));
- data->SetInteger(L"comm_map", static_cast<int>(info->committed.mapped));
- data->SetInteger(L"comm_image", static_cast<int>(info->committed.image));
- data->SetInteger(L"pid", info->pid);
- data->SetString(L"version", info->version);
- data->SetInteger(L"processes", info->num_processes);
+ data->SetInteger(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);
}
// Helper for AboutMemory to append memory usage information for all
@@ -545,9 +572,9 @@ void AboutMemoryHandler::AppendProcess(ListValue* child_data,
std::wstring child_label(ChildProcessInfo::GetTypeNameInEnglish(info->type));
if (info->is_diagnostics)
child_label.append(L" (diagnostics)");
- child->SetString(L"child_name", child_label);
+ child->SetString(ASCIIToUTF16("child_name"), WideToUTF16Hack(child_label));
ListValue* titles = new ListValue();
- child->Set(L"titles", titles);
+ child->Set(ASCIIToUTF16("titles"), titles);
for (size_t i = 0; i < info->titles.size(); ++i)
titles->Append(new StringValue(info->titles[i]));
}
@@ -557,7 +584,7 @@ void AboutMemoryHandler::OnDetailsAvailable() {
// the root of the JSON hierarchy for about:memory jstemplate
DictionaryValue root;
ListValue* browsers = new ListValue();
- root.Set(L"browsers", browsers);
+ root.Set(ASCIIToUTF16("browsers"), browsers);
ProcessData* browser_processes = processes();
@@ -588,7 +615,8 @@ void AboutMemoryHandler::OnDetailsAvailable() {
}
DictionaryValue* browser_data = new DictionaryValue();
browsers->Append(browser_data);
- browser_data->SetString(L"name", browser_processes[index].name);
+ browser_data->SetString(ASCIIToUTF16("name"),
+ WideToUTF16Hack(browser_processes[index].name));
BindProcessMetrics(browser_data, &aggregate);
@@ -608,9 +636,9 @@ void AboutMemoryHandler::OnDetailsAvailable() {
// Set the browser & renderer detailed process data.
DictionaryValue* browser_data = new DictionaryValue();
- root.Set(L"browzr_data", browser_data);
+ root.Set(ASCIIToUTF16("browzr_data"), browser_data);
ListValue* child_data = new ListValue();
- root.Set(L"child_data", child_data);
+ root.Set(ASCIIToUTF16("child_data"), child_data);
ProcessData process = browser_processes[0]; // Chrome is the first browser.
for (size_t index = 0; index < process.processes.size(); index++) {
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index d4ec343..a3d8dba 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -113,8 +113,10 @@ void SetOverrideHomePage(const CommandLine& command_line,
std::wstring new_homepage = URLFixerUpper::FixupRelativeFile(
browser_directory,
command_line.GetSwitchValue(switches::kHomePage));
- prefs->transient()->SetString(prefs::kHomePage, new_homepage);
- prefs->transient()->SetBoolean(prefs::kHomePageIsNewTabPage, false);
+ prefs->transient()->SetString(WideToUTF16Hack(prefs::kHomePage),
+ WideToUTF16Hack(new_homepage));
+ prefs->transient()->SetBoolean(
+ WideToUTF16Hack(prefs::kHomePageIsNewTabPage), false);
}
}
@@ -474,7 +476,8 @@ bool BrowserInit::ProcessCommandLine(
SetOverrideHomePage(command_line, profile->GetPrefs());
if (command_line.HasSwitch(switches::kBrowserStartRenderersManually))
- prefs->transient()->SetBoolean(prefs::kStartRenderersManually, true);
+ prefs->transient()->SetBoolean(
+ WideToUTF16Hack(prefs::kStartRenderersManually), true);
bool silent_launch = false;
#if defined(OS_WIN)
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index fc4513c..07c87fc 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -144,16 +144,22 @@ void HandleErrorTestParameters(const CommandLine& command_line) {
struct LazyDirectoryListerCacher {
LazyDirectoryListerCacher() {
DictionaryValue value;
- value.SetString(L"header",
- l10n_util::GetString(IDS_DIRECTORY_LISTING_HEADER));
- value.SetString(L"parentDirText",
- l10n_util::GetString(IDS_DIRECTORY_LISTING_PARENT));
- value.SetString(L"headerName",
- l10n_util::GetString(IDS_DIRECTORY_LISTING_NAME));
- value.SetString(L"headerSize",
- l10n_util::GetString(IDS_DIRECTORY_LISTING_SIZE));
- value.SetString(L"headerDateModified",
- l10n_util::GetString(IDS_DIRECTORY_LISTING_DATE_MODIFIED));
+ value.SetString(
+ 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)));
html_data = jstemplate_builder::GetTemplateHtml(
ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_DIR_HEADER_HTML),
@@ -508,8 +514,8 @@ int BrowserMain(const MainFunctionParams& parameters) {
MetricsService* metrics = NULL;
if (!parsed_command_line.HasSwitch(switches::kDisableMetrics)) {
if (parsed_command_line.HasSwitch(switches::kMetricsRecordingOnly)) {
- local_state->transient()->SetBoolean(prefs::kMetricsReportingEnabled,
- false);
+ local_state->transient()->SetBoolean(
+ WideToUTF16Hack(prefs::kMetricsReportingEnabled), false);
}
metrics = browser_process->metrics_service();
DCHECK(metrics);
diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc
index b0efcad..23ac2c3 100644
--- a/chrome/browser/dom_ui/dom_ui.cc
+++ b/chrome/browser/dom_ui/dom_ui.cc
@@ -111,7 +111,7 @@ void DOMMessageHandler::SetURLAndTitle(DictionaryValue* dictionary,
std::wstring title,
const GURL& gurl) {
std::wstring wstring_url = UTF8ToWide(gurl.spec());
- dictionary->SetString(L"url", wstring_url);
+ dictionary->SetString(ASCIIToUTF16("url"), WideToUTF16Hack(wstring_url));
bool using_url_as_the_title = false;
if (title.empty()) {
@@ -133,7 +133,7 @@ void DOMMessageHandler::SetURLAndTitle(DictionaryValue* dictionary,
DCHECK(success ? (title != title_to_set) : (title == title_to_set));
}
}
- dictionary->SetString(L"title", title_to_set);
+ dictionary->SetString(ASCIIToUTF16("title"), WideToUTF16Hack(title_to_set));
}
bool DOMMessageHandler::ExtractIntegerValue(const Value* value, int* out_int) {
diff --git a/chrome/browser/dom_ui/history_ui.cc b/chrome/browser/dom_ui/history_ui.cc
index 9bc5d61..2423458 100644
--- a/chrome/browser/dom_ui/history_ui.cc
+++ b/chrome/browser/dom_ui/history_ui.cc
@@ -49,32 +49,34 @@ HistoryUIHTMLSource::HistoryUIHTMLSource()
void HistoryUIHTMLSource::StartDataRequest(const std::string& path,
int request_id) {
DictionaryValue localized_strings;
- localized_strings.SetString(L"title",
- l10n_util::GetString(IDS_HISTORY_TITLE));
- localized_strings.SetString(L"loading",
- l10n_util::GetString(IDS_HISTORY_LOADING));
- localized_strings.SetString(L"newest",
- l10n_util::GetString(IDS_HISTORY_NEWEST));
- localized_strings.SetString(L"newer",
- l10n_util::GetString(IDS_HISTORY_NEWER));
- localized_strings.SetString(L"older",
- l10n_util::GetString(IDS_HISTORY_OLDER));
- localized_strings.SetString(L"searchresultsfor",
- l10n_util::GetString(IDS_HISTORY_SEARCHRESULTSFOR));
- localized_strings.SetString(L"history",
- l10n_util::GetString(IDS_HISTORY_BROWSERESULTS));
- localized_strings.SetString(L"cont",
- l10n_util::GetString(IDS_HISTORY_CONTINUED));
- localized_strings.SetString(L"searchbutton",
- l10n_util::GetString(IDS_HISTORY_SEARCH_BUTTON));
- localized_strings.SetString(L"noresults",
- l10n_util::GetString(IDS_HISTORY_NO_RESULTS));
- localized_strings.SetString(L"noitems",
- l10n_util::GetString(IDS_HISTORY_NO_ITEMS));
- localized_strings.SetString(L"deleteday",
- l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_LINK));
- localized_strings.SetString(L"deletedaywarning",
- l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING));
+ localized_strings.SetString(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)));
static const StringPiece history_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -226,7 +228,7 @@ void BrowsingHistoryHandler::QueryComplete(
SetURLAndTitle(page_value, page.title(), page.url());
// Need to pass the time in epoch time (fastest JS conversion).
- page_value->SetInteger(L"time",
+ page_value->SetInteger(ASCIIToUTF16("time"),
static_cast<int>(page.visit_time().ToTimeT()));
// Until we get some JS i18n infrastructure, we also need to
@@ -246,15 +248,19 @@ void BrowsingHistoryHandler::QueryComplete(
IDS_HISTORY_DATE_WITH_RELATIVE_TIME,
date_str, base::TimeFormatFriendlyDate(page.visit_time()));
}
- page_value->SetString(L"dateRelativeDay", date_str);
- page_value->SetString(L"dateTimeOfDay",
- base::TimeFormatTimeOfDay(page.visit_time()));
+ page_value->SetString(ASCIIToUTF16("dateRelativeDay"),
+ WideToUTF16Hack(date_str));
+ page_value->SetString(
+ ASCIIToUTF16("dateTimeOfDay"),
+ WideToUTF16Hack(base::TimeFormatTimeOfDay(page.visit_time())));
} else {
- page_value->SetString(L"dateShort",
- base::TimeFormatShortDate(page.visit_time()));
- page_value->SetString(L"snippet", page.snippet().text());
+ page_value->SetString(
+ ASCIIToUTF16("dateShort"),
+ WideToUTF16Hack(base::TimeFormatShortDate(page.visit_time())));
+ page_value->SetString(
+ ASCIIToUTF16("snippet"), WideToUTF16Hack(page.snippet().text()));
}
- page_value->SetBoolean(L"starred",
+ page_value->SetBoolean(ASCIIToUTF16("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 afb7baa..1195cc9 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -125,14 +125,14 @@ class PaintTimer : public RenderWidgetHost::PaintObserver {
void SetURLTitleAndDirection(DictionaryValue* dictionary,
const std::wstring& title,
const GURL& gurl) {
- std::wstring wstring_url = UTF8ToWide(gurl.spec());
- dictionary->SetString(L"url", wstring_url);
+ string16 string_url = UTF8ToUTF16(gurl.spec());
+ dictionary->SetString(ASCIIToUTF16("url"), string_url);
bool using_url_as_the_title = false;
std::wstring title_to_set(title);
if (title_to_set.empty()) {
using_url_as_the_title = true;
- title_to_set = wstring_url;
+ title_to_set = UTF16ToWideHack(string_url);
}
// We set the "dir" attribute of the title, so that in RTL locales, a LTR
@@ -168,8 +168,8 @@ void SetURLTitleAndDirection(DictionaryValue* dictionary,
}
}
}
- dictionary->SetString(L"title", title_to_set);
- dictionary->SetString(L"direction", direction);
+ dictionary->SetString(ASCIIToUTF16("title"), WideToUTF16Hack(title_to_set));
+ dictionary->SetString(ASCIIToUTF16("direction"), WideToUTF16Hack(direction));
}
} // end anonymous namespace
@@ -208,35 +208,43 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path,
profile_name);
}
DictionaryValue localized_strings;
- localized_strings.SetString(L"title", title);
- localized_strings.SetString(L"mostvisited", most_visited);
- localized_strings.SetString(L"searches",
- l10n_util::GetString(IDS_NEW_TAB_SEARCHES));
- localized_strings.SetString(L"bookmarks",
- l10n_util::GetString(IDS_NEW_TAB_BOOKMARKS));
- localized_strings.SetString(L"showhistory",
- l10n_util::GetString(IDS_NEW_TAB_HISTORY_SHOW));
- localized_strings.SetString(L"searchhistory",
- l10n_util::GetString(IDS_NEW_TAB_HISTORY_SEARCH));
- localized_strings.SetString(L"recentlyclosed",
- l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED));
- localized_strings.SetString(L"mostvisitedintro",
- l10n_util::GetStringF(IDS_NEW_TAB_MOST_VISITED_INTRO,
- l10n_util::GetString(IDS_WELCOME_PAGE_URL)));
- localized_strings.SetString(L"closedwindow",
- l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW));
-
- localized_strings.SetString(L"textdirection",
- (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- kRTLHtmlTextDirection : kDefaultHtmlTextDirection);
+ localized_strings.SetString(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));
// Let the tab know whether it's the first tab being viewed.
- localized_strings.SetString(L"firstview",
- first_view_ ? L"true" : std::wstring());
+ localized_strings.SetString(ASCIIToUTF16("firstview"),
+ first_view_ ? ASCIIToUTF16("true") : string16());
first_view_ = false;
#ifdef CHROME_PERSONALIZATION
- localized_strings.SetString(L"p13nsrc", Personalization::GetNewTabSource());
+ localized_strings.SetString(ASCIIToUTF16("p13nsrc"),
+ Personalization::GetNewTabSource());
#endif
static const StringPiece new_tab_html(
@@ -263,15 +271,19 @@ IncognitoTabHTMLSource::IncognitoTabHTMLSource()
void IncognitoTabHTMLSource::StartDataRequest(const std::string& path,
int request_id) {
DictionaryValue localized_strings;
- localized_strings.SetString(L"title",
- l10n_util::GetString(IDS_NEW_TAB_TITLE));
- localized_strings.SetString(L"content",
- l10n_util::GetStringF(IDS_NEW_TAB_OTR_MESSAGE,
- l10n_util::GetString(IDS_LEARN_MORE_INCOGNITO_URL)));
-
- localized_strings.SetString(L"textdirection",
- (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- kRTLHtmlTextDirection : kDefaultHtmlTextDirection);
+ localized_strings.SetString(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));
static const StringPiece incognito_tab_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -481,12 +493,15 @@ void TemplateURLHandler::OnTemplateURLModelChanged() {
if (!urlref)
continue;
DictionaryValue* entry_value = new DictionaryValue;
- entry_value->SetString(L"short_name", urls[i]->short_name());
- entry_value->SetString(L"keyword", urls[i]->keyword());
+ entry_value->SetString(ASCIIToUTF16("short_name"),
+ WideToUTF16Hack(urls[i]->short_name()));
+ entry_value->SetString(ASCIIToUTF16("keyword"),
+ WideToUTF16Hack(urls[i]->keyword()));
const GURL& url = urls[i]->GetFavIconURL();
if (url.is_valid())
- entry_value->SetString(L"favIconURL", UTF8ToWide(url.spec()));
+ entry_value->SetString(ASCIIToUTF16("favIconURL"),
+ UTF8ToUTF16(url.spec()));
urls_value.Append(entry_value);
}
@@ -645,7 +660,7 @@ void RecentlyClosedTabsHandler::TabRestoreServiceChanged(
(entry->type == TabRestoreService::WINDOW &&
WindowToValue(*static_cast<TabRestoreService::Window*>(entry),
value))) {
- value->SetInteger(L"sessionId", entry->id);
+ value->SetInteger(ASCIIToUTF16("sessionId"), entry->id);
list_value.Append(value);
added_count++;
} else {
@@ -673,7 +688,7 @@ bool RecentlyClosedTabsHandler::TabToValue(
SetURLTitleAndDirection(dictionary, current_navigation.title(),
current_navigation.url());
- dictionary->SetString(L"type", L"tab");
+ dictionary->SetString(ASCIIToUTF16("type"), ASCIIToUTF16("tab"));
return true;
}
@@ -698,8 +713,8 @@ bool RecentlyClosedTabsHandler::WindowToValue(
return false;
}
- dictionary->SetString(L"type", L"window");
- dictionary->Set(L"tabs", tab_values);
+ dictionary->SetString(ASCIIToUTF16("type"), ASCIIToUTF16("window"));
+ dictionary->Set(ASCIIToUTF16("tabs"), tab_values);
return true;
}
diff --git a/chrome/browser/extensions/extension.cc b/chrome/browser/extensions/extension.cc
index 918268f..1db97ceb 100644
--- a/chrome/browser/extensions/extension.cc
+++ b/chrome/browser/extensions/extension.cc
@@ -163,14 +163,14 @@ bool Extension::InitFromValue(const DictionaryValue& source,
std::string* error) {
// Check format version.
int format_version = 0;
- if (!source.GetInteger(kFormatVersionKey, &format_version) ||
+ if (!source.GetInteger(WideToUTF16Hack(kFormatVersionKey), &format_version) ||
static_cast<uint32>(format_version) != kExpectedFormatVersion) {
*error = kInvalidFormatVersionError;
return false;
}
// Initialize id.
- if (!source.GetString(kIdKey, &id_)) {
+ if (!source.GetString(WideToUTF16Hack(kIdKey), &id_)) {
*error = kInvalidIdError;
return false;
}
@@ -193,7 +193,7 @@ bool Extension::InitFromValue(const DictionaryValue& source,
// Initialize version.
std::string version_str;
- if (!source.GetString(kVersionKey, &version_str)) {
+ if (!source.GetString(WideToUTF16Hack(kVersionKey), &version_str)) {
*error = kInvalidVersionError;
return false;
}
@@ -204,14 +204,14 @@ bool Extension::InitFromValue(const DictionaryValue& source,
}
// Initialize name.
- if (!source.GetString(kNameKey, &name_)) {
+ if (!source.GetString(WideToUTF16Hack(kNameKey), &name_)) {
*error = kInvalidNameError;
return false;
}
// Initialize description (optional).
- if (source.HasKey(kDescriptionKey)) {
- if (!source.GetString(kDescriptionKey, &description_)) {
+ if (source.HasKey(WideToUTF16Hack(kDescriptionKey))) {
+ if (!source.GetString(WideToUTF16Hack(kDescriptionKey), &description_)) {
*error = kInvalidDescriptionError;
return false;
}
@@ -220,17 +220,17 @@ bool Extension::InitFromValue(const DictionaryValue& source,
// Initialize zip hash (only present in zip)
// There's no need to verify it at this point. If it's in a bogus format
// it won't pass the hash verify step.
- if (source.HasKey(kZipHashKey)) {
- if (!source.GetString(kZipHashKey, &zip_hash_)) {
+ if (source.HasKey(WideToUTF16Hack(kZipHashKey))) {
+ if (!source.GetString(WideToUTF16Hack(kZipHashKey), &zip_hash_)) {
*error = kInvalidZipHashError;
return false;
}
}
// Initialize plugins dir (optional).
- if (source.HasKey(kPluginsDirKey)) {
+ if (source.HasKey(WideToUTF16Hack(kPluginsDirKey))) {
std::string plugins_dir;
- if (!source.GetString(kPluginsDirKey, &plugins_dir)) {
+ if (!source.GetString(WideToUTF16Hack(kPluginsDirKey), &plugins_dir)) {
*error = kInvalidPluginsDirError;
return false;
}
@@ -238,9 +238,9 @@ bool Extension::InitFromValue(const DictionaryValue& source,
}
// Initialize content scripts (optional).
- if (source.HasKey(kContentScriptsKey)) {
+ if (source.HasKey(WideToUTF16Hack(kContentScriptsKey))) {
ListValue* list_value;
- if (!source.GetList(kContentScriptsKey, &list_value)) {
+ if (!source.GetList(WideToUTF16Hack(kContentScriptsKey), &list_value)) {
*error = kInvalidContentScriptsListError;
return false;
}
@@ -255,12 +255,12 @@ bool Extension::InitFromValue(const DictionaryValue& source,
ListValue* matches;
ListValue* js;
- if (!content_script->GetList(kMatchesKey, &matches)) {
+ if (!content_script->GetList(WideToUTF16Hack(kMatchesKey), &matches)) {
*error = FormatErrorMessage(kInvalidMatchesError, IntToString(i));
return false;
}
- if (!content_script->GetList(kJsKey, &js)) {
+ if (!content_script->GetList(WideToUTF16Hack(kJsKey), &js)) {
*error = FormatErrorMessage(kInvalidJsListError, IntToString(i));
return false;
}
@@ -277,9 +277,10 @@ bool Extension::InitFromValue(const DictionaryValue& source,
}
UserScript script;
- if (content_script->HasKey(kRunAtKey)) {
+ if (content_script->HasKey(WideToUTF16Hack(kRunAtKey))) {
std::string run_location;
- if (!content_script->GetString(kRunAtKey, &run_location)) {
+ if (!content_script->GetString(WideToUTF16Hack(kRunAtKey),
+ &run_location)) {
*error = FormatErrorMessage(kInvalidRunAtError, IntToString(i));
return false;
}
@@ -328,4 +329,3 @@ bool Extension::InitFromValue(const DictionaryValue& source,
return true;
}
-
diff --git a/chrome/browser/extensions/extension_unittest.cc b/chrome/browser/extensions/extension_unittest.cc
index aa8d791..7d41b0c 100644
--- a/chrome/browser/extensions/extension_unittest.cc
+++ b/chrome/browser/extensions/extension_unittest.cc
@@ -43,64 +43,65 @@ TEST(ExtensionTest, InitFromValueInvalid) {
// Test missing and invalid format versions
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->Remove(Extension::kFormatVersionKey, NULL);
+ input_value->Remove(WideToUTF16Hack(Extension::kFormatVersionKey), NULL);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidFormatVersionError, error);
- input_value->SetString(Extension::kFormatVersionKey, "foo");
+ input_value->SetString(WideToUTF16Hack(Extension::kFormatVersionKey), "foo");
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidFormatVersionError, error);
- input_value->SetInteger(Extension::kFormatVersionKey, 2);
+ input_value->SetInteger(WideToUTF16Hack(Extension::kFormatVersionKey), 2);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidFormatVersionError, error);
// Test missing and invalid ids
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->Remove(Extension::kIdKey, NULL);
+ input_value->Remove(WideToUTF16Hack(Extension::kIdKey), NULL);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidIdError, error);
- input_value->SetInteger(Extension::kIdKey, 42);
+ input_value->SetInteger(WideToUTF16Hack(Extension::kIdKey), 42);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidIdError, error);
// Test missing and invalid versions
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->Remove(Extension::kVersionKey, NULL);
+ input_value->Remove(WideToUTF16Hack(Extension::kVersionKey), NULL);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidVersionError, error);
- input_value->SetInteger(Extension::kVersionKey, 42);
+ input_value->SetInteger(WideToUTF16Hack(Extension::kVersionKey), 42);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidVersionError, error);
// Test missing and invalid names
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->Remove(Extension::kNameKey, NULL);
+ input_value->Remove(WideToUTF16Hack(Extension::kNameKey), NULL);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidNameError, error);
- input_value->SetInteger(Extension::kNameKey, 42);
+ input_value->SetInteger(WideToUTF16Hack(Extension::kNameKey), 42);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidNameError, error);
// Test invalid description
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->SetInteger(Extension::kDescriptionKey, 42);
+ input_value->SetInteger(WideToUTF16Hack(Extension::kDescriptionKey), 42);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidDescriptionError, error);
// Test invalid user scripts list
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->SetInteger(Extension::kContentScriptsKey, 42);
+ input_value->SetInteger(WideToUTF16Hack(Extension::kContentScriptsKey), 42);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_EQ(Extension::kInvalidContentScriptsListError, error);
// Test invalid user script item
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
ListValue* content_scripts = NULL;
- input_value->GetList(Extension::kContentScriptsKey, &content_scripts);
+ input_value->GetList(WideToUTF16Hack(Extension::kContentScriptsKey),
+ &content_scripts);
ASSERT_FALSE(NULL == content_scripts);
content_scripts->Set(0, Value::CreateIntegerValue(42));
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
@@ -108,19 +109,21 @@ TEST(ExtensionTest, InitFromValueInvalid) {
// Test missing and invalid matches array
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->GetList(Extension::kContentScriptsKey, &content_scripts);
+ input_value->GetList(WideToUTF16Hack(Extension::kContentScriptsKey),
+ &content_scripts);
DictionaryValue* user_script = NULL;
content_scripts->GetDictionary(0, &user_script);
- user_script->Remove(Extension::kMatchesKey, NULL);
+ user_script->Remove(WideToUTF16Hack(Extension::kMatchesKey), NULL);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchesError));
- user_script->Set(Extension::kMatchesKey, Value::CreateIntegerValue(42));
+ user_script->Set(WideToUTF16Hack(Extension::kMatchesKey),
+ Value::CreateIntegerValue(42));
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchesError));
ListValue* matches = new ListValue;
- user_script->Set(Extension::kMatchesKey, matches);
+ user_script->Set(WideToUTF16Hack(Extension::kMatchesKey), matches);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchCountError));
@@ -131,18 +134,20 @@ TEST(ExtensionTest, InitFromValueInvalid) {
// Test missing and invalid files array
input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy()));
- input_value->GetList(Extension::kContentScriptsKey, &content_scripts);
+ input_value->GetList(WideToUTF16Hack(Extension::kContentScriptsKey),
+ &content_scripts);
content_scripts->GetDictionary(0, &user_script);
- user_script->Remove(Extension::kJsKey, NULL);
+ user_script->Remove(WideToUTF16Hack(Extension::kJsKey), NULL);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsListError));
- user_script->Set(Extension::kJsKey, Value::CreateIntegerValue(42));
+ user_script->Set(WideToUTF16Hack(Extension::kJsKey),
+ Value::CreateIntegerValue(42));
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsListError));
ListValue* files = new ListValue;
- user_script->Set(Extension::kJsKey, files);
+ user_script->Set(WideToUTF16Hack(Extension::kJsKey), files);
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsCountError));
@@ -169,11 +174,14 @@ TEST(ExtensionTest, InitFromValueValid) {
DictionaryValue input_value;
// Test minimal 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");
+ 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"));
EXPECT_TRUE(extension.InitFromValue(input_value, &error));
EXPECT_EQ("", error);
@@ -193,11 +201,14 @@ TEST(ExtensionTest, GetResourceURLAndPath) {
#endif
Extension extension(path);
DictionaryValue input_value;
- 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");
+ 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"));
EXPECT_TRUE(extension.InitFromValue(input_value, NULL));
EXPECT_EQ(extension.url().spec() + "bar/baz.js",
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 3271920..be6f068 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -402,14 +402,15 @@ DictionaryValue* ExtensionsServiceBackend::ReadManifest() {
// again later, checking it here allows us to skip some potentially expensive
// work.
std::string id;
- if (!manifest->GetString(Extension::kIdKey, &id)) {
+ if (!manifest->GetString(WideToUTF16Hack(Extension::kIdKey), &id)) {
ReportExtensionInstallError("missing id key");
return NULL;
}
FilePath dest_dir = install_directory_.AppendASCII(id.c_str());
if (file_util::PathExists(dest_dir)) {
std::string version;
- if (!manifest->GetString(Extension::kVersionKey, &version)) {
+ if (!manifest->GetString(WideToUTF16Hack(Extension::kVersionKey),
+ &version)) {
ReportExtensionInstallError("missing version key");
return NULL;
}
@@ -421,7 +422,8 @@ DictionaryValue* ExtensionsServiceBackend::ReadManifest() {
}
std::string zip_hash;
- if (!manifest->GetString(Extension::kZipHashKey, &zip_hash)) {
+ if (!manifest->GetString(WideToUTF16Hack(Extension::kZipHashKey),
+ &zip_hash)) {
ReportExtensionInstallError("missing zip_hash key");
return NULL;
}
diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc
index c4d2344..beda4d8 100644
--- a/chrome/browser/extensions/extensions_ui.cc
+++ b/chrome/browser/extensions/extensions_ui.cc
@@ -30,8 +30,9 @@ ExtensionsUIHTMLSource::ExtensionsUIHTMLSource()
void ExtensionsUIHTMLSource::StartDataRequest(const std::string& path,
int request_id) {
DictionaryValue localized_strings;
- localized_strings.SetString(L"title",
- l10n_util::GetString(IDS_EXTENSIONS_TITLE));
+ localized_strings.SetString(
+ ASCIIToUTF16("title"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_EXTENSIONS_TITLE)));
static const StringPiece extensions_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -87,4 +88,3 @@ GURL ExtensionsUI::GetBaseURL() {
url += kExtensionsHost;
return GURL(url);
}
-
diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc
index 2d3f924..306dcf6 100644
--- a/chrome/browser/importer/importer.cc
+++ b/chrome/browser/importer/importer.cc
@@ -658,25 +658,24 @@ void ImporterHost::DetectFirefoxProfiles() {
std::wstring source_path;
for (int i = 0; ; ++i) {
- std::wstring current_profile = L"Profile" + IntToWString(i);
+ string16 current_profile = ASCIIToUTF16("Profile") + IntToString16(i);
if (!root.HasKey(current_profile)) {
// Profiles are continuously numbered. So we exit when we can't
// find the i-th one.
break;
}
- 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);
+ string16 is_relative, path, profile_path;
+ if (root.GetString(current_profile + ASCIIToUTF16(".IsRelative"),
+ &is_relative) &&
+ root.GetString(current_profile + ASCIIToUTF16(".Path"), &path)) {
ReplaceSubstringsAfterOffset(
- &path16, 0, ASCIIToUTF16("/"), ASCIIToUTF16("\\"));
- path.assign(UTF16ToWideHack(path16));
+ &path, 0, ASCIIToUTF16("/"), ASCIIToUTF16("\\"));
#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 == L"1") {
+ if (is_relative == ASCIIToUTF16("1")) {
profile_path = file_util::GetDirectoryFromPath(ini_file);
file_util::AppendToPath(&profile_path, path);
} else {
@@ -687,12 +686,13 @@ 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.
- std::wstring is_default;
- if ((root.GetString(current_profile + L".Default", &is_default) &&
- is_default == L"1") || i == 0) {
- source_path = profile_path;
+ string16 is_default;
+ if ((root.GetString(current_profile + ASCIIToUTF16(".Default"),
+ &is_default) &&
+ is_default == ASCIIToUTF16("1")) || i == 0) {
+ source_path = UTF16ToWideHack(profile_path);
// We break out of the loop when we have found the default profile.
- if (is_default == L"1")
+ if (is_default == ASCIIToUTF16("1"))
break;
}
}
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index a504b11..9c045d8 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -383,24 +383,28 @@ void MetricsLog::WritePluginStabilityElements(PrefService* pref) {
}
DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter);
- std::wstring plugin_name;
- plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name);
+ string16 plugin_name;
+ plugin_dict->GetString(WideToUTF16Hack(prefs::kStabilityPluginName),
+ &plugin_name);
OPEN_ELEMENT_FOR_SCOPE("pluginstability");
// Use "filename" instead of "name", otherwise we need to update the
// UMA servers.
- WriteAttribute("filename", CreateBase64Hash(WideToUTF8(plugin_name)));
+ WriteAttribute("filename", CreateBase64Hash(UTF16ToUTF8(plugin_name)));
int launches = 0;
- plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches);
+ plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches),
+ &launches);
WriteIntAttribute("launchcount", launches);
int instances = 0;
- plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances);
+ plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances),
+ &instances);
WriteIntAttribute("instancecount", instances);
int crashes = 0;
- plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes);
+ plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes),
+ &crashes);
WriteIntAttribute("crashcount", crashes);
}
@@ -568,10 +572,11 @@ void MetricsLog::WriteAllProfilesMetrics(
const std::wstring profile_prefix(prefs::kProfilePrefix);
for (DictionaryValue::key_iterator i = all_profiles_metrics.begin_keys();
i != all_profiles_metrics.end_keys(); ++i) {
- const std::wstring& key_name = *i;
+ const string16 key_name16 = *i;
+ const std::wstring& key_name = UTF16ToWideHack(key_name16);
if (key_name.compare(0, profile_prefix.size(), profile_prefix) == 0) {
DictionaryValue* profile;
- if (all_profiles_metrics.GetDictionary(key_name, &profile))
+ if (all_profiles_metrics.GetDictionary(key_name16, &profile))
WriteProfileMetrics(key_name.substr(profile_prefix.size()), *profile);
}
}
@@ -585,13 +590,13 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash,
i != profile_metrics.end_keys(); ++i) {
Value* value;
if (profile_metrics.Get(*i, &value)) {
- DCHECK(*i != L"id");
+ DCHECK(*i != ASCIIToUTF16("id"));
switch (value->GetType()) {
case Value::TYPE_STRING: {
std::string string_value;
if (value->GetAsString(&string_value)) {
OPEN_ELEMENT_FOR_SCOPE("profileparam");
- WriteAttribute("name", WideToUTF8(*i));
+ WriteAttribute("name", UTF16ToUTF8(*i));
WriteAttribute("value", string_value);
}
break;
@@ -601,7 +606,7 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash,
bool bool_value;
if (value->GetAsBoolean(&bool_value)) {
OPEN_ELEMENT_FOR_SCOPE("profileparam");
- WriteAttribute("name", WideToUTF8(*i));
+ WriteAttribute("name", UTF16ToUTF8(*i));
WriteIntAttribute("value", bool_value ? 1 : 0);
}
break;
@@ -611,7 +616,7 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash,
int int_value;
if (value->GetAsInteger(&int_value)) {
OPEN_ELEMENT_FOR_SCOPE("profileparam");
- WriteAttribute("name", WideToUTF8(*i));
+ WriteAttribute("name", UTF16ToUTF8(*i));
WriteIntAttribute("value", int_value);
}
break;
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index e081bd9..8c12373 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -1675,38 +1675,46 @@ void MetricsService::RecordPluginChanges(PrefService* pref) {
}
DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*value_iter);
- std::wstring plugin_name;
- plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name);
+ string16 plugin_name;
+ plugin_dict->GetString(WideToUTF16Hack(prefs::kStabilityPluginName),
+ &plugin_name);
if (plugin_name.empty()) {
NOTREACHED();
continue;
}
- if (child_process_stats_buffer_.find(plugin_name) ==
+ if (child_process_stats_buffer_.find(UTF16ToWideHack(plugin_name)) ==
child_process_stats_buffer_.end())
continue;
- ChildProcessStats stats = child_process_stats_buffer_[plugin_name];
+ ChildProcessStats stats =
+ child_process_stats_buffer_[UTF16ToWideHack(plugin_name)];
if (stats.process_launches) {
int launches = 0;
- plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches);
+ plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches),
+ &launches);
launches += stats.process_launches;
- plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, launches);
+ plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches),
+ launches);
}
if (stats.process_crashes) {
int crashes = 0;
- plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes);
+ plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes),
+ &crashes);
crashes += stats.process_crashes;
- plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, crashes);
+ plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes),
+ crashes);
}
if (stats.instances) {
int instances = 0;
- plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances);
+ plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances),
+ &instances);
instances += stats.instances;
- plugin_dict->SetInteger(prefs::kStabilityPluginInstances, instances);
+ plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances),
+ instances);
}
- child_process_stats_buffer_.erase(plugin_name);
+ child_process_stats_buffer_.erase(UTF16ToWideHack(plugin_name));
}
// Now go through and add dictionaries for plugins that didn't already have
@@ -1718,12 +1726,13 @@ void MetricsService::RecordPluginChanges(PrefService* pref) {
ChildProcessStats stats = cache_iter->second;
DictionaryValue* plugin_dict = new DictionaryValue;
- plugin_dict->SetString(prefs::kStabilityPluginName, plugin_name);
- plugin_dict->SetInteger(prefs::kStabilityPluginLaunches,
+ plugin_dict->SetString(WideToUTF16Hack(prefs::kStabilityPluginName),
+ WideToUTF16Hack(plugin_name));
+ plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches),
stats.process_launches);
- plugin_dict->SetInteger(prefs::kStabilityPluginCrashes,
+ plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes),
stats.process_crashes);
- plugin_dict->SetInteger(prefs::kStabilityPluginInstances,
+ plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances),
stats.instances);
plugins->Append(plugin_dict);
}
@@ -1835,7 +1844,7 @@ void MetricsService::AddProfileMetric(Profile* profile,
DCHECK(prof_prefs);
const std::wstring pref_key = std::wstring(prefs::kProfilePrefix) + id_hash +
L"." + key;
- prof_prefs->SetInteger(pref_key.c_str(), value);
+ prof_prefs->SetInteger(WideToUTF16Hack(pref_key), value);
}
static bool IsSingleThreaded() {
diff --git a/chrome/browser/page_state.cc b/chrome/browser/page_state.cc
index 827416c..c970bbe 100644
--- a/chrome/browser/page_state.cc
+++ b/chrome/browser/page_state.cc
@@ -28,7 +28,7 @@ void PageState::InitWithURL(const GURL& url) {
// We know that the query string is UTF-8 since it's an internal URL.
std::wstring value = UTF8ToWide(
UnescapeURLComponent(escaped, UnescapeRule::REPLACE_PLUS_WITH_SPACE));
- state_->Set(UTF8ToWide(query_string.substr(keyComp.begin, keyComp.len)),
+ state_->Set(UTF8ToUTF16(query_string.substr(keyComp.begin, keyComp.len)),
new StringValue(value));
}
}
@@ -59,10 +59,12 @@ void PageState::GetByteRepresentation(std::string* out) const {
void PageState::SetProperty(const std::wstring& key,
const std::wstring& value) {
- state_->Set(key, new StringValue(value));
+ state_->Set(WideToUTF16Hack(key), new StringValue(value));
}
-bool PageState::GetProperty(const std::wstring& key, std::wstring* value) const {
+bool PageState::GetProperty(const std::wstring& wkey,
+ std::wstring* value) const {
+ string16 key(WideToUTF16(wkey));
if (state_->HasKey(key)) {
Value* v;
state_->Get(key, &v);
diff --git a/chrome/browser/profile_manager.h b/chrome/browser/profile_manager.h
index 3735492..e8798a2 100644
--- a/chrome/browser/profile_manager.h
+++ b/chrome/browser/profile_manager.h
@@ -15,6 +15,7 @@
#include "base/file_path.h"
#include "base/message_loop.h"
#include "base/non_thread_safe.h"
+#include "base/string_util.h"
#include "base/system_monitor.h"
#include "base/values.h"
#include "chrome/browser/profile.h"
@@ -33,20 +34,21 @@ class AvailableProfile {
// Decodes a DictionaryValue into an AvailableProfile
static AvailableProfile* FromValue(DictionaryValue* value) {
DCHECK(value);
- std::wstring name, id;
+ string16 name, id;
FilePath::StringType directory;
- value->GetString(L"name", &name);
- value->GetString(L"id", &id);
- value->GetString(L"directory", &directory);
- return new AvailableProfile(name, id, FilePath(directory));
+ value->GetString(ASCIIToUTF16("name"), &name);
+ value->GetString(ASCIIToUTF16("id"), &id);
+ value->GetString(ASCIIToUTF16("directory"), &directory);
+ return new AvailableProfile(UTF16ToWideHack(name), UTF16ToWideHack(id),
+ FilePath(directory));
}
// Encodes this AvailableProfile into a new DictionaryValue
DictionaryValue* ToValue() {
DictionaryValue* value = new DictionaryValue;
- value->SetString(L"name", name_);
- value->SetString(L"id", id_);
- value->SetString(L"directory", directory_.value());
+ value->SetString(ASCIIToUTF16("name"), WideToUTF16Hack(name_));
+ value->SetString(ASCIIToUTF16("id"), WideToUTF16Hack(id_));
+ value->SetString(ASCIIToUTF16("directory"), directory_.value());
return value;
}
@@ -183,4 +185,3 @@ class ProfileManager : public NonThreadSafe,
};
#endif // CHROME_BROWSER_PROFILE_MANAGER_H__
-
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
index 2eafe9a1..c07c750 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
@@ -103,11 +103,14 @@ void SafeBrowsingBlockingPage::PopulateStringDictionary(
const std::wstring& description1,
const std::wstring& description2,
const std::wstring& description3) {
- strings->SetString(L"title", title);
- strings->SetString(L"headLine", headline);
- strings->SetString(L"description1", description1);
- strings->SetString(L"description2", description2);
- strings->SetString(L"description3", description3);
+ strings->SetString(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));
}
void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary(
@@ -115,14 +118,17 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary(
bool malware = false;
bool phishing = false;
- std::wstring phishing_label =
- l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_LABEL);
- std::wstring phishing_link =
- l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR);
- std::wstring malware_label =
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_LABEL);
- std::wstring malware_link =
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE);
+ string16 phishing_label =
+ WideToUTF16Hack(l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_LABEL));
+ string16 phishing_link =
+ WideToUTF16Hack(
+ l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR));
+ string16 malware_label =
+ WideToUTF16Hack(
+ l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_LABEL));
+ string16 malware_link =
+ WideToUTF16Hack(
+ l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE));
ListValue* error_strings = new ListValue;
for (UnsafeResourceList::const_iterator iter = unsafe_resources_.begin();
@@ -131,20 +137,26 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary(
DictionaryValue* current_error_strings = new DictionaryValue;
if (resource.threat_type == SafeBrowsingService::URL_MALWARE) {
malware = true;
- current_error_strings->SetString(L"type", L"malware");
- current_error_strings->SetString(L"typeLabel", malware_label);
- current_error_strings->SetString(L"errorLink", malware_link);
+ current_error_strings->SetString(ASCIIToUTF16("type"),
+ ASCIIToUTF16("malware"));
+ current_error_strings->SetString(ASCIIToUTF16("typeLabel"),
+ malware_label);
+ current_error_strings->SetString(ASCIIToUTF16("errorLink"), malware_link);
} else {
DCHECK(resource.threat_type == SafeBrowsingService::URL_PHISHING);
phishing = true;
- current_error_strings->SetString(L"type", L"phishing");
- current_error_strings->SetString(L"typeLabel", phishing_label);
- current_error_strings->SetString(L"errorLink", phishing_link);
+ current_error_strings->SetString(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"url", UTF8ToWide(resource.url.spec()));
+ current_error_strings->SetString(ASCIIToUTF16("url"),
+ UTF8ToUTF16(resource.url.spec()));
error_strings->Append(current_error_strings);
}
- strings->Set(L"errors", error_strings);
+ strings->Set(ASCIIToUTF16("errors"), error_strings);
DCHECK(phishing || malware);
if (malware && phishing) {
@@ -178,15 +190,18 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary(
L"", L"");
}
- strings->SetString(L"confirm_text",
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION_AGREE));
- strings->SetString(L"continue_button",
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON));
- strings->SetString(L"back_button",
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON));
- strings->SetString(L"textdirection",
+ strings->SetString(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"),
(l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- L"rtl" : L"ltr");
+ ASCIIToUTF16("rtl") : ASCIIToUTF16("ltr"));
}
void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary(
@@ -194,7 +209,7 @@ void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary(
std::wstring link = StringPrintf(kSbDiagnosticHtml,
l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE).c_str());
- strings->SetString(L"badURL", UTF8ToWide(url().host()));
+ strings->SetString(ASCIIToUTF16("badURL"), UTF8ToUTF16(url().host()));
// Check to see if we're blocking the main page, or a sub-resource on the
// main page.
std::wstring description1, description2;
@@ -220,15 +235,18 @@ void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary(
description1, description2,
l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION3));
- strings->SetString(L"confirm_text",
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION_AGREE));
- strings->SetString(L"continue_button",
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON));
- strings->SetString(L"back_button",
- l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON));
- strings->SetString(L"textdirection",
+ strings->SetString(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"),
(l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- L"rtl" : L"ltr");
+ ASCIIToUTF16("rtl") : ASCIIToUTF16("ltr"));
}
void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary(
@@ -243,15 +261,18 @@ void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary(
UTF8ToWide(url().host())),
L"");
- strings->SetString(L"continue_button",
- l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_PROCEED_BUTTON));
- strings->SetString(L"back_button",
- l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_BACK_BUTTON));
- strings->SetString(L"report_error",
- l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR));
- strings->SetString(L"textdirection",
+ strings->SetString(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"),
(l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- L"rtl" : L"ltr");
+ ASCIIToUTF16("rtl") : ASCIIToUTF16("ltr"));
}
void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
@@ -435,4 +456,3 @@ bool SafeBrowsingBlockingPage::IsMainPage(
return unsafe_resources.size() == 1 &&
unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME;
}
-
diff --git a/chrome/browser/ssl/ssl_blocking_page.cc b/chrome/browser/ssl/ssl_blocking_page.cc
index c98975d..1983559 100644
--- a/chrome/browser/ssl/ssl_blocking_page.cc
+++ b/chrome/browser/ssl/ssl_blocking_page.cc
@@ -44,23 +44,30 @@ std::string SSLBlockingPage::GetHTMLContents() {
// Let's build the html error page.
DictionaryValue strings;
SSLErrorInfo error_info = delegate_->GetSSLErrorInfo(error_);
- strings.SetString(L"title",
- l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_TITLE));
- strings.SetString(L"headLine", error_info.title());
- strings.SetString(L"description", error_info.details());
-
- strings.SetString(L"moreInfoTitle",
- l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE));
+ strings.SetString(
+ 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)));
SetExtraInfo(&strings, error_info.extra_information());
- strings.SetString(L"proceed",
- l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_PROCEED));
- strings.SetString(L"exit",
- l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_EXIT));
+ strings.SetString(
+ 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"textdirection",
+ strings.SetString(
+ ASCIIToUTF16("textdirection"),
(l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- L"rtl" : L"ltr");
+ ASCIIToUTF16("rtl") : ASCIIToUTF16("ltr"));
static const StringPiece html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -131,15 +138,16 @@ void SSLBlockingPage::SetExtraInfo(
DictionaryValue* strings,
const std::vector<std::wstring>& extra_info) {
DCHECK(extra_info.size() < 5); // We allow 5 paragraphs max.
- const std::wstring keys[5] = {
- L"moreInfo1", L"moreInfo2", L"moreInfo3", L"moreInfo4", L"moreInfo5"
+ const string16 keys[5] = {
+ ASCIIToUTF16("moreInfo1"), ASCIIToUTF16("moreInfo2"),
+ ASCIIToUTF16("moreInfo3"), ASCIIToUTF16("moreInfo4"),
+ ASCIIToUTF16("moreInfo5")
};
int i;
for (i = 0; i < static_cast<int>(extra_info.size()); i++) {
- strings->SetString(keys[i], extra_info[i]);
+ strings->SetString(keys[i], WideToUTF16Hack(extra_info[i]));
}
for (;i < 5; i++) {
- strings->SetString(keys[i], L"");
+ strings->SetString(keys[i], ASCIIToUTF16(""));
}
}
-
diff --git a/chrome/browser/ssl/ssl_policy.cc b/chrome/browser/ssl/ssl_policy.cc
index 4a0fdef..49ee40c 100644
--- a/chrome/browser/ssl/ssl_policy.cc
+++ b/chrome/browser/ssl/ssl_policy.cc
@@ -76,18 +76,26 @@ static void ShowErrorPage(SSLPolicy* policy, SSLManager::CertError* error) {
// Let's build the html error page.
DictionaryValue strings;
- strings.SetString(L"title", l10n_util::GetString(IDS_SSL_ERROR_PAGE_TITLE));
- strings.SetString(L"headLine", error_info.title());
- strings.SetString(L"description", error_info.details());
- strings.SetString(L"moreInfoTitle",
- l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE));
+ strings.SetString(
+ 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)));
SSLBlockingPage::SetExtraInfo(&strings, error_info.extra_information());
- strings.SetString(L"back", l10n_util::GetString(IDS_SSL_ERROR_PAGE_BACK));
+ strings.SetString(
+ ASCIIToUTF16("back"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_SSL_ERROR_PAGE_BACK)));
- strings.SetString(L"textdirection",
+ strings.SetString(
+ ASCIIToUTF16("textdirection"),
(l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- L"rtl" : L"ltr");
+ ASCIIToUTF16("rtl") : ASCIIToUTF16("ltr"));
static const StringPiece html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
diff --git a/chrome/common/json_value_serializer_unittest.cc b/chrome/common/json_value_serializer_unittest.cc
index 1fc9e97..7504471 100644
--- a/chrome/common/json_value_serializer_unittest.cc
+++ b/chrome/common/json_value_serializer_unittest.cc
@@ -24,20 +24,20 @@ TEST(JSONValueSerializerTest, Roundtrip) {
DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get());
Value* null_value = NULL;
- ASSERT_TRUE(root_dict->Get(L"null", &null_value));
+ ASSERT_TRUE(root_dict->Get(ASCIIToUTF16("null"), &null_value));
ASSERT_TRUE(null_value);
ASSERT_TRUE(null_value->IsType(Value::TYPE_NULL));
bool bool_value = false;
- ASSERT_TRUE(root_dict->GetBoolean(L"bool", &bool_value));
+ ASSERT_TRUE(root_dict->GetBoolean(ASCIIToUTF16("bool"), &bool_value));
ASSERT_TRUE(bool_value);
int int_value = 0;
- ASSERT_TRUE(root_dict->GetInteger(L"int", &int_value));
+ ASSERT_TRUE(root_dict->GetInteger(ASCIIToUTF16("int"), &int_value));
ASSERT_EQ(42, int_value);
double real_value = 0.0;
- ASSERT_TRUE(root_dict->GetReal(L"real", &real_value));
+ ASSERT_TRUE(root_dict->GetReal(ASCIIToUTF16("real"), &real_value));
ASSERT_DOUBLE_EQ(3.14, real_value);
// We shouldn't be able to write using this serializer, since it was
@@ -92,7 +92,7 @@ TEST(JSONValueSerializerTest, StringEscape) {
// Test JSONWriter interface
std::string output_js;
DictionaryValue valueRoot;
- valueRoot.SetString(L"all_chars", all_chars);
+ valueRoot.SetString(ASCIIToUTF16("all_chars"), WideToUTF16Hack(all_chars));
JSONWriter::Write(&valueRoot, false, &output_js);
ASSERT_EQ(expected_output, output_js);
@@ -106,7 +106,7 @@ TEST(JSONValueSerializerTest, UnicodeStrings) {
// unicode string json -> escaped ascii text
DictionaryValue root;
std::wstring test(L"\x7F51\x9875");
- root.SetString(L"web", test);
+ root.SetString(ASCIIToUTF16("web"), WideToUTF16Hack(test));
std::string expected = "{\"web\":\"\\u7F51\\u9875\"}";
@@ -121,16 +121,16 @@ TEST(JSONValueSerializerTest, UnicodeStrings) {
ASSERT_TRUE(deserial_root.get());
DictionaryValue* dict_root =
static_cast<DictionaryValue*>(deserial_root.get());
- std::wstring web_value;
- ASSERT_TRUE(dict_root->GetString(L"web", &web_value));
- ASSERT_EQ(test, web_value);
+ string16 web_value;
+ ASSERT_TRUE(dict_root->GetString(ASCIIToUTF16("web"), &web_value));
+ ASSERT_EQ(test, UTF16ToWideHack(web_value));
}
TEST(JSONValueSerializerTest, HexStrings) {
// hex string json -> escaped ascii text
DictionaryValue root;
std::wstring test(L"\x01\x02");
- root.SetString(L"test", test);
+ root.SetString(ASCIIToUTF16("test"), WideToUTF16Hack(test));
std::string expected = "{\"test\":\"\\x01\\x02\"}";
@@ -145,9 +145,9 @@ TEST(JSONValueSerializerTest, HexStrings) {
ASSERT_TRUE(deserial_root.get());
DictionaryValue* dict_root =
static_cast<DictionaryValue*>(deserial_root.get());
- std::wstring test_value;
- ASSERT_TRUE(dict_root->GetString(L"test", &test_value));
- ASSERT_EQ(test, test_value);
+ string16 test_value;
+ ASSERT_TRUE(dict_root->GetString(ASCIIToUTF16("test"), &test_value));
+ ASSERT_EQ(test, UTF16ToWideHack(test_value));
// Test converting escaped regular chars
std::string escaped_chars = "{\"test\":\"\\x67\\x6f\"}";
@@ -155,8 +155,8 @@ TEST(JSONValueSerializerTest, HexStrings) {
deserial_root.reset(deserializer2.Deserialize(NULL));
ASSERT_TRUE(deserial_root.get());
dict_root = static_cast<DictionaryValue*>(deserial_root.get());
- ASSERT_TRUE(dict_root->GetString(L"test", &test_value));
- ASSERT_EQ(std::wstring(L"go"), test_value);
+ ASSERT_TRUE(dict_root->GetString(ASCIIToUTF16("test"), &test_value));
+ ASSERT_EQ(L"go", UTF16ToWideHack(test_value));
}
TEST(JSONValueSerializerTest, AllowTrailingComma) {
@@ -260,21 +260,21 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) {
DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get());
Value* null_value = NULL;
- ASSERT_TRUE(root_dict->Get(L"null", &null_value));
+ ASSERT_TRUE(root_dict->Get(ASCIIToUTF16("null"), &null_value));
ASSERT_TRUE(null_value);
ASSERT_TRUE(null_value->IsType(Value::TYPE_NULL));
bool bool_value = false;
- ASSERT_TRUE(root_dict->GetBoolean(L"bool", &bool_value));
+ ASSERT_TRUE(root_dict->GetBoolean(ASCIIToUTF16("bool"), &bool_value));
ASSERT_TRUE(bool_value);
int int_value = 0;
- ASSERT_TRUE(root_dict->GetInteger(L"int", &int_value));
+ ASSERT_TRUE(root_dict->GetInteger(ASCIIToUTF16("int"), &int_value));
ASSERT_EQ(42, int_value);
- std::wstring string_value;
- ASSERT_TRUE(root_dict->GetString(L"string", &string_value));
- ASSERT_EQ(L"hello", string_value);
+ string16 string_value;
+ ASSERT_TRUE(root_dict->GetString(ASCIIToUTF16("string"), &string_value));
+ ASSERT_EQ(L"hello", UTF16ToWideHack(string_value));
// Now try writing.
std::wstring written_file_path = test_dir_;
diff --git a/chrome/common/pref_service.cc b/chrome/common/pref_service.cc
index b728a87..fd27de1 100644
--- a/chrome/common/pref_service.cc
+++ b/chrome/common/pref_service.cc
@@ -289,7 +289,7 @@ bool PrefService::GetBoolean(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
bool result = false;
- if (transient_->GetBoolean(path, &result))
+ if (transient_->GetBoolean(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -306,7 +306,7 @@ int PrefService::GetInteger(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
int result = 0;
- if (transient_->GetInteger(path, &result))
+ if (transient_->GetInteger(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -323,7 +323,7 @@ double PrefService::GetReal(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
double result = 0.0;
- if (transient_->GetReal(path, &result))
+ if (transient_->GetReal(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -339,10 +339,11 @@ double PrefService::GetReal(const wchar_t* path) const {
std::wstring PrefService::GetString(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
- std::wstring result;
- if (transient_->GetString(path, &result))
- return result;
+ string16 result16;
+ if (transient_->GetString(WideToUTF16Hack(path), &result16))
+ return UTF16ToWideHack(result16);
+ std::wstring result;
const Preference* pref = FindPreference(path);
if (!pref) {
#if defined(OS_WIN)
@@ -359,7 +360,8 @@ std::wstring PrefService::GetString(const wchar_t* path) const {
bool PrefService::HasPrefPath(const wchar_t* path) const {
Value* value = NULL;
- return (transient_->Get(path, &value) || persistent_->Get(path, &value));
+ string16 path16 = WideToUTF16Hack(path);
+ return (transient_->Get(path16, &value) || persistent_->Get(path16, &value));
}
const PrefService::Preference* PrefService::FindPreference(
@@ -374,7 +376,7 @@ const DictionaryValue* PrefService::GetDictionary(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
DictionaryValue* result = NULL;
- if (transient_->GetDictionary(path, &result))
+ if (transient_->GetDictionary(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -392,7 +394,7 @@ const ListValue* PrefService::GetList(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
ListValue* result = NULL;
- if (transient_->GetList(path, &result))
+ if (transient_->GetList(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -473,10 +475,11 @@ void PrefService::ClearPref(const wchar_t* path) {
return;
}
- transient_->Remove(path, NULL);
+ string16 path16 = WideToUTF16Hack(path);
+ transient_->Remove(path16, NULL);
Value* value;
- bool has_old_value = persistent_->Get(path, &value);
- persistent_->Remove(path, NULL);
+ bool has_old_value = persistent_->Get(path16, &value);
+ persistent_->Remove(path16, NULL);
if (has_old_value)
FireObservers(path);
@@ -496,7 +499,7 @@ void PrefService::SetBoolean(const wchar_t* path, bool value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetBoolean(path, value);
+ bool rv = persistent_->SetBoolean(WideToUTF16Hack(path), value);
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -516,7 +519,7 @@ void PrefService::SetInteger(const wchar_t* path, int value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetInteger(path, value);
+ bool rv = persistent_->SetInteger(WideToUTF16Hack(path), value);
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -536,7 +539,7 @@ void PrefService::SetReal(const wchar_t* path, double value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetReal(path, value);
+ bool rv = persistent_->SetReal(WideToUTF16Hack(path), value);
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -556,7 +559,8 @@ void PrefService::SetString(const wchar_t* path, const std::wstring& value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetString(path, value);
+ bool rv = persistent_->SetString(WideToUTF16Hack(path),
+ WideToUTF16Hack(value));
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -576,10 +580,11 @@ DictionaryValue* PrefService::GetMutableDictionary(const wchar_t* path) {
}
DictionaryValue* dict = NULL;
- bool rv = persistent_->GetDictionary(path, &dict);
+ string16 path16 = WideToUTF16Hack(path);
+ bool rv = persistent_->GetDictionary(path16, &dict);
if (!rv) {
dict = new DictionaryValue;
- rv = persistent_->Set(path, dict);
+ rv = persistent_->Set(path16, dict);
DCHECK(rv);
}
return dict;
@@ -599,10 +604,11 @@ ListValue* PrefService::GetMutableList(const wchar_t* path) {
}
ListValue* list = NULL;
- bool rv = persistent_->GetList(path, &list);
+ string16 path16 = WideToUTF16Hack(path);
+ bool rv = persistent_->GetList(path16, &list);
if (!rv) {
list = new ListValue;
- rv = persistent_->Set(path, list);
+ rv = persistent_->Set(path16, list);
DCHECK(rv);
}
return list;
@@ -619,7 +625,7 @@ Value* PrefService::GetPrefCopy(const wchar_t* path) {
void PrefService::FireObserversIfChanged(const wchar_t* path,
const Value* old_value) {
Value* new_value = NULL;
- persistent_->Get(path, &new_value);
+ persistent_->Get(WideToUTF16Hack(path), &new_value);
if (!old_value->Equals(new_value))
FireObservers(path);
}
@@ -672,7 +678,7 @@ const Value* PrefService::Preference::GetValue() const {
"Must register pref before getting its value";
Value* temp_value = NULL;
- if (root_pref_->Get(name_.c_str(), &temp_value) &&
+ if (root_pref_->Get(WideToUTF16Hack(name_), &temp_value) &&
temp_value->GetType() == type_) {
return temp_value;
}
diff --git a/chrome/renderer/localized_error.cc b/chrome/renderer/localized_error.cc
index af89563..b6f6575 100644
--- a/chrome/renderer/localized_error.cc
+++ b/chrome/renderer/localized_error.cc
@@ -86,10 +86,12 @@ WebErrorNetErrorMap net_error_options[] = {
void GetLocalizedErrorValues(const WebError& error,
DictionaryValue* error_strings) {
// Grab strings that are applicable to all error pages
- error_strings->SetString(L"detailsLink",
- l10n_util::GetString(IDS_ERRORPAGES_DETAILS_LINK));
- error_strings->SetString(L"detailsHeading",
- l10n_util::GetString(IDS_ERRORPAGES_DETAILS_HEADING));
+ error_strings->SetString(
+ ASCIIToUTF16("detailsLink"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ERRORPAGES_DETAILS_LINK)));
+ error_strings->SetString(
+ ASCIIToUTF16("detailsHeading"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ERRORPAGES_DETAILS_HEADING)));
// Grab the strings and settings that depend on the error type. Init
// options with default values.
@@ -114,40 +116,49 @@ void GetLocalizedErrorValues(const WebError& error,
suggestions_heading =
l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_HEADING);
}
- error_strings->SetString(L"suggestionsHeading", suggestions_heading);
+ error_strings->SetString(ASCIIToUTF16("suggestionsHeading"),
+ WideToUTF16Hack(suggestions_heading));
std::wstring failed_url(ASCIIToWide(error.GetFailedURL().spec()));
// URLs are always LTR.
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
l10n_util::WrapStringWithLTRFormatting(&failed_url);
- error_strings->SetString(L"title",
- l10n_util::GetStringF(options.title_resource_id,
- failed_url));
- error_strings->SetString(L"heading",
- l10n_util::GetString(options.heading_resource_id));
+ error_strings->SetString(
+ 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)));
DictionaryValue* summary = new DictionaryValue;
- summary->SetString(L"msg",
- l10n_util::GetString(options.summary_resource_id));
+ summary->SetString(
+ ASCIIToUTF16("msg"),
+ WideToUTF16Hack(l10n_util::GetString(options.summary_resource_id)));
// TODO(tc): we want the unicode url here since it's being displayed
- summary->SetString(L"failedUrl", failed_url);
- error_strings->Set(L"summary", summary);
+ summary->SetString(ASCIIToUTF16("failedUrl"), WideToUTF16Hack(failed_url));
+ error_strings->Set(ASCIIToUTF16("summary"), summary);
// Error codes are expected to be negative
DCHECK(error_code < 0);
std::wstring details = l10n_util::GetString(options.details_resource_id);
- error_strings->SetString(L"details",
- l10n_util::GetStringF(IDS_ERRORPAGES_DETAILS_TEMPLATE,
- IntToWString(-error_code),
- ASCIIToWide(net::ErrorToString(error_code)),
- details));
+ error_strings->SetString(
+ ASCIIToUTF16("details"),
+ WideToUTF16Hack(l10n_util::GetStringF(
+ IDS_ERRORPAGES_DETAILS_TEMPLATE,
+ IntToWString(-error_code),
+ ASCIIToWide(net::ErrorToString(error_code)),
+ details)));
if (options.suggestions & SUGGEST_RELOAD) {
DictionaryValue* suggest_reload = new DictionaryValue;
- suggest_reload->SetString(L"msg",
- l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_RELOAD));
- suggest_reload->SetString(L"reloadUrl", failed_url);
- error_strings->Set(L"suggestionsReload", suggest_reload);
+ suggest_reload->SetString(
+ 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);
}
if (options.suggestions & SUGGEST_HOSTNAME) {
@@ -155,17 +166,21 @@ void GetLocalizedErrorValues(const WebError& error,
const GURL& failed_url = error.GetFailedURL();
if (std::string() == failed_url.path()) {
DictionaryValue* suggest_home_page = new DictionaryValue;
- suggest_home_page->SetString(L"suggestionsHomepageMsg",
- l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_HOMEPAGE));
+ suggest_home_page->SetString(
+ ASCIIToUTF16("suggestionsHomepageMsg"),
+ WideToUTF16Hack(l10n_util::GetString(
+ IDS_ERRORPAGES_SUGGESTION_HOMEPAGE)));
std::wstring homepage(ASCIIToWide(failed_url.GetWithEmptyPath().spec()));
// URLs are always LTR.
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
l10n_util::WrapStringWithLTRFormatting(&homepage);
- suggest_home_page->SetString(L"homePage", homepage);
+ suggest_home_page->SetString(ASCIIToUTF16("homePage"),
+ WideToUTF16Hack(homepage));
// TODO(tc): we actually want the unicode hostname
- suggest_home_page->SetString(L"hostName",
- ASCIIToWide(failed_url.host()));
- error_strings->Set(L"suggestionsHomepage", suggest_home_page);
+ suggest_home_page->SetString(ASCIIToUTF16("hostName"),
+ UTF8ToUTF16(failed_url.host()));
+ error_strings->Set(ASCIIToUTF16("suggestionsHomepage"),
+ suggest_home_page);
}
}
@@ -188,11 +203,14 @@ void GetLocalizedErrorValues(const WebError& error,
learn_more_url = learn_more_url.ReplaceComponents(repl);
DictionaryValue* suggest_learn_more = new DictionaryValue;
- suggest_learn_more->SetString(L"msg",
- l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_LEARNMORE));
- suggest_learn_more->SetString(L"learnMoreUrl",
- ASCIIToWide(learn_more_url.spec()));
- error_strings->Set(L"suggestionsLearnMore", suggest_learn_more);
+ suggest_learn_more->SetString(
+ 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);
}
}
}
@@ -204,13 +222,18 @@ void GetFormRepostErrorValues(const GURL& display_url,
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
l10n_util::WrapStringWithLTRFormatting(&failed_url);
error_strings->SetString(
- L"title", l10n_util::GetStringF(IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
- failed_url.c_str()));
- error_strings->SetString(L"heading",
- l10n_util::GetString(IDS_HTTP_POST_WARNING_TITLE));
- error_strings->SetString(L"suggestionsHeading", L"");
+ 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(""));
DictionaryValue* summary = new DictionaryValue;
- summary->SetString(L"msg",
- l10n_util::GetString(IDS_ERRORPAGES_HTTP_POST_WARNING));
- error_strings->Set(L"summary", summary);
+ summary->SetString(
+ ASCIIToUTF16("msg"),
+ WideToUTF16Hack(l10n_util::GetString(IDS_ERRORPAGES_HTTP_POST_WARNING)));
+ error_strings->Set(ASCIIToUTF16("summary"), summary);
}
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 59ba2c9..00da8a6 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1380,9 +1380,10 @@ void RenderView::LoadNavigationErrorPage(WebFrame* frame,
GetLocalizedErrorValues(error, &error_strings);
resource_id = IDR_NET_ERROR_HTML;
}
- error_strings.SetString(L"textdirection",
- (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
- L"rtl" : L"ltr");
+ error_strings.SetString(
+ ASCIIToUTF16("textdirection"),
+ (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
+ ASCIIToUTF16("rtl") : ASCIIToUTF16("ltr"));
alt_html = GetAltHTMLForTemplate(error_strings, resource_id);
} else {