Title: [87597] trunk
Revision
87597
Author
[email protected]
Date
2011-05-27 20:27:16 -0700 (Fri, 27 May 2011)

Log Message

2011-05-27  Jochen Eisinger  <[email protected]>

        Reviewed by Adam Barth.

        Check access policy on all storage operations
        https://bugs.webkit.org/show_bug.cgi?id=61581

        * platform/chromium/permissionclient/storage-permission-expected.txt: Added.
        * platform/chromium/permissionclient/storage-permission.html: Added.
2011-05-27  Jochen Eisinger  <[email protected]>

        Reviewed by Adam Barth.

        Add Frame parameter to all StorageArea methods. The chromium
        embedder uses the Frame as context to decide whether or not
        to allow usage of the storage API.
        https://bugs.webkit.org/show_bug.cgi?id=61581

        Test: platform/chromium/permissionclient/storage-permission.html

        * storage/Storage.cpp:
        (WebCore::Storage::length):
        (WebCore::Storage::key):
        (WebCore::Storage::getItem):
        (WebCore::Storage::contains):
        * storage/StorageArea.h:
        * storage/StorageAreaImpl.cpp:
        (WebCore::StorageAreaImpl::length):
        (WebCore::StorageAreaImpl::key):
        (WebCore::StorageAreaImpl::getItem):
        (WebCore::StorageAreaImpl::contains):
        * storage/StorageAreaImpl.h:
2011-05-27  Jochen Eisinger  <[email protected]>

        Reviewed by Adam Barth.

        Check access policy on all storage operations
        https://bugs.webkit.org/show_bug.cgi?id=61581

        * src/StorageAreaProxy.cpp:
        (WebCore::StorageAreaProxy::length):
        (WebCore::StorageAreaProxy::key):
        (WebCore::StorageAreaProxy::getItem):
        (WebCore::StorageAreaProxy::setItem):
        (WebCore::StorageAreaProxy::removeItem):
        (WebCore::StorageAreaProxy::clear):
        (WebCore::StorageAreaProxy::contains):
        (WebCore::StorageAreaProxy::canAccessStorage):
        * src/StorageAreaProxy.h:
        * src/WebStorageAreaImpl.cpp:
        (WebKit::WebStorageAreaImpl::length):
        (WebKit::WebStorageAreaImpl::key):
        (WebKit::WebStorageAreaImpl::getItem):
2011-05-27  Jochen Eisinger  <[email protected]>

        Reviewed by Adam Barth.

        Add layoutTestController.setStorageAllowed() to control whether access
        to the localStorage API is enabled via the WebPermissionClient
        https://bugs.webkit.org/show_bug.cgi?id=61581

        * DumpRenderTree/chromium/LayoutTestController.cpp:
        (LayoutTestController::LayoutTestController):
        (LayoutTestController::setStorageAllowed):
        * DumpRenderTree/chromium/LayoutTestController.h:
        * DumpRenderTree/chromium/TestShell.cpp:
        (TestShell::TestShell):
        (TestShell::createNewWindow):
        * DumpRenderTree/chromium/TestShell.h:
        * DumpRenderTree/chromium/WebPermissions.h: Added.
        (WebPermissions::WebPermissions):
        (WebPermissions::allowStorage):
        (WebPermissions::setStorageAllowed):
        (WebPermissions::reset):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (87596 => 87597)


--- trunk/LayoutTests/ChangeLog	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/LayoutTests/ChangeLog	2011-05-28 03:27:16 UTC (rev 87597)
@@ -1,3 +1,13 @@
+2011-05-27  Jochen Eisinger  <[email protected]>
+
+        Reviewed by Adam Barth.
+
+        Check access policy on all storage operations
+        https://bugs.webkit.org/show_bug.cgi?id=61581
+
+        * platform/chromium/permissionclient/storage-permission-expected.txt: Added.
+        * platform/chromium/permissionclient/storage-permission.html: Added.
+
 2011-05-27  Adam Klein  <[email protected]>
 
         Unreviewed. Hopefully last rebaseline from r87526.

