diff options
-rw-r--r-- | chrome/renderer/render_view.cc | 18 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 6 | ||||
-rw-r--r-- | webkit/api/public/WebFrameClient.h | 10 | ||||
-rw-r--r-- | webkit/glue/empty_webframeclient.h | 6 | ||||
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.cc | 23 | ||||
-rw-r--r-- | webkit/tools/layout_tests/test_expectations.txt | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 26 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.h | 5 |
8 files changed, 85 insertions, 13 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 490a1ee..b36ebda 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1919,6 +1919,24 @@ WebNavigationPolicy RenderView::decidePolicyForNavigation( return default_policy; } +bool RenderView::canHandleRequest(const WebKit::WebURLRequest& request) { + return true; +} + +WebKit::WebURLError RenderView::cannotShowURLError( + const WebKit::WebURLRequest& request) { + // No need to set fields of WebURLError. It is passed to + // unableToImplementPolicyWithError() below. + return WebKit::WebURLError(); +} + +void RenderView::unableToImplementPolicyWithError( + WebFrame*, const WebKit::WebURLError&) { + // We don't need to do anything here. + // The implementations of this method in WebKit/mac WebKit/win are + // just to log some information of the parameters. +} + void RenderView::willSubmitForm(WebFrame* frame, const WebForm& form) { NavigationState* navigation_state = NavigationState::FromDataSource(frame->provisionalDataSource()); diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 05eedff..7ccf210 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -86,6 +86,7 @@ namespace WebKit { class WebDragData; class WebMediaPlayer; class WebMediaPlayerClient; +class WebURLRequest; struct WebFindOptions; } @@ -286,6 +287,11 @@ class RenderView : public RenderWidget, WebKit::WebFrame* frame, const WebKit::WebURLRequest& request, WebKit::WebNavigationType type, const WebKit::WebNode&, WebKit::WebNavigationPolicy default_policy, bool is_redirect); + virtual bool canHandleRequest(const WebKit::WebURLRequest& request); + virtual WebKit::WebURLError cannotShowURLError( + const WebKit::WebURLRequest& request); + virtual void unableToImplementPolicyWithError( + WebKit::WebFrame* frame, const WebKit::WebURLError& error); virtual void willSubmitForm(WebKit::WebFrame* frame, const WebKit::WebForm& form); virtual void willPerformClientRedirect( diff --git a/webkit/api/public/WebFrameClient.h b/webkit/api/public/WebFrameClient.h index 82f9eed..f0fd8b3 100644 --- a/webkit/api/public/WebFrameClient.h +++ b/webkit/api/public/WebFrameClient.h @@ -91,6 +91,16 @@ namespace WebKit { const WebNode& originatingNode, WebNavigationPolicy defaultPolicy, bool isRedirect) = 0; + // Query if the specified request can be handled. + virtual bool canHandleRequest(const WebURLRequest& request) = 0; + + // Called if canHandledRequest() returns false. + virtual WebURLError cannotShowURLError( + const WebURLRequest& request) = 0; + + // Notify that a URL cannot be handled. + virtual void unableToImplementPolicyWithError( + WebFrame*, const WebURLError&) = 0; // Navigational notifications ------------------------------------------ diff --git a/webkit/glue/empty_webframeclient.h b/webkit/glue/empty_webframeclient.h index 62a52c0..6b1af5e 100644 --- a/webkit/glue/empty_webframeclient.h +++ b/webkit/glue/empty_webframeclient.h @@ -6,6 +6,7 @@ #define WEBKIT_GLUE_EMPTY_WEBFRAMECLIENT_H_ #include "webkit/api/public/WebFrameClient.h" +#include "webkit/api/public/WebURLError.h" namespace webkit_glue { @@ -30,6 +31,11 @@ class EmptyWebFrameClient : public WebKit::WebFrameClient { WebKit::WebNavigationType type, const WebKit::WebNode& originating_node, WebKit::WebNavigationPolicy default_policy, bool is_redirect) { return default_policy; } + virtual bool canHandleRequest(const WebKit::WebURLRequest&) { return true; } + virtual WebKit::WebURLError cannotShowURLError( + const WebKit::WebURLRequest& request) { return WebKit::WebURLError(); } + virtual void unableToImplementPolicyWithError( + WebKit::WebFrame*, const WebKit::WebURLError&) {} virtual void willSubmitForm(WebKit::WebFrame* frame, const WebKit::WebForm& form) {} virtual void willPerformClientRedirect( diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 826625dd..3fe52c62 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -849,8 +849,11 @@ void WebFrameLoaderClient::cancelPolicyCheck() { // FIXME } -void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&) { - // FIXME +void WebFrameLoaderClient::dispatchUnableToImplementPolicy( + const ResourceError& error) { + WebKit::WebURLError url_error = + webkit_glue::ResourceErrorToWebURLError(error); + webframe_->client()->unableToImplementPolicyWithError(webframe_, url_error); } void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, @@ -999,10 +1002,13 @@ ResourceError WebFrameLoaderClient::cancelledError( return ResourceError(net::kErrorDomain, net::ERR_ABORTED, request.url().string(), String()); } -ResourceError WebFrameLoaderClient::cannotShowURLError(const ResourceRequest&) { - // FIXME - return ResourceError(); + +ResourceError WebFrameLoaderClient::cannotShowURLError( + const ResourceRequest& request) { + return webkit_glue::WebURLErrorToResourceError( + webframe_->client()->cannotShowURLError(WrappedResourceRequest(request))); } + ResourceError WebFrameLoaderClient::interruptForPolicyChangeError( const ResourceRequest& request) { return ResourceError(kInternalErrorDomain, ERR_POLICY_CHANGE, @@ -1034,10 +1040,9 @@ bool WebFrameLoaderClient::shouldFallBack(const ResourceError& error) { return error.errorCode() != net::ERR_ABORTED; } -bool WebFrameLoaderClient::canHandleRequest(const ResourceRequest&) const { - // FIXME: this appears to be used only by the context menu code to determine - // if "open" should be displayed in the menu when clicking on a link. - return true; +bool WebFrameLoaderClient::canHandleRequest( + const ResourceRequest& request) const { + return webframe_->client()->canHandleRequest(WrappedResourceRequest(request)); } bool WebFrameLoaderClient::canShowMIMEType(const String& mime_type) const { diff --git a/webkit/tools/layout_tests/test_expectations.txt b/webkit/tools/layout_tests/test_expectations.txt index 29efeec..8c3a91d 100644 --- a/webkit/tools/layout_tests/test_expectations.txt +++ b/webkit/tools/layout_tests/test_expectations.txt @@ -2643,10 +2643,6 @@ BUG10861 WIN : LayoutTests/http/tests/plugins/post-url-file.html = PASS BUG10861 MAC : LayoutTests/http/tests/plugins/post-url-file.html = TIMEOUT // New failures from WebKit merge 42725:42805 -// Need to implement WebFrameLoaderClient::dispatchUnableToImplmentPolicy(). -BUG24074 : LayoutTests/http/tests/misc/redirect-to-external-url.html = FAIL - -// New failures from WebKit merge 42725:42805 // WebKit change http://trac.webkit.org/changeset/42785 // added a test which submits a form and then uses history.back() // to go back. in test_shell history.back() does not go back, diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 69d1224..0ed4780 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -657,6 +657,32 @@ WebNavigationPolicy TestWebViewDelegate::decidePolicyForNavigation( return result; } +bool TestWebViewDelegate::canHandleRequest(const WebURLRequest& request) { + GURL url = request.url(); + // Just reject the scheme used in + // LayoutTests/http/tests/misc/redirect-to-external-url.html + return !url.SchemeIs("spaceballs"); +} + +WebURLError TestWebViewDelegate::cannotShowURLError( + const WebURLRequest& request) { + WebURLError error; + // A WebKit layout test expects the following values. + // unableToImplementPolicyWithError() below prints them. + error.domain = WebString::fromUTF8("WebKitErrorDomain"); + error.reason = 101; + error.unreachableURL = request.url(); + return error; +} + +void TestWebViewDelegate::unableToImplementPolicyWithError( + WebFrame* frame, const WebURLError& error) { + std::string domain = error.domain.utf8(); + printf("Policy delegate: unable to implement policy with error domain '%s', " + "error code %d, in frame '%s'\n", + domain.data(), error.reason, frame->name().utf8().data()); +} + void TestWebViewDelegate::willPerformClientRedirect( WebFrame* frame, const WebURL& from, const WebURL& to, double interval, double fire_time) { diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index ad82a4a..155bb64 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -182,6 +182,11 @@ class TestWebViewDelegate : public WebViewDelegate, WebKit::WebFrame*, const WebKit::WebURLRequest&, WebKit::WebNavigationType, const WebKit::WebNode&, WebKit::WebNavigationPolicy default_policy, bool isRedirect); + virtual bool canHandleRequest(const WebKit::WebURLRequest&); + virtual WebKit::WebURLError cannotShowURLError( + const WebKit::WebURLRequest& request); + virtual void unableToImplementPolicyWithError( + WebKit::WebFrame*, const WebKit::WebURLError&); virtual void willSubmitForm(WebKit::WebFrame*, const WebKit::WebForm&) {} virtual void willPerformClientRedirect( WebKit::WebFrame*, const WebKit::WebURL& from, const WebKit::WebURL& to, |