Title: [104227] branches/safari-534.54-branch/Source

Diff

Modified: branches/safari-534.54-branch/Source/WebCore/ChangeLog (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebCore/ChangeLog	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebCore/ChangeLog	2012-01-05 22:55:24 UTC (rev 104227)
@@ -1,5 +1,66 @@
 2011-1-5  Lucas Forschler  <[email protected]>
 
+    Merge 99439
+
+    2011-11-07  Jessie Berlin  <[email protected]>
+
+            Need a way to allow a scheme access to Local Storage and Databases while Private Browsing is
+            enabled.
+            https://bugs.webkit.org/show_bug.cgi?id=71631
+
+            Reviewed by Jon Honeycutt.
+
+            Check the SchemeRegistry before preventing read/write access to Local Storage and Databases
+            in Private Browsing.
+
+            * WebCore.exp.in:
+            Export the symbols for registering the schemes as allowing Local Storage and Database access
+            in Private Browsing.
+
+            * dom/Document.cpp:
+            (WebCore::Document::allowDatabaseAccess):
+            Check if the scheme allows Database access in Private Browsing.
+
+            * platform/SchemeRegistry.cpp:
+            (WebCore::schemesAllowingLocalStorageAccessInPrivateBrowsing):
+            (WebCore::schemesAllowingDatabaseAccessInPrivateBrowsing):
+            (WebCore::SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing):
+            (WebCore::SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing):
+            (WebCore::SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing):
+            (WebCore::SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing):
+            * platform/SchemeRegistry.h:
+
+            * storage/Storage.cpp:
+            (WebCore::Storage::length):
+            Ask the storage area if it is disabled by Private Browsing in the frame instead of just
+            checking if Private Browsing is enabled for that frame because the answer might depend on
+            what type of storage that storage area is.
+            (WebCore::Storage::key):
+            Ditto.
+            (WebCore::Storage::getItem):
+            Ditto.
+            (WebCore::Storage::contains):
+            Ditto.
+
+            * storage/StorageArea.h:
+            Make it possible to query a StorageArea for whether it is disabled by Private Browsing in a
+            Frame.
+            * storage/StorageAreaImpl.cpp:
+            (WebCore::StorageAreaImpl::disabledByPrivateBrowsingInFrame):
+            Renamed from privateBrowsingEnabled.
+            Check not only if Private Browsing is enabled for the Frame, but also if the storage type is
+            Local Storage and if there is an exception for the scheme of the resource currently loaded
+            into the Frame.
+            (WebCore::StorageAreaImpl::setItem):
+            Renamed privateBrowsingEnabled -> disabledByPrivateBrowsingInFrame.
+            (WebCore::StorageAreaImpl::removeItem):
+            Ditto.
+            (WebCore::StorageAreaImpl::clear):
+            Ditto.
+            * storage/StorageAreaImpl.h:
+
+2011-1-5  Lucas Forschler  <[email protected]>
+
     Merge 98796
 
     2011-10-28  Ryosuke Niwa  <[email protected]>

Modified: branches/safari-534.54-branch/Source/WebCore/WebCore.exp.in (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebCore/WebCore.exp.in	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebCore/WebCore.exp.in	2012-01-05 22:55:24 UTC (rev 104227)
@@ -368,6 +368,8 @@
 __ZN7WebCore14SchemeRegistry25registerURLSchemeAsSecureERKN3WTF6StringE
 __ZN7WebCore14SchemeRegistry32registerURLSchemeAsEmptyDocumentERKN3WTF6StringE
 __ZN7WebCore14SchemeRegistry34shouldLoadURLSchemeAsEmptyDocumentERKN3WTF6StringE
+__ZN7WebCore14SchemeRegistry62registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsingERKN3WTF6StringE
+__ZN7WebCore14SchemeRegistry58registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsingERKN3WTF6StringE
 __ZN7WebCore14ScrollableArea16handleWheelEventERNS_18PlatformWheelEventE
 __ZN7WebCore14ScrollableArea17willEndLiveResizeEv
 __ZN7WebCore14ScrollableArea19willStartLiveResizeEv

Modified: branches/safari-534.54-branch/Source/WebCore/dom/Document.cpp (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebCore/dom/Document.cpp	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebCore/dom/Document.cpp	2012-01-05 22:55:24 UTC (rev 104227)
@@ -124,6 +124,7 @@
 #include "RenderTextControl.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
+#include "SchemeRegistry.h"
 #include "ScopedEventQueue.h"
 #include "ScriptCallStack.h"
 #include "ScriptController.h"
@@ -4583,7 +4584,7 @@
 
 bool Document::allowDatabaseAccess() const
 {
-    if (!page() || page()->settings()->privateBrowsingEnabled())
+    if (!page() || (page()->settings()->privateBrowsingEnabled() && !SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing(securityOrigin()->protocol())))
         return false;
     return true;
 }

Modified: branches/safari-534.54-branch/Source/WebCore/platform/SchemeRegistry.cpp (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebCore/platform/SchemeRegistry.cpp	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebCore/platform/SchemeRegistry.cpp	2012-01-05 22:55:24 UTC (rev 104227)
@@ -125,6 +125,18 @@
     return localURLSchemes();
 }
 
+static URLSchemesMap& schemesAllowingLocalStorageAccessInPrivateBrowsing()
+{
+    DEFINE_STATIC_LOCAL(URLSchemesMap, schemesAllowingLocalStorageAccessInPrivateBrowsing, ());
+    return schemesAllowingLocalStorageAccessInPrivateBrowsing;
+}
+
+static URLSchemesMap& schemesAllowingDatabaseAccessInPrivateBrowsing()
+{
+    DEFINE_STATIC_LOCAL(URLSchemesMap, schemesAllowingDatabaseAccessInPrivateBrowsing, ());
+    return schemesAllowingDatabaseAccessInPrivateBrowsing;
+}
+
 bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme)
 {
     if (scheme.isEmpty())
@@ -192,4 +204,28 @@
     canDisplayOnlyIfCanRequestSchemes().add(scheme);
 }
 
+void SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing(const String& scheme)
+{
+    schemesAllowingLocalStorageAccessInPrivateBrowsing().add(scheme);
+}
+
+bool SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing(const String& scheme)
+{
+    if (scheme.isEmpty())
+        return false;
+    return schemesAllowingLocalStorageAccessInPrivateBrowsing().contains(scheme);
+}
+
+void SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing(const String& scheme)
+{
+    schemesAllowingDatabaseAccessInPrivateBrowsing().add(scheme);
+}
+
+bool SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing(const String& scheme)
+{
+    if (scheme.isEmpty())
+        return false;
+    return schemesAllowingDatabaseAccessInPrivateBrowsing().contains(scheme);
+}
+
 } // namespace WebCore

Modified: branches/safari-534.54-branch/Source/WebCore/platform/SchemeRegistry.h (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebCore/platform/SchemeRegistry.h	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebCore/platform/SchemeRegistry.h	2012-01-05 22:55:24 UTC (rev 104227)
@@ -63,6 +63,13 @@
     // passed to SecurityOrigin::canDisplay.
     static bool canDisplayOnlyIfCanRequest(const String& scheme);
     static void registerAsCanDisplayOnlyIfCanRequest(const String& scheme);
+
+    // Let some schemes opt-out of Private Browsing's default behavior of prohibiting read/write
+    // access to Local Storage and Databases.
+    static void registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing(const String& scheme);
+    static bool allowsLocalStorageAccessInPrivateBrowsing(const String& scheme);
+    static void registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing(const String& scheme);
+    static bool allowsDatabaseAccessInPrivateBrowsing(const String& scheme);
 };
 
 } // namespace WebCore