Added: trunk/LayoutTests/platform/chromium/permissionclient/storage-permission-expected.txt (0 => 87597)


--- trunk/LayoutTests/platform/chromium/permissionclient/storage-permission-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/permissionclient/storage-permission-expected.txt	2011-05-28 03:27:16 UTC (rev 87597)
@@ -0,0 +1,16 @@
+This test verifies that all access to localStorage can be blocked
+Length is 0
+Value for FOO is null
+Length is 1
+Value for FOO is BAR
+Key for index 0 is FOO
+Disabling localStorage access.
+Length is 0
+Value for FOO is null
+Caught exception trying to change item: Error: QUOTA_EXCEEDED_ERR: DOM Exception 22
+Length is 0
+Value for FOO is null
+Key for index 0 is null
+Length is 0
+Value for FOO is null
+

Added: trunk/LayoutTests/platform/chromium/permissionclient/storage-permission.html (0 => 87597)


--- trunk/LayoutTests/platform/chromium/permissionclient/storage-permission.html	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/permissionclient/storage-permission.html	2011-05-28 03:27:16 UTC (rev 87597)
@@ -0,0 +1,64 @@
+<html>
+<head>
+<script src=""
+<script>
+
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function log(a)
+{
+    document.getElementById("logger").innerHTML += a + "<br>";
+}
+
+function runTest()
+{
+    if (!window.localStorage) {
+        log("window.localStorage DOES NOT exist");
+        return;
+    }
+
+    if (window.layoutTestController && layoutTestController.setStorageAllowed)
+        layoutTestController.setStorageAllowed(true);
+    else
+        log("This test requires layoutTestController.setStorageAllowed, so it be can't run in a browser.");
+    
+    log("Length is " + localStorage.length);
+    log("Value for FOO is " + localStorage.getItem("FOO"));
+
+    localStorage.setItem("FOO", "BAR");
+    
+    log("Length is " + localStorage.length);
+    log("Value for FOO is " + localStorage.getItem("FOO"));
+    log("Key for index 0 is " + localStorage.key(0));
+    
+    log("Disabling localStorage access.");
+    if (window.layoutTestController && layoutTestController.setStorageAllowed)
+        layoutTestController.setStorageAllowed(false);
+
+    log("Length is " + localStorage.length);
+    log("Value for FOO is " + localStorage.getItem("FOO"));
+
+    try {
+        localStorage.setItem("FOO", "BAZ");
+    } catch(e) {
+        log("Caught exception trying to change item: " + e);
+    }
+    
+    log("Length is " + localStorage.length);
+    log("Value for FOO is " + localStorage.getItem("FOO"));
+    log("Key for index 0 is " + localStorage.key(0));
+    
+    localStorage.removeItem("FOO");
+    
+    log("Length is " + localStorage.length);
+    log("Value for FOO is " + localStorage.getItem("FOO"));
+}
+
+</script>
+</head>
+<body _onload_="runTest();">
+This test verifies that all access to localStorage can be blocked<br>
+<div id="logger"></div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (87596 => 87597)


--- trunk/Source/WebCore/ChangeLog	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Source/WebCore/ChangeLog	2011-05-28 03:27:16 UTC (rev 87597)
@@ -1,3 +1,27 @@
+2011-05-27  Jochen Eisinger  <[email protected]>
+
+        Reviewed by Adam Barth.
+
+        Add Frame parameter to all StorageArea methods. The chromium
+        embedder uses the Frame as context to decide whether or not
+        to allow usage of the storage API.
+        https://bugs.webkit.org/show_bug.cgi?id=61581
+
+        Test: platform/chromium/permissionclient/storage-permission.html
+
+        * storage/Storage.cpp:
+        (WebCore::Storage::length):
+        (WebCore::Storage::key):
+        (WebCore::Storage::getItem):
+        (WebCore::Storage::contains):
+        * storage/StorageArea.h:
+        * storage/StorageAreaImpl.cpp:
+        (WebCore::StorageAreaImpl::length):
+        (WebCore::StorageAreaImpl::key):
+        (WebCore::StorageAreaImpl::getItem):
+        (WebCore::StorageAreaImpl::contains):
+        * storage/StorageAreaImpl.h:
+
 2011-05-27  Nate Chapin  <[email protected]>
 
         Reviewed by Jian Li.

