[BlackBerry] Upstream FrameLoaderClientBlackBerry::securityOriginForNewDocument()
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Aug 2012 22:07:46 +0000 (22:07 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Aug 2012 22:07:46 +0000 (22:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94139

Patch by Yong Li <yoli@rim.com> on 2012-08-15
Reviewed by Antonio Gomes.

Keep same security origin when a file URL automatically redirects to its child folder.
This patch will be reverted when we finish the better solution.
PR# 172333 and PR# 180590.

* WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
(WebCore::FrameLoaderClientBlackBerry::FrameLoaderClientBlackBerry):
(WebCore::FrameLoaderClientBlackBerry::dispatchDidStartProvisionalLoad):
(WebCore::FrameLoaderClientBlackBerry::securityOriginForNewDocument):
(WebCore):
* WebCoreSupport/FrameLoaderClientBlackBerry.h:
(FrameLoaderClientBlackBerry):

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

Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp
Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.h

index 6ba8913..f93db4f 100644 (file)
@@ -1,5 +1,24 @@
 2012-08-15  Yong Li  <yoli@rim.com>
 
+        [BlackBerry] Upstream FrameLoaderClientBlackBerry::securityOriginForNewDocument()
+        https://bugs.webkit.org/show_bug.cgi?id=94139
+
+        Reviewed by Antonio Gomes.
+
+        Keep same security origin when a file URL automatically redirects to its child folder.
+        This patch will be reverted when we finish the better solution.
+        PR# 172333 and PR# 180590.
+
+        * WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
+        (WebCore::FrameLoaderClientBlackBerry::FrameLoaderClientBlackBerry):
+        (WebCore::FrameLoaderClientBlackBerry::dispatchDidStartProvisionalLoad):
+        (WebCore::FrameLoaderClientBlackBerry::securityOriginForNewDocument):
+        (WebCore):
+        * WebCoreSupport/FrameLoaderClientBlackBerry.h:
+        (FrameLoaderClientBlackBerry):
+
+2012-08-15  Yong Li  <yoli@rim.com>
+
         [BlackBerry] Should not keep recreating GeoTracker in setEnableHighAccuracy()
         https://bugs.webkit.org/show_bug.cgi?id=94136
 
index a0312b0..7e422e6 100644 (file)
@@ -108,6 +108,7 @@ FrameLoaderClientBlackBerry::FrameLoaderClientBlackBerry()
     , m_pluginView(0)
     , m_hasSentResponseToPlugin(false)
     , m_cancelLoadOnNextData(false)
+    , m_wasProvisionalLoadTriggeredByUserGesture(true) // To avoid affecting the first load.
 {
 }
 
@@ -504,6 +505,8 @@ void FrameLoaderClientBlackBerry::dispatchDidStartProvisionalLoad()
 
     if (m_webPagePrivate->m_dumpRenderTree)
         m_webPagePrivate->m_dumpRenderTree->didStartProvisionalLoadForFrame(m_frame);
+
+    m_wasProvisionalLoadTriggeredByUserGesture = ScriptController::processingUserGesture();
 }
 
 void FrameLoaderClientBlackBerry::dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse& response)
@@ -1252,4 +1255,22 @@ void FrameLoaderClientBlackBerry::dispatchDidLoadFromApplicationCache(const Reso
     m_webPagePrivate->m_client->notifyDidLoadFromApplicationCache();
 }
 
+PassRefPtr<SecurityOrigin> FrameLoaderClientBlackBerry::securityOriginForNewDocument(const KURL& url)
+{
+    // What we are trying to do here is to keep using the old path as origin when a file-based html page
+    // changes its location to some html in a subfolder. This will allow some file-based html packages
+    // to work smoothly even with security checks enabled.
+
+    RefPtr<SecurityOrigin> newSecurityOrigin = SecurityOrigin::create(url);
+
+    if (m_wasProvisionalLoadTriggeredByUserGesture || !url.isLocalFile())
+        return newSecurityOrigin;
+
+    RefPtr<SecurityOrigin> currentSecurityOrigin = m_frame->document()->securityOrigin();
+    if (currentSecurityOrigin && currentSecurityOrigin->containsInFolder(newSecurityOrigin.get()))
+        return currentSecurityOrigin;
+
+    return newSecurityOrigin;
+}
+
 } // WebCore
index ba6b7e4..b969674 100644 (file)
@@ -170,6 +170,8 @@ public:
 
     virtual PassRefPtr<FrameNetworkingContext> createNetworkingContext();
 
+    virtual PassRefPtr<SecurityOrigin> securityOriginForNewDocument(const KURL&);
+
     void readyToRender(bool pageIsVisuallyNonEmpty);
 
     void doPendingFragmentScroll();
@@ -215,6 +217,8 @@ private:
 
     // Used to stop media files from loading because we don't need to have the entire file loaded by WebKit.
     bool m_cancelLoadOnNextData;
+
+    bool m_wasProvisionalLoadTriggeredByUserGesture;
 };
 
 } // WebCore