Title: [146845] trunk/Source/WebKit/blackberry
Revision
146845
Author
mary...@torchmobile.com.cn
Date
2013-03-25 20:13:02 -0700 (Mon, 25 Mar 2013)

Log Message

[BlackBerry] add needReferer in WebPage load() api
https://bugs.webkit.org/show_bug.cgi?id=113167

Reviewed by Rob Buis.

PR310175, internally reviewed by Joe Mason.
Sometimes when client load request, it need to add referer with current frame like
save link/image in option menu, so we add needRef in load() interface in webpage.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::load):
(BlackBerry::WebKit::WebPage::load):
(BlackBerry::WebKit::WebPage::loadExtended):
(BlackBerry::WebKit::WebPage::loadFile):
(BlackBerry::WebKit::WebPage::download):
* Api/WebPage.h:
* Api/WebPage_p.h:
(WebPagePrivate):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (146844 => 146845)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-03-26 03:11:09 UTC (rev 146844)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-03-26 03:13:02 UTC (rev 146845)
@@ -663,7 +663,7 @@
     }
 };
 
-void WebPagePrivate::load(const BlackBerry::Platform::String& url, const BlackBerry::Platform::String& networkToken, const BlackBerry::Platform::String& 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 BlackBerry::Platform::String& overrideContentType, const BlackBerry::Platform::String& suggestedSaveName)
+void WebPagePrivate::load(const BlackBerry::Platform::String& url, const BlackBerry::Platform::String& networkToken, const BlackBerry::Platform::String& method, Platform::NetworkRequest::CachePolicy cachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool isInitial, bool mustHandleInternally, bool needReferer, bool forceDownload, const BlackBerry::Platform::String& overrideContentType, const BlackBerry::Platform::String& suggestedSaveName)
 {
     stopCurrentLoad();
     DeferredTaskLoadManualScript::finishOrCancel(this);
@@ -702,6 +702,8 @@
 
     for (unsigned i = 0; i + 1 < headersLength; i += 2)
         request.addHTTPHeaderField(headers[i], headers[i + 1]);
+    if (needReferer && focusedOrMainFrame() && focusedOrMainFrame()->document())
+        request.addHTTPHeaderField("Referer", focusedOrMainFrame()->document()->url().string().utf8().data());
 
     if (forceDownload)
         request.setForceDownload(true);
@@ -711,14 +713,14 @@
     m_mainFrame->loader()->load(FrameLoadRequest(m_mainFrame, request));
 }
 
-void WebPage::load(const BlackBerry::Platform::String& url, const BlackBerry::Platform::String& networkToken, bool isInitial)
+void WebPage::load(const BlackBerry::Platform::String& url, const BlackBerry::Platform::String& networkToken, bool isInitial, bool needReferer, bool forceDownload)
 {
-    d->load(url, networkToken, "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, isInitial, false);
+    d->load(url, networkToken, "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, isInitial, false, needReferer, forceDownload);
 }
 
 void WebPage::loadExtended(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 mustHandleInternally)
 {
-    d->load(url, networkToken, method, cachePolicy, data, dataLength, headers, headersLength, false, mustHandleInternally, false, "");
+    d->load(url, networkToken, method, cachePolicy, data, dataLength, headers, headersLength, false, mustHandleInternally, false, false, "");
 }
 
 void WebPage::loadFile(const BlackBerry::Platform::String& path, const BlackBerry::Platform::String& overrideContentType)
@@ -729,7 +731,7 @@
     else if (!fileUrl.startsWith("file:///"))
         return;
 
-    d->load(fileUrl, BlackBerry::Platform::String::emptyString(), BlackBerry::Platform::String("GET", 3), Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, false, false, false, overrideContentType.c_str());
+    d->load(fileUrl, BlackBerry::Platform::String::emptyString(), BlackBerry::Platform::String("GET", 3), Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, 0, 0, false, false, false, false, overrideContentType.c_str());
 }
 
 void WebPage::download(const Platform::NetworkRequest& request)
@@ -740,7 +742,7 @@
         headers.push_back(list[i].first.c_str());
         headers.push_back(list[i].second.c_str());
     }