Modified: trunk/Source/WebCore/storage/Storage.cpp (87596 => 87597)


--- trunk/Source/WebCore/storage/Storage.cpp	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Source/WebCore/storage/Storage.cpp	2011-05-28 03:27:16 UTC (rev 87597)
@@ -59,7 +59,7 @@
     if (!m_frame || !m_frame->page() || m_frame->page()->settings()->privateBrowsingEnabled())
         return 0;
 
-    return m_storageArea->length();
+    return m_storageArea->length(m_frame);
 }
 
 String Storage::key(unsigned index) const
@@ -67,7 +67,7 @@
     if (!m_frame || !m_frame->page() || m_frame->page()->settings()->privateBrowsingEnabled())
         return String();
 
-    return m_storageArea->key(index);
+    return m_storageArea->key(index, m_frame);
 }
 
 String Storage::getItem(const String& key) const
@@ -75,7 +75,7 @@
     if (!m_frame || !m_frame->page() || m_frame->page()->settings()->privateBrowsingEnabled())
         return String();
 
-    return m_storageArea->getItem(key);
+    return m_storageArea->getItem(key, m_frame);
 }
 
 void Storage::setItem(const String& key, const String& value, ExceptionCode& ec)
@@ -108,7 +108,7 @@
     if (!m_frame || !m_frame->page() || m_frame->page()->settings()->privateBrowsingEnabled())
         return false;
 
-    return m_storageArea->contains(key);
+    return m_storageArea->contains(key, m_frame);
 }
 
 }

Modified: trunk/Source/WebCore/storage/StorageArea.h (87596 => 87597)


--- trunk/Source/WebCore/storage/StorageArea.h	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Source/WebCore/storage/StorageArea.h	2011-05-28 03:27:16 UTC (rev 87597)
@@ -47,13 +47,14 @@
         virtual ~StorageArea() { }
 
         // The HTML5 DOM Storage API
-        virtual unsigned length() const = 0;
-        virtual String key(unsigned index) const = 0;
-        virtual String getItem(const String& key) const = 0;
+        // FIXME: We should pass Document instead of Frame. Also, that parameter should go first.
+        virtual unsigned length(Frame* sourceFrame) const = 0;
+        virtual String key(unsigned index, Frame* sourceFrame) const = 0;
+        virtual String getItem(const String& key, Frame* sourceFrame) const = 0;
         virtual String setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame) = 0;
         virtual String removeItem(const String& key, Frame* sourceFrame) = 0;
         virtual bool clear(Frame* sourceFrame) = 0;
-        virtual bool contains(const String& key) const = 0;
+        virtual bool contains(const String& key, Frame* sourceFrame) const = 0;
     };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/storage/StorageAreaImpl.cpp (87596 => 87597)


--- trunk/Source/WebCore/storage/StorageAreaImpl.cpp	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Source/WebCore/storage/StorageAreaImpl.cpp	2011-05-28 03:27:16 UTC (rev 87597)
@@ -107,7 +107,7 @@
 #endif
 }
 
-unsigned StorageAreaImpl::length() const
+unsigned StorageAreaImpl::length(Frame*) const
 {
     ASSERT(!m_isShutdown);
     blockUntilImportComplete();
@@ -115,7 +115,7 @@
     return m_storageMap->length();
 }
 
-String StorageAreaImpl::key(unsigned index) const
+String StorageAreaImpl::key(unsigned index, Frame*) const
 {
     ASSERT(!m_isShutdown);
     blockUntilImportComplete();
@@ -123,7 +123,7 @@
     return m_storageMap->key(index);
 }
 
-String StorageAreaImpl::getItem(const String& key) const
+String StorageAreaImpl::getItem(const String& key, Frame*) const
 {
     ASSERT(!m_isShutdown);
     blockUntilImportComplete();
@@ -204,7 +204,7 @@
     return true;
 }
 
-bool StorageAreaImpl::contains(const String& key) const
+bool StorageAreaImpl::contains(const String& key, Frame*) const
 {
     ASSERT(!m_isShutdown);
     blockUntilImportComplete();

Modified: trunk/Source/WebCore/storage/StorageAreaImpl.h (87596 => 87597)


--- trunk/Source/WebCore/storage/StorageAreaImpl.h	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Source/WebCore/storage/StorageAreaImpl.h	2011-05-28 03:27:16 UTC (rev 87597)
@@ -45,13 +45,13 @@
         virtual ~StorageAreaImpl();
 
         // The HTML5 DOM Storage API (and contains)
-        virtual unsigned length() const;
-        virtual String key(unsigned index) const;
-        virtual String getItem(const String& key) const;
+        virtual unsigned length(Frame* sourceFrame) const;
+        virtual String key(unsigned index, Frame* sourceFrame) const;
+        virtual String getItem(const String& key, Frame* sourceFrame) const;
         virtual String setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame);
         virtual String removeItem(const String& key, Frame* sourceFrame);
         virtual bool clear(Frame* sourceFrame);
-        virtual bool contains(const String& key) const;
+        virtual bool contains(const String& key, Frame* sourceFrame) const;
 
         PassRefPtr<StorageAreaImpl> copy();
         void close();

Modified: trunk/Source/WebKit/chromium/ChangeLog (87596 => 87597)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-05-28 03:27:16 UTC (rev 87597)
@@ -1,5 +1,27 @@
 2011-05-27  Jochen Eisinger  <[email protected]>
 
+        Reviewed by Adam Barth.
+
+        Check access policy on all storage operations
+        https://bugs.webkit.org/show_bug.cgi?id=61581
+
+        * src/StorageAreaProxy.cpp:
+        (WebCore::StorageAreaProxy::length):
+        (WebCore::StorageAreaProxy::key):
+        (WebCore::StorageAreaProxy::getItem):
+        (WebCore::StorageAreaProxy::setItem):
+        (WebCore::StorageAreaProxy::removeItem):
+        (WebCore::StorageAreaProxy::clear):
+        (WebCore::StorageAreaProxy::contains):
+        (WebCore::StorageAreaProxy::canAccessStorage):
+        * src/StorageAreaProxy.h:
+        * src/WebStorageAreaImpl.cpp:
+        (WebKit::WebStorageAreaImpl::length):
+        (WebKit::WebStorageAreaImpl::key):
+        (WebKit::WebStorageAreaImpl::getItem):
+
+2011-05-27  Jochen Eisinger  <[email protected]>
+
         Reviewed by Darin Fisher.
 
         [chromium] drop unused WebFrame parameter to WebStorageArea::setItem

Modified: trunk/Source/WebKit/chromium/src/StorageAreaProxy.cpp (87596 => 87597)


--- trunk/Source/WebKit/chromium/src/StorageAreaProxy.cpp	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Source/WebKit/chromium/src/StorageAreaProxy.cpp	2011-05-28 03:27:16 UTC (rev 87597)
@@ -63,28 +63,32 @@
 {
 }
 
-unsigned StorageAreaProxy::length() const
+unsigned StorageAreaProxy::length(Frame* frame) const
 {
-    return m_storageArea->length();
+    if (canAccessStorage(frame))
+        return m_storageArea->length();
+    return 0;
 }
 
-String StorageAreaProxy::key(unsigned index) const
+String StorageAreaProxy::key(unsigned index, Frame* frame) const
 {
-    return m_storageArea->key(index);
+    if (canAccessStorage(frame))
+        return m_storageArea->key(index);
+    return String();
 }
 
