diff options
author | mkosiba@chromium.org <mkosiba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-11 15:31:58 +0000 |
---|---|---|
committer | mkosiba@chromium.org <mkosiba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-11 15:31:58 +0000 |
commit | d7b175e8762301a1bfca9d17681111bbf5bf5c0a (patch) | |
tree | 3dbd962ef0417f8977eebfd362ee5ffbcb5c1e27 | |
parent | c2ee7f0e04e752bd40b1461e92756e7a320e40ec (diff) | |
download | chromium_src-d7b175e8762301a1bfca9d17681111bbf5bf5c0a.zip chromium_src-d7b175e8762301a1bfca9d17681111bbf5bf5c0a.tar.gz chromium_src-d7b175e8762301a1bfca9d17681111bbf5bf5c0a.tar.bz2 |
Add error description to the DidFailProvisionalLoad callback.
This will add an error description field to the TabContentsObserver::
DidFailProvisionalLoad callback.
The change should not have any impact on current behavior.
This is needed for the Chromium port on Android.
BUG=none
TEST=base_unittests,content_unittests,browser_tests
Review URL: http://codereview.chromium.org/8142032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104895 0039d316-1c4b-4281-b951-d872f2087c98
19 files changed, 205 insertions, 116 deletions
diff --git a/chrome/browser/extensions/extension_webnavigation_api.cc b/chrome/browser/extensions/extension_webnavigation_api.cc index b675871..c7471f9 100644 --- a/chrome/browser/extensions/extension_webnavigation_api.cc +++ b/chrome/browser/extensions/extension_webnavigation_api.cc @@ -547,7 +547,8 @@ void ExtensionWebNavigationTabObserver::DidFailProvisionalLoad( int64 frame_id, bool is_main_frame, const GURL& validated_url, - int error_code) { + int error_code, + const string16& error_description) { if (!navigation_state_.CanSendEvents(frame_id)) return; navigation_state_.SetErrorOccurredInFrame(frame_id); diff --git a/chrome/browser/extensions/extension_webnavigation_api.h b/chrome/browser/extensions/extension_webnavigation_api.h index 932734f..5d24907 100644 --- a/chrome/browser/extensions/extension_webnavigation_api.h +++ b/chrome/browser/extensions/extension_webnavigation_api.h @@ -142,10 +142,12 @@ class ExtensionWebNavigationTabObserver : public TabContentsObserver { bool is_main_frame, const GURL& url, PageTransition::Type transition_type) OVERRIDE; - virtual void DidFailProvisionalLoad(int64 frame_id, - bool is_main_frame, - const GURL& validated_url, - int error_code) OVERRIDE; + virtual void DidFailProvisionalLoad( + int64 frame_id, + bool is_main_frame, + const GURL& validated_url, + int error_code, + const string16& error_description) OVERRIDE; virtual void DocumentLoadedInFrame(int64 frame_id) OVERRIDE; virtual void DidFinishLoad(int64 frame_id) OVERRIDE; virtual void DidOpenRequestedURL(TabContents* new_contents, diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 561574d..0c10574 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -533,47 +533,56 @@ bool ChromeContentRendererClient::HasErrorPage(int http_status_code, return true; } -std::string ChromeContentRendererClient::GetNavigationErrorHtml( - const WebURLRequest& failed_request, - const WebURLError& error) { - GURL failed_url = error.unreachableURL; - std::string html; +void ChromeContentRendererClient::GetNavigationErrorStrings( + const WebKit::WebURLRequest& failed_request, + const WebKit::WebURLError& error, + std::string* error_html, + string16* error_description) { + const GURL failed_url = error.unreachableURL; 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"); - // Use a local error page. - int resource_id; - DictionaryValue error_strings; if (failed_url.is_valid() && !failed_url.SchemeIs(chrome::kExtensionScheme)) extension = extension_dispatcher_->extensions()->GetByURL(failed_url); - if (extension) { - LocalizedError::GetAppErrorStrings(error, failed_url, extension, - &error_strings); - // TODO(erikkay): Should we use a different template for different - // error messages? - resource_id = IDR_ERROR_APP_HTML; - } else { - if (error.domain == WebString::fromUTF8(net::kErrorDomain) && - error.reason == net::ERR_CACHE_MISS && - EqualsASCII(failed_request.httpMethod(), "POST")) { - LocalizedError::GetFormRepostStrings(failed_url, &error_strings); + if (error_html) { + // Use a local error page. + int resource_id; + DictionaryValue error_strings; + if (extension) { + LocalizedError::GetAppErrorStrings(error, failed_url, extension, + &error_strings); + + // TODO(erikkay): Should we use a different template for different + // error messages? + resource_id = IDR_ERROR_APP_HTML; } else { - LocalizedError::GetStrings(error, &error_strings); + if (is_repost) { + LocalizedError::GetFormRepostStrings(failed_url, &error_strings); + } else { + LocalizedError::GetStrings(error, &error_strings); + } + resource_id = IDR_NET_ERROR_HTML; } - resource_id = IDR_NET_ERROR_HTML; - } - const base::StringPiece template_html( - ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); - if (template_html.empty()) { - NOTREACHED() << "unable to load template. ID: " << resource_id; - } else { - // "t" is the id of the templates root node. - html = jstemplate_builder::GetTemplatesHtml( - template_html, &error_strings, "t"); + const base::StringPiece template_html( + ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); + if (template_html.empty()) { + NOTREACHED() << "unable to load template. ID: " << resource_id; + } else { + // "t" is the id of the templates root node. + *error_html = jstemplate_builder::GetTemplatesHtml( + template_html, &error_strings, "t"); + } } - return html; + if (error_description) { + if (!extension && !is_repost) + *error_description = LocalizedError::GetErrorDetails(error); + } } bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h index 9bb6cad..a5b4d29 100644 --- a/chrome/renderer/chrome_content_renderer_client.h +++ b/chrome/renderer/chrome_content_renderer_client.h @@ -10,6 +10,7 @@ #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" +#include "base/string16.h" #include "content/public/renderer/content_renderer_client.h" class ChromeRenderProcessObserver; @@ -50,9 +51,11 @@ class ChromeContentRendererClient : public content::ContentRendererClient { WebKit::WebPlugin** plugin) OVERRIDE; virtual bool HasErrorPage(int http_status_code, std::string* error_domain) OVERRIDE; - virtual std::string GetNavigationErrorHtml( + virtual void GetNavigationErrorStrings( const WebKit::WebURLRequest& failed_request, - const WebKit::WebURLError& error) OVERRIDE; + const WebKit::WebURLError& error, + std::string* error_html, + string16* error_description) OVERRIDE; virtual bool RunIdleHandlerWhenWidgetsHidden() OVERRIDE; virtual bool AllowPopup(const GURL& creator) OVERRIDE; virtual bool ShouldFork(WebKit::WebFrame* frame, diff --git a/chrome/renderer/localized_error.cc b/chrome/renderer/localized_error.cc index 681d783..ad14e96 100644 --- a/chrome/renderer/localized_error.cc +++ b/chrome/renderer/localized_error.cc @@ -630,6 +630,15 @@ void LocalizedError::GetStrings(const WebKit::WebURLError& error, } } +string16 LocalizedError::GetErrorDetails(const WebKit::WebURLError& error) { + const LocalizedErrorMap* error_map = + LookupErrorMap(error.domain.utf8(), error.reason); + if (error_map) + return l10n_util::GetStringUTF16(error_map->details_resource_id); + else + return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN); +} + bool LocalizedError::HasStrings(const std::string& error_domain, int error_code) { return LookupErrorMap(error_domain, error_code) != NULL; diff --git a/chrome/renderer/localized_error.h b/chrome/renderer/localized_error.h index f327161..1006ae6 100644 --- a/chrome/renderer/localized_error.h +++ b/chrome/renderer/localized_error.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,6 +9,7 @@ #include <string> #include "base/basictypes.h" +#include "base/string16.h" class Extension; class GURL; @@ -28,6 +29,9 @@ class LocalizedError { static void GetStrings(const WebKit::WebURLError& error, base::DictionaryValue* strings); + // Returns a description of the encountered error. + static string16 GetErrorDetails(const WebKit::WebURLError& error); + // Returns true if an error page exists for the specified parameters. static bool HasStrings(const std::string& error_domain, int error_code); diff --git a/content/browser/tab_contents/navigation_controller_unittest.cc b/content/browser/tab_contents/navigation_controller_unittest.cc index f856cbe..900acb5 100644 --- a/content/browser/tab_contents/navigation_controller_unittest.cc +++ b/content/browser/tab_contents/navigation_controller_unittest.cc @@ -423,13 +423,16 @@ TEST_F(NavigationControllerTest, LoadURL_AbortCancelsPending) { // It may abort before committing, if it's a download or due to a stop or // a new navigation from the user. + ViewHostMsg_DidFailProvisionalLoadWithError_Params params; + params.frame_id = 1; + params.is_main_frame = true; + params.error_code = net::ERR_ABORTED; + params.error_description = string16(); + params.url = kNewURL; + params.showing_repost_interstitial = false; rvh()->TestOnMessageReceived( - ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id - 1, // frame_id - true, // is_main_frame - net::ERR_ABORTED, // error - kNewURL, // url - false)); // repost + ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id + params)); // This should clear the pending entry and notify of a navigation state // change, so that we do not keep displaying kNewURL. @@ -479,13 +482,16 @@ TEST_F(NavigationControllerTest, LoadURL_RedirectAbortCancelsPending) { // It may abort before committing, if it's a download or due to a stop or // a new navigation from the user. + ViewHostMsg_DidFailProvisionalLoadWithError_Params params; + params.frame_id = 1; + params.is_main_frame = true; + params.error_code = net::ERR_ABORTED; + params.error_description = string16(); + params.url = kRedirectURL; + params.showing_repost_interstitial = false; rvh()->TestOnMessageReceived( - ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id - 1, // frame_id - true, // is_main_frame - net::ERR_ABORTED, // error - kRedirectURL, // url - false)); // repost + ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id + params)); // This should clear the pending entry and notify of a navigation state // change, so that we do not keep displaying kNewURL. @@ -1529,13 +1535,16 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { // which causes the pending entry to be cleared. TestRenderViewHost* rvh = static_cast<TestRenderViewHost*>(our_contents.render_view_host()); + ViewHostMsg_DidFailProvisionalLoadWithError_Params fail_load_params; + fail_load_params.frame_id = 1; + fail_load_params.is_main_frame = true; + fail_load_params.error_code = net::ERR_ABORTED; + fail_load_params.error_description = string16(); + fail_load_params.url = url; + fail_load_params.showing_repost_interstitial = false; rvh->TestOnMessageReceived( - ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id - 1, // frame_id - true, // is_main_frame - net::ERR_ABORTED, // error - url, // url - false)); // repost + ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id + fail_load_params)); // Now the pending restored entry commits. ViewHostMsg_FrameNavigate_Params params; diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 855956d..1865ac5 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -904,21 +904,19 @@ void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, } void TabContents::OnDidFailProvisionalLoadWithError( - int64 frame_id, - bool is_main_frame, - int error_code, - const GURL& url, - bool showing_repost_interstitial) { - VLOG(1) << "Failed Provisional Load: " << url.possibly_invalid_spec() - << ", error_code: " << error_code - << " is_main_frame: " << is_main_frame - << " showing_repost_interstitial: " << showing_repost_interstitial - << " frame_id: " << frame_id; - GURL validated_url(url); + const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { + VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() + << ", error_code: " << params.error_code + << ", error_description: " << params.error_description + << ", is_main_frame: " << params.is_main_frame + << ", showing_repost_interstitial: " << + params.showing_repost_interstitial + << ", frame_id: " << params.frame_id; + GURL validated_url(params.url); render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), GetRenderProcessHost()->id(), &validated_url); - if (net::ERR_ABORTED == error_code) { + if (net::ERR_ABORTED == params.error_code) { // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. // This means that the interstitial won't be torn down properly, which is // bad. But if we have an interstitial, go back to another tab type, and @@ -959,18 +957,26 @@ void TabContents::OnDidFailProvisionalLoadWithError( // Send out a notification that we failed a provisional load with an error. ProvisionalLoadDetails details( - is_main_frame, controller_.IsURLInPageNavigation(validated_url), - validated_url, std::string(), false, frame_id); - details.set_error_code(error_code); + params.is_main_frame, + controller_.IsURLInPageNavigation(validated_url), + validated_url, + std::string(), + false, + params.frame_id); + details.set_error_code(params.error_code); NotificationService::current()->Notify( content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, Source<NavigationController>(&controller_), Details<ProvisionalLoadDetails>(&details)); - FOR_EACH_OBSERVER(TabContentsObserver, observers_, - DidFailProvisionalLoad(frame_id, is_main_frame, - validated_url, error_code)); + FOR_EACH_OBSERVER(TabContentsObserver, + observers_, + DidFailProvisionalLoad(params.frame_id, + params.is_main_frame, + validated_url, + params.error_code, + params.error_description)); } void TabContents::OnDidLoadResourceFromMemoryCache( diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 9307e63..8d4848b 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -54,10 +54,11 @@ class TabContentsObserver; class TabContentsView; struct ThumbnailScore; class URLPattern; +struct ViewHostMsg_DidFailProvisionalLoadWithError_Params; struct ViewHostMsg_FrameNavigate_Params; +struct ViewHostMsg_RunFileChooser_Params; struct WebPreferences; class WebUI; -struct ViewHostMsg_RunFileChooser_Params; // Describes what goes in the main content area of a tab. TabContents is // the only type of TabContents, and these should be merged together. @@ -511,11 +512,8 @@ class CONTENT_EXPORT TabContents : public PageNavigator, const GURL& opener_url, const GURL& source_url, const GURL& target_url); - void OnDidFailProvisionalLoadWithError(int64 frame_id, - bool main_frame, - int error_code, - const GURL& url, - bool showing_repost_interstitial); + void OnDidFailProvisionalLoadWithError( + const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params); void OnDidLoadResourceFromMemoryCache(const GURL& url, const std::string& security_info, const std::string& http_request, diff --git a/content/browser/tab_contents/tab_contents_observer.cc b/content/browser/tab_contents/tab_contents_observer.cc index f1e71ff..f464523 100644 --- a/content/browser/tab_contents/tab_contents_observer.cc +++ b/content/browser/tab_contents/tab_contents_observer.cc @@ -46,10 +46,12 @@ void TabContentsObserver::DidCommitProvisionalLoadForFrame( PageTransition::Type transition_type) { } -void TabContentsObserver::DidFailProvisionalLoad(int64 frame_id, - bool is_main_frame, - const GURL& validated_url, - int error_code) { +void TabContentsObserver::DidFailProvisionalLoad( + int64 frame_id, + bool is_main_frame, + const GURL& validated_url, + int error_code, + const string16& error_description) { } void TabContentsObserver::DocumentLoadedInFrame(int64 frame_id) { diff --git a/content/browser/tab_contents/tab_contents_observer.h b/content/browser/tab_contents/tab_contents_observer.h index dfb884c..3388c7a 100644 --- a/content/browser/tab_contents/tab_contents_observer.h +++ b/content/browser/tab_contents/tab_contents_observer.h @@ -47,7 +47,8 @@ class CONTENT_EXPORT TabContentsObserver : public IPC::Channel::Listener, virtual void DidFailProvisionalLoad(int64 frame_id, bool is_main_frame, const GURL& validated_url, - int error_code); + int error_code, + const string16& error_description); virtual void DocumentLoadedInFrame(int64 frame_id); virtual void DidFinishLoad(int64 frame_id); virtual void DidGetUserGesture(); diff --git a/content/common/view_messages.h b/content/common/view_messages.h index e8dea34..62c7955 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -551,6 +551,23 @@ IPC_STRUCT_BEGIN(ViewHostMsg_UpdateRect_Params) IPC_STRUCT_MEMBER(int, flags) IPC_STRUCT_END() +IPC_STRUCT_BEGIN(ViewHostMsg_DidFailProvisionalLoadWithError_Params) + // The frame ID for the failure report. + IPC_STRUCT_MEMBER(int64, frame_id) + // True if this is the top-most frame. + IPC_STRUCT_MEMBER(bool, is_main_frame) + // Error code as reported in the DidFailProvisionalLoad callback. + IPC_STRUCT_MEMBER(int, error_code) + // An error message generated from the error_code. This can be an empty + // string if we were unable to find a meaningful description. + IPC_STRUCT_MEMBER(string16, error_description) + // The URL that the error is reported for. + IPC_STRUCT_MEMBER(GURL, url) + // True if the failure is the result of navigating to a POST again + // and we're going to show the POST interstitial. + IPC_STRUCT_MEMBER(bool, showing_repost_interstitial) +IPC_STRUCT_END() + IPC_STRUCT_BEGIN(ViewMsg_SwapOut_Params) // The identifier of the RenderProcessHost for the currently closing view. // @@ -1369,14 +1386,9 @@ IPC_MESSAGE_ROUTED4(ViewHostMsg_DidStartProvisionalLoadForFrame, GURL /* url */) // Sent when the renderer fails a provisional load with an error. -IPC_MESSAGE_ROUTED5(ViewHostMsg_DidFailProvisionalLoadWithError, - int64 /* frame_id */, - bool /* true if it is the main frame */, - int /* error_code */, - GURL /* url */, - bool /* true if the failure is the result of - navigating to a POST again and we're going to - show the POST interstitial */) +IPC_MESSAGE_ROUTED1(ViewHostMsg_DidFailProvisionalLoadWithError, + ViewHostMsg_DidFailProvisionalLoadWithError_Params) + // Tells the render view that a ViewHostMsg_PaintAtSize message was // processed, and the DIB is ready for use. |tag| has the same value that @@ -1941,4 +1953,3 @@ IPC_MESSAGE_ROUTED0(ViewHostMsg_LockMouse) // whenever the mouse is unlocked (which may or may not be caused by // ViewHostMsg_UnlockMouse). IPC_MESSAGE_ROUTED0(ViewHostMsg_UnlockMouse) - diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h index a0f8bba..362525c 100644 --- a/content/public/renderer/content_renderer_client.h +++ b/content/public/renderer/content_renderer_client.h @@ -70,10 +70,19 @@ class ContentRendererClient { virtual bool HasErrorPage(int http_status_code, std::string* error_domain) = 0; - // Returns the html to display when a navigation error occurs. - virtual std::string GetNavigationErrorHtml( + // Returns the information to display when a navigation error occurs. + // If |error_html| is not null then it may be set to a HTML page containing + // the details of the error and maybe links to more info. + // If |error_description| is not null it may be set to contain a brief + // message describing the error that has occurred. + // Either of the out parameters may be not written to in certain cases + // (lack of information on the error code) so the caller should take care to + // initialize the string values with safe defaults before the call. + virtual void GetNavigationErrorStrings( const WebKit::WebURLRequest& failed_request, - const WebKit::WebURLError& error) = 0; + const WebKit::WebURLError& error, + std::string* error_html, + string16* error_description) = 0; // Returns true if the renderer process should schedule the idle handler when // all widgets are hidden. diff --git a/content/renderer/mock_content_renderer_client.cc b/content/renderer/mock_content_renderer_client.cc index eef7981..984afa9 100644 --- a/content/renderer/mock_content_renderer_client.cc +++ b/content/renderer/mock_content_renderer_client.cc @@ -42,10 +42,11 @@ bool MockContentRendererClient::HasErrorPage(int http_status_code, return false; } -std::string MockContentRendererClient::GetNavigationErrorHtml( +void MockContentRendererClient::GetNavigationErrorStrings( const WebKit::WebURLRequest& failed_request, - const WebKit::WebURLError& error) { - return std::string(); + const WebKit::WebURLError& error, + std::string* error_html, + string16* error_description) { } bool MockContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { diff --git a/content/renderer/mock_content_renderer_client.h b/content/renderer/mock_content_renderer_client.h index 28dd4a8..bcec7ac 100644 --- a/content/renderer/mock_content_renderer_client.h +++ b/content/renderer/mock_content_renderer_client.h @@ -29,9 +29,11 @@ class MockContentRendererClient : public ContentRendererClient { WebKit::WebPlugin** plugin) OVERRIDE; virtual bool HasErrorPage(int http_status_code, std::string* error_domain) OVERRIDE; - virtual std::string GetNavigationErrorHtml( + virtual void GetNavigationErrorStrings( const WebKit::WebURLRequest& failed_request, - const WebKit::WebURLError& error) OVERRIDE; + const WebKit::WebURLError& error, + std::string* error_html, + string16* error_description) OVERRIDE; virtual bool RunIdleHandlerWhenWidgetsHidden() OVERRIDE; virtual bool AllowPopup(const GURL& creator) OVERRIDE; virtual bool ShouldFork(WebKit::WebFrame* frame, diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc index 78df67c6..5db8908 100644 --- a/content/renderer/render_view_browsertest.cc +++ b/content/renderer/render_view_browsertest.cc @@ -894,7 +894,7 @@ TEST_F(RenderViewImplTest, InsertCharacters) { TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) { GetMainFrame()->enableViewSourceMode(true); WebURLError error; - error.domain.fromUTF8("test_domain"); + error.domain = WebString::fromUTF8(net::kErrorDomain); error.reason = net::ERR_FILE_NOT_FOUND; error.unreachableURL = GURL("http://foo"); WebFrame* web_frame = GetMainFrame(); @@ -907,7 +907,7 @@ TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) { TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { GetMainFrame()->enableViewSourceMode(true); WebURLError error; - error.domain.fromUTF8("test_domain"); + error.domain = WebString::fromUTF8(net::kErrorDomain); error.reason = net::ERR_ABORTED; error.unreachableURL = GURL("http://foo"); WebFrame* web_frame = GetMainFrame(); diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 03a6615..e6bf678 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -1252,10 +1252,18 @@ void RenderViewImpl::LoadNavigationErrorPage( const WebURLError& error, const std::string& html, bool replace) { - std::string alt_html = !html.empty() ? html : - content::GetContentClient()->renderer()->GetNavigationErrorHtml( - failed_request, error); - frame->loadHTMLString(alt_html, + std::string alt_html; + const std::string* error_html; + + if (!html.empty()) { + error_html = &html; + } else { + content::GetContentClient()->renderer()->GetNavigationErrorStrings( + failed_request, error, &alt_html, NULL); + error_html = &alt_html; + } + + frame->loadHTMLString(*error_html, GURL(chrome::kUnreachableWebDataURL), error.unreachableURL, replace); @@ -2352,9 +2360,20 @@ void RenderViewImpl::didFailProvisionalLoad(WebFrame* frame, bool show_repost_interstitial = (error.reason == net::ERR_CACHE_MISS && EqualsASCII(failed_request.httpMethod(), "POST")); + + ViewHostMsg_DidFailProvisionalLoadWithError_Params params; + params.frame_id = frame->identifier(); + params.is_main_frame = !frame->parent(); + params.error_code = error.reason; + content::GetContentClient()->renderer()->GetNavigationErrorStrings( + failed_request, + error, + NULL, + ¶ms.error_description); + params.url = error.unreachableURL; + params.showing_repost_interstitial = show_repost_interstitial; Send(new ViewHostMsg_DidFailProvisionalLoadWithError( - routing_id_, frame->identifier(), !frame->parent(), error.reason, - error.unreachableURL, show_repost_interstitial)); + routing_id_, params)); // Don't display an error page if this is simply a cancelled load. Aside // from being dumb, WebCore doesn't expect it and it will cause a crash. diff --git a/content/shell/shell_content_renderer_client.cc b/content/shell/shell_content_renderer_client.cc index 0c5f499..ab6ad0d 100644 --- a/content/shell/shell_content_renderer_client.cc +++ b/content/shell/shell_content_renderer_client.cc @@ -41,10 +41,11 @@ bool ShellContentRendererClient::HasErrorPage(int http_status_code, return false; } -std::string ShellContentRendererClient::GetNavigationErrorHtml( +void ShellContentRendererClient::GetNavigationErrorStrings( const WebKit::WebURLRequest& failed_request, - const WebKit::WebURLError& error) { - return std::string(); + const WebKit::WebURLError& error, + std::string* error_html, + string16* error_description) { } bool ShellContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { diff --git a/content/shell/shell_content_renderer_client.h b/content/shell/shell_content_renderer_client.h index aa8011a..43f1151 100644 --- a/content/shell/shell_content_renderer_client.h +++ b/content/shell/shell_content_renderer_client.h @@ -26,9 +26,11 @@ class ShellContentRendererClient : public ContentRendererClient { WebKit::WebPlugin** plugin) OVERRIDE; virtual bool HasErrorPage(int http_status_code, std::string* error_domain) OVERRIDE; - virtual std::string GetNavigationErrorHtml( + virtual void GetNavigationErrorStrings( const WebKit::WebURLRequest& failed_request, - const WebKit::WebURLError& error) OVERRIDE; + const WebKit::WebURLError& error, + std::string* error_html, + string16* error_description) OVERRIDE; virtual bool RunIdleHandlerWhenWidgetsHidden() OVERRIDE; virtual bool AllowPopup(const GURL& creator) OVERRIDE; virtual bool ShouldFork(WebKit::WebFrame* frame, |