diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-15 19:50:13 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-15 19:50:13 +0000 |
commit | 5df266ac4bb90178e8e880909eddf65aab34da72 (patch) | |
tree | d42c1b150af0e3ebcbab33f95a8719788e9cd416 /chrome/renderer | |
parent | 02691705540232dffa1c2a0cd5fc574cdbb09612 (diff) | |
download | chromium_src-5df266ac4bb90178e8e880909eddf65aab34da72.zip chromium_src-5df266ac4bb90178e8e880909eddf65aab34da72.tar.gz chromium_src-5df266ac4bb90178e8e880909eddf65aab34da72.tar.bz2 |
Add an alternate error page for connection errors. This is already supported by Link Doctor, we just didn't have it at the time we implemented it.
ERR_CONNECTION_FAILED is from winhttp and ERR_CONNECTION_REFUSED is from new-http. These error codes seem to only be used in one or the other.
http://b/1359790
Review URL: http://codereview.chromium.org/7119
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3410 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/render_view.cc | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 748e612..0da4929 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1232,18 +1232,30 @@ void RenderView::DidFailProvisionalLoadWithError(WebView* webview, static_cast<RenderViewExtraRequestData*>(failed_request.GetExtraData()); bool replace = extra_data && !extra_data->is_new_navigation(); - const GURL& failed_url = error.GetFailedURL(); - const GURL& error_page_url = GetAlternateErrorPageURL(failed_url, - WebViewDelegate::DNS_ERROR); - if (error.GetErrorCode() == net::ERR_NAME_NOT_RESOLVED && - error_page_url.is_valid()) { - // Ask the WebFrame to fetch the alternate error page for us. - frame->LoadAlternateHTMLErrorPage(&failed_request, error, error_page_url, - replace, GURL(kUnreachableWebDataURL)); - } else { - LoadNavigationErrorPage(frame, &failed_request, error, std::string(), - replace); + // Use the alternate error page service if this is a DNS failure or + // connection failure. ERR_CONNECTION_FAILED can be dropped once we no longer + // use winhttp. + int ec = error.GetErrorCode(); + if (ec == net::ERR_NAME_NOT_RESOLVED || + ec == net::ERR_CONNECTION_FAILED || + ec == net::ERR_CONNECTION_REFUSED || + ec == net::ERR_ADDRESS_UNREACHABLE || + ec == net::ERR_TIMED_OUT) { + const GURL& failed_url = error.GetFailedURL(); + const GURL& error_page_url = GetAlternateErrorPageURL(failed_url, + ec == net::ERR_NAME_NOT_RESOLVED ? WebViewDelegate::DNS_ERROR + : WebViewDelegate::CONNECTION_ERROR); + if (error_page_url.is_valid()) { + // Ask the WebFrame to fetch the alternate error page for us. + frame->LoadAlternateHTMLErrorPage(&failed_request, error, error_page_url, + replace, GURL(kUnreachableWebDataURL)); + return; + } } + + // Fallback to a local error page. + LoadNavigationErrorPage(frame, &failed_request, error, std::string(), + replace); } void RenderView::LoadNavigationErrorPage(WebFrame* frame, @@ -1903,6 +1915,10 @@ GURL RenderView::GetAlternateErrorPageURL(const GURL& failedURL, params.append("http404"); break; + case CONNECTION_ERROR: + params.append("connectionerror"); + break; + default: NOTREACHED() << "unknown ErrorPageType"; } |