-    d->load(request.getUrlRef(), BlackBerry::Platform::String::emptyString(), "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, headers.empty() ? 0 : &headers[0], headers.size(), false, false, true, "", request.getSuggestedSaveName().c_str());
+    d->load(request.getUrlRef(), BlackBerry::Platform::String::emptyString(), "GET", Platform::NetworkRequest::UseProtocolCachePolicy, 0, 0, headers.empty() ? 0 : &headers[0], headers.size(), false, false, false, true, "", request.getSuggestedSaveName().c_str());
 }
 
 void WebPagePrivate::loadString(const BlackBerry::Platform::String& string, const BlackBerry::Platform::String& baseURL, const BlackBerry::Platform::String& contentType, const BlackBerry::Platform::String& failingURL)

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.h (146844 => 146845)


--- trunk/Source/WebKit/blackberry/Api/WebPage.h	2013-03-26 03:11:09 UTC (rev 146844)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.h	2013-03-26 03:13:02 UTC (rev 146845)
@@ -93,7 +93,7 @@
 
     WebPageClient* client() const;
 
-    void load(const BlackBerry::Platform::String& url, const BlackBerry::Platform::String& networkToken, bool isInitial = false);
+    void load(const BlackBerry::Platform::String& url, const BlackBerry::Platform::String& networkToken, bool isInitial = false, bool needReferer = false, bool forceDownload = false);
 
     void loadExtended(const char* url, const char* networkToken, const char* method, Platform::NetworkRequest::CachePolicy = Platform::NetworkRequest::UseProtocolCachePolicy, const char* data = "" size_t dataLength = 0, const char* const* headers = 0, size_t headersLength = 0, bool mustHandleInternally = false);
 

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (146844 => 146845)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2013-03-26 03:11:09 UTC (rev 146844)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2013-03-26 03:13:02 UTC (rev 146845)
@@ -114,7 +114,7 @@
     bool handleMouseEvent(WebCore::PlatformMouseEvent&);
     bool handleWheelEvent(WebCore::PlatformWheelEvent&);
 
-    void load(const BlackBerry::Platform::String& url, const BlackBerry::Platform::String& networkToken, const BlackBerry::Platform::String& 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 BlackBerry::Platform::String& overrideContentType = BlackBerry::Platform::String::emptyString(), const BlackBerry::Platform::String& suggestedSaveName = BlackBerry::Platform::String::emptyString());
+    void load(const BlackBerry::Platform::String& url, const BlackBerry::Platform::String& networkToken, const BlackBerry::Platform::String& method, Platform::NetworkRequest::CachePolicy, const char* data, size_t dataLength, const char* const* headers, size_t headersLength, bool isInitial, bool mustHandleInternally = false, bool needReferer = false, bool forceDownload = false, const BlackBerry::Platform::String& overrideContentType = BlackBerry::Platform::String::emptyString(), const BlackBerry::Platform::String& suggestedSaveName = BlackBerry::Platform::String::emptyString());
     void loadString(const BlackBerry::Platform::String&, const BlackBerry::Platform::String& baseURL, const BlackBerry::Platform::String& mimeType, const BlackBerry::Platform::String& failingURL);
     bool executeJavaScript(const BlackBerry::Platform::String& script, _javascript_DataType& returnType, BlackBerry::Platform::String& returnValue);
     bool executeJavaScriptInIsolatedWorld(const WebCore::ScriptSourceCode&, _javascript_DataType& returnType, BlackBerry::Platform::String& returnValue);

Modified: trunk/Source/WebKit/blackberry/ChangeLog (146844 => 146845)


--- trunk/Source/WebKit/blackberry/ChangeLog	2013-03-26 03:11:09 UTC (rev 146844)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2013-03-26 03:13:02 UTC (rev 146845)
@@ -1,3 +1,24 @@
+2013-03-25  Mary Wu  <mary...@torchmobile.com.cn>
+
+        [BlackBerry] add needReferer in WebPage load() api
+        https://bugs.webkit.org/show_bug.cgi?id=113167
+
+        Reviewed by Rob Buis.
+
+        PR310175, internally reviewed by Joe Mason.
+        Sometimes when client load request, it need to add referer with current frame like
+        save link/image in option menu, so we add needRef in load() interface in webpage.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::load):
+        (BlackBerry::WebKit::WebPage::load):
+        (BlackBerry::WebKit::WebPage::loadExtended):
+        (BlackBerry::WebKit::WebPage::loadFile):
+        (BlackBerry::WebKit::WebPage::download):
+        * Api/WebPage.h:
+        * Api/WebPage_p.h:
+        (WebPagePrivate):
+
 2013-03-22  Nima Ghanavatian  <nghanavat...@blackberry.com>
 
         [BlackBerry] Build fix in InputHandler
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to