Modified: branches/safari-534.54-branch/Source/WebCore/storage/Storage.cpp (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebCore/storage/Storage.cpp	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebCore/storage/Storage.cpp	2012-01-05 22:55:24 UTC (rev 104227)
@@ -56,7 +56,7 @@
 
 unsigned Storage::length() const
 {
-    if (!m_frame || !m_frame->page() || m_frame->page()->settings()->privateBrowsingEnabled())
+    if (!m_frame || !m_frame->page() || m_storageArea->disabledByPrivateBrowsingInFrame(m_frame))
         return 0;
 
     return m_storageArea->length();
@@ -64,7 +64,7 @@
 
 String Storage::key(unsigned index) const
 {
-    if (!m_frame || !m_frame->page() || m_frame->page()->settings()->privateBrowsingEnabled())
+    if (!m_frame || !m_frame->page() || m_storageArea->disabledByPrivateBrowsingInFrame(m_frame))
         return String();
 
     return m_storageArea->key(index);
@@ -72,7 +72,7 @@
 
 String Storage::getItem(const String& key) const
 {
-    if (!m_frame || !m_frame->page() || m_frame->page()->settings()->privateBrowsingEnabled())
+    if (!m_frame || !m_frame->page() || m_storageArea->disabledByPrivateBrowsingInFrame(m_frame))
         return String();
 
     return m_storageArea->getItem(key);
@@ -105,7 +105,7 @@
 
 bool Storage::contains(const String& key) const
 {
-    if (!m_frame || !m_frame->page() || m_frame->page()->settings()->privateBrowsingEnabled())
+    if (!m_frame || !m_frame->page() || m_storageArea->disabledByPrivateBrowsingInFrame(m_frame))
         return false;
 
     return m_storageArea->contains(key);

Modified: branches/safari-534.54-branch/Source/WebCore/storage/StorageArea.h (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebCore/storage/StorageArea.h	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebCore/storage/StorageArea.h	2012-01-05 22:55:24 UTC (rev 104227)
@@ -54,6 +54,8 @@
         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 disabledByPrivateBrowsingInFrame(const Frame* sourceFrame) const = 0;
     };
 
 } // namespace WebCore

Modified: branches/safari-534.54-branch/Source/WebCore/storage/StorageAreaImpl.cpp (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebCore/storage/StorageAreaImpl.cpp	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebCore/storage/StorageAreaImpl.cpp	2012-01-05 22:55:24 UTC (rev 104227)
@@ -31,6 +31,7 @@
 #include "ExceptionCode.h"
 #include "Frame.h"
 #include "Page.h"
+#include "SchemeRegistry.h"
 #include "SecurityOrigin.h"
 #include "Settings.h"
 #include "StorageAreaSync.h"
@@ -94,7 +95,7 @@
     ASSERT(!m_isShutdown);
 }
 
-static bool privateBrowsingEnabled(Frame* frame)
+bool StorageAreaImpl::disabledByPrivateBrowsingInFrame(const Frame* frame) const
 {
 #if PLATFORM(CHROMIUM)
     // The frame pointer can be NULL in Chromium since this call is made in a different
@@ -103,7 +104,11 @@
     ASSERT(!frame);
     return false;
 #else
-    return frame->page()->settings()->privateBrowsingEnabled();
+    if (!frame->page() || !frame->page()->settings()->privateBrowsingEnabled())
+        return false;
+    if (m_storageType != LocalStorage)
+        return true;
+    return !SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing(frame->document()->securityOrigin()->protocol());
 #endif
 }
 
@@ -137,7 +142,7 @@
     ASSERT(!value.isNull());
     blockUntilImportComplete();
 
-    if (privateBrowsingEnabled(frame)) {
+    if (disabledByPrivateBrowsingInFrame(frame)) {
         ec = QUOTA_EXCEEDED_ERR;
         return String();
     }
@@ -167,7 +172,7 @@
     ASSERT(!m_isShutdown);
     blockUntilImportComplete();
 
-    if (privateBrowsingEnabled(frame))
+    if (disabledByPrivateBrowsingInFrame(frame))
         return String();
 
     String oldValue;
@@ -189,7 +194,7 @@
     ASSERT(!m_isShutdown);
     blockUntilImportComplete();
 
-    if (privateBrowsingEnabled(frame))
+    if (disabledByPrivateBrowsingInFrame(frame))
         return false;
 
     if (!m_storageMap->length())

Modified: branches/safari-534.54-branch/Source/WebCore/storage/StorageAreaImpl.h (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebCore/storage/StorageAreaImpl.h	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebCore/storage/StorageAreaImpl.h	2012-01-05 22:55:24 UTC (rev 104227)
@@ -53,6 +53,8 @@
         virtual bool clear(Frame* sourceFrame);
         virtual bool contains(const String& key) const;
 
+        virtual bool disabledByPrivateBrowsingInFrame(const Frame* sourceFrame) const;
+
         PassRefPtr<StorageAreaImpl> copy();
         void close();
 

Modified: branches/safari-534.54-branch/Source/WebKit/chromium/ChangeLog (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebKit/chromium/ChangeLog	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebKit/chromium/ChangeLog	2012-01-05 22:55:24 UTC (rev 104227)
@@ -1,3 +1,19 @@
+2011-1-5  Lucas Forschler  <[email protected]>
+
+    Merge 99439
+
+    2011-11-07  Jessie Berlin  <[email protected]>
+
+            Need a way to allow a scheme access to Local Storage and Databases while Private Browsing is
+            enabled.
+            https://bugs.webkit.org/show_bug.cgi?id=71631
+
+            Reviewed by Jon Honeycutt.
+
+            * src/StorageAreaProxy.h:
+            (WebCore::StorageAreaProxy::disabledByPrivateBrowsingInFrame):
+            Chromium uses a different method to track its icognito mode, so always return false.
+
 2011-12-20  Lucas Forschler  <[email protected]>
 
     Merge 90164

Modified: branches/safari-534.54-branch/Source/WebKit/chromium/src/StorageAreaProxy.h (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebKit/chromium/src/StorageAreaProxy.h	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebKit/chromium/src/StorageAreaProxy.h	2012-01-05 22:55:24 UTC (rev 104227)
@@ -51,6 +51,8 @@
     virtual bool clear(Frame* sourceFrame);
     virtual bool contains(const String& key) const;
 
+    virtual bool disabledByPrivateBrowsingInFrame(const Frame*) const { return false; }
+
 private:
     void storageEvent(const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*, Frame* sourceFrame);
 

Modified: branches/safari-534.54-branch/Source/WebKit/mac/ChangeLog (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebKit/mac/ChangeLog	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebKit/mac/ChangeLog	2012-01-05 22:55:24 UTC (rev 104227)
@@ -1,5 +1,27 @@
 2011-1-5  Lucas Forschler  <[email protected]>
 
+    Merge 99439
+
+    2011-11-07  Jessie Berlin  <[email protected]>
+
+            Need a way to allow a scheme access to Local Storage and Databases while Private Browsing is
+            enabled.
+            https://bugs.webkit.org/show_bug.cgi?id=71631
+
+            Reviewed by Jon Honeycutt.
+
+            Add WebKit1 API to register a scheme as ignoring Private Browsing for Local Storage and
+            Databases.
+
+            * WebView/WebView.mm:
+            (+[WebView _registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing:]):
+            Call through to the SchemeRegistry function.
+            (+[WebView _registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing:]):
+            Ditto.
+            * WebView/WebViewPrivate.h:
+
+2011-1-5  Lucas Forschler  <[email protected]>
+
     Merge 98970
 
     2011-11-01  Darin Adler  <[email protected]>

Modified: branches/safari-534.54-branch/Source/WebKit/mac/WebView/WebView.mm (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebKit/mac/WebView/WebView.mm	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebKit/mac/WebView/WebView.mm	2012-01-05 22:55:24 UTC (rev 104227)
@@ -2764,6 +2764,16 @@
     SchemeRegistry::registerURLSchemeAsSecure(scheme);
 }
 
++ (void)_registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing:(NSString *)scheme
+{
+    SchemeRegistry::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing(scheme);
+}
+
++ (void)_registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing:(NSString *)scheme
+{
+    SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing(scheme);
+}
+
 - (void)_scaleWebView:(float)scale atOrigin:(NSPoint)origin
 {
     Frame* coreFrame = [self _mainCoreFrame];

Modified: branches/safari-534.54-branch/Source/WebKit/mac/WebView/WebViewPrivate.h (104226 => 104227)


--- branches/safari-534.54-branch/Source/WebKit/mac/WebView/WebViewPrivate.h	2012-01-05 22:42:54 UTC (rev 104226)
+++ branches/safari-534.54-branch/Source/WebKit/mac/WebView/WebViewPrivate.h	2012-01-05 22:55:24 UTC (rev 104227)
@@ -550,6 +550,8 @@
 
 + (void)_setDomainRelaxationForbidden:(BOOL)forbidden forURLScheme:(NSString *)scheme;
 + (void)_registerURLSchemeAsSecure:(NSString *)scheme;
++ (void)_registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing:(NSString *)scheme;
++ (void)_registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing:(NSString *)scheme;
 
 - (void)_scaleWebView:(float)scale atOrigin:(NSPoint)origin;
 - (float)_viewScaleFactor;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to