-String StorageAreaProxy::getItem(const String& key) const
+String StorageAreaProxy::getItem(const String& key, Frame* frame) const
 {
-    return m_storageArea->getItem(key);
+    if (canAccessStorage(frame))
+        return m_storageArea->getItem(key);
+    return String();
 }
 
 String StorageAreaProxy::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame)
 {
     WebKit::WebStorageArea::Result result = WebKit::WebStorageArea::ResultOK;
     WebKit::WebString oldValue;
-    WebKit::WebFrameImpl* webFrame = WebKit::WebFrameImpl::fromFrame(frame);
-    WebKit::WebViewImpl* webView = webFrame->viewImpl();
-    if (webView->permissionClient() && !webView->permissionClient()->allowStorage(webFrame, m_storageType == LocalStorage))
+    if (!canAccessStorage(frame))
         ec = QUOTA_EXCEEDED_ERR;
     else {
         m_storageArea->setItem(key, value, frame->document()->url(), result, oldValue);
@@ -98,6 +102,8 @@
 
 String StorageAreaProxy::removeItem(const String& key, Frame* frame)
 {
+    if (!canAccessStorage(frame))
+        return String();
     WebKit::WebString oldValue;
     m_storageArea->removeItem(key, frame->document()->url(), oldValue);
     if (!oldValue.isNull())
@@ -107,6 +113,8 @@
 
 bool StorageAreaProxy::clear(Frame* frame)
 {
+    if (!canAccessStorage(frame))
+        return false;
     bool clearedSomething;
     m_storageArea->clear(frame->document()->url(), clearedSomething);
     if (clearedSomething)
@@ -114,9 +122,9 @@
     return clearedSomething;
 }
 
-bool StorageAreaProxy::contains(const String& key) const
+bool StorageAreaProxy::contains(const String& key, Frame* frame) const
 {
-    return !getItem(key).isNull();
+    return !getItem(key, frame).isNull();
 }
 
 // Copied from WebCore/storage/StorageEventDispatcher.cpp out of necessity.  It's probably best to keep it current.
@@ -162,6 +170,13 @@
     }
 }
 
+bool StorageAreaProxy::canAccessStorage(Frame* frame) const
+{
+    WebKit::WebFrameImpl* webFrame = WebKit::WebFrameImpl::fromFrame(frame);
+    WebKit::WebViewImpl* webView = webFrame->viewImpl();
+    return !webView->permissionClient() || webView->permissionClient()->allowStorage(webFrame, m_storageType == LocalStorage);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(DOM_STORAGE)

Modified: trunk/Source/WebKit/chromium/src/StorageAreaProxy.h (87596 => 87597)


--- trunk/Source/WebKit/chromium/src/StorageAreaProxy.h	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Source/WebKit/chromium/src/StorageAreaProxy.h	2011-05-28 03:27:16 UTC (rev 87597)
@@ -43,16 +43,17 @@
     virtual ~StorageAreaProxy();
 
     // The HTML5 DOM Storage API
-    virtual unsigned length() const;
-    virtual String key(unsigned index) const;
-    virtual String getItem(const String& key) const;
+    virtual unsigned length(Frame* sourceFrame) const;
+    virtual String key(unsigned index, Frame* sourceFrame) const;
+    virtual String getItem(const String& key, Frame* sourceFrame) const;
     virtual String setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame);
     virtual String removeItem(const String& key, Frame* sourceFrame);
     virtual bool clear(Frame* sourceFrame);
-    virtual bool contains(const String& key) const;
+    virtual bool contains(const String& key, Frame* sourceFrame) const;
 
 private:
     void storageEvent(const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*, Frame* sourceFrame);
+    bool canAccessStorage(Frame*) const;
 
     OwnPtr<WebKit::WebStorageArea> m_storageArea;
     StorageType m_storageType;

Modified: trunk/Source/WebKit/chromium/src/WebStorageAreaImpl.cpp (87596 => 87597)


--- trunk/Source/WebKit/chromium/src/WebStorageAreaImpl.cpp	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Source/WebKit/chromium/src/WebStorageAreaImpl.cpp	2011-05-28 03:27:16 UTC (rev 87597)
@@ -53,17 +53,17 @@
 
 unsigned WebStorageAreaImpl::length()
 {
-    return m_storageArea->length();
+    return m_storageArea->length(0);
 }
 
 WebString WebStorageAreaImpl::key(unsigned index)
 {
-    return m_storageArea->key(index);
+    return m_storageArea->key(index, 0);
 }
 
 WebString WebStorageAreaImpl::getItem(const WebString& key)
 {
-    return m_storageArea->getItem(key);
+    return m_storageArea->getItem(key, 0);
 }
 
 void WebStorageAreaImpl::setItem(const WebString& key, const WebString& value, const WebURL& url, Result& result, WebString& oldValue)

Modified: trunk/Tools/ChangeLog (87596 => 87597)


--- trunk/Tools/ChangeLog	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Tools/ChangeLog	2011-05-28 03:27:16 UTC (rev 87597)
@@ -1,3 +1,25 @@
+2011-05-27  Jochen Eisinger  <[email protected]>
+
+        Reviewed by Adam Barth.
+
+        Add layoutTestController.setStorageAllowed() to control whether access
+        to the localStorage API is enabled via the WebPermissionClient
+        https://bugs.webkit.org/show_bug.cgi?id=61581
+
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        (LayoutTestController::setStorageAllowed):
+        * DumpRenderTree/chromium/LayoutTestController.h:
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::TestShell):
+        (TestShell::createNewWindow):
+        * DumpRenderTree/chromium/TestShell.h:
+        * DumpRenderTree/chromium/WebPermissions.h: Added.
+        (WebPermissions::WebPermissions):
+        (WebPermissions::allowStorage):
+        (WebPermissions::setStorageAllowed):
+        (WebPermissions::reset):
+
 2011-05-27  Dirk Pranke  <[email protected]>
 
         Reviewed by Eric Seidel.

Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp (87596 => 87597)


