diff options
author | dsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 21:49:53 +0000 |
---|---|---|
committer | dsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 21:49:53 +0000 |
commit | 3a79b3cc8393d54d72c8c7e14615fe64d86fd039 (patch) | |
tree | 2730ef27672c8f9c9e1b6ef3f443434ac98bfd4f /chrome/browser/browser_about_handler.cc | |
parent | 1c9e90e17741f9c34f4cbe7f3e68a8300ed24e08 (diff) | |
download | chromium_src-3a79b3cc8393d54d72c8c7e14615fe64d86fd039.zip chromium_src-3a79b3cc8393d54d72c8c7e14615fe64d86fd039.tar.gz chromium_src-3a79b3cc8393d54d72c8c7e14615fe64d86fd039.tar.bz2 |
Port DictionaryValue to use string16 instead of wstring.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=10818
Review URL: http://codereview.chromium.org/31014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10833 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_about_handler.cc')
-rw-r--r-- | chrome/browser/browser_about_handler.cc | 160 |
1 files changed, 94 insertions, 66 deletions
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++) { |