WebKit2: WebPageWin needs implementations of hasLocalDataForURL and canHandleRequest
authorbweinstein@apple.com <bweinstein@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Dec 2010 19:34:25 +0000 (19:34 +0000)
committerbweinstein@apple.com <bweinstein@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Dec 2010 19:34:25 +0000 (19:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=51090

Reviewed by Adam Roben.

Implement these functions for WebKit2 on Windows.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::hasLocalDataForURL): Does the cross-platform part of the check for having local
    data (file URL or subresource), then calls platformHasLocalDataForURL to let the platform do
    their specific checks.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::platformHasLocalDataForURL): Moved the cross-platform code from here to WebPage::hasLocalDataForURL.
* WebProcess/WebPage/qt/WebPageQt.cpp:
(WebKit::WebPage::platformHasLocalDataForURL): Renamed from hasLocalDataForURL.
* WebProcess/WebPage/win/WebPageWin.cpp:
(WebKit::WebPage::platformHasLocalDataForURL): Renamed from hasLocalDataForURL and implemented with CFNetwork calls. This is the
    CFNetwork equivalent of the code in WebPageMac::platformHasLocalDataForURL.
(WebKit::WebPage::canHandleRequest): Copied the line of code from WebView::canHandleRequest in WebKit1, with a FIXME saying
    this might not be enough (although it was in WebKit1 on Windows).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@74131 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit2/ChangeLog
WebKit2/WebProcess/WebPage/WebPage.cpp
WebKit2/WebProcess/WebPage/WebPage.h
WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp
WebKit2/WebProcess/WebPage/win/WebPageWin.cpp

index 2abc126..9c5d9f8 100644 (file)
@@ -1,3 +1,27 @@
+2010-12-15  Brian Weinstein  <bweinstein@apple.com>
+
+        Reviewed by Adam Roben.
+
+        WebKit2: WebPageWin needs implementations of hasLocalDataForURL and canHandleRequest
+        https://bugs.webkit.org/show_bug.cgi?id=51090
+        
+        Implement these functions for WebKit2 on Windows.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::hasLocalDataForURL): Does the cross-platform part of the check for having local
+            data (file URL or subresource), then calls platformHasLocalDataForURL to let the platform do
+            their specific checks.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::platformHasLocalDataForURL): Moved the cross-platform code from here to WebPage::hasLocalDataForURL.
+        * WebProcess/WebPage/qt/WebPageQt.cpp:
+        (WebKit::WebPage::platformHasLocalDataForURL): Renamed from hasLocalDataForURL.
+        * WebProcess/WebPage/win/WebPageWin.cpp:
+        (WebKit::WebPage::platformHasLocalDataForURL): Renamed from hasLocalDataForURL and implemented with CFNetwork calls. This is the
+            CFNetwork equivalent of the code in WebPageMac::platformHasLocalDataForURL.
+        (WebKit::WebPage::canHandleRequest): Copied the line of code from WebView::canHandleRequest in WebKit1, with a FIXME saying
+            this might not be enough (although it was in WebKit1 on Windows).
+
 2010-12-15  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r74117.
index c3b92a7..e8c77ed 100644 (file)
 #include "WebProcessProxyMessageKinds.h"
 #include "WebProcessProxyMessages.h"
 #include <WebCore/AbstractDatabase.h>
+#include <WebCore/ArchiveResource.h>
 #include <WebCore/Chrome.h>
 #include <WebCore/ContextMenuController.h>
+#include <WebCore/DocumentLoader.h>
 #include <WebCore/EventHandler.h>
 #include <WebCore/FocusController.h>
 #include <WebCore/Frame.h>
@@ -1264,4 +1266,17 @@ void WebPage::SandboxExtensionTracker::didFailProvisionalLoad(WebFrame* frame)
     m_provisionalSandboxExtension = 0;
 }
 
+bool WebPage::hasLocalDataForURL(const KURL& url)
+{
+    if (url.isLocalFile())
+        return true;
+
+    FrameLoader* frameLoader = m_page->mainFrame()->loader();
+    DocumentLoader* documentLoader = frameLoader ? frameLoader->documentLoader() : 0;
+    if (documentLoader && documentLoader->subresource(url))
+        return true;
+
+    return platformHasLocalDataForURL(url);
+}
+
 } // namespace WebKit
