Commit 21ca9583 authored by mmenke@chromium.org's avatar mmenke@chromium.org

Revert 194514 - New network error page: Fix resubmit warning page

This was causing renderer crashes when the alternate error page
passed in a NULL WebURLRequest.

> New network error page:  Fix resubmit warning when
> navigating forward / back to a page generated by a
> POST that can not be retrieved from the CACHE.
> 
> This was broken (knowingly) in revision 191712
> (https://codereview.chromium.org/12277011/).
> 
> BUG=174194,226909
> 
> Review URL: https://codereview.chromium.org/13811022

TBR=mmenke@chromium.org

Review URL: https://codereview.chromium.org/14369002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195014 0039d316-1c4b-4281-b951-d872f2087c98
parent c9802d4f
...@@ -9144,12 +9144,6 @@ The following plug-in is unresponsive: <ph name="PLUGIN_NAME">$1 ...@@ -9144,12 +9144,6 @@ The following plug-in is unresponsive: <ph name="PLUGIN_NAME">$1
</message> </message>
</if> </if>
<message name="IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_HEADER" desc="When a page fails to load, sometimes we suggest reloading a page. In the case that reloading the page requires resubmitting data to a website, we use this as a header above a short set of instructions.">
Reload this webpage.
</message>
<message name="IDS_ERRORPAGES_SUGGESTION_RELOAD_REPOST_BODY" desc="When a page fails to load, sometimes we suggest reloading a page. In the case that reloading the page requires resubmitting data to a website, this is displayed below a short header.">
Press the reload button to resubmit the data needed to load the page.
</message>
<message name="IDS_ERRORPAGES_SUGGESTION_DISABLE_EXTENSION_HEADER" desc="When a page fails to load, we provide a suggestion that the user try disabling an extension that's blocking it."> <message name="IDS_ERRORPAGES_SUGGESTION_DISABLE_EXTENSION_HEADER" desc="When a page fails to load, we provide a suggestion that the user try disabling an extension that's blocking it.">
Disable your extensions and then reload this webpage. Disable your extensions and then reload this webpage.
</message> </message>
...@@ -9685,7 +9679,7 @@ The following plug-in is unresponsive: <ph name="PLUGIN_NAME">$1 ...@@ -9685,7 +9679,7 @@ The following plug-in is unresponsive: <ph name="PLUGIN_NAME">$1
</message> </message>
<message name="IDS_ERRORPAGES_HTTP_POST_WARNING" desc="The error message displayed when the user navigates back or forward to a page which would resubmit post data. They can hit reload to send POST data again and load the page."> <message name="IDS_ERRORPAGES_HTTP_POST_WARNING" desc="The error message displayed when the user navigates back or forward to a page which would resubmit post data. They can hit reload to send POST data again and load the page.">
This webpage requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed. This webpage requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed. Press Reload to resend that data and display this page.
</message> </message>
<message name="IDS_ERRORPAGES_APP_WARNING" desc="The error message displayed when the browser can not reach the requested page from an app."> <message name="IDS_ERRORPAGES_APP_WARNING" desc="The error message displayed when the browser can not reach the requested page from an app.">
......
...@@ -294,18 +294,6 @@ const LocalizedErrorMap net_error_options[] = { ...@@ -294,18 +294,6 @@ const LocalizedErrorMap net_error_options[] = {
}, },
}; };
// 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[] = { const LocalizedErrorMap http_error_options[] = {
{403, {403,
IDS_ERRORPAGES_TITLE_ACCESS_DENIED, IDS_ERRORPAGES_TITLE_ACCESS_DENIED,
...@@ -377,12 +365,8 @@ const LocalizedErrorMap* FindErrorMapInArray(const LocalizedErrorMap* maps, ...@@ -377,12 +365,8 @@ const LocalizedErrorMap* FindErrorMapInArray(const LocalizedErrorMap* maps,
} }
const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain, const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain,
int error_code, bool is_post) { int error_code) {
if (error_domain == net::kErrorDomain) { 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, return FindErrorMapInArray(net_error_options,
arraysize(net_error_options), arraysize(net_error_options),
error_code); error_code);
...@@ -422,9 +406,8 @@ DictionaryValue* GetStandardMenuItemsText() { ...@@ -422,9 +406,8 @@ DictionaryValue* GetStandardMenuItemsText() {
const char LocalizedError::kHttpErrorDomain[] = "http"; const char LocalizedError::kHttpErrorDomain[] = "http";
void LocalizedError::GetStrings(const WebKit::WebURLError& error, void LocalizedError::GetStrings(const WebKit::WebURLError& error,
bool is_post, DictionaryValue* error_strings,
const std::string& locale, const std::string& locale) {
DictionaryValue* error_strings) {
bool rtl = LocaleIsRTL(); bool rtl = LocaleIsRTL();
error_strings->SetString("textdirection", rtl ? "rtl" : "ltr"); error_strings->SetString("textdirection", rtl ? "rtl" : "ltr");
...@@ -441,8 +424,8 @@ void LocalizedError::GetStrings(const WebKit::WebURLError& error, ...@@ -441,8 +424,8 @@ void LocalizedError::GetStrings(const WebKit::WebURLError& error,
const std::string error_domain = error.domain.utf8(); const std::string error_domain = error.domain.utf8();
int error_code = error.reason; int error_code = error.reason;
const LocalizedErrorMap* error_map = LookupErrorMap(error_domain, error_code, const LocalizedErrorMap* error_map =
is_post); LookupErrorMap(error_domain, error_code);
if (error_map) if (error_map)
options = *error_map; options = *error_map;
...@@ -539,26 +522,11 @@ void LocalizedError::GetStrings(const WebKit::WebURLError& error, ...@@ -539,26 +522,11 @@ void LocalizedError::GetStrings(const WebKit::WebURLError& error,
#endif // defined(OS_MACOSX) || defined(OS_WIN) #endif // defined(OS_MACOSX) || defined(OS_WIN)
if (options.suggestions & SUGGEST_RELOAD) { if (options.suggestions & SUGGEST_RELOAD) {
if (!is_post) { DictionaryValue* reload_button = new DictionaryValue;
DictionaryValue* reload_button = new DictionaryValue; reload_button->SetString("msg",
reload_button->SetString("msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD));
l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD)); reload_button->SetString("reloadUrl", failed_url_string);
reload_button->SetString("reloadUrl", failed_url_string); error_strings->Set("reload", reload_button);
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) { if (options.suggestions & SUGGEST_CHECK_CONNECTION) {
...@@ -685,10 +653,9 @@ void LocalizedError::GetStrings(const WebKit::WebURLError& error, ...@@ -685,10 +653,9 @@ void LocalizedError::GetStrings(const WebKit::WebURLError& error,
error_strings->Set("suggestions", suggestions); 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 = const LocalizedErrorMap* error_map =
LookupErrorMap(error.domain.utf8(), error.reason, is_post); LookupErrorMap(error.domain.utf8(), error.reason);
if (error_map) if (error_map)
return l10n_util::GetStringUTF16(error_map->details_resource_id); return l10n_util::GetStringUTF16(error_map->details_resource_id);
else else
...@@ -697,10 +664,27 @@ string16 LocalizedError::GetErrorDetails(const WebKit::WebURLError& error, ...@@ -697,10 +664,27 @@ string16 LocalizedError::GetErrorDetails(const WebKit::WebURLError& error,
bool LocalizedError::HasStrings(const std::string& error_domain, bool LocalizedError::HasStrings(const std::string& error_domain,
int error_code) { int error_code) {
// Whether or not the there are strings for an error does not depend on return LookupErrorMap(error_domain, error_code) != NULL;
// 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( void LocalizedError::GetAppErrorStrings(
......
...@@ -29,17 +29,23 @@ class LocalizedError { ...@@ -29,17 +29,23 @@ class LocalizedError {
// Fills |error_strings| with values to be used to build an error page used // Fills |error_strings| with values to be used to build an error page used
// on HTTP errors, like 404 or connection reset. // on HTTP errors, like 404 or connection reset.
static void GetStrings(const WebKit::WebURLError& error, static void GetStrings(const WebKit::WebURLError& error,
bool is_post, base::DictionaryValue* strings,
const std::string& locale, const std::string& locale);
base::DictionaryValue* strings);
// Returns a description of the encountered error. // Returns a description of the encountered error.
static string16 GetErrorDetails(const WebKit::WebURLError& error, static string16 GetErrorDetails(const WebKit::WebURLError& error);
bool is_post);
// Returns true if an error page exists for the specified parameters. // Returns true if an error page exists for the specified parameters.
static bool HasStrings(const std::string& error_domain, int error_code); static bool HasStrings(const std::string& error_domain, int error_code);
// Fills |error_strings| with values to be used to build an error page which
// warns against reposting form data. This is special cased because the form
// repost "error page" has no real error associated with it, and doesn't have
// enough strings localized to meaningfully fill the net error template.
// TODO(mmenke): Get rid of this and merge with GetStrings.
static void GetFormRepostStrings(const GURL& display_url,
base::DictionaryValue* error_strings);
// Fills |error_strings| with values to be used to build an error page used // Fills |error_strings| with values to be used to build an error page used
// on HTTP errors, like 404 or connection reset, but using information from // on HTTP errors, like 404 or connection reset, but using information from
// the associated |app| in order to make the error page look like it's more // the associated |app| in order to make the error page look like it's more
......
...@@ -828,6 +828,10 @@ void ChromeContentRendererClient::GetNavigationErrorStrings( ...@@ -828,6 +828,10 @@ void ChromeContentRendererClient::GetNavigationErrorStrings(
string16* error_description) { string16* error_description) {
const GURL failed_url = error.unreachableURL; const GURL failed_url = error.unreachableURL;
const Extension* extension = NULL; const Extension* extension = NULL;
const bool is_repost =
error.reason == net::ERR_CACHE_MISS &&
error.domain == WebString::fromUTF8(net::kErrorDomain) &&
EqualsASCII(failed_request.httpMethod(), "POST");
if (failed_url.is_valid() && if (failed_url.is_valid() &&
!failed_url.SchemeIs(extensions::kExtensionScheme)) { !failed_url.SchemeIs(extensions::kExtensionScheme)) {
...@@ -835,8 +839,6 @@ void ChromeContentRendererClient::GetNavigationErrorStrings( ...@@ -835,8 +839,6 @@ void ChromeContentRendererClient::GetNavigationErrorStrings(
ExtensionURLInfo(failed_url)); ExtensionURLInfo(failed_url));
} }
bool is_post = EqualsASCII(failed_request.httpMethod(), "POST");
if (error_html) { if (error_html) {
// Use a local error page. // Use a local error page.
int resource_id; int resource_id;
...@@ -849,11 +851,12 @@ void ChromeContentRendererClient::GetNavigationErrorStrings( ...@@ -849,11 +851,12 @@ void ChromeContentRendererClient::GetNavigationErrorStrings(
// error messages? // error messages?
resource_id = IDR_ERROR_APP_HTML; resource_id = IDR_ERROR_APP_HTML;
} else { } else {
LocalizedError::GetStrings( if (is_repost) {
error, LocalizedError::GetFormRepostStrings(failed_url, &error_strings);
is_post, } else {
RenderThread::Get()->GetLocale(), LocalizedError::GetStrings(error, &error_strings,
&error_strings); RenderThread::Get()->GetLocale());
}
resource_id = IDR_NET_ERROR_HTML; resource_id = IDR_NET_ERROR_HTML;
} }
...@@ -869,8 +872,8 @@ void ChromeContentRendererClient::GetNavigationErrorStrings( ...@@ -869,8 +872,8 @@ void ChromeContentRendererClient::GetNavigationErrorStrings(
} }
if (error_description) { if (error_description) {
if (!extension) if (!extension && !is_repost)
*error_description = LocalizedError::GetErrorDetails(error, is_post); *error_description = LocalizedError::GetErrorDetails(error);
} }
} }
......
...@@ -101,8 +101,7 @@ NetErrorHelper::NetErrorHelper(RenderView* render_view) ...@@ -101,8 +101,7 @@ NetErrorHelper::NetErrorHelper(RenderView* render_view)
&NetErrorHelper::TrackerCallback, &NetErrorHelper::TrackerCallback,
base::Unretained(this)))), base::Unretained(this)))),
dns_error_page_state_(NetErrorTracker::DNS_ERROR_PAGE_NONE), dns_error_page_state_(NetErrorTracker::DNS_ERROR_PAGE_NONE),
updated_error_page_(false), updated_error_page_(false) {
is_failed_post_(false) {
} }
NetErrorHelper::~NetErrorHelper() { NetErrorHelper::~NetErrorHelper() {
...@@ -114,9 +113,6 @@ void NetErrorHelper::DidStartProvisionalLoad(WebKit::WebFrame* frame) { ...@@ -114,9 +113,6 @@ void NetErrorHelper::DidStartProvisionalLoad(WebKit::WebFrame* frame) {
void NetErrorHelper::DidFailProvisionalLoad(WebKit::WebFrame* frame, void NetErrorHelper::DidFailProvisionalLoad(WebKit::WebFrame* frame,
const WebKit::WebURLError& error) { const WebKit::WebURLError& error) {
WebKit::WebDataSource* data_source = frame->provisionalDataSource();
const WebKit::WebURLRequest& failed_request = data_source->request();
is_failed_post_ = EqualsASCII(failed_request.httpMethod(), "POST");
tracker_.OnFailProvisionalLoad(GetFrameType(frame), GetErrorType(error)); tracker_.OnFailProvisionalLoad(GetFrameType(frame), GetErrorType(error));
} }
...@@ -184,9 +180,8 @@ void NetErrorHelper::UpdateErrorPage(DnsProbeResult dns_probe_result) { ...@@ -184,9 +180,8 @@ void NetErrorHelper::UpdateErrorPage(DnsProbeResult dns_probe_result) {
DictionaryValue error_strings; DictionaryValue error_strings;
LocalizedError::GetStrings(NetErrorToWebURLError(net_error), LocalizedError::GetStrings(NetErrorToWebURLError(net_error),
is_failed_post_, &error_strings,
RenderThread::Get()->GetLocale(), RenderThread::Get()->GetLocale());
&error_strings);
// TODO(ttuttle): Update error page with error_strings. // TODO(ttuttle): Update error page with error_strings.
} }
...@@ -39,7 +39,6 @@ class NetErrorHelper : public content::RenderViewObserver { ...@@ -39,7 +39,6 @@ class NetErrorHelper : public content::RenderViewObserver {
NetErrorTracker tracker_; NetErrorTracker tracker_;
NetErrorTracker::DnsErrorPageState dns_error_page_state_; NetErrorTracker::DnsErrorPageState dns_error_page_state_;
bool updated_error_page_; bool updated_error_page_;
bool is_failed_post_;
}; };
#endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment