diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-08 01:40:13 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-08 01:40:13 +0000 |
commit | e6a2ce57d998f2e436d584c264efb3d02b06018e (patch) | |
tree | 75e4703b676dc48880090865834364ea844360a4 /content | |
parent | a813c8e4868ecd41fe76a387b9a5a92a2f7fe67c (diff) | |
download | chromium_src-e6a2ce57d998f2e436d584c264efb3d02b06018e.zip chromium_src-e6a2ce57d998f2e436d584c264efb3d02b06018e.tar.gz chromium_src-e6a2ce57d998f2e436d584c264efb3d02b06018e.tar.bz2 |
Simplify embedder API around showing custom error pages so that the embedder doesn't have to call content back in its callback. This removes one method from RenderView that we need to expose in its API.
BUG=98716
Review URL: http://codereview.chromium.org/8198021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/content_tests.gypi | 2 | ||||
-rw-r--r-- | content/public/renderer/content_renderer_client.h | 10 | ||||
-rw-r--r-- | content/renderer/mock_content_renderer_client.cc | 6 | ||||
-rw-r--r-- | content/renderer/mock_content_renderer_client.h | 5 | ||||
-rw-r--r-- | content/renderer/render_view.cc | 13 | ||||
-rw-r--r-- | content/shell/shell_content_renderer_client.cc | 6 | ||||
-rw-r--r-- | content/shell/shell_content_renderer_client.h | 5 |
7 files changed, 29 insertions, 18 deletions
diff --git a/content/content_tests.gypi b/content/content_tests.gypi index a341c25..45b6210 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -34,6 +34,7 @@ 'browser/geolocation/mock_location_provider.cc', 'browser/geolocation/mock_location_provider.h', 'browser/mock_content_browser_client.cc', + 'browser/mock_content_browser_client.h', 'browser/mock_resource_context.cc', 'browser/mock_resource_context.h', 'browser/renderer_host/dummy_resource_handler.cc', @@ -53,6 +54,7 @@ 'gpu/gpu_idirect3d9_mock_win.cc', 'gpu/gpu_idirect3d9_mock_win.h', 'renderer/mock_content_renderer_client.cc', + 'renderer/mock_content_renderer_client.h', 'renderer/mock_render_process.cc', 'renderer/mock_render_process.h', 'test/browser_test.h', diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h index 3ed428b..9855ee0 100644 --- a/content/public/renderer/content_renderer_client.h +++ b/content/public/renderer/content_renderer_client.h @@ -62,10 +62,12 @@ class ContentRendererClient { const WebKit::WebPluginParams& params, WebKit::WebPlugin** plugin) = 0; - // Give the embedder the ability to set an error page. - virtual void ShowErrorPage(RenderView* render_view, - WebKit::WebFrame* frame, - int http_status_code) = 0; + // Returns true if the embedder has an error page to show for the given http + // status code. If so |error_domain| should be set to according to WebURLError + // and the embedder's GetNavigationErrorHtml will be called afterwards to get + // the error html. + 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( diff --git a/content/renderer/mock_content_renderer_client.cc b/content/renderer/mock_content_renderer_client.cc index b8a8e6d..eef7981 100644 --- a/content/renderer/mock_content_renderer_client.cc +++ b/content/renderer/mock_content_renderer_client.cc @@ -37,9 +37,9 @@ bool MockContentRendererClient::OverrideCreatePlugin( return false; } -void MockContentRendererClient::ShowErrorPage(RenderView* render_view, - WebKit::WebFrame* frame, - int http_status_code) { +bool MockContentRendererClient::HasErrorPage(int http_status_code, + std::string* error_domain) { + return false; } std::string MockContentRendererClient::GetNavigationErrorHtml( diff --git a/content/renderer/mock_content_renderer_client.h b/content/renderer/mock_content_renderer_client.h index ea25c4f..28dd4a8 100644 --- a/content/renderer/mock_content_renderer_client.h +++ b/content/renderer/mock_content_renderer_client.h @@ -27,9 +27,8 @@ class MockContentRendererClient : public ContentRendererClient { WebKit::WebFrame* frame, const WebKit::WebPluginParams& params, WebKit::WebPlugin** plugin) OVERRIDE; - virtual void ShowErrorPage(RenderView* render_view, - WebKit::WebFrame* frame, - int http_status_code) OVERRIDE; + virtual bool HasErrorPage(int http_status_code, + std::string* error_domain) OVERRIDE; virtual std::string GetNavigationErrorHtml( const WebKit::WebURLRequest& failed_request, const WebKit::WebURLError& error) OVERRIDE; diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc index 4dfc3f9..ffee00d 100644 --- a/content/renderer/render_view.cc +++ b/content/renderer/render_view.cc @@ -2690,8 +2690,17 @@ void RenderView::didFinishResourceLoad( } } - content::GetContentClient()->renderer()->ShowErrorPage( - this, frame, http_status_code); + std::string error_domain; + if (content::GetContentClient()->renderer()->HasErrorPage( + http_status_code, &error_domain)) { + WebURLError error; + error.unreachableURL = frame->document().url(); + error.domain = WebString::fromUTF8(error_domain); + error.reason = http_status_code; + + LoadNavigationErrorPage( + frame, frame->dataSource()->request(), error, std::string(), true); + } } void RenderView::didFailResourceLoad( diff --git a/content/shell/shell_content_renderer_client.cc b/content/shell/shell_content_renderer_client.cc index ea94b90..0c5f499 100644 --- a/content/shell/shell_content_renderer_client.cc +++ b/content/shell/shell_content_renderer_client.cc @@ -36,9 +36,9 @@ bool ShellContentRendererClient::OverrideCreatePlugin( return false; } -void ShellContentRendererClient::ShowErrorPage(RenderView* render_view, - WebKit::WebFrame* frame, - int http_status_code) { +bool ShellContentRendererClient::HasErrorPage(int http_status_code, + std::string* error_domain) { + return false; } std::string ShellContentRendererClient::GetNavigationErrorHtml( diff --git a/content/shell/shell_content_renderer_client.h b/content/shell/shell_content_renderer_client.h index 05449ee..aa8011a 100644 --- a/content/shell/shell_content_renderer_client.h +++ b/content/shell/shell_content_renderer_client.h @@ -24,9 +24,8 @@ class ShellContentRendererClient : public ContentRendererClient { WebKit::WebFrame* frame, const WebKit::WebPluginParams& params, WebKit::WebPlugin** plugin) OVERRIDE; - virtual void ShowErrorPage(RenderView* render_view, - WebKit::WebFrame* frame, - int http_status_code) OVERRIDE; + virtual bool HasErrorPage(int http_status_code, + std::string* error_domain) OVERRIDE; virtual std::string GetNavigationErrorHtml( const WebKit::WebURLRequest& failed_request, const WebKit::WebURLError& error) OVERRIDE; |