Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8241)

Unified Diff: chrome/common/localized_error.cc

Issue 13811022: New network error page: Fix resubmit warning page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync prior to commit Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/localized_error.h ('k') | chrome/renderer/chrome_content_renderer_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/localized_error.cc
===================================================================
--- chrome/common/localized_error.cc (revision 194509)
+++ chrome/common/localized_error.cc (working copy)
@@ -294,6 +294,18 @@
},
};
+// Special error page to be used in the case of navigating back to a page
+// generated by a POST. LocalizedError::HasStrings expects this net error code
+// to also appear in the array above.
+const LocalizedErrorMap repost_error = {
+ net::ERR_CACHE_MISS,
+ IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
+ IDS_HTTP_POST_WARNING_TITLE,
+ IDS_ERRORPAGES_HTTP_POST_WARNING,
+ IDS_ERRORPAGES_DETAILS_CACHE_MISS,
+ SUGGEST_RELOAD,
+};
+
const LocalizedErrorMap http_error_options[] = {
{403,
IDS_ERRORPAGES_TITLE_ACCESS_DENIED,
@@ -365,8 +377,12 @@
}
const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain,
- int error_code) {
+ int error_code, bool is_post) {
if (error_domain == net::kErrorDomain) {
+ // Display a different page in the special case of navigating through the
+ // history to an uncached page created by a POST.
+ if (is_post && error_code == net::ERR_CACHE_MISS)
+ return &repost_error;
return FindErrorMapInArray(net_error_options,
arraysize(net_error_options),
error_code);
@@ -406,8 +422,9 @@
const char LocalizedError::kHttpErrorDomain[] = "http";
void LocalizedError::GetStrings(const WebKit::WebURLError& error,
- DictionaryValue* error_strings,
- const std::string& locale) {
+ bool is_post,
+ const std::string& locale,
+ DictionaryValue* error_strings) {
bool rtl = LocaleIsRTL();
error_strings->SetString("textdirection", rtl ? "rtl" : "ltr");
@@ -424,8 +441,8 @@
const std::string error_domain = error.domain.utf8();
int error_code = error.reason;
- const LocalizedErrorMap* error_map =
- LookupErrorMap(error_domain, error_code);
+ const LocalizedErrorMap* error_map = LookupErrorMap(error_domain, error_code,
+ is_post);
if (error_map)
options = *error_map;
@@ -522,11 +539,26 @@
#endif // defined(OS_MACOSX) || defined(OS_WIN)
if (options.suggestions & SUGGEST_RELOAD) {
- DictionaryValue* reload_button = new DictionaryValue;
- reload_button->SetString("msg",
- l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD));
- reload_button->SetString("reloadUrl", failed_url_string);
- error_strings->Set("reload", reload_button);
+ if (!is_post) {
+ DictionaryValue* reload_button = new DictionaryValue;
+ reload_button->SetString("msg",
+ l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD));
+ reload_button->SetString("reloadUrl", failed_url_string);
+ error_strings->Set("reload", reload_button);
+ } else {
+ // If the page was created by a post, it can't be reloaded in the same
+ // way, so just add a suggestion instead.
+ // TODO(mmenke): Make the reload button bring up the repost confirmation
+ // dialog for pages resulting from posts.
+ DictionaryValue* suggest_reload_repost = new DictionaryValue;
+ suggest_reload_repost->SetString("header",
+ l10n_util::GetStringUTF16(
+ IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_HEADER));
+ suggest_reload_repost->SetString("body",
+ l10n_util::GetStringUTF16(
+ IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_BODY));
+ suggestions->Append(suggest_reload_repost);
+ }
}
if (options.suggestions & SUGGEST_CHECK_CONNECTION) {
@@ -653,9 +685,10 @@
error_strings->Set("suggestions", suggestions);
}
-string16 LocalizedError::GetErrorDetails(const WebKit::WebURLError& error) {
+string16 LocalizedError::GetErrorDetails(const WebKit::WebURLError& error,
+ bool is_post) {
const LocalizedErrorMap* error_map =
- LookupErrorMap(error.domain.utf8(), error.reason);
+ LookupErrorMap(error.domain.utf8(), error.reason, is_post);
if (error_map)
return l10n_util::GetStringUTF16(error_map->details_resource_id);
else
@@ -664,29 +697,12 @@
bool LocalizedError::HasStrings(const std::string& error_domain,
int error_code) {
- return LookupErrorMap(error_domain, error_code) != NULL;
+ // Whether or not the there are strings for an error does not depend on
+ // whether or not the page was be generated by a POST, so just claim it was
+ // not.
+ return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != NULL;
}
-void LocalizedError::GetFormRepostStrings(const GURL& display_url,
- DictionaryValue* error_strings) {
- bool rtl = LocaleIsRTL();
- error_strings->SetString("textdirection", rtl ? "rtl" : "ltr");
-
- string16 failed_url(ASCIIToUTF16(display_url.spec()));
- // URLs are always LTR.
- if (rtl)
- base::i18n::WrapStringWithLTRFormatting(&failed_url);
- error_strings->SetString(
- "title", l10n_util::GetStringFUTF16(IDS_ERRORPAGES_TITLE_NOT_AVAILABLE,
- failed_url));
- error_strings->SetString(
- "heading", l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_TITLE));
- DictionaryValue* summary = new DictionaryValue;
- summary->SetString(
- "msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_HTTP_POST_WARNING));
- error_strings->Set("summary", summary);
-}
-
void LocalizedError::GetAppErrorStrings(
const WebURLError& error,
const GURL& display_url,
« no previous file with comments | « chrome/common/localized_error.h ('k') | chrome/renderer/chrome_content_renderer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698