Title: [116265] trunk/Source
Revision
116265
Author
[email protected]
Date
2012-05-06 21:09:39 -0700 (Sun, 06 May 2012)

Log Message

[BlackBerry] Support html5 download attribute.
https://bugs.webkit.org/show_bug.cgi?id=85044

Reviewed by Antonio Gomes.

Source/WebCore:

Pass download attribute filename to networkJob and it could be
overridden by the Content-Disposition HTTP header's filename parameter.

* platform/network/blackberry/NetworkJob.cpp:
(WebCore::NetworkJob::initialize):
* platform/network/blackberry/ResourceRequest.h:
(WebCore::ResourceRequest::setSuggestSaveName):
(WebCore::ResourceRequest::suggestSaveName):
(ResourceRequest):
* platform/network/blackberry/ResourceRequestBlackBerry.cpp:
(WebCore::ResourceRequest::initializePlatformRequest):

Source/WebKit/blackberry:

If a link has download attribute, we should pass that value and be able to
save file with the name according to HTML5:
http://updates.html5rocks.com/2011/08/Downloading-resources-in-HTML5-a-download

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::load):
(BlackBerry::WebKit::WebPage::download):
* Api/WebPage_p.h:
(WebPagePrivate):
* WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
(WebCore::FrameLoaderClientBlackBerry::startDownload):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (116264 => 116265)


--- trunk/Source/WebCore/ChangeLog	2012-05-07 03:43:03 UTC (rev 116264)
+++ trunk/Source/WebCore/ChangeLog	2012-05-07 04:09:39 UTC (rev 116265)
@@ -1,3 +1,22 @@
+2012-05-06  Mary Wu  <[email protected]>
+
+        [BlackBerry] Support html5 download attribute.
+        https://bugs.webkit.org/show_bug.cgi?id=85044
+
+        Reviewed by Antonio Gomes.
+
+        Pass download attribute filename to networkJob and it could be
+        overridden by the Content-Disposition HTTP header's filename parameter.
+
+        * platform/network/blackberry/NetworkJob.cpp:
+        (WebCore::NetworkJob::initialize):
+        * platform/network/blackberry/ResourceRequest.h:
+        (WebCore::ResourceRequest::setSuggestSaveName):
+        (WebCore::ResourceRequest::suggestSaveName):
+        (ResourceRequest):
+        * platform/network/blackberry/ResourceRequestBlackBerry.cpp:
+        (WebCore::ResourceRequest::initializePlatformRequest):
+
 2012-05-06  Kenichi Ishibashi  <[email protected]>
 
         Disallow unquoted -webkit-font-feature-settings tags

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp (116264 => 116265)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2012-05-07 03:43:03 UTC (rev 116264)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2012-05-07 04:09:39 UTC (rev 116265)
@@ -164,6 +164,11 @@
     if (m_isData || m_isAbout)
         return true;
 
+    if (!request.getSuggestedSaveName().empty()) {
+        m_contentDisposition = "filename=";
+        m_contentDisposition += request.getSuggestedSaveName().c_str();
+    }
+
     BlackBerry::Platform::FilterStream* wrappedStream = m_streamFactory->createNetworkStream(request, m_playerId);
     if (!wrappedStream)
         return false;

Modified: trunk/Source/WebCore/platform/network/blackberry/ResourceRequest.h (116264 => 116265)


--- trunk/Source/WebCore/platform/network/blackberry/ResourceRequest.h	2012-05-07 03:43:03 UTC (rev 116264)
+++ trunk/Source/WebCore/platform/network/blackberry/ResourceRequest.h	2012-05-07 04:09:39 UTC (rev 116265)
@@ -117,6 +117,8 @@
     void initializePlatformRequest(BlackBerry::Platform::NetworkRequest&, bool cookiesEnabled, bool isInitial = false, bool isRedirect = false) const;
     void setForceDownload(bool forceDownload) { m_forceDownload = true; }
     bool forceDownload() const { return m_forceDownload; }
+    void setSuggestedSaveName(const String& name) { m_suggestedSaveName = name; }
+    String suggestedSaveName() const { return m_suggestedSaveName; }
 
     // What this request is for.
     TargetType targetType() const { return m_targetType; }
@@ -133,6 +135,7 @@
     String m_token;
     String m_anchorText;
     String m_overrideContentType;
+    String m_suggestedSaveName;
     bool m_isXMLHTTPRequest;
     bool m_mustHandleInternally;
     bool m_isRequestedByPlugin;
@@ -150,6 +153,7 @@
     String m_token;
     String m_anchorText;
     String m_overrideContentType;
+    String m_suggestedSaveName;
     bool m_isXMLHTTPRequest;
     bool m_mustHandleInternally;
     bool m_isRequestedByPlugin;

Modified: trunk/Source/WebCore/platform/network/blackberry/ResourceRequestBlackBerry.cpp (116264 => 116265)


--- trunk/Source/WebCore/platform/network/blackberry/ResourceRequestBlackBerry.cpp	2012-05-07 03:43:03 UTC (rev 116264)
+++ trunk/Source/WebCore/platform/network/blackberry/ResourceRequestBlackBerry.cpp	2012-05-07 04:09:39 UTC (rev 116265)
@@ -155,6 +155,7 @@
                 timeoutInterval());
 
         platformRequest.setConditional(isConditional());
