diff options
Diffstat (limited to 'Tools/DumpRenderTree/chromium/WebViewHost.cpp')
-rw-r--r-- | Tools/DumpRenderTree/chromium/WebViewHost.cpp | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.cpp b/Tools/DumpRenderTree/chromium/WebViewHost.cpp index ef82f2b88..6c48bc1e1 100644 --- a/Tools/DumpRenderTree/chromium/WebViewHost.cpp +++ b/Tools/DumpRenderTree/chromium/WebViewHost.cpp @@ -450,6 +450,15 @@ bool WebViewHost::handleCurrentKeyboardEvent() return frame->executeCommand(WebString::fromUTF8(m_editCommandName), WebString::fromUTF8(m_editCommandValue)); } +// WebKit::WebPrerendererClient + +void WebViewHost::willAddPrerender(WebKit::WebPrerender*) +{ +} + + +// WebKit::WebSpellCheckClient + void WebViewHost::spellCheck(const WebString& text, int& misspelledOffset, int& misspelledLength, WebVector<WebString>* optionalSuggestions) { // Check the spelling of the given text. @@ -1206,6 +1215,21 @@ void WebViewHost::removeIdentifierForRequest(unsigned identifier) m_resourceIdentifierMap.remove(identifier); } +static void blockRequest(WebURLRequest& request) +{ + request.setURL(WebURL()); +} + +static bool isLocalhost(const string& host) +{ + return host == "127.0.0.1" || host == "localhost"; +} + +static bool hostIsUsedBySomeTestsToGenerateError(const string& host) +{ + return host == "255.255.255.255"; +} + void WebViewHost::willSendRequest(WebFrame* frame, unsigned identifier, WebURLRequest& request, const WebURLResponse& redirectResponse) { // Need to use GURL for host() and SchemeIs() @@ -1228,29 +1252,25 @@ void WebViewHost::willSendRequest(WebFrame* frame, unsigned identifier, WebURLRe if (!redirectResponse.isNull() && m_blocksRedirects) { fputs("Returning null for this redirect\n", stdout); - // To block the request, we set its URL to an empty one. - request.setURL(WebURL()); + blockRequest(request); return; } if (m_requestReturnNull) { - // To block the request, we set its URL to an empty one. - request.setURL(WebURL()); + blockRequest(request); return; } string host = url.host(); - // 255.255.255.255 is used in some tests that expect to get back an error. - if (!host.empty() && (url.SchemeIs("http") || url.SchemeIs("https")) - && host != "127.0.0.1" - && host != "255.255.255.255" - && host != "localhost" - && !m_shell->allowExternalPages()) { - printf("Blocked access to external URL %s\n", requestURL.c_str()); - - // To block the request, we set its URL to an empty one. - request.setURL(WebURL()); - return; + if (!host.empty() && (url.SchemeIs("http") || url.SchemeIs("https"))) { + GURL testURL = webView()->mainFrame()->document().url(); + const string& testHost = testURL.host(); + if (!isLocalhost(host) && !hostIsUsedBySomeTestsToGenerateError(host) && ((!testURL.SchemeIs("http") && !testURL.SchemeIs("https")) || isLocalhost(testHost)) + && !m_shell->allowExternalPages()) { + printf("Blocked access to external URL %s\n", requestURL.c_str()); + blockRequest(request); + return; + } } HashSet<String>::const_iterator end = m_clearHeaders.end(); @@ -1409,6 +1429,7 @@ void WebViewHost::setWebWidget(WebKit::WebWidget* widget) { m_webWidget = widget; webView()->setSpellCheckClient(this); + webView()->setPrerendererClient(this); webView()->setCompositorSurfaceReady(); } |