summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/localized_error.cc
diff options
context:
space:
mode:
authordsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 21:49:53 +0000
committerdsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 21:49:53 +0000
commit3a79b3cc8393d54d72c8c7e14615fe64d86fd039 (patch)
tree2730ef27672c8f9c9e1b6ef3f443434ac98bfd4f /chrome/renderer/localized_error.cc
parent1c9e90e17741f9c34f4cbe7f3e68a8300ed24e08 (diff)
downloadchromium_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/renderer/localized_error.cc')
-rw-r--r--chrome/renderer/localized_error.cc107
1 files changed, 65 insertions, 42 deletions
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);
}