diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-27 20:43:40 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-27 20:43:40 +0000 |
commit | 467751964600388345aa537e1436b036d159ac92 (patch) | |
tree | da731453c74e06e785477c11b47d2d645f7ca2a4 /chrome | |
parent | e1acf6f902e50222baf99bfb492ecc38a1604975 (diff) | |
download | chromium_src-467751964600388345aa537e1436b036d159ac92.zip chromium_src-467751964600388345aa537e1436b036d159ac92.tar.gz chromium_src-467751964600388345aa537e1436b036d159ac92.tar.bz2 |
Add a suggestion to "Learn more about this problem." if there is
a redirect loop. We could easily use this for other errors too
if there are URLs to the help center.
BUG=http://crbug.com/2445
Review URL: http://codereview.chromium.org/8174
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4023 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/generated_resources.grd | 7 | ||||
-rw-r--r-- | chrome/renderer/localized_error.cc | 42 | ||||
-rw-r--r-- | chrome/renderer/resources/error_no_details.html | 3 | ||||
-rw-r--r-- | chrome/renderer/resources/neterror.html | 3 |
4 files changed, 45 insertions, 10 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index a07aa04..d376e64 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -2167,12 +2167,15 @@ each locale. --> Below is the original error message </message> - <message name="IDS_ERRORPAGES_SUGGESTION_RELOAD" desc="Suggest reloading to the user"> + <message name="IDS_ERRORPAGES_SUGGESTION_RELOAD" desc="When a page fails to load, we provide a suggestion that the user try reloading the page later"> <a jsvalues="href:reloadUrl">Reload</a> this web page later. </message> - <message name="IDS_ERRORPAGES_SUGGESTION_HOMEPAGE" desc="String suggesting to try just the hostname of the site."> + <message name="IDS_ERRORPAGES_SUGGESTION_HOMEPAGE" desc="When a page fails to load, sometimes we provide a suggesting of trying just the hostname of the site."> Go to the homepage of the site: </message> + <message name="IDS_ERRORPAGES_SUGGESTION_LEARNMORE" desc="When a web page fails to load, we provide a link to the help center to learn more about the failure."> + <ph name="BEGIN_LINK"><a jsvalues="href:learnMoreUrl"></ph>Learn more<ph name="END_LINK"></a></ph> about this problem. + </message> <message name="IDS_ERRORPAGES_TITLE_NOT_AVAILABLE" desc="Title of the error page when we can't connect to a site."> <ph name="SITE">$1<ex>google.xom</ex></ph> is not available diff --git a/chrome/renderer/localized_error.cc b/chrome/renderer/localized_error.cc index 78328cb4..b0e6d0e 100644 --- a/chrome/renderer/localized_error.cc +++ b/chrome/renderer/localized_error.cc @@ -17,10 +17,14 @@ namespace { +static const char* kRedirectLoopLearnMoreUrl = + "http://www.google.com/support/chrome/bin/answer.py?answer=95626"; + enum NAV_SUGGESTIONS { SUGGEST_NONE = 0, SUGGEST_RELOAD = 1 << 0, SUGGEST_HOSTNAME = 1 << 1, + SUGGEST_LEARNMORE = 1 << 2, }; struct WebErrorNetErrorMap { @@ -73,7 +77,7 @@ WebErrorNetErrorMap net_error_options[] = { IDS_ERRORPAGES_HEADING_TOO_MANY_REDIRECTS, IDS_ERRORPAGES_SUMMARY_TOO_MANY_REDIRECTS, IDS_ERRORPAGES_DETAILS_TOO_MANY_REDIRECTS, - SUGGEST_RELOAD, + SUGGEST_RELOAD | SUGGEST_LEARNMORE, }, }; @@ -112,13 +116,13 @@ void GetLocalizedErrorValues(const WebError& error, } error_strings->SetString(L"suggestionsHeading", suggestions_heading); - std::wstring failed_url(UTF8ToWide(error.GetFailedURL().spec())); + 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.c_str())); + failed_url)); error_strings->SetString(L"heading", l10n_util::GetString(options.heading_resource_id)); @@ -126,7 +130,7 @@ void GetLocalizedErrorValues(const WebError& error, summary->SetString(L"msg", l10n_util::GetString(options.summary_resource_id)); // TODO(tc): we want the unicode url here since it's being displayed - summary->SetString(L"failedUrl", failed_url.c_str()); + summary->SetString(L"failedUrl", failed_url); error_strings->Set(L"summary", summary); // Error codes are expected to be negative @@ -142,7 +146,7 @@ void GetLocalizedErrorValues(const WebError& error, DictionaryValue* suggest_reload = new DictionaryValue; suggest_reload->SetString(L"msg", l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_RELOAD)); - suggest_reload->SetString(L"reloadUrl", failed_url.c_str()); + suggest_reload->SetString(L"reloadUrl", failed_url); error_strings->Set(L"suggestionsReload", suggest_reload); } @@ -153,22 +157,44 @@ void GetLocalizedErrorValues(const WebError& error, DictionaryValue* suggest_home_page = new DictionaryValue; suggest_home_page->SetString(L"suggestionsHomepageMsg", l10n_util::GetString(IDS_ERRORPAGES_SUGGESTION_HOMEPAGE)); - std::wstring homepage(UTF8ToWide(failed_url.GetWithEmptyPath().spec())); + 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); // TODO(tc): we actually want the unicode hostname suggest_home_page->SetString(L"hostName", - UTF8ToWide(failed_url.host())); + ASCIIToWide(failed_url.host())); error_strings->Set(L"suggestionsHomepage", suggest_home_page); } } + + if (options.suggestions & SUGGEST_LEARNMORE) { + GURL learn_more_url; + switch (options.error_code) { + case net::ERR_TOO_MANY_REDIRECTS: + learn_more_url = GURL(kRedirectLoopLearnMoreUrl); + break; + default: + break; + } + // TODO(tc): Move browser/google_util.* to common and uncomment: + // learn_more_url = google_util::AppendGoogleLocaleParam(learn_more_url); + + if (learn_more_url.is_valid()) { + 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); + } + } } void GetFormRepostErrorValues(const GURL& display_url, DictionaryValue* error_strings) { - std::wstring failed_url(UTF8ToWide(display_url.spec())); + std::wstring failed_url(ASCIIToWide(display_url.spec())); // URLs are always LTR. if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) l10n_util::WrapStringWithLTRFormatting(&failed_url); diff --git a/chrome/renderer/resources/error_no_details.html b/chrome/renderer/resources/error_no_details.html index c7d68ae..414be9a 100644 --- a/chrome/renderer/resources/error_no_details.html +++ b/chrome/renderer/resources/error_no_details.html @@ -64,6 +64,9 @@ a:visited { <span jscontent="suggestionsHomepageMsg"></span> <a jscontent="hostName" jsvalues="href:homePage"></a> </li> + <li jsselect="suggestionsLearnMore"> + <span jseval="this.innerHTML = $this.msg;"></span> + </li> </ul> </div> diff --git a/chrome/renderer/resources/neterror.html b/chrome/renderer/resources/neterror.html index 988b612..4625561 100644 --- a/chrome/renderer/resources/neterror.html +++ b/chrome/renderer/resources/neterror.html @@ -84,6 +84,9 @@ function toggleDiv(id) { <span jscontent="suggestionsHomepageMsg"></span> <a jscontent="hostName" jsvalues="href:homePage"></a> </li> + <li jsselect="suggestionsLearnMore"> + <span jseval="this.innerHTML = $this.msg;"></span> + </li> </ul> </div> |