index eef827f..cb10bba 100644 (file)
@@ -267,6 +267,8 @@ private:
 
     void loadData(PassRefPtr<WebCore::SharedBuffer>, const String& MIMEType, const String& encodingName, const WebCore::KURL& baseURL, const WebCore::KURL& failingURL);
 
+    bool platformHasLocalDataForURL(const WebCore::KURL&);
+
     // Actions
     void tryClose();
     void loadURL(const String&, const SandboxExtension::Handle& sandboxExtensionHandle);
index 7bb3115..12c7700 100644 (file)
@@ -30,8 +30,6 @@
 #include "WebEvent.h"
 #include "WebPageProxyMessages.h"
 #include "WebProcess.h"
-#include <WebCore/ArchiveResource.h>
-#include <WebCore/DocumentLoader.h>
 #include <WebCore/FocusController.h>
 #include <WebCore/Frame.h>
 #include <WebCore/FrameView.h>
@@ -342,16 +340,8 @@ bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboard
     return true;
 }
 
-bool WebPage::hasLocalDataForURL(const WebCore::KURL& url)
+bool WebPage::platformHasLocalDataForURL(const WebCore::KURL& url)
 {
-    if (url.isLocalFile())
-        return true;
-    
-    FrameLoader* frameLoader = m_page->mainFrame()->loader();
-    DocumentLoader* documentLoader = frameLoader ? frameLoader->documentLoader() : 0;
-    if (documentLoader && documentLoader->subresource(url))
-        return true;
-
     NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url];
     [request setValue:(NSString*)userAgent() forHTTPHeaderField:@"User-Agent"];
     NSCachedURLResponse *cachedResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:request];
index b65fa18..fe1a89c 100644 (file)
@@ -264,7 +264,7 @@ bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboard
     return true;
 }
 
-bool WebPage::hasLocalDataForURL(const WebCore::KURL&)
+bool WebPage::platformHasLocalDataForURL(const WebCore::KURL&)
 {
     // FIXME: Implement
     return false;
index bc3b131..20b95ee 100644 (file)
 #endif
 #include <WinUser.h>
 
+#if USE(CFNETWORK)
+#include <CFNetwork/CFURLCachePriv.h>
+#include <CFNetwork/CFURLProtocolPriv.h>
+#include <CFNetwork/CFURLRequestPriv.h>
+#endif
+
 using namespace WebCore;
 
 namespace WebKit {
@@ -236,16 +242,28 @@ bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboard
     return true;
 }
 
-bool WebPage::hasLocalDataForURL(const WebCore::KURL&)
+bool WebPage::platformHasLocalDataForURL(const WebCore::KURL& url)
 {
-    // FIXME <rdar://problem/8608754>: Implement
+#if USE(CFNETWORK)
+    RetainPtr<CFURLRef> cfURL(AdoptCF, url.createCFURL());
+    RetainPtr<CFMutableURLRequestRef> request(AdoptCF, CFURLRequestCreateMutable(0, cfURL.get(), kCFURLRequestCachePolicyReloadIgnoringCache, 60, 0));
+    
+    RetainPtr<CFStringRef> userAgent(AdoptCF, userAgent().createCFString());
+    CFURLRequestSetHTTPHeaderFieldValue(request.get(), CFSTR("User-Agent"), userAgent.get());
+
+    RetainPtr<CFURLCacheRef> cache(AdoptCF, CFURLCacheCopySharedURLCache());
+
+    RetainPtr<CFCachedURLResponseRef> response(AdoptCF, CFURLCacheCopyResponseForRequest(cache.get(), request.get()));    
+    return response;
+#else
     return false;
+#endif
 }
 
-bool WebPage::canHandleRequest(const WebCore::ResourceRequest&)
+bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request)
 {
-    // FIXME <rdar://problem/8608754>: Implement
-    return true;
+    // FIXME: Are there other requests we need to be able to handle? WebKit1's WebView.cpp has a FIXME here as well.
+    return CFURLProtocolCanHandleRequest(request.cfURLRequest());
 }
 
 } // namespace WebKit