--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2011-05-28 03:27:16 UTC (rev 87597)
@@ -47,6 +47,7 @@
 #include "WebInputElement.h"
 #include "WebKit.h"
 #include "WebNotificationPresenter.h"
+#include "WebPermissions.h"
 #include "WebScriptSource.h"
 #include "WebSecurityPolicy.h"
 #include "WebSettings.h"
@@ -214,6 +215,7 @@
     bindMethod("deleteLocalStorageForOrigin", &LayoutTestController::deleteLocalStorageForOrigin);
     bindMethod("observeStorageTrackerNotifications", &LayoutTestController::observeStorageTrackerNotifications);
     bindMethod("syncLocalStorage", &LayoutTestController::syncLocalStorage);
+    bindMethod("setStorageAllowed", &LayoutTestController::setStorageAllowed);
     
     // The fallback method is called when an unknown method is invoked.
     bindFallbackMethod(&LayoutTestController::fallbackMethod);
@@ -1820,6 +1822,13 @@
     // Not Implemented
 }
 
+void LayoutTestController::setStorageAllowed(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() > 0 && arguments[0].isBool())
+        m_shell->webPermissions()->setStorageAllowed(arguments[0].toBoolean());
+    result->setNull();
+}
+
 void LayoutTestController::setPluginsEnabled(const CppArgumentList& arguments, CppVariant* result)
 {
     if (arguments.size() > 0 && arguments[0].isBool()) {

Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h (87596 => 87597)


--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h	2011-05-28 03:27:16 UTC (rev 87597)
@@ -369,6 +369,7 @@
     void localStorageDiskUsageForOrigin(const CppArgumentList&, CppVariant*);
     void observeStorageTrackerNotifications(const CppArgumentList&, CppVariant*);
     void syncLocalStorage(const CppArgumentList&, CppVariant*);
+    void setStorageAllowed(const CppArgumentList&, CppVariant*);
 
     // Enable or disable plugins.
     void setPluginsEnabled(const CppArgumentList&, CppVariant*);

Modified: trunk/Tools/DumpRenderTree/chromium/TestShell.cpp (87596 => 87597)


--- trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2011-05-28 03:27:16 UTC (rev 87597)
@@ -40,6 +40,7 @@
 #include "WebFrame.h"
 #include "WebHistoryItem.h"
 #include "WebKit.h"
+#include "WebPermissions.h"
 #include "WebRuntimeFeatures.h"
 #include "WebScriptController.h"
 #include "WebSettings.h"
@@ -113,6 +114,7 @@
     WebRuntimeFeatures::enableIndexedDatabase(true);
     WebRuntimeFeatures::enableFileSystem(true);
     WebRuntimeFeatures::enableJavaScriptI18NAPI(true);
+    m_webPermissions = adoptPtr(new WebPermissions());
     m_accessibilityController = adoptPtr(new AccessibilityController(this));
     m_layoutTestController = adoptPtr(new LayoutTestController(this));
     m_eventSender = adoptPtr(new EventSender(this));
@@ -242,6 +244,7 @@
 void TestShell::resetTestController()
 {
     resetWebSettings(*webView());
+    m_webPermissions->reset();
     m_accessibilityController->reset();
     m_layoutTestController->reset();
     m_eventSender->reset();
@@ -596,6 +599,7 @@
 {
     WebViewHost* host = new WebViewHost(this);
     WebView* view = WebView::create(host);
+    view->setPermissionClient(webPermissions());
     view->setDevToolsAgentClient(devToolsAgent);
     host->setWebWidget(view);
     m_prefs.applyTo(view);

Modified: trunk/Tools/DumpRenderTree/chromium/TestShell.h (87596 => 87597)


--- trunk/Tools/DumpRenderTree/chromium/TestShell.h	2011-05-28 02:28:00 UTC (rev 87596)
+++ trunk/Tools/DumpRenderTree/chromium/TestShell.h	2011-05-28 03:27:16 UTC (rev 87597)
@@ -58,6 +58,7 @@
 class DRTDevToolsAgent;
 class DRTDevToolsCallArgs;
 class DRTDevToolsClient;
+class WebPermissions;
 
 struct TestParams {
     bool dumpTree;
@@ -96,6 +97,8 @@
     WebPreferences* preferences() { return &m_prefs; }
     void applyPreferences() { m_prefs.applyTo(m_webView); }
 
+    WebPermissions* webPermissions() { return m_webPermissions.get(); }
+
     void bindJSObjectsToWindow(WebKit::WebFrame*);
     void runFileTest(const TestParams&);
     void callJSGC();
@@ -191,6 +194,7 @@
     bool m_testShellMode;
     WebViewHost* m_webViewHost;
     WebViewHost* m_devTools;
+    OwnPtr<WebPermissions> m_webPermissions;
     OwnPtr<DRTDevToolsAgent> m_drtDevToolsAgent;
     OwnPtr<DRTDevToolsClient> m_drtDevToolsClient;
     OwnPtr<AccessibilityController> m_accessibilityController;

Added: trunk/Tools/DumpRenderTree/chromium/WebPermissions.h (0 => 87597)


--- trunk/Tools/DumpRenderTree/chromium/WebPermissions.h	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/chromium/WebPermissions.h	2011-05-28 03:27:16 UTC (rev 87597)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebPermissions_h
+#define WebPermissions_h
+
+#include "WebPermissionClient.h"
+
+class WebPermissions : public WebKit::WebPermissionClient {
+public:
+    WebPermissions() : m_storageAllowed(true) { }
+
+    virtual bool allowStorage(WebKit::WebFrame*, bool local) { return m_storageAllowed; }
+
+    // Sets the policy whether to allow storage or not.
+    void setStorageAllowed(bool storageAllowed) { m_storageAllowed = storageAllowed; }
+
+    // Resets the policy to allow all access.
+    void reset() { m_storageAllowed = true; }
+
+private:
+    bool m_storageAllowed;
+};
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to