diff options
author | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 20:46:40 +0000 |
---|---|---|
committer | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 20:46:40 +0000 |
commit | 6470ee8f59dba5eecfce4a64d7ff3930ae716095 (patch) | |
tree | 86e020619f32c56f5796a0ea20975c71607ac91f /chrome/browser | |
parent | 409993dec55a874e0659acf421a87070d450a262 (diff) | |
download | chromium_src-6470ee8f59dba5eecfce4a64d7ff3930ae716095.zip chromium_src-6470ee8f59dba5eecfce4a64d7ff3930ae716095.tar.gz chromium_src-6470ee8f59dba5eecfce4a64d7ff3930ae716095.tar.bz2 |
Revert dsh's change 10818
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10821 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/autocomplete/search_provider.cc | 2 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_codec.cc | 76 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_html_writer.cc | 51 | ||||
-rw-r--r-- | chrome/browser/browser_about_handler.cc | 152 | ||||
-rw-r--r-- | chrome/browser/browser_init.cc | 9 | ||||
-rw-r--r-- | chrome/browser/browser_main.cc | 29 | ||||
-rw-r--r-- | chrome/browser/dom_ui/dom_ui.cc | 4 | ||||
-rw-r--r-- | chrome/browser/dom_ui/history_ui.cc | 70 | ||||
-rw-r--r-- | chrome/browser/dom_ui/new_tab_ui.cc | 103 | ||||
-rw-r--r-- | chrome/browser/extensions/extension.cc | 34 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_unittest.cc | 61 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.cc | 8 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_log.cc | 25 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service.cc | 37 | ||||
-rw-r--r-- | chrome/browser/page_state.cc | 7 | ||||
-rw-r--r-- | chrome/browser/profile_manager.h | 19 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_blocking_page.cc | 106 | ||||
-rw-r--r-- | chrome/browser/ssl/ssl_blocking_page.cc | 42 | ||||
-rw-r--r-- | chrome/browser/ssl/ssl_policy.cc | 23 |
19 files changed, 378 insertions, 480 deletions
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index 571217a..23d4407c 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -302,7 +302,7 @@ bool SearchProvider::ParseSuggestResults(Value* root_val) { DictionaryValue* dict_val = static_cast<DictionaryValue*>(optional_val); // Parse Google Suggest specific type extension. - static const string16 kGoogleSuggestType(LIT16("google:suggesttype")); + static const std::wstring kGoogleSuggestType(L"google:suggesttype"); if (dict_val->HasKey(kGoogleSuggestType)) dict_val->GetList(kGoogleSuggestType, &type_list); } diff --git a/chrome/browser/bookmarks/bookmark_codec.cc b/chrome/browser/bookmarks/bookmark_codec.cc index 1eba304..dd39fc8 100644 --- a/chrome/browser/bookmarks/bookmark_codec.cc +++ b/chrome/browser/bookmarks/bookmark_codec.cc @@ -36,13 +36,12 @@ Value* BookmarkCodec::Encode(BookmarkModel* model) { Value* BookmarkCodec::Encode(BookmarkNode* bookmark_bar_node, BookmarkNode* other_folder_node) { DictionaryValue* roots = new DictionaryValue(); - roots->Set(WideToUTF16Hack(kRootFolderNameKey), EncodeNode(bookmark_bar_node)); - roots->Set(WideToUTF16Hack(kOtherBookmarFolderNameKey), - EncodeNode(other_folder_node)); + roots->Set(kRootFolderNameKey, EncodeNode(bookmark_bar_node)); + roots->Set(kOtherBookmarFolderNameKey, EncodeNode(other_folder_node)); DictionaryValue* main = new DictionaryValue(); - main->SetInteger(WideToUTF16Hack(kVersionKey), kCurrentVersion); - main->Set(WideToUTF16Hack(kRootsKey), roots); + main->SetInteger(kVersionKey, kCurrentVersion); + main->Set(kRootsKey, roots); return main; } @@ -53,12 +52,11 @@ bool BookmarkCodec::Decode(BookmarkModel* model, const Value& value) { const DictionaryValue& d_value = static_cast<const DictionaryValue&>(value); int version; - if (!d_value.GetInteger(WideToUTF16Hack(kVersionKey), &version) || - version != kCurrentVersion) + if (!d_value.GetInteger(kVersionKey, &version) || version != kCurrentVersion) return false; // Unknown version. Value* roots; - if (!d_value.Get(WideToUTF16Hack(kRootsKey), &roots)) + if (!d_value.Get(kRootsKey, &roots)) return false; // No roots. if (roots->GetType() != Value::TYPE_DICTIONARY) @@ -67,14 +65,11 @@ bool BookmarkCodec::Decode(BookmarkModel* model, const Value& value) { DictionaryValue* roots_d_value = static_cast<DictionaryValue*>(roots); Value* root_folder_value; Value* other_folder_value; - if (!roots_d_value->Get(WideToUTF16Hack(kRootFolderNameKey), - &root_folder_value) || + if (!roots_d_value->Get(kRootFolderNameKey, &root_folder_value) || root_folder_value->GetType() != Value::TYPE_DICTIONARY || - !roots_d_value->Get(WideToUTF16Hack(kOtherBookmarFolderNameKey), - &other_folder_value) || - other_folder_value->GetType() != Value::TYPE_DICTIONARY) { + !roots_d_value->Get(kOtherBookmarFolderNameKey, &other_folder_value) || + other_folder_value->GetType() != Value::TYPE_DICTIONARY) return false; // Invalid type for root folder and/or other folder. - } DecodeNode(model, *static_cast<DictionaryValue*>(root_folder_value), NULL, model->GetBookmarkBarNode()); @@ -94,22 +89,21 @@ bool BookmarkCodec::Decode(BookmarkModel* model, const Value& value) { Value* BookmarkCodec::EncodeNode(BookmarkNode* node) { DictionaryValue* value = new DictionaryValue(); - value->SetString(WideToUTF16Hack(kNameKey), - WideToUTF16Hack(node->GetTitle())); - value->SetString(WideToUTF16Hack(kDateAddedKey), - Int64ToString16(node->date_added().ToInternalValue())); + value->SetString(kNameKey, node->GetTitle()); + value->SetString(kDateAddedKey, + Int64ToWString(node->date_added().ToInternalValue())); if (node->GetType() == history::StarredEntry::URL) { - value->SetString(WideToUTF16Hack(kTypeKey), WideToUTF16Hack(kTypeURL)); - value->SetString(WideToUTF16Hack(kURLKey), - UTF8ToUTF16(node->GetURL().possibly_invalid_spec())); + value->SetString(kTypeKey, kTypeURL); + value->SetString(kURLKey, + UTF8ToWide(node->GetURL().possibly_invalid_spec())); } else { - value->SetString(WideToUTF16Hack(kTypeKey), WideToUTF16Hack(kTypeFolder)); - value->SetString(WideToUTF16Hack(kDateModifiedKey), - Int64ToString16(node->date_group_modified(). + value->SetString(kTypeKey, kTypeFolder); + value->SetString(kDateModifiedKey, + Int64ToWString(node->date_group_modified(). ToInternalValue())); ListValue* child_values = new ListValue(); - value->Set(WideToUTF16Hack(kChildrenKey), child_values); + value->Set(kChildrenKey, child_values); for (int i = 0; i < node->GetChildCount(); ++i) child_values->Append(EncodeNode(node->GetChild(i))); } @@ -139,42 +133,40 @@ bool BookmarkCodec::DecodeNode(BookmarkModel* model, const DictionaryValue& value, BookmarkNode* parent, BookmarkNode* node) { - string16 title; - if (!value.GetString(WideToUTF16Hack(kNameKey), &title)) + std::wstring title; + if (!value.GetString(kNameKey, &title)) return false; // TODO(sky): this should be more flexible. Don't hoark if we can't parse it // all. - string16 date_added_string; - if (!value.GetString(WideToUTF16Hack(kDateAddedKey), &date_added_string)) + std::wstring date_added_string; + if (!value.GetString(kDateAddedKey, &date_added_string)) return false; - string16 type_string; - if (!value.GetString(WideToUTF16Hack(kTypeKey), &type_string)) + std::wstring type_string; + if (!value.GetString(kTypeKey, &type_string)) return false; - if (type_string != WideToUTF16Hack(kTypeURL) && - type_string != WideToUTF16Hack(kTypeFolder)) + if (type_string != kTypeURL && type_string != kTypeFolder) return false; // Unknown type. - if (type_string == WideToUTF16Hack(kTypeURL)) { - string16 url_string; - if (!value.GetString(WideToUTF16Hack(kURLKey), &url_string)) + if (type_string == kTypeURL) { + std::wstring url_string; + if (!value.GetString(kURLKey, &url_string)) return false; // TODO(sky): this should ignore the node if not a valid URL. if (!node) - node = new BookmarkNode(model, GURL(UTF16ToUTF8(url_string))); + node = new BookmarkNode(model, GURL(WideToUTF8(url_string))); if (parent) parent->Add(parent->GetChildCount(), node); node->type_ = history::StarredEntry::URL; } else { - string16 last_modified_date; - if (!value.GetString(WideToUTF16Hack(kDateModifiedKey), - &last_modified_date)) + std::wstring last_modified_date; + if (!value.GetString(kDateModifiedKey, &last_modified_date)) return false; Value* child_values; - if (!value.Get(WideToUTF16Hack(kChildrenKey), &child_values)) + if (!value.Get(kChildrenKey, &child_values)) return false; if (child_values->GetType() != Value::TYPE_LIST) @@ -193,7 +185,7 @@ bool BookmarkCodec::DecodeNode(BookmarkModel* model, return false; } - node->SetTitle(UTF16ToWideHack(title)); + node->SetTitle(title); node->date_added_ = Time::FromInternalValue( StringToInt64(WideToUTF16Hack(date_added_string))); return true; diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc index 9561543..5ec7ca0 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer.cc @@ -85,7 +85,7 @@ class Writer : public Task { if (!Write(kHeader) || bookmarks_->GetType() != Value::TYPE_DICTIONARY || !static_cast<DictionaryValue*>(bookmarks_.get())->Get( - WideToUTF16Hack(BookmarkCodec::kRootsKey), &roots) || + BookmarkCodec::kRootsKey, &roots) || roots->GetType() != Value::TYPE_DICTIONARY) { NOTREACHED(); return; @@ -94,12 +94,11 @@ class Writer : public Task { DictionaryValue* roots_d_value = static_cast<DictionaryValue*>(roots); Value* root_folder_value; Value* other_folder_value; - if (!roots_d_value->Get(WideToUTF16Hack(BookmarkCodec::kRootFolderNameKey), + if (!roots_d_value->Get(BookmarkCodec::kRootFolderNameKey, &root_folder_value) || root_folder_value->GetType() != Value::TYPE_DICTIONARY || - !roots_d_value->Get( - WideToUTF16Hack(BookmarkCodec::kOtherBookmarFolderNameKey), - &other_folder_value) || + !roots_d_value->Get(BookmarkCodec::kOtherBookmarFolderNameKey, + &other_folder_value) || other_folder_value->GetType() != Value::TYPE_DICTIONARY) { NOTREACHED(); return; // Invalid type for root folder and/or other folder. @@ -204,32 +203,29 @@ class Writer : public Task { // Writes the node and all its children, returning true on success. bool WriteNode(const DictionaryValue& value, history::StarredEntry::Type folder_type) { - string16 title, date_added_string, type_string; - if (!value.GetString(WideToUTF16Hack(BookmarkCodec::kNameKey), &title) || - !value.GetString(WideToUTF16Hack(BookmarkCodec::kDateAddedKey), - &date_added_string) || - !value.GetString(WideToUTF16Hack(BookmarkCodec::kTypeKey), - &type_string) || - (type_string != WideToUTF16Hack(BookmarkCodec::kTypeURL) && - type_string != WideToUTF16Hack(BookmarkCodec::kTypeFolder))) { + std::wstring title, date_added_string, type_string; + if (!value.GetString(BookmarkCodec::kNameKey, &title) || + !value.GetString(BookmarkCodec::kDateAddedKey, &date_added_string) || + !value.GetString(BookmarkCodec::kTypeKey, &type_string) || + (type_string != BookmarkCodec::kTypeURL && + type_string != BookmarkCodec::kTypeFolder)) { NOTREACHED(); return false; } - if (type_string == WideToUTF16Hack(BookmarkCodec::kTypeURL)) { - string16 url_string; - if (!value.GetString(WideToUTF16Hack(BookmarkCodec::kURLKey), - &url_string)) { + if (type_string == BookmarkCodec::kTypeURL) { + std::wstring url_string; + if (!value.GetString(BookmarkCodec::kURLKey, &url_string)) { NOTREACHED(); return false; } if (!WriteIndent() || !Write(kBookmarkStart) || - !Write(UTF16ToWideHack(url_string), ATTRIBUTE_VALUE) || + !Write(url_string, ATTRIBUTE_VALUE) || !Write(kAddDate) || - !WriteTime(UTF16ToWideHack(date_added_string)) || + !WriteTime(date_added_string) || !Write(kBookmarkAttributeEnd) || - !Write(UTF16ToWideHack(title), CONTENT) || + !Write(title, CONTENT) || !Write(kBookmarkEnd) || !Write(kNewline)) { return false; @@ -238,12 +234,11 @@ class Writer : public Task { } // Folder. - string16 last_modified_date; + std::wstring last_modified_date; Value* child_values; - if (!value.GetString(WideToUTF16Hack(BookmarkCodec::kDateModifiedKey), + if (!value.GetString(BookmarkCodec::kDateModifiedKey, &last_modified_date) || - !value.Get(WideToUTF16Hack(BookmarkCodec::kChildrenKey), - &child_values) || + !value.Get(BookmarkCodec::kChildrenKey, &child_values) || child_values->GetType() != Value::TYPE_LIST) { NOTREACHED(); return false; @@ -254,19 +249,19 @@ class Writer : public Task { // bar folder. if (!WriteIndent() || !Write(kFolderStart) || - !WriteTime(UTF16ToWideHack(date_added_string)) || + !WriteTime(date_added_string) || !Write(kLastModified) || - !WriteTime(UTF16ToWideHack(last_modified_date))) { + !WriteTime(last_modified_date)) { return false; } if (folder_type == history::StarredEntry::BOOKMARK_BAR) { if (!Write(kBookmarkBar)) return false; - title = LIT16("Bookmark Bar"); + title = L"Bookmark Bar"; } else if (!Write(kFolderAttributeEnd)) { return false; } - if (!Write(UTF16ToWideHack(title), CONTENT) || + if (!Write(title, CONTENT) || !Write(kFolderEnd) || !Write(kNewline) || !WriteIndent() || diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 238804d..7f25a60 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -253,9 +253,8 @@ bool BrowserAboutHandler::SupportsURL(GURL* url) { std::string BrowserAboutHandler::AboutVersion() { // Strings used in the JsTemplate file. DictionaryValue localized_strings; - localized_strings.SetString( - LIT16("title"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_TITLE))); + localized_strings.SetString(L"title", + l10n_util::GetString(IDS_ABOUT_VERSION_TITLE)); scoped_ptr<FileVersionInfo> version_info( FileVersionInfo::CreateFileVersionInfoForCurrentModule()); if (version_info == NULL) { @@ -273,34 +272,26 @@ std::string BrowserAboutHandler::AboutVersion() { std::wstring js_engine = L"JavaScriptCore"; #endif - localized_strings.SetString( - LIT16("name"), - WideToUTF16Hack(l10n_util::GetString(IDS_PRODUCT_NAME))); - localized_strings.SetString(LIT16("version"), - WideToUTF16Hack(version_info->file_version())); - localized_strings.SetString(LIT16("js_engine"), WideToUTF16Hack(js_engine)); - localized_strings.SetString(LIT16("js_version"), WideToUTF16Hack(js_version)); - localized_strings.SetString(LIT16("webkit_version"), - WideToUTF16Hack(webkit_version)); - localized_strings.SetString( - LIT16("company"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_COMPANY_NAME))); - localized_strings.SetString( - LIT16("copyright"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT))); - localized_strings.SetString(LIT16("cl"), - WideToUTF16Hack(version_info->last_change())); + localized_strings.SetString(L"name", + l10n_util::GetString(IDS_PRODUCT_NAME)); + localized_strings.SetString(L"version", version_info->file_version()); + localized_strings.SetString(L"js_engine", js_engine); + localized_strings.SetString(L"js_version", js_version); + localized_strings.SetString(L"webkit_version", webkit_version); + localized_strings.SetString(L"company", + l10n_util::GetString(IDS_ABOUT_VERSION_COMPANY_NAME)); + localized_strings.SetString(L"copyright", + l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT)); + localized_strings.SetString(L"cl", version_info->last_change()); if (version_info->is_official_build()) { - localized_strings.SetString( - LIT16("official"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_OFFICIAL))); + localized_strings.SetString(L"official", + l10n_util::GetString(IDS_ABOUT_VERSION_OFFICIAL)); } else { - localized_strings.SetString( - LIT16("official"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_VERSION_UNOFFICIAL))); + localized_strings.SetString(L"official", + l10n_util::GetString(IDS_ABOUT_VERSION_UNOFFICIAL)); } - localized_strings.SetString(LIT16("useragent"), - UTF8ToUTF16(webkit_glue::GetUserAgent(GURL()))); + localized_strings.SetString(L"useragent", + UTF8ToWide(webkit_glue::GetUserAgent(GURL()))); static const StringPiece version_html( ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -341,36 +332,26 @@ std::string BrowserAboutHandler::AboutTerms() { std::string BrowserAboutHandler::AboutPlugins() { // Strings used in the JsTemplate file. DictionaryValue localized_strings; - localized_strings.SetString( - LIT16("title"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_TITLE))); - localized_strings.SetString( - LIT16("headingPlugs"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_PLUGS))); - localized_strings.SetString( - LIT16("headingNoPlugs"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_NOPLUGS))); - localized_strings.SetString( - LIT16("filename"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_FILENAME_LABEL))); - localized_strings.SetString( - LIT16("mimetype"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_MIMETYPE_LABEL))); - localized_strings.SetString( - LIT16("description"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_DESCRIPTION_LABEL))); - localized_strings.SetString( - LIT16("suffixes"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_SUFFIX_LABEL))); - localized_strings.SetString( - LIT16("enabled"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_LABEL))); - localized_strings.SetString( - LIT16("enabled_yes"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_YES))); - localized_strings.SetString( - LIT16("enabled_no"), - WideToUTF16Hack(l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_NO))); + localized_strings.SetString(L"title", + l10n_util::GetString(IDS_ABOUT_PLUGINS_TITLE)); + localized_strings.SetString(L"headingPlugs", + l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_PLUGS)); + localized_strings.SetString(L"headingNoPlugs", + l10n_util::GetString(IDS_ABOUT_PLUGINS_HEADING_NOPLUGS)); + localized_strings.SetString(L"filename", + l10n_util::GetString(IDS_ABOUT_PLUGINS_FILENAME_LABEL)); + localized_strings.SetString(L"mimetype", + l10n_util::GetString(IDS_ABOUT_PLUGINS_MIMETYPE_LABEL)); + localized_strings.SetString(L"description", + l10n_util::GetString(IDS_ABOUT_PLUGINS_DESCRIPTION_LABEL)); + localized_strings.SetString(L"suffixes", + l10n_util::GetString(IDS_ABOUT_PLUGINS_SUFFIX_LABEL)); + localized_strings.SetString(L"enabled", + l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_LABEL)); + localized_strings.SetString(L"enabled_yes", + l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_YES)); + localized_strings.SetString(L"enabled_no", + l10n_util::GetString(IDS_ABOUT_PLUGINS_ENABLED_NO)); static const StringPiece plugins_html( ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -423,15 +404,15 @@ std::string BrowserAboutHandler::AboutStats() { // We maintain two lists - one for counters and one for timers. // Timers actually get stored on both lists. ListValue* counters; - if (!root.GetList(LIT16("counters"), &counters)) { + if (!root.GetList(L"counters", &counters)) { counters = new ListValue(); - root.Set(LIT16("counters"), counters); + root.Set(L"counters", counters); } ListValue* timers; - if (!root.GetList(LIT16("timers"), &timers)) { + if (!root.GetList(L"timers", &timers)) { timers = new ListValue(); - root.Set(LIT16("timers"), timers); + root.Set(L"timers", timers); } // NOTE: Counters start at index 1. @@ -455,9 +436,9 @@ std::string BrowserAboutHandler::AboutStats() { scan_index < counters->GetSize(); scan_index++) { DictionaryValue* dictionary; if (counters->GetDictionary(scan_index, &dictionary)) { - string16 scan_name; - if (dictionary->GetString(LIT16("name"), &scan_name) && - UTF16ToUTF8(scan_name) == name) { + std::wstring scan_name; + if (dictionary->GetString(L"name", &scan_name) && + WideToASCII(scan_name) == name) { counter = dictionary; } } else { @@ -467,7 +448,7 @@ std::string BrowserAboutHandler::AboutStats() { if (counter == NULL) { counter = new DictionaryValue(); - counter->SetString(LIT16("name"), UTF8ToUTF16(name)); + counter->SetString(L"name", ASCIIToWide(name)); counters->Append(counter); } @@ -477,11 +458,11 @@ std::string BrowserAboutHandler::AboutStats() { int new_value = table->GetRowValue(index); int prior_value = 0; int delta = 0; - if (counter->GetInteger(LIT16("value"), &prior_value)) { + if (counter->GetInteger(L"value", &prior_value)) { delta = new_value - prior_value; } - counter->SetInteger(LIT16("value"), new_value); - counter->SetInteger(LIT16("delta"), delta); + counter->SetInteger(L"value", new_value); + counter->SetInteger(L"delta", delta); } break; case 'm': @@ -492,7 +473,7 @@ std::string BrowserAboutHandler::AboutStats() { case 't': { int time = table->GetRowValue(index); - counter->SetInteger(LIT16("time"), time); + counter->SetInteger(L"time", time); // Store this on the timers list as well. timers->Append(counter); @@ -538,16 +519,16 @@ void AboutMemoryHandler::BindProcessMetrics(DictionaryValue* data, DCHECK(data && info); // Bind metrics to dictionary. - data->SetInteger(LIT16("ws_priv"), static_cast<int>(info->working_set.priv)); - data->SetInteger(LIT16("ws_shareable"), + data->SetInteger(L"ws_priv", static_cast<int>(info->working_set.priv)); + data->SetInteger(L"ws_shareable", static_cast<int>(info->working_set.shareable)); - data->SetInteger(LIT16("ws_shared"), static_cast<int>(info->working_set.shared)); - data->SetInteger(LIT16("comm_priv"), static_cast<int>(info->committed.priv)); - data->SetInteger(LIT16("comm_map"), static_cast<int>(info->committed.mapped)); - data->SetInteger(LIT16("comm_image"), static_cast<int>(info->committed.image)); - data->SetInteger(LIT16("pid"), info->pid); - data->SetString(LIT16("version"), WideToUTF16Hack(info->version)); - data->SetInteger(LIT16("processes"), info->num_processes); + data->SetInteger(L"ws_shared", static_cast<int>(info->working_set.shared)); + data->SetInteger(L"comm_priv", static_cast<int>(info->committed.priv)); + data->SetInteger(L"comm_map", static_cast<int>(info->committed.mapped)); + data->SetInteger(L"comm_image", static_cast<int>(info->committed.image)); + data->SetInteger(L"pid", info->pid); + data->SetString(L"version", info->version); + data->SetInteger(L"processes", info->num_processes); } // Helper for AboutMemory to append memory usage information for all @@ -564,9 +545,9 @@ void AboutMemoryHandler::AppendProcess(ListValue* child_data, std::wstring child_label(ChildProcessInfo::GetTypeNameInEnglish(info->type)); if (info->is_diagnostics) child_label.append(L" (diagnostics)"); - child->SetString(LIT16("child_name"), WideToUTF16Hack(child_label)); + child->SetString(L"child_name", child_label); ListValue* titles = new ListValue(); - child->Set(LIT16("titles"), titles); + child->Set(L"titles", titles); for (size_t i = 0; i < info->titles.size(); ++i) titles->Append(new StringValue(info->titles[i])); } @@ -576,7 +557,7 @@ void AboutMemoryHandler::OnDetailsAvailable() { // the root of the JSON hierarchy for about:memory jstemplate DictionaryValue root; ListValue* browsers = new ListValue(); - root.Set(LIT16("browsers"), browsers); + root.Set(L"browsers", browsers); ProcessData* browser_processes = processes(); @@ -607,8 +588,7 @@ void AboutMemoryHandler::OnDetailsAvailable() { } DictionaryValue* browser_data = new DictionaryValue(); browsers->Append(browser_data); - browser_data->SetString(LIT16("name"), - WideToUTF16Hack(browser_processes[index].name)); + browser_data->SetString(L"name", browser_processes[index].name); BindProcessMetrics(browser_data, &aggregate); @@ -628,9 +608,9 @@ void AboutMemoryHandler::OnDetailsAvailable() { // Set the browser & renderer detailed process data. DictionaryValue* browser_data = new DictionaryValue(); - root.Set(LIT16("browzr_data"), browser_data); + root.Set(L"browzr_data", browser_data); ListValue* child_data = new ListValue(); - root.Set(LIT16("child_data"), child_data); + root.Set(L"child_data", child_data); ProcessData process = browser_processes[0]; // Chrome is the first browser. for (size_t index = 0; index < process.processes.size(); index++) { diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index a3d8dba..d4ec343 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -113,10 +113,8 @@ void SetOverrideHomePage(const CommandLine& command_line, std::wstring new_homepage = URLFixerUpper::FixupRelativeFile( browser_directory, command_line.GetSwitchValue(switches::kHomePage)); - prefs->transient()->SetString(WideToUTF16Hack(prefs::kHomePage), - WideToUTF16Hack(new_homepage)); - prefs->transient()->SetBoolean( - WideToUTF16Hack(prefs::kHomePageIsNewTabPage), false); + prefs->transient()->SetString(prefs::kHomePage, new_homepage); + prefs->transient()->SetBoolean(prefs::kHomePageIsNewTabPage, false); } } @@ -476,8 +474,7 @@ bool BrowserInit::ProcessCommandLine( SetOverrideHomePage(command_line, profile->GetPrefs()); if (command_line.HasSwitch(switches::kBrowserStartRenderersManually)) - prefs->transient()->SetBoolean( - WideToUTF16Hack(prefs::kStartRenderersManually), true); + prefs->transient()->SetBoolean(prefs::kStartRenderersManually, true); bool silent_launch = false; #if defined(OS_WIN) diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index b2366c1..fc4513c 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -144,21 +144,16 @@ void HandleErrorTestParameters(const CommandLine& command_line) { struct LazyDirectoryListerCacher { LazyDirectoryListerCacher() { DictionaryValue value; - value.SetString( - LIT16("header"), - WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_HEADER))); - value.SetString( - LIT16("parentDirText"), - WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_PARENT))); - value.SetString( - LIT16("headerName"), - WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_NAME))); - value.SetString( - LIT16("headerSize"), - WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_SIZE))); - value.SetString( - LIT16("headerDateModified"), - WideToUTF16Hack(l10n_util::GetString(IDS_DIRECTORY_LISTING_DATE_MODIFIED))); + value.SetString(L"header", + l10n_util::GetString(IDS_DIRECTORY_LISTING_HEADER)); + value.SetString(L"parentDirText", + l10n_util::GetString(IDS_DIRECTORY_LISTING_PARENT)); + value.SetString(L"headerName", + l10n_util::GetString(IDS_DIRECTORY_LISTING_NAME)); + value.SetString(L"headerSize", + l10n_util::GetString(IDS_DIRECTORY_LISTING_SIZE)); + value.SetString(L"headerDateModified", + l10n_util::GetString(IDS_DIRECTORY_LISTING_DATE_MODIFIED)); html_data = jstemplate_builder::GetTemplateHtml( ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_DIR_HEADER_HTML), @@ -513,8 +508,8 @@ int BrowserMain(const MainFunctionParams& parameters) { MetricsService* metrics = NULL; if (!parsed_command_line.HasSwitch(switches::kDisableMetrics)) { if (parsed_command_line.HasSwitch(switches::kMetricsRecordingOnly)) { - local_state->transient()->SetBoolean( - WideToUTF16Hack(prefs::kMetricsReportingEnabled), false); + local_state->transient()->SetBoolean(prefs::kMetricsReportingEnabled, + false); } metrics = browser_process->metrics_service(); DCHECK(metrics); diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc index 9a52bdd..b0efcad 100644 --- a/chrome/browser/dom_ui/dom_ui.cc +++ b/chrome/browser/dom_ui/dom_ui.cc @@ -111,7 +111,7 @@ void DOMMessageHandler::SetURLAndTitle(DictionaryValue* dictionary, std::wstring title, const GURL& gurl) { std::wstring wstring_url = UTF8ToWide(gurl.spec()); - dictionary->SetString(LIT16("url"), WideToUTF16Hack(wstring_url)); + dictionary->SetString(L"url", wstring_url); bool using_url_as_the_title = false; if (title.empty()) { @@ -133,7 +133,7 @@ void DOMMessageHandler::SetURLAndTitle(DictionaryValue* dictionary, DCHECK(success ? (title != title_to_set) : (title == title_to_set)); } } - dictionary->SetString(LIT16("title"), WideToUTF16Hack(title_to_set)); + dictionary->SetString(L"title", title_to_set); } bool DOMMessageHandler::ExtractIntegerValue(const Value* value, int* out_int) { diff --git a/chrome/browser/dom_ui/history_ui.cc b/chrome/browser/dom_ui/history_ui.cc index bbc1602..9bc5d61 100644 --- a/chrome/browser/dom_ui/history_ui.cc +++ b/chrome/browser/dom_ui/history_ui.cc @@ -49,32 +49,32 @@ HistoryUIHTMLSource::HistoryUIHTMLSource() void HistoryUIHTMLSource::StartDataRequest(const std::string& path, int request_id) { DictionaryValue localized_strings; - localized_strings.SetString(LIT16("title"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_TITLE))); - localized_strings.SetString(LIT16("loading"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_LOADING))); - localized_strings.SetString(LIT16("newest"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NEWEST))); - localized_strings.SetString(LIT16("newer"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NEWER))); - localized_strings.SetString(LIT16("older"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_OLDER))); - localized_strings.SetString(LIT16("searchresultsfor"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_SEARCHRESULTSFOR))); - localized_strings.SetString(LIT16("history"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_BROWSERESULTS))); - localized_strings.SetString(LIT16("cont"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_CONTINUED))); - localized_strings.SetString(LIT16("searchbutton"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_SEARCH_BUTTON))); - localized_strings.SetString(LIT16("noresults"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NO_RESULTS))); - localized_strings.SetString(LIT16("noitems"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_NO_ITEMS))); - localized_strings.SetString(LIT16("deleteday"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_LINK))); - localized_strings.SetString(LIT16("deletedaywarning"), - WideToUTF16Hack(l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING))); + localized_strings.SetString(L"title", + l10n_util::GetString(IDS_HISTORY_TITLE)); + localized_strings.SetString(L"loading", + l10n_util::GetString(IDS_HISTORY_LOADING)); + localized_strings.SetString(L"newest", + l10n_util::GetString(IDS_HISTORY_NEWEST)); + localized_strings.SetString(L"newer", + l10n_util::GetString(IDS_HISTORY_NEWER)); + localized_strings.SetString(L"older", + l10n_util::GetString(IDS_HISTORY_OLDER)); + localized_strings.SetString(L"searchresultsfor", + l10n_util::GetString(IDS_HISTORY_SEARCHRESULTSFOR)); + localized_strings.SetString(L"history", + l10n_util::GetString(IDS_HISTORY_BROWSERESULTS)); + localized_strings.SetString(L"cont", + l10n_util::GetString(IDS_HISTORY_CONTINUED)); + localized_strings.SetString(L"searchbutton", + l10n_util::GetString(IDS_HISTORY_SEARCH_BUTTON)); + localized_strings.SetString(L"noresults", + l10n_util::GetString(IDS_HISTORY_NO_RESULTS)); + localized_strings.SetString(L"noitems", + l10n_util::GetString(IDS_HISTORY_NO_ITEMS)); + localized_strings.SetString(L"deleteday", + l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_LINK)); + localized_strings.SetString(L"deletedaywarning", + l10n_util::GetString(IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING)); static const StringPiece history_html( ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -226,7 +226,7 @@ void BrowsingHistoryHandler::QueryComplete( SetURLAndTitle(page_value, page.title(), page.url()); // Need to pass the time in epoch time (fastest JS conversion). - page_value->SetInteger(LIT16("time"), + page_value->SetInteger(L"time", static_cast<int>(page.visit_time().ToTimeT())); // Until we get some JS i18n infrastructure, we also need to @@ -246,17 +246,13 @@ void BrowsingHistoryHandler::QueryComplete( IDS_HISTORY_DATE_WITH_RELATIVE_TIME, date_str, base::TimeFormatFriendlyDate(page.visit_time())); } - page_value->SetString(LIT16("dateRelativeDay"), - WideToUTF16Hack(date_str)); - page_value->SetString( - LIT16("dateTimeOfDay"), - WideToUTF16Hack(base::TimeFormatTimeOfDay(page.visit_time()))); + page_value->SetString(L"dateRelativeDay", date_str); + page_value->SetString(L"dateTimeOfDay", + base::TimeFormatTimeOfDay(page.visit_time())); } else { - page_value->SetString( - LIT16("dateShort"), - WideToUTF16Hack(base::TimeFormatShortDate(page.visit_time()))); - page_value->SetString( - LIT16("snippet"), WideToUTF16Hack(page.snippet().text())); + page_value->SetString(L"dateShort", + base::TimeFormatShortDate(page.visit_time())); + page_value->SetString(L"snippet", page.snippet().text()); } page_value->SetBoolean(L"starred", dom_ui_->get_profile()->GetBookmarkModel()->IsBookmarked(page.url())); diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc index 26366f7..afb7baa 100644 --- a/chrome/browser/dom_ui/new_tab_ui.cc +++ b/chrome/browser/dom_ui/new_tab_ui.cc @@ -125,14 +125,14 @@ class PaintTimer : public RenderWidgetHost::PaintObserver { void SetURLTitleAndDirection(DictionaryValue* dictionary, const std::wstring& title, const GURL& gurl) { - string16 string_url = UTF8ToUTF16(gurl.spec()); - dictionary->SetString(LIT16("url"), string_url); + std::wstring wstring_url = UTF8ToWide(gurl.spec()); + dictionary->SetString(L"url", wstring_url); bool using_url_as_the_title = false; std::wstring title_to_set(title); if (title_to_set.empty()) { using_url_as_the_title = true; - title_to_set = UTF16ToWideHack(string_url); + title_to_set = wstring_url; } // We set the "dir" attribute of the title, so that in RTL locales, a LTR @@ -168,8 +168,8 @@ void SetURLTitleAndDirection(DictionaryValue* dictionary, } } } - dictionary->SetString(LIT16("title"), WideToUTF16Hack(title_to_set)); - dictionary->SetString(LIT16("direction"), WideToUTF16Hack(direction)); + dictionary->SetString(L"title", title_to_set); + dictionary->SetString(L"direction", direction); } } // end anonymous namespace @@ -208,42 +208,35 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path, profile_name); } DictionaryValue localized_strings; - localized_strings.SetString(LIT16("title"), WideToUTF16Hack(title)); - localized_strings.SetString(LIT16("mostvisited"), - WideToUTF16Hack(most_visited)); - localized_strings.SetString(LIT16("searches"), - WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_SEARCHES))); - localized_strings.SetString(LIT16("bookmarks"), - WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_BOOKMARKS))); - localized_strings.SetString(LIT16("showhistory"), - WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_HISTORY_SHOW))); - localized_strings.SetString(LIT16("searchhistory"), - WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_HISTORY_SEARCH))); - localized_strings.SetString(LIT16("recentlyclosed"), - WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED))); - localized_strings.SetString( - LIT16("mostvisitedintro"), - WideToUTF16Hack(l10n_util::GetStringF( - IDS_NEW_TAB_MOST_VISITED_INTRO, - l10n_util::GetString(IDS_WELCOME_PAGE_URL)))); - localized_strings.SetString( - LIT16("closedwindow"), - WideToUTF16Hack( - l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW))); - - localized_strings.SetString( - LIT16("textdirection"), - WideToUTF16Hack( - (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - kRTLHtmlTextDirection : kDefaultHtmlTextDirection)); + localized_strings.SetString(L"title", title); + localized_strings.SetString(L"mostvisited", most_visited); + localized_strings.SetString(L"searches", + l10n_util::GetString(IDS_NEW_TAB_SEARCHES)); + localized_strings.SetString(L"bookmarks", + l10n_util::GetString(IDS_NEW_TAB_BOOKMARKS)); + localized_strings.SetString(L"showhistory", + l10n_util::GetString(IDS_NEW_TAB_HISTORY_SHOW)); + localized_strings.SetString(L"searchhistory", + l10n_util::GetString(IDS_NEW_TAB_HISTORY_SEARCH)); + localized_strings.SetString(L"recentlyclosed", + l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED)); + localized_strings.SetString(L"mostvisitedintro", + l10n_util::GetStringF(IDS_NEW_TAB_MOST_VISITED_INTRO, + l10n_util::GetString(IDS_WELCOME_PAGE_URL))); + localized_strings.SetString(L"closedwindow", + l10n_util::GetString(IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW)); + + localized_strings.SetString(L"textdirection", + (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? + kRTLHtmlTextDirection : kDefaultHtmlTextDirection); // Let the tab know whether it's the first tab being viewed. - localized_strings.SetString(LIT16("firstview"), - first_view_ ? LIT16("true") : string16()); + localized_strings.SetString(L"firstview", + first_view_ ? L"true" : std::wstring()); first_view_ = false; #ifdef CHROME_PERSONALIZATION - localized_strings.SetString(LIT16("p13nsrc"), Personalization::GetNewTabSource()); + localized_strings.SetString(L"p13nsrc", Personalization::GetNewTabSource()); #endif static const StringPiece new_tab_html( @@ -270,19 +263,15 @@ IncognitoTabHTMLSource::IncognitoTabHTMLSource() void IncognitoTabHTMLSource::StartDataRequest(const std::string& path, int request_id) { DictionaryValue localized_strings; - localized_strings.SetString(LIT16("title"), - WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_TITLE))); - localized_strings.SetString( - LIT16("content"), - WideToUTF16Hack(l10n_util::GetStringF( - IDS_NEW_TAB_OTR_MESSAGE, - l10n_util::GetString(IDS_LEARN_MORE_INCOGNITO_URL)))); - - localized_strings.SetString( - LIT16("textdirection"), - WideToUTF16Hack( - (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - kRTLHtmlTextDirection : kDefaultHtmlTextDirection)); + localized_strings.SetString(L"title", + l10n_util::GetString(IDS_NEW_TAB_TITLE)); + localized_strings.SetString(L"content", + l10n_util::GetStringF(IDS_NEW_TAB_OTR_MESSAGE, + l10n_util::GetString(IDS_LEARN_MORE_INCOGNITO_URL))); + + localized_strings.SetString(L"textdirection", + (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? + kRTLHtmlTextDirection : kDefaultHtmlTextDirection); static const StringPiece incognito_tab_html( ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -492,14 +481,12 @@ void TemplateURLHandler::OnTemplateURLModelChanged() { if (!urlref) continue; DictionaryValue* entry_value = new DictionaryValue; - entry_value->SetString(LIT16("short_name"), - WideToUTF16Hack(urls[i]->short_name())); - entry_value->SetString(LIT16("keyword"), - WideToUTF16Hack(urls[i]->keyword())); + entry_value->SetString(L"short_name", urls[i]->short_name()); + entry_value->SetString(L"keyword", urls[i]->keyword()); const GURL& url = urls[i]->GetFavIconURL(); if (url.is_valid()) - entry_value->SetString(LIT16("favIconURL"), UTF8ToUTF16(url.spec())); + entry_value->SetString(L"favIconURL", UTF8ToWide(url.spec())); urls_value.Append(entry_value); } @@ -658,7 +645,7 @@ void RecentlyClosedTabsHandler::TabRestoreServiceChanged( (entry->type == TabRestoreService::WINDOW && WindowToValue(*static_cast<TabRestoreService::Window*>(entry), value))) { - value->SetInteger(LIT16("sessionId"), entry->id); + value->SetInteger(L"sessionId", entry->id); list_value.Append(value); added_count++; } else { @@ -686,7 +673,7 @@ bool RecentlyClosedTabsHandler::TabToValue( SetURLTitleAndDirection(dictionary, current_navigation.title(), current_navigation.url()); - dictionary->SetString(LIT16("type"), LIT16("tab")); + dictionary->SetString(L"type", L"tab"); return true; } @@ -711,8 +698,8 @@ bool RecentlyClosedTabsHandler::WindowToValue( return false; } - dictionary->SetString(LIT16("type"), LIT16("window")); - dictionary->Set(LIT16("tabs"), tab_values); + dictionary->SetString(L"type", L"window"); + dictionary->Set(L"tabs", tab_values); return true; } diff --git a/chrome/browser/extensions/extension.cc b/chrome/browser/extensions/extension.cc index 1db97ceb..918268f 100644 --- a/chrome/browser/extensions/extension.cc +++ b/chrome/browser/extensions/extension.cc @@ -163,14 +163,14 @@ bool Extension::InitFromValue(const DictionaryValue& source, std::string* error) { // Check format version. int format_version = 0; - if (!source.GetInteger(WideToUTF16Hack(kFormatVersionKey), &format_version) || + if (!source.GetInteger(kFormatVersionKey, &format_version) || static_cast<uint32>(format_version) != kExpectedFormatVersion) { *error = kInvalidFormatVersionError; return false; } // Initialize id. - if (!source.GetString(WideToUTF16Hack(kIdKey), &id_)) { + if (!source.GetString(kIdKey, &id_)) { *error = kInvalidIdError; return false; } @@ -193,7 +193,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, // Initialize version. std::string version_str; - if (!source.GetString(WideToUTF16Hack(kVersionKey), &version_str)) { + if (!source.GetString(kVersionKey, &version_str)) { *error = kInvalidVersionError; return false; } @@ -204,14 +204,14 @@ bool Extension::InitFromValue(const DictionaryValue& source, } // Initialize name. - if (!source.GetString(WideToUTF16Hack(kNameKey), &name_)) { + if (!source.GetString(kNameKey, &name_)) { *error = kInvalidNameError; return false; } // Initialize description (optional). - if (source.HasKey(WideToUTF16Hack(kDescriptionKey))) { - if (!source.GetString(WideToUTF16Hack(kDescriptionKey), &description_)) { + if (source.HasKey(kDescriptionKey)) { + if (!source.GetString(kDescriptionKey, &description_)) { *error = kInvalidDescriptionError; return false; } @@ -220,17 +220,17 @@ bool Extension::InitFromValue(const DictionaryValue& source, // Initialize zip hash (only present in zip) // There's no need to verify it at this point. If it's in a bogus format // it won't pass the hash verify step. - if (source.HasKey(WideToUTF16Hack(kZipHashKey))) { - if (!source.GetString(WideToUTF16Hack(kZipHashKey), &zip_hash_)) { + if (source.HasKey(kZipHashKey)) { + if (!source.GetString(kZipHashKey, &zip_hash_)) { *error = kInvalidZipHashError; return false; } } // Initialize plugins dir (optional). - if (source.HasKey(WideToUTF16Hack(kPluginsDirKey))) { + if (source.HasKey(kPluginsDirKey)) { std::string plugins_dir; - if (!source.GetString(WideToUTF16Hack(kPluginsDirKey), &plugins_dir)) { + if (!source.GetString(kPluginsDirKey, &plugins_dir)) { *error = kInvalidPluginsDirError; return false; } @@ -238,9 +238,9 @@ bool Extension::InitFromValue(const DictionaryValue& source, } // Initialize content scripts (optional). - if (source.HasKey(WideToUTF16Hack(kContentScriptsKey))) { + if (source.HasKey(kContentScriptsKey)) { ListValue* list_value; - if (!source.GetList(WideToUTF16Hack(kContentScriptsKey), &list_value)) { + if (!source.GetList(kContentScriptsKey, &list_value)) { *error = kInvalidContentScriptsListError; return false; } @@ -255,12 +255,12 @@ bool Extension::InitFromValue(const DictionaryValue& source, ListValue* matches; ListValue* js; - if (!content_script->GetList(WideToUTF16Hack(kMatchesKey), &matches)) { + if (!content_script->GetList(kMatchesKey, &matches)) { *error = FormatErrorMessage(kInvalidMatchesError, IntToString(i)); return false; } - if (!content_script->GetList(WideToUTF16Hack(kJsKey), &js)) { + if (!content_script->GetList(kJsKey, &js)) { *error = FormatErrorMessage(kInvalidJsListError, IntToString(i)); return false; } @@ -277,10 +277,9 @@ bool Extension::InitFromValue(const DictionaryValue& source, } UserScript script; - if (content_script->HasKey(WideToUTF16Hack(kRunAtKey))) { + if (content_script->HasKey(kRunAtKey)) { std::string run_location; - if (!content_script->GetString(WideToUTF16Hack(kRunAtKey), - &run_location)) { + if (!content_script->GetString(kRunAtKey, &run_location)) { *error = FormatErrorMessage(kInvalidRunAtError, IntToString(i)); return false; } @@ -329,3 +328,4 @@ bool Extension::InitFromValue(const DictionaryValue& source, return true; } + diff --git a/chrome/browser/extensions/extension_unittest.cc b/chrome/browser/extensions/extension_unittest.cc index 259c8db..aa8d791 100644 --- a/chrome/browser/extensions/extension_unittest.cc +++ b/chrome/browser/extensions/extension_unittest.cc @@ -43,65 +43,64 @@ TEST(ExtensionTest, InitFromValueInvalid) { // Test missing and invalid format versions input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->Remove(WideToUTF16Hack(Extension::kFormatVersionKey), NULL); + input_value->Remove(Extension::kFormatVersionKey, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidFormatVersionError, error); - input_value->SetString(WideToUTF16Hack(Extension::kFormatVersionKey), "foo"); + input_value->SetString(Extension::kFormatVersionKey, "foo"); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidFormatVersionError, error); - input_value->SetInteger(WideToUTF16Hack(Extension::kFormatVersionKey), 2); + input_value->SetInteger(Extension::kFormatVersionKey, 2); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidFormatVersionError, error); // Test missing and invalid ids input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->Remove(WideToUTF16Hack(Extension::kIdKey), NULL); + input_value->Remove(Extension::kIdKey, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidIdError, error); - input_value->SetInteger(WideToUTF16Hack(Extension::kIdKey), 42); + input_value->SetInteger(Extension::kIdKey, 42); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidIdError, error); // Test missing and invalid versions input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->Remove(WideToUTF16Hack(Extension::kVersionKey), NULL); + input_value->Remove(Extension::kVersionKey, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidVersionError, error); - input_value->SetInteger(WideToUTF16Hack(Extension::kVersionKey), 42); + input_value->SetInteger(Extension::kVersionKey, 42); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidVersionError, error); // Test missing and invalid names input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->Remove(WideToUTF16Hack(Extension::kNameKey), NULL); + input_value->Remove(Extension::kNameKey, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidNameError, error); - input_value->SetInteger(WideToUTF16Hack(Extension::kNameKey), 42); + input_value->SetInteger(Extension::kNameKey, 42); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidNameError, error); // Test invalid description input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->SetInteger(WideToUTF16Hack(Extension::kDescriptionKey), 42); + input_value->SetInteger(Extension::kDescriptionKey, 42); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidDescriptionError, error); // Test invalid user scripts list input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->SetInteger(WideToUTF16Hack(Extension::kContentScriptsKey), 42); + input_value->SetInteger(Extension::kContentScriptsKey, 42); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_EQ(Extension::kInvalidContentScriptsListError, error); // Test invalid user script item input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); ListValue* content_scripts = NULL; - input_value->GetList(WideToUTF16Hack(Extension::kContentScriptsKey), - &content_scripts); + input_value->GetList(Extension::kContentScriptsKey, &content_scripts); ASSERT_FALSE(NULL == content_scripts); content_scripts->Set(0, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); @@ -109,21 +108,19 @@ TEST(ExtensionTest, InitFromValueInvalid) { // Test missing and invalid matches array input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->GetList(WideToUTF16Hack(Extension::kContentScriptsKey), - &content_scripts); + input_value->GetList(Extension::kContentScriptsKey, &content_scripts); DictionaryValue* user_script = NULL; content_scripts->GetDictionary(0, &user_script); - user_script->Remove(WideToUTF16Hack(Extension::kMatchesKey), NULL); + user_script->Remove(Extension::kMatchesKey, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchesError)); - user_script->Set(WideToUTF16Hack(Extension::kMatchesKey), - Value::CreateIntegerValue(42)); + user_script->Set(Extension::kMatchesKey, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchesError)); ListValue* matches = new ListValue; - user_script->Set(WideToUTF16Hack(Extension::kMatchesKey), matches); + user_script->Set(Extension::kMatchesKey, matches); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchCountError)); @@ -134,20 +131,18 @@ TEST(ExtensionTest, InitFromValueInvalid) { // Test missing and invalid files array input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->GetList(WideToUTF16Hack(Extension::kContentScriptsKey), - &content_scripts); + input_value->GetList(Extension::kContentScriptsKey, &content_scripts); content_scripts->GetDictionary(0, &user_script); - user_script->Remove(WideToUTF16Hack(Extension::kJsKey), NULL); + user_script->Remove(Extension::kJsKey, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsListError)); - user_script->Set(WideToUTF16Hack(Extension::kJsKey), - Value::CreateIntegerValue(42)); + user_script->Set(Extension::kJsKey, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsListError)); ListValue* files = new ListValue; - user_script->Set(WideToUTF16Hack(Extension::kJsKey), files); + user_script->Set(Extension::kJsKey, files); EXPECT_FALSE(extension.InitFromValue(*input_value, &error)); EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsCountError)); @@ -174,11 +169,11 @@ TEST(ExtensionTest, InitFromValueValid) { DictionaryValue input_value; // Test minimal extension - input_value.SetInteger(WideToUTF16Hack(Extension::kFormatVersionKey), 1); - input_value.SetString(WideToUTF16Hack(Extension::kIdKey), + input_value.SetInteger(Extension::kFormatVersionKey, 1); + input_value.SetString(Extension::kIdKey, "00123456789ABCDEF0123456789ABCDEF0123456"); - input_value.SetString(WideToUTF16Hack(Extension::kVersionKey), "1.0.0.0"); - input_value.SetString(WideToUTF16Hack(Extension::kNameKey), "my extension"); + input_value.SetString(Extension::kVersionKey, "1.0.0.0"); + input_value.SetString(Extension::kNameKey, "my extension"); EXPECT_TRUE(extension.InitFromValue(input_value, &error)); EXPECT_EQ("", error); @@ -198,11 +193,11 @@ TEST(ExtensionTest, GetResourceURLAndPath) { #endif Extension extension(path); DictionaryValue input_value; - input_value.SetInteger(WideToUTF16Hack(Extension::kFormatVersionKey), 1); - input_value.SetString(WideToUTF16Hack(Extension::kIdKey), + input_value.SetInteger(Extension::kFormatVersionKey, 1); + input_value.SetString(Extension::kIdKey, "00123456789ABCDEF0123456789ABCDEF0123456"); - input_value.SetString(WideToUTF16Hack(Extension::kVersionKey), "1.0.0.0"); - input_value.SetString(WideToUTF16Hack(Extension::kNameKey), "my extension"); + input_value.SetString(Extension::kVersionKey, "1.0.0.0"); + input_value.SetString(Extension::kNameKey, "my extension"); EXPECT_TRUE(extension.InitFromValue(input_value, NULL)); EXPECT_EQ(extension.url().spec() + "bar/baz.js", diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index be6f068..3271920 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -402,15 +402,14 @@ DictionaryValue* ExtensionsServiceBackend::ReadManifest() { // again later, checking it here allows us to skip some potentially expensive // work. std::string id; - if (!manifest->GetString(WideToUTF16Hack(Extension::kIdKey), &id)) { + if (!manifest->GetString(Extension::kIdKey, &id)) { ReportExtensionInstallError("missing id key"); return NULL; } FilePath dest_dir = install_directory_.AppendASCII(id.c_str()); if (file_util::PathExists(dest_dir)) { std::string version; - if (!manifest->GetString(WideToUTF16Hack(Extension::kVersionKey), - &version)) { + if (!manifest->GetString(Extension::kVersionKey, &version)) { ReportExtensionInstallError("missing version key"); return NULL; } @@ -422,8 +421,7 @@ DictionaryValue* ExtensionsServiceBackend::ReadManifest() { } std::string zip_hash; - if (!manifest->GetString(WideToUTF16Hack(Extension::kZipHashKey), - &zip_hash)) { + if (!manifest->GetString(Extension::kZipHashKey, &zip_hash)) { ReportExtensionInstallError("missing zip_hash key"); return NULL; } diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index 57da551..a504b11 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -383,24 +383,24 @@ void MetricsLog::WritePluginStabilityElements(PrefService* pref) { } DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter); - string16 plugin_name; - plugin_dict->GetString(WideToUTF16Hack(prefs::kStabilityPluginName), &plugin_name); + std::wstring plugin_name; + plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); OPEN_ELEMENT_FOR_SCOPE("pluginstability"); // Use "filename" instead of "name", otherwise we need to update the // UMA servers. - WriteAttribute("filename", CreateBase64Hash(UTF16ToUTF8(plugin_name))); + WriteAttribute("filename", CreateBase64Hash(WideToUTF8(plugin_name))); int launches = 0; - plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches), &launches); + plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches); WriteIntAttribute("launchcount", launches); int instances = 0; - plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances), &instances); + plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances); WriteIntAttribute("instancecount", instances); int crashes = 0; - plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes), &crashes); + plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes); WriteIntAttribute("crashcount", crashes); } @@ -568,11 +568,10 @@ void MetricsLog::WriteAllProfilesMetrics( const std::wstring profile_prefix(prefs::kProfilePrefix); for (DictionaryValue::key_iterator i = all_profiles_metrics.begin_keys(); i != all_profiles_metrics.end_keys(); ++i) { - const string16 key_name16 = *i; - const std::wstring& key_name = UTF16ToWideHack(key_name16); + const std::wstring& key_name = *i; if (key_name.compare(0, profile_prefix.size(), profile_prefix) == 0) { DictionaryValue* profile; - if (all_profiles_metrics.GetDictionary(key_name16, &profile)) + if (all_profiles_metrics.GetDictionary(key_name, &profile)) WriteProfileMetrics(key_name.substr(profile_prefix.size()), *profile); } } @@ -586,13 +585,13 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash, i != profile_metrics.end_keys(); ++i) { Value* value; if (profile_metrics.Get(*i, &value)) { - DCHECK(*i != LIT16("id")); + DCHECK(*i != L"id"); switch (value->GetType()) { case Value::TYPE_STRING: { std::string string_value; if (value->GetAsString(&string_value)) { OPEN_ELEMENT_FOR_SCOPE("profileparam"); - WriteAttribute("name", UTF16ToUTF8(*i)); + WriteAttribute("name", WideToUTF8(*i)); WriteAttribute("value", string_value); } break; @@ -602,7 +601,7 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash, bool bool_value; if (value->GetAsBoolean(&bool_value)) { OPEN_ELEMENT_FOR_SCOPE("profileparam"); - WriteAttribute("name", UTF16ToUTF8(*i)); + WriteAttribute("name", WideToUTF8(*i)); WriteIntAttribute("value", bool_value ? 1 : 0); } break; @@ -612,7 +611,7 @@ void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash, int int_value; if (value->GetAsInteger(&int_value)) { OPEN_ELEMENT_FOR_SCOPE("profileparam"); - WriteAttribute("name", UTF16ToUTF8(*i)); + WriteAttribute("name", WideToUTF8(*i)); WriteIntAttribute("value", int_value); } break; diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index db92b9c..e081bd9 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -1675,15 +1675,13 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { } DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*value_iter); - string16 plugin_name16; - plugin_dict->GetString(WideToUTF16Hack(prefs::kStabilityPluginName), - &plugin_name16); - if (plugin_name16.empty()) { + std::wstring plugin_name; + plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); + if (plugin_name.empty()) { NOTREACHED(); continue; } - std::wstring plugin_name = UTF16ToWideHack(plugin_name16); if (child_process_stats_buffer_.find(plugin_name) == child_process_stats_buffer_.end()) continue; @@ -1691,27 +1689,21 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { ChildProcessStats stats = child_process_stats_buffer_[plugin_name]; if (stats.process_launches) { int launches = 0; - plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches), - &launches); + plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches); launches += stats.process_launches; - plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches), - launches); + plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, launches); } if (stats.process_crashes) { int crashes = 0; - plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes), - &crashes); + plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes); crashes += stats.process_crashes; - plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes), - crashes); + plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, crashes); } if (stats.instances) { int instances = 0; - plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances), - &instances); + plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances); instances += stats.instances; - plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances), - instances); + plugin_dict->SetInteger(prefs::kStabilityPluginInstances, instances); } child_process_stats_buffer_.erase(plugin_name); @@ -1726,13 +1718,12 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { ChildProcessStats stats = cache_iter->second; DictionaryValue* plugin_dict = new DictionaryValue; - plugin_dict->SetString(WideToUTF16Hack(prefs::kStabilityPluginName), - WideToUTF16Hack(plugin_name)); - plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches), + plugin_dict->SetString(prefs::kStabilityPluginName, plugin_name); + plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, stats.process_launches); - plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes), + plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, stats.process_crashes); - plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances), + plugin_dict->SetInteger(prefs::kStabilityPluginInstances, stats.instances); plugins->Append(plugin_dict); } @@ -1844,7 +1835,7 @@ void MetricsService::AddProfileMetric(Profile* profile, DCHECK(prof_prefs); const std::wstring pref_key = std::wstring(prefs::kProfilePrefix) + id_hash + L"." + key; - prof_prefs->SetInteger(WideToUTF16Hack(pref_key), value); + prof_prefs->SetInteger(pref_key.c_str(), value); } static bool IsSingleThreaded() { diff --git a/chrome/browser/page_state.cc b/chrome/browser/page_state.cc index 3e013f2..827416c 100644 --- a/chrome/browser/page_state.cc +++ b/chrome/browser/page_state.cc @@ -28,7 +28,7 @@ void PageState::InitWithURL(const GURL& url) { // We know that the query string is UTF-8 since it's an internal URL. std::wstring value = UTF8ToWide( UnescapeURLComponent(escaped, UnescapeRule::REPLACE_PLUS_WITH_SPACE)); - state_->Set(UTF8ToUTF16(query_string.substr(keyComp.begin, keyComp.len)), + state_->Set(UTF8ToWide(query_string.substr(keyComp.begin, keyComp.len)), new StringValue(value)); } } @@ -59,11 +59,10 @@ void PageState::GetByteRepresentation(std::string* out) const { void PageState::SetProperty(const std::wstring& key, const std::wstring& value) { - state_->Set(WideToUTF16Hack(key), new StringValue(value)); + state_->Set(key, new StringValue(value)); } -bool PageState::GetProperty(const std::wstring& wkey, std::wstring* value) const { - string16 key(WideToUTF16(wkey)); +bool PageState::GetProperty(const std::wstring& key, std::wstring* value) const { if (state_->HasKey(key)) { Value* v; state_->Get(key, &v); diff --git a/chrome/browser/profile_manager.h b/chrome/browser/profile_manager.h index ba8581d..3735492 100644 --- a/chrome/browser/profile_manager.h +++ b/chrome/browser/profile_manager.h @@ -15,7 +15,6 @@ #include "base/file_path.h" #include "base/message_loop.h" #include "base/non_thread_safe.h" -#include "base/string_util.h" #include "base/system_monitor.h" #include "base/values.h" #include "chrome/browser/profile.h" @@ -34,21 +33,20 @@ class AvailableProfile { // Decodes a DictionaryValue into an AvailableProfile static AvailableProfile* FromValue(DictionaryValue* value) { DCHECK(value); - string16 name, id; + std::wstring name, id; FilePath::StringType directory; - value->GetString(LIT16("name"), &name); - value->GetString(LIT16("id"), &id); - value->GetString(LIT16("directory"), &directory); - return new AvailableProfile(UTF16ToWideHack(name), UTF16ToWideHack(id), - FilePath(directory)); + value->GetString(L"name", &name); + value->GetString(L"id", &id); + value->GetString(L"directory", &directory); + return new AvailableProfile(name, id, FilePath(directory)); } // Encodes this AvailableProfile into a new DictionaryValue DictionaryValue* ToValue() { DictionaryValue* value = new DictionaryValue; - value->SetString(LIT16("name"), WideToUTF16Hack(name_)); - value->SetString(LIT16("id"), WideToUTF16Hack(id_)); - value->SetString(LIT16("directory"), directory_.value()); + value->SetString(L"name", name_); + value->SetString(L"id", id_); + value->SetString(L"directory", directory_.value()); return value; } @@ -185,3 +183,4 @@ class ProfileManager : public NonThreadSafe, }; #endif // CHROME_BROWSER_PROFILE_MANAGER_H__ + diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc index 2590556..2eafe9a1 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc @@ -103,11 +103,11 @@ void SafeBrowsingBlockingPage::PopulateStringDictionary( const std::wstring& description1, const std::wstring& description2, const std::wstring& description3) { - strings->SetString(LIT16("title"), WideToUTF16Hack(title)); - strings->SetString(LIT16("headLine"), WideToUTF16Hack(headline)); - strings->SetString(LIT16("description1"), WideToUTF16Hack(description1)); - strings->SetString(LIT16("description2"), WideToUTF16Hack(description2)); - strings->SetString(LIT16("description3"), WideToUTF16Hack(description3)); + strings->SetString(L"title", title); + strings->SetString(L"headLine", headline); + strings->SetString(L"description1", description1); + strings->SetString(L"description2", description2); + strings->SetString(L"description3", description3); } void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary( @@ -115,17 +115,14 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary( bool malware = false; bool phishing = false; - string16 phishing_label = - WideToUTF16Hack(l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_LABEL)); - string16 phishing_link = - WideToUTF16Hack( - l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR)); - string16 malware_label = - WideToUTF16Hack( - l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_LABEL)); - string16 malware_link = - WideToUTF16Hack( - l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE)); + std::wstring phishing_label = + l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_LABEL); + std::wstring phishing_link = + l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR); + std::wstring malware_label = + l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_LABEL); + std::wstring malware_link = + l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE); ListValue* error_strings = new ListValue; for (UnsafeResourceList::const_iterator iter = unsafe_resources_.begin(); @@ -134,21 +131,20 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary( DictionaryValue* current_error_strings = new DictionaryValue; if (resource.threat_type == SafeBrowsingService::URL_MALWARE) { malware = true; - current_error_strings->SetString(LIT16("type"), LIT16("malware")); - current_error_strings->SetString(LIT16("typeLabel"), malware_label); - current_error_strings->SetString(LIT16("errorLink"), malware_link); + current_error_strings->SetString(L"type", L"malware"); + current_error_strings->SetString(L"typeLabel", malware_label); + current_error_strings->SetString(L"errorLink", malware_link); } else { DCHECK(resource.threat_type == SafeBrowsingService::URL_PHISHING); phishing = true; - current_error_strings->SetString(LIT16("type"), LIT16("phishing")); - current_error_strings->SetString(LIT16("typeLabel"), phishing_label); - current_error_strings->SetString(LIT16("errorLink"), phishing_link); + current_error_strings->SetString(L"type", L"phishing"); + current_error_strings->SetString(L"typeLabel", phishing_label); + current_error_strings->SetString(L"errorLink", phishing_link); } - current_error_strings->SetString(LIT16("url"), - UTF8ToUTF16(resource.url.spec())); + current_error_strings->SetString(L"url", UTF8ToWide(resource.url.spec())); error_strings->Append(current_error_strings); } - strings->Set(LIT16("errors"), error_strings); + strings->Set(L"errors", error_strings); DCHECK(phishing || malware); if (malware && phishing) { @@ -182,18 +178,15 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary( L"", L""); } - strings->SetString(LIT16("confirm_text"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_MALWARE_DESCRIPTION_AGREE))); - strings->SetString(LIT16("continue_button"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON))); - strings->SetString(LIT16("back_button"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON))); - strings->SetString(LIT16("textdirection"), + strings->SetString(L"confirm_text", + l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION_AGREE)); + strings->SetString(L"continue_button", + l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON)); + strings->SetString(L"back_button", + l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); + strings->SetString(L"textdirection", (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - LIT16("rtl") : LIT16("ltr")); + L"rtl" : L"ltr"); } void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary( @@ -201,7 +194,7 @@ void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary( std::wstring link = StringPrintf(kSbDiagnosticHtml, l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE).c_str()); - strings->SetString(LIT16("badURL"), UTF8ToUTF16(url().host())); + strings->SetString(L"badURL", UTF8ToWide(url().host())); // Check to see if we're blocking the main page, or a sub-resource on the // main page. std::wstring description1, description2; @@ -227,18 +220,15 @@ void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary( description1, description2, l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION3)); - strings->SetString(LIT16("confirm_text"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_MALWARE_DESCRIPTION_AGREE))); - strings->SetString(LIT16("continue_button"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON))); - strings->SetString(LIT16("back_button"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON))); - strings->SetString(LIT16("textdirection"), + strings->SetString(L"confirm_text", + l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION_AGREE)); + strings->SetString(L"continue_button", + l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_PROCEED_BUTTON)); + strings->SetString(L"back_button", + l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); + strings->SetString(L"textdirection", (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - LIT16("rtl") : LIT16("ltr")); + L"rtl" : L"ltr"); } void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary( @@ -253,18 +243,15 @@ void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary( UTF8ToWide(url().host())), L""); - strings->SetString(LIT16("continue_button"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_PHISHING_PROCEED_BUTTON))); - strings->SetString(LIT16("back_button"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_PHISHING_BACK_BUTTON))); - strings->SetString(LIT16("report_error"), - WideToUTF16Hack(l10n_util::GetString( - IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR))); - strings->SetString(LIT16("textdirection"), + strings->SetString(L"continue_button", + l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_PROCEED_BUTTON)); + strings->SetString(L"back_button", + l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_BACK_BUTTON)); + strings->SetString(L"report_error", + l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_REPORT_ERROR)); + strings->SetString(L"textdirection", (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - LIT16("rtl") : LIT16("ltr")); + L"rtl" : L"ltr"); } void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) { @@ -448,3 +435,4 @@ bool SafeBrowsingBlockingPage::IsMainPage( return unsafe_resources.size() == 1 && unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME; } + diff --git a/chrome/browser/ssl/ssl_blocking_page.cc b/chrome/browser/ssl/ssl_blocking_page.cc index 966b514..c98975d 100644 --- a/chrome/browser/ssl/ssl_blocking_page.cc +++ b/chrome/browser/ssl/ssl_blocking_page.cc @@ -44,29 +44,23 @@ std::string SSLBlockingPage::GetHTMLContents() { // Let's build the html error page. DictionaryValue strings; SSLErrorInfo error_info = delegate_->GetSSLErrorInfo(error_); - strings.SetString( - LIT16("title"), - WideToUTF16Hack(l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_TITLE))); - strings.SetString(LIT16("headLine"), WideToUTF16Hack(error_info.title())); - strings.SetString(LIT16("description"), - WideToUTF16Hack(error_info.details())); - - strings.SetString( - LIT16("moreInfoTitle"), - WideToUTF16Hack(l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE))); + strings.SetString(L"title", + l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_TITLE)); + strings.SetString(L"headLine", error_info.title()); + strings.SetString(L"description", error_info.details()); + + strings.SetString(L"moreInfoTitle", + l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE)); SetExtraInfo(&strings, error_info.extra_information()); - strings.SetString( - LIT16("proceed"), - WideToUTF16Hack(l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_PROCEED))); - strings.SetString( - LIT16("exit"), - WideToUTF16Hack(l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_EXIT))); + strings.SetString(L"proceed", + l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_PROCEED)); + strings.SetString(L"exit", + l10n_util::GetString(IDS_SSL_BLOCKING_PAGE_EXIT)); - strings.SetString( - LIT16("textdirection"), + strings.SetString(L"textdirection", (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - LIT16("rtl") : LIT16("ltr")); + L"rtl" : L"ltr"); static const StringPiece html( ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -137,15 +131,15 @@ void SSLBlockingPage::SetExtraInfo( DictionaryValue* strings, const std::vector<std::wstring>& extra_info) { DCHECK(extra_info.size() < 5); // We allow 5 paragraphs max. - const string16 keys[5] = { - LIT16("moreInfo1"), LIT16("moreInfo2"), LIT16("moreInfo3"), - LIT16("moreInfo4"), LIT16("moreInfo5") + const std::wstring keys[5] = { + L"moreInfo1", L"moreInfo2", L"moreInfo3", L"moreInfo4", L"moreInfo5" }; int i; for (i = 0; i < static_cast<int>(extra_info.size()); i++) { - strings->SetString(keys[i], WideToUTF16Hack(extra_info[i])); + strings->SetString(keys[i], extra_info[i]); } for (;i < 5; i++) { - strings->SetString(keys[i], LIT16("")); + strings->SetString(keys[i], L""); } } + diff --git a/chrome/browser/ssl/ssl_policy.cc b/chrome/browser/ssl/ssl_policy.cc index 7b18048..4a0fdef 100644 --- a/chrome/browser/ssl/ssl_policy.cc +++ b/chrome/browser/ssl/ssl_policy.cc @@ -76,25 +76,18 @@ static void ShowErrorPage(SSLPolicy* policy, SSLManager::CertError* error) { // Let's build the html error page. DictionaryValue strings; - strings.SetString( - LIT16("title"), - WideToUTF16Hack(l10n_util::GetString(IDS_SSL_ERROR_PAGE_TITLE))); - strings.SetString(LIT16("headLine"), WideToUTF16Hack(error_info.title())); - strings.SetString(LIT16("description"), - WideToUTF16Hack(error_info.details())); - strings.SetString( - LIT16("moreInfoTitle"), - WideToUTF16Hack(l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE))); + strings.SetString(L"title", l10n_util::GetString(IDS_SSL_ERROR_PAGE_TITLE)); + strings.SetString(L"headLine", error_info.title()); + strings.SetString(L"description", error_info.details()); + strings.SetString(L"moreInfoTitle", + l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE)); SSLBlockingPage::SetExtraInfo(&strings, error_info.extra_information()); - strings.SetString( - LIT16("back"), - WideToUTF16Hack(l10n_util::GetString(IDS_SSL_ERROR_PAGE_BACK))); + strings.SetString(L"back", l10n_util::GetString(IDS_SSL_ERROR_PAGE_BACK)); - strings.SetString( - LIT16("textdirection"), + strings.SetString(L"textdirection", (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? - LIT16("rtl") : LIT16("ltr")); + L"rtl" : L"ltr"); static const StringPiece html( ResourceBundle::GetSharedInstance().GetRawDataResource( |