+        platformRequest.setSuggestedSaveName(suggestedSaveName().utf8().data());
 
         if (httpBody() && !httpBody()->isEmpty()) {
             const Vector<FormDataElement>& elements = httpBody()->elements();
@@ -234,6 +235,7 @@
     data->m_token = m_token;
     data->m_anchorText = m_anchorText;
     data->m_overrideContentType = m_overrideContentType;
+    data->m_suggestedSaveName = m_suggestedSaveName;
     data->m_isXMLHTTPRequest = m_isXMLHTTPRequest;
     data->m_mustHandleInternally = m_mustHandleInternally;
     data->m_isRequestedByPlugin = m_isRequestedByPlugin;
@@ -247,6 +249,7 @@
     m_token = data->m_token;
     m_anchorText = data->m_anchorText;
     m_overrideContentType = data->m_overrideContentType;
+    m_suggestedSaveName = data->m_suggestedSaveName;
     m_isXMLHTTPRequest = data->m_isXMLHTTPRequest;
     m_mustHandleInternally = data->m_mustHandleInternally;
     m_isRequestedByPlugin = data->m_isRequestedByPlugin;

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (116264 => 116265)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-05-07 03:43:03 UTC (rev 116264)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-05-07 04:09:39 UTC (rev 116265)
@@ -557,7 +557,7 @@
     }
 };
 
-void WebPagePrivate::load(const char* url, const char* networkToken, const char* method, Platform::NetworkRequest::CachePolicy cachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool isInitial, bool mustHandleInternally, bool forceDownload, const char* overrideContentType)
+void WebPagePrivate::load(const char* url, const char* networkToken, const char* method, Platform::NetworkRequest::CachePolicy cachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool isInitial, bool mustHandleInternally, bool forceDownload, const char* overrideContentType, const char* suggestedSaveName)
 {
     stopCurrentLoad();
     DeferredTaskLoadManualScript::finishOrCancel(this);
@@ -600,6 +600,8 @@
     if (forceDownload)
         request.setForceDownload(true);
 
+    request.setSuggestedSaveName(suggestedSaveName);
+
     m_mainFrame->loader()->load(request, "" /* name */, false);
 }
 
@@ -626,7 +628,7 @@
 
 void WebPage::download(const Platform::NetworkRequest& request)
 {
-    d->load(request.getUrlRef().c_str(), 0, "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, false, false, true, "");
+    d->load(request.getUrlRef().c_str(), 0, "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, false, false, true, "", request.getSuggestedSaveName().c_str());
 }
 
 void WebPagePrivate::loadString(const char* string, const char* baseURL, const char* contentType, const char* failingURL)

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (116264 => 116265)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-05-07 03:43:03 UTC (rev 116264)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-05-07 04:09:39 UTC (rev 116265)
@@ -88,7 +88,7 @@
     bool handleMouseEvent(WebCore::PlatformMouseEvent&);
     bool handleWheelEvent(WebCore::PlatformWheelEvent&);
 
-    void load(const char* url, const char* networkToken, const char* method, Platform::NetworkRequest::CachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool isInitial, bool mustHandleInternally = false, bool forceDownload = false, const char* overrideContentType = "");
+    void load(const char* url, const char* networkToken, const char* method, Platform::NetworkRequest::CachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool isInitial, bool mustHandleInternally = false, bool forceDownload = false, const char* overrideContentType = "", const char* suggestedSaveName = "");
     void loadString(const char* string, const char* baseURL, const char* mimeType, const char* failingURL = 0);
     bool executeJavaScript(const char* script, _javascript_DataType& returnType, WebString& returnValue);
     bool executeJavaScriptInIsolatedWorld(const WebCore::ScriptSourceCode&, _javascript_DataType& returnType, WebString& returnValue);

Modified: trunk/Source/WebKit/blackberry/ChangeLog (116264 => 116265)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-05-07 03:43:03 UTC (rev 116264)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-05-07 04:09:39 UTC (rev 116265)
@@ -1,3 +1,22 @@
+2012-05-06  Mary Wu  <[email protected]>
+
+        [BlackBerry] Support html5 download attribute.
+        https://bugs.webkit.org/show_bug.cgi?id=85044
+
+        Reviewed by Antonio Gomes.
+
+        If a link has download attribute, we should pass that value and be able to
+        save file with the name according to HTML5:
+        http://updates.html5rocks.com/2011/08/Downloading-resources-in-HTML5-a-download
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::load):
+        (BlackBerry::WebKit::WebPage::download):
+        * Api/WebPage_p.h:
+        (WebPagePrivate):
+        * WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
+        (WebCore::FrameLoaderClientBlackBerry::startDownload):
+
 2012-05-06  Jonathan Dong  <[email protected]>
 
         [BlackBerry] Autofill backing store implementation upstream

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp (116264 => 116265)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2012-05-07 03:43:03 UTC (rev 116264)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2012-05-07 04:09:39 UTC (rev 116265)
@@ -1134,10 +1134,9 @@
     return FrameNetworkingContextBlackBerry::create(m_frame);
 }
 
-void FrameLoaderClientBlackBerry::startDownload(const ResourceRequest& request, const String& /*suggestedName*/)
+void FrameLoaderClientBlackBerry::startDownload(const ResourceRequest& request, const String& suggestedName)
 {
-    // FIXME: use the suggestedName?
-    m_webPagePrivate->load(request.url().string().utf8().data(), 0, "GET", NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, false, false, true, "");
+    m_webPagePrivate->load(request.url().string().utf8().data(), 0, "GET", NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, false, false, true, "", suggestedName.utf8().data());
 }
 
 void FrameLoaderClientBlackBerry::download(ResourceHandle* handle, const ResourceRequest&, const ResourceRequest&, const ResourceResponse& r)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to