[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

beidson at apple.com beidson at apple.com
Mon Feb 21 00:13:45 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 89873df114dbe36605b96084c1218a45497bdbfd
Author: beidson at apple.com <beidson at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 28 22:48:35 2011 +0000

    https://bugs.webkit.org/show_bug.cgi?id=53330
    Need InjectedBundle API to get the response MIMEType for a URL
    
    Reviewed by John Sullivan.
    
    * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
    (WKBundleFrameCopyMIMETypeForResourceWithURL):
    * WebProcess/InjectedBundle/API/c/WKBundleFrame.h:
    
    Get the MIMEType from the in-memory cache, or cachedResponseMIMETypeForURL() if not available:
    * WebProcess/WebPage/WebFrame.cpp:
    (WebKit::WebFrame::mimeTypeForResourceWithURL):
    * WebProcess/WebPage/WebFrame.h:
    
    Get the MIMEType from the platform's disk cache if available:
    * WebProcess/WebPage/WebPage.h:
    * WebProcess/WebPage/mac/WebPageMac.mm:
    (WebKit::WebPage::cachedResponseMIMETypeForURL):
    * WebProcess/WebPage/qt/WebPageQt.cpp:
    (WebKit::WebPage::cachedResponseMIMETypeForURL):
    * WebProcess/WebPage/win/WebPageWin.cpp:
    (WebKit::WebPage::cachedResponseMIMETypeForURL):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76993 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index a2df534..d272eea 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,28 @@
+2011-01-28  Brady Eidson  <beidson at apple.com>
+
+        Reviewed by John Sullivan.
+
+        https://bugs.webkit.org/show_bug.cgi?id=53330
+        Need InjectedBundle API to get the response MIMEType for a URL
+
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
+        (WKBundleFrameCopyMIMETypeForResourceWithURL):
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.h:
+
+        Get the MIMEType from the in-memory cache, or cachedResponseMIMETypeForURL() if not available:
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::mimeTypeForResourceWithURL):
+        * WebProcess/WebPage/WebFrame.h:
+
+        Get the MIMEType from the platform's disk cache if available:
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::cachedResponseMIMETypeForURL):
+        * WebProcess/WebPage/qt/WebPageQt.cpp:
+        (WebKit::WebPage::cachedResponseMIMETypeForURL):
+        * WebProcess/WebPage/win/WebPageWin.cpp:
+        (WebKit::WebPage::cachedResponseMIMETypeForURL):
+
 2011-01-28  Anders Carlsson  <andersca at apple.com>
 
         Reviewed by Sam Weinig.
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
index ffd4adc..2ec36b7 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
@@ -231,3 +231,8 @@ WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRe
 {
     return toCopiedAPI(toImpl(frameRef)->suggestedFilenameForResourceWithURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string())));
 }
+
+WKStringRef WKBundleFrameCopyMIMETypeForResourceWithURL(WKBundleFrameRef frameRef, WKURLRef urlRef)
+{
+    return toCopiedAPI(toImpl(frameRef)->mimeTypeForResourceWithURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string())));
+}
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h
index 93a7978..e6fd0c8 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h
@@ -63,6 +63,7 @@ WK_EXPORT WKRect WKBundleFrameGetVisibleContentBounds(WKBundleFrameRef frame);
 WK_EXPORT WKSize WKBundleFrameGetScrollOffset(WKBundleFrameRef frame);
 
 WK_EXPORT WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frame, WKURLRef url);
+WK_EXPORT WKStringRef WKBundleFrameCopyMIMETypeForResourceWithURL(WKBundleFrameRef frame, WKURLRef url);
 
 #ifdef __cplusplus
 }
diff --git a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp
index 67eceea..46bd027 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp
@@ -544,4 +544,20 @@ String WebFrame::suggestedFilenameForResourceWithURL(const KURL& url) const
     return resource->response().suggestedFilename();
 }
 
+String WebFrame::mimeTypeForResourceWithURL(const KURL& url) const
+{
+    if (!m_coreFrame)
+        return String();
+
+    DocumentLoader* loader = m_coreFrame->loader()->documentLoader();
+    if (!loader)
+        return String();
+    
+    RefPtr<ArchiveResource> resource = loader->subresource(url);
+    if (resource)
+        return resource->mimeType();
+
+    return page()->cachedResponseMIMETypeForURL(url);
+}
+
 } // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/WebFrame.h b/Source/WebKit2/WebProcess/WebPage/WebFrame.h
index f254e7a..9aa3d64 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebFrame.h
+++ b/Source/WebKit2/WebProcess/WebPage/WebFrame.h
@@ -110,6 +110,7 @@ public:
 
     String provisionalURL() const;
     String suggestedFilenameForResourceWithURL(const WebCore::KURL&) const;
+    String mimeTypeForResourceWithURL(const WebCore::KURL&) const;
 
     // Simple listener class used by plug-ins to know when frames finish or fail loading.
     class LoadListener {
diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h
index 1fefb5b..873b425 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebPage.h
+++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h
@@ -252,6 +252,7 @@ public:
     WebContextMenu* contextMenu();
     
     bool hasLocalDataForURL(const WebCore::KURL&);
+    String cachedResponseMIMETypeForURL(const WebCore::KURL&);
     
     static bool canHandleRequest(const WebCore::ResourceRequest&);
 
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm b/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
index 8c726c3..8621837 100644
--- a/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
+++ b/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
@@ -358,6 +358,16 @@ bool WebPage::platformHasLocalDataForURL(const WebCore::KURL& url)
     return cachedResponse;
 }
 
+String WebPage::cachedResponseMIMETypeForURL(const WebCore::KURL& url)
+{
+    NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url];
+    [request setValue:(NSString*)userAgent() forHTTPHeaderField:@"User-Agent"];
+    NSCachedURLResponse *cachedResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:request];
+    [request release];
+    
+    return [[cachedResponse response] MIMEType];
+}
+
 bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request)
 {
     if ([NSURLConnection canHandleRequest:request.nsURLRequest()])
diff --git a/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp b/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp
index 5701e9a..cad0c04 100644
--- a/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp
@@ -271,6 +271,12 @@ bool WebPage::platformHasLocalDataForURL(const WebCore::KURL&)
     return false;
 }
 
+String WebPage::cachedResponseMIMETypeForURL(const WebCore::KURL&)
+{
+    // FIXME: Implement
+    return String();
+}
+
 bool WebPage::canHandleRequest(const WebCore::ResourceRequest&)
 {
     // FIXME: Implement
diff --git a/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp b/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
index 8a1a126..e20af3a 100644
--- a/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
@@ -262,6 +262,27 @@ bool WebPage::platformHasLocalDataForURL(const WebCore::KURL& url)
 #endif
 }
 
+String WebPage::cachedResponseMIMETypeForURL(const WebCore::KURL& url)
+{
+#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> cachedResponse(AdoptCF, CFURLCacheCopyResponseForRequest(cache.get(), request.get()));
+    
+    CFURLResponseRef response = CFCachedURLResponseGetWrappedResponse(cachedResponse.get());
+    
+    return response ? CFURLResponseGetMIMEType(response) : String();
+#else
+    return String();
+#endif
+}
+
 bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request)
 {
 #if USE(CFNETWORK)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list