CookieJar uses Document class, which is a layering violation
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Nov 2012 18:08:04 +0000 (18:08 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Nov 2012 18:08:04 +0000 (18:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=101621

Reviewed by Brady Eidson.

Source/WebCore:

Split CookieJar in two parts, one that takes a Document, and another that is a pure
platform one, using NetworkingContext to access the correct platform storage.

* GNUmakefile.list.am:
* PlatformBlackBerry.cmake:
* Target.pri:
* WebCore.gypi:
* WebCore.gyp/WebCore.gyp:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
Updated.

* loader/CookieJar.cpp: Added.
(WebCore::networkingContext):
(WebCore::cookies):
(WebCore::setCookies):
(WebCore::cookiesEnabled):
(WebCore::cookieRequestHeaderFieldValue):
(WebCore::getRawCookies):
(WebCore::deleteCookie):
(WebCore::getHostnamesWithCookies):
(WebCore::deleteCookiesForHostname):
(WebCore::deleteAllCookies):
* loader/CookieJar.h: Copied from Source/WebCore/platform/CookieJar.h.
This is an adaptor for pure platform implementations. Clients continue to use the
old interface unchanged.

* platform/blackberry/CookieJarBlackBerry.cpp: Removed.
* loader/blackberry/CookieJarBlackBerry.cpp: Copied from Source/WebCore/platform/blackberry/CookieJarBlackBerry.cpp.
* platform/network/chromium/CookieJarChromium.cpp: Removed.
* loader/chromium/CookieJarChromium.cpp: Copied from Source/WebCore/platform/network/chromium/CookieJarChromium.cpp.
These platforms do not have a pure platform implementation yet, so they just keep
to use original implementations. Since the code is not in platform/ any more, the
violation is resolved for Chromium and Blackberry, too.

* platform/CookieJar.h: Removed.
* platform/network/PlatformCookieJar.h: Copied from Source/WebCore/platform/CookieJar.h.
The platform interface is now more uniform - all functions take a NetworkingContext
instead of hardcoding which cookie storage to use in some cases.
Renamed functions that are only useful for document.cookie implementation to look
less generic.

* platform/mac/CookieJar.mm: Removed.
* platform/network/mac/CookieJarMac.mm: Copied from Source/WebCore/platform/mac/CookieJar.mm.
(WebCore::cookiesForDOM): This now takes a context instead of Document, and also
takes a firstParty URL (unused on Mac, but used on some other platforms).
(WebCore::cookieRequestHeaderFieldValue): Get cookie storage from context (and
use shared one if context is null).
(WebCore::setCookiesFromDOM): Ditto.
(WebCore::cookiesEnabled): Ditto.
(WebCore::getRawCookies): Ditto.
(WebCore::deleteCookie): Ditto.
(WebCore::getHostnamesWithCookies): Ditto. This used to only support default storage,
but its cleaner to have a uniform interface.
(WebCore::deleteCookiesForHostname): Ditto.
(WebCore::deleteAllCookies): Ditto.

* platform/network/cf/CookieJarCFNet.cpp:
Same changes as on Mac.

* platform/network/curl/CookieJarCurl.cpp:
Updated for new interface. Implementation is largely a dummy one.

* platform/qt/CookieJarQt.h: Removed.
* platform/network/qt/CookieJarQt.h: Copied from Source/WebCore/platform/qt/CookieJarQt.h.
Moved to a common location, most cookie files were in network/ already.

* platform/qt/CookieJarQt.cpp: Removed.
* platform/network/qt/CookieJarQt.cpp: Copied from Source/WebCore/platform/qt/CookieJarQt.cpp.
(WebCore::setCookiesFromDOM): Use context's or shared cooke jar as appropriate.
(WebCore::cookiesForDOM): Ditto.
(WebCore::cookieRequestHeaderFieldValue): Ditto.
(WebCore::cookiesEnabled): Ditto.
(WebCore::getRawCookies): Ditto.
(WebCore::deleteCookie): Ditto.
(WebCore::getHostnamesWithCookies): Back-end implementation can only handle shared
jar here, assert that argument does not request another one.
(WebCore::deleteCookiesForHostname): Ditto.
(WebCore::deleteAllCookies): Ditto.

* platform/network/soup/CookieJarSoup.cpp:
(WebCore::cookieJarForContext):
(WebCore::setCookiesFromDOM):
(WebCore::cookiesForContext):
(WebCore::cookiesForDOM):
(WebCore::cookieRequestHeaderFieldValue):
(WebCore::cookiesEnabled):
(WebCore::getRawCookies):
(WebCore::deleteCookie):
(WebCore::getHostnamesWithCookies):
(WebCore::deleteCookiesForHostname):
(WebCore::deleteAllCookies):
Updated for new function signatures, and use the same cross-platform logic for
choosing a cookie jar.

* platform/network/soup/CookieJarSoup.h: Don't include unnecessary CooieJar.h.

* platform/network/win/CookieJarWin.cpp:
(WebCore::setCookiesFromDOM):
(WebCore::cookiesForDOM):
(WebCore::cookieRequestHeaderFieldValue):
(WebCore::cookiesEnabled):
(WebCore::getRawCookies):
(WebCore::deleteCookie):
(WebCore::getHostnamesWithCookies):
(WebCore::deleteCookiesForHostname):
(WebCore::deleteAllCookies):
Updated for new function signatures.

Source/WebKit2:

* UIProcess/API/C/WKAPICast.h: Don't include CookieJar.h, its completely unnecessary.

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

24 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/PlatformBlackBerry.cmake
Source/WebCore/Target.pri
Source/WebCore/WebCore.gyp/WebCore.gyp
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/CookieJar.cpp [new file with mode: 0644]
Source/WebCore/loader/CookieJar.h [moved from Source/WebCore/platform/CookieJar.h with 90% similarity]
Source/WebCore/loader/blackberry/CookieJarBlackBerry.cpp [moved from Source/WebCore/platform/blackberry/CookieJarBlackBerry.cpp with 96% similarity]
Source/WebCore/loader/chromium/CookieJarChromium.cpp [moved from Source/WebCore/platform/network/chromium/CookieJarChromium.cpp with 95% similarity]
Source/WebCore/platform/network/PlatformCookieJar.h [new file with mode: 0644]
Source/WebCore/platform/network/cf/CookieJarCFNet.cpp
Source/WebCore/platform/network/curl/CookieJarCurl.cpp
Source/WebCore/platform/network/mac/CookieJarMac.mm [moved from Source/WebCore/platform/mac/CookieJar.mm with 69% similarity]
Source/WebCore/platform/network/qt/CookieJarQt.cpp [moved from Source/WebCore/platform/qt/CookieJarQt.cpp with 83% similarity]
Source/WebCore/platform/network/qt/CookieJarQt.h [moved from Source/WebCore/platform/qt/CookieJarQt.h with 100% similarity]
Source/WebCore/platform/network/soup/CookieJarSoup.cpp
Source/WebCore/platform/network/soup/CookieJarSoup.h
Source/WebCore/platform/network/win/CookieJarWin.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKAPICast.h

index d0d5688..9abb139 100644 (file)
@@ -1622,6 +1622,7 @@ SET(WebCore_SOURCES
     inspector/WorkerRuntimeAgent.cpp
 
     loader/CachedMetadata.cpp
+    loader/CookieJar.cpp
     loader/CrossOriginAccessControl.cpp
     loader/CrossOriginPreflightResultCache.cpp
     loader/DocumentLoadTiming.cpp
index b22b4d3..43da99e 100644 (file)
@@ -1,3 +1,119 @@
+2012-11-09  Alexey Proskuryakov  <ap@apple.com>
+
+        CookieJar uses Document class, which is a layering violation
+        https://bugs.webkit.org/show_bug.cgi?id=101621
+
+        Reviewed by Brady Eidson.
+
+        Split CookieJar in two parts, one that takes a Document, and another that is a pure
+        platform one, using NetworkingContext to access the correct platform storage.
+
+        * GNUmakefile.list.am:
+        * PlatformBlackBerry.cmake:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.gyp/WebCore.gyp:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        Updated.
+
+        * loader/CookieJar.cpp: Added.
+        (WebCore::networkingContext):
+        (WebCore::cookies):
+        (WebCore::setCookies):
+        (WebCore::cookiesEnabled):
+        (WebCore::cookieRequestHeaderFieldValue):
+        (WebCore::getRawCookies):
+        (WebCore::deleteCookie):
+        (WebCore::getHostnamesWithCookies):
+        (WebCore::deleteCookiesForHostname):
+        (WebCore::deleteAllCookies):
+        * loader/CookieJar.h: Copied from Source/WebCore/platform/CookieJar.h.
+        This is an adaptor for pure platform implementations. Clients continue to use the
+        old interface unchanged.
+
+        * platform/blackberry/CookieJarBlackBerry.cpp: Removed.
+        * loader/blackberry/CookieJarBlackBerry.cpp: Copied from Source/WebCore/platform/blackberry/CookieJarBlackBerry.cpp.
+        * platform/network/chromium/CookieJarChromium.cpp: Removed.
+        * loader/chromium/CookieJarChromium.cpp: Copied from Source/WebCore/platform/network/chromium/CookieJarChromium.cpp.
+        These platforms do not have a pure platform implementation yet, so they just keep
+        to use original implementations. Since the code is not in platform/ any more, the
+        violation is resolved for Chromium and Blackberry, too.
+
+        * platform/CookieJar.h: Removed.
+        * platform/network/PlatformCookieJar.h: Copied from Source/WebCore/platform/CookieJar.h.
+        The platform interface is now more uniform - all functions take a NetworkingContext
+        instead of hardcoding which cookie storage to use in some cases.
+        Renamed functions that are only useful for document.cookie implementation to look
+        less generic.
+
+        * platform/mac/CookieJar.mm: Removed.
+        * platform/network/mac/CookieJarMac.mm: Copied from Source/WebCore/platform/mac/CookieJar.mm.
+        (WebCore::cookiesForDOM): This now takes a context instead of Document, and also
+        takes a firstParty URL (unused on Mac, but used on some other platforms).
+        (WebCore::cookieRequestHeaderFieldValue): Get cookie storage from context (and
+        use shared one if context is null).
+        (WebCore::setCookiesFromDOM): Ditto.
+        (WebCore::cookiesEnabled): Ditto.
+        (WebCore::getRawCookies): Ditto.
+        (WebCore::deleteCookie): Ditto.
+        (WebCore::getHostnamesWithCookies): Ditto. This used to only support default storage,
+        but its cleaner to have a uniform interface.
+        (WebCore::deleteCookiesForHostname): Ditto.
+        (WebCore::deleteAllCookies): Ditto.
+
+        * platform/network/cf/CookieJarCFNet.cpp:
+        Same changes as on Mac.
+
+        * platform/network/curl/CookieJarCurl.cpp:
+        Updated for new interface. Implementation is largely a dummy one.
+
+        * platform/qt/CookieJarQt.h: Removed.
+        * platform/network/qt/CookieJarQt.h: Copied from Source/WebCore/platform/qt/CookieJarQt.h.
+        Moved to a common location, most cookie files were in network/ already.
+
+        * platform/qt/CookieJarQt.cpp: Removed.
+        * platform/network/qt/CookieJarQt.cpp: Copied from Source/WebCore/platform/qt/CookieJarQt.cpp.
+        (WebCore::setCookiesFromDOM): Use context's or shared cooke jar as appropriate.
+        (WebCore::cookiesForDOM): Ditto.
+        (WebCore::cookieRequestHeaderFieldValue): Ditto.
+        (WebCore::cookiesEnabled): Ditto.
+        (WebCore::getRawCookies): Ditto.
+        (WebCore::deleteCookie): Ditto.
+        (WebCore::getHostnamesWithCookies): Back-end implementation can only handle shared
+        jar here, assert that argument does not request another one.
+        (WebCore::deleteCookiesForHostname): Ditto.
+        (WebCore::deleteAllCookies): Ditto.
+
+        * platform/network/soup/CookieJarSoup.cpp:
+        (WebCore::cookieJarForContext):
+        (WebCore::setCookiesFromDOM):
+        (WebCore::cookiesForContext):
+        (WebCore::cookiesForDOM):
+        (WebCore::cookieRequestHeaderFieldValue):
+        (WebCore::cookiesEnabled):
+        (WebCore::getRawCookies):
+        (WebCore::deleteCookie):
+        (WebCore::getHostnamesWithCookies):
+        (WebCore::deleteCookiesForHostname):
+        (WebCore::deleteAllCookies):
+        Updated for new function signatures, and use the same cross-platform logic for
+        choosing a cookie jar.
+
+        * platform/network/soup/CookieJarSoup.h: Don't include unnecessary CooieJar.h.
+        
+        * platform/network/win/CookieJarWin.cpp:
+        (WebCore::setCookiesFromDOM):
+        (WebCore::cookiesForDOM):
+        (WebCore::cookieRequestHeaderFieldValue):
+        (WebCore::cookiesEnabled):
+        (WebCore::getRawCookies):
+        (WebCore::deleteCookie):
+        (WebCore::getHostnamesWithCookies):
+        (WebCore::deleteCookiesForHostname):
+        (WebCore::deleteAllCookies):
+        Updated for new function signatures.
+
 2012-11-09  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
 
         [css] Text decoration's "blink" not valid when CSS3_TEXT is enabled
index 3df9dd9..76b68fb 100644 (file)
@@ -3857,6 +3857,8 @@ webcore_sources += \
        Source/WebCore/loader/cache/CachePolicy.h \
        Source/WebCore/loader/CachedMetadata.cpp \
        Source/WebCore/loader/CachedMetadata.h \
+       Source/WebCore/loader/CookieJar.cpp \
+       Source/WebCore/loader/CookieJar.h \
        Source/WebCore/loader/CrossOriginAccessControl.cpp \
        Source/WebCore/loader/CrossOriginAccessControl.h \
        Source/WebCore/loader/CrossOriginPreflightResultCache.cpp \
@@ -4247,7 +4249,6 @@ webcore_sources += \
        Source/WebCore/platform/ContextMenuItem.h \
        Source/WebCore/platform/Cookie.h \
        Source/WebCore/platform/CookiesStrategy.h \
-       Source/WebCore/platform/CookieJar.h \
        Source/WebCore/platform/CrossThreadCopier.cpp \
        Source/WebCore/platform/CrossThreadCopier.h \
        Source/WebCore/platform/Cursor.cpp \
@@ -4715,6 +4716,7 @@ webcore_sources += \
        Source/WebCore/platform/network/ProxyServer.h \
        Source/WebCore/platform/network/NetworkStateNotifier.cpp \
        Source/WebCore/platform/network/NetworkStateNotifier.h \
+       Source/WebCore/platform/network/PlatformCookieJar.h \
        Source/WebCore/platform/network/ProtectionSpaceHash.h \
        Source/WebCore/platform/network/ProtectionSpace.cpp \
        Source/WebCore/platform/network/ProtectionSpace.h \
index 622d0ee..161c1c6 100644 (file)
@@ -141,6 +141,7 @@ LIST(APPEND WebCore_INCLUDE_DIRECTORIES
 LIST(APPEND WebCore_SOURCES
     editing/blackberry/EditorBlackBerry.cpp
     editing/blackberry/SmartReplaceBlackBerry.cpp
+    loader/blackberry/CookieJarBlackBerry.cpp
     page/blackberry/AccessibilityObjectBlackBerry.cpp
     page/blackberry/DragControllerBlackBerry.cpp
     page/blackberry/EventHandlerBlackBerry.cpp
@@ -148,7 +149,6 @@ LIST(APPEND WebCore_SOURCES
     platform/blackberry/ClipboardBlackBerry.cpp
     platform/blackberry/ContextMenuBlackBerry.cpp
     platform/blackberry/ContextMenuItemBlackBerry.cpp
-    platform/blackberry/CookieJarBlackBerry.cpp
     platform/blackberry/CursorBlackBerry.cpp
     platform/blackberry/DragDataBlackBerry.cpp
     platform/blackberry/DragImageBlackBerry.cpp
index 74665e1..6e16eb1 100644 (file)
@@ -817,6 +817,7 @@ SOURCES += \
     loader/cache/CachedSVGDocument.cpp \
     loader/cache/CachedSVGDocument.h \
     loader/cache/CachedXSLStyleSheet.cpp \
+    loader/CookieJar.cpp \
     loader/CrossOriginAccessControl.cpp \
     loader/CrossOriginPreflightResultCache.cpp \
     loader/cache/CachedResourceLoader.cpp \
@@ -1949,6 +1950,7 @@ HEADERS += \
     loader/cache/CachedSVGDocument.h \
     loader/cache/CachedXSLStyleSheet.h \
     loader/cache/MemoryCache.h \
+    loader/CookieJar.h \
     loader/CrossOriginAccessControl.h \
     loader/CrossOriginPreflightResultCache.h \
     loader/cache/CachedResourceLoader.h \
@@ -2238,6 +2240,7 @@ HEADERS += \
     platform/network/MIMESniffing.h \
     platform/network/NetworkingContext.h \
     platform/network/NetworkStateNotifier.h \
+    platform/network/PlatformCookieJar.h \
     platform/network/ProtectionSpace.h \
     platform/network/ProxyServer.h \
     platform/network/qt/QtMIMETypeSniffer.h \
@@ -2250,6 +2253,7 @@ HEADERS += \
     platform/network/ResourceRequestBase.h \
     platform/network/ResourceResponseBase.h \
     platform/network/qt/NetworkStateNotifierPrivate.h \
+    platform/network/qt/CookieJarQt.h \
     platform/PlatformExportMacros.h \
     platform/PlatformMemoryInstrumentation.h \
     platform/PlatformTouchEvent.h \
@@ -2257,7 +2261,6 @@ HEADERS += \
     platform/PopupMenu.h \
     platform/ReferrerPolicy.h \
     platform/qt/ClipboardQt.h \
-    platform/qt/CookieJarQt.h \
     platform/qt/QWebPageClient.h \
     platform/qt/QStyleFacade.h \
     platform/qt/RenderThemeQStyle.h \
@@ -2804,6 +2807,7 @@ SOURCES += \
     platform/graphics/texmap/TextureMapperLayer.cpp \
     platform/network/DNSResolveQueue.cpp \
     platform/network/MIMESniffing.cpp \
+    platform/network/qt/CookieJarQt.cpp \
     platform/network/qt/CredentialStorageQt.cpp \
     platform/network/qt/ResourceHandleQt.cpp \
     platform/network/qt/ResourceRequestQt.cpp \
@@ -2817,7 +2821,6 @@ SOURCES += \
     platform/qt/ClipboardQt.cpp \
     platform/qt/ContextMenuItemQt.cpp \
     platform/qt/ContextMenuQt.cpp \
-    platform/qt/CookieJarQt.cpp \
     platform/qt/CursorQt.cpp \
     platform/qt/DragDataQt.cpp \
     platform/qt/DragImageQt.cpp \
index 2190572..ed29453 100644 (file)
         ['exclude', 'inspector/InspectorFrontendClientLocal\\.cpp$'],
         ['exclude', 'inspector/JavaScript[^/]*\\.cpp$'],
         ['exclude', 'loader/UserStyleSheetLoader\\.cpp$'],
+        ['exclude', 'loader/CookieJar\\.cpp$'],
         ['exclude', 'loader/appcache/'],
         ['exclude', 'loader/archive/cf/LegacyWebArchiveMac\\.mm$'],
         ['exclude', 'loader/archive/cf/LegacyWebArchive\\.cpp$'],
index c465606..0c9635b 100644 (file)
             'inspector/InspectorValues.h',
             'inspector/ScriptBreakpoint.h',
             'inspector/ScriptDebugListener.h',
+            'loader/CookieJar.h',
             'loader/CrossOriginPreflightResultCache.h',
             'loader/DocumentLoadTiming.h',
             'loader/DocumentLoader.h',
             'platform/ContextMenu.h',
             'platform/ContextMenuItem.h',
             'platform/Cookie.h',
-            'platform/CookieJar.h',
             'platform/CookiesStrategy.h',
             'platform/Cursor.h',
             'platform/DateComponents.h',
             'platform/PlatformMouseEvent.h',
             'platform/PlatformScreen.h',
             'platform/PlatformStrategies.h',
+            'platform/PlatformCookieJar.h',
             'platform/PlatformWheelEvent.h',
             'platform/PopupMenu.h',
             'platform/PopupMenuClient.h',
             'inspector/WorkerRuntimeAgent.h',
             'loader/CachedMetadata.cpp',
             'loader/CachedMetadata.h',
+            'loader/CookieJar.cpp',
             'loader/CrossOriginAccessControl.cpp',
             'loader/CrossOriginAccessControl.h',
             'loader/CrossOriginPreflightResultCache.cpp',
             'loader/cache/MemoryCache.cpp',
             'loader/cf/ResourceLoaderCFNet.cpp',
             'loader/chromium/CachedRawResourceChromium.cpp',
+            'loader/chromium/CookieJarChromium.cpp',
             'loader/chromium/DocumentThreadableLoaderChromium.cpp',
             'loader/chromium/ResourceLoaderChromium.cpp',
             'loader/chromium/SubresourceLoaderChromium.cpp',
             'platform/mac/ClipboardMac.mm',
             'platform/mac/ContextMenuItemMac.mm',
             'platform/mac/ContextMenuMac.mm',
-            'platform/mac/CookieJar.mm',
             'platform/mac/CursorMac.mm',
             'platform/mac/DragDataMac.mm',
             'platform/mac/DragImageMac.mm',
             'platform/network/cf/SocketStreamHandleCFNet.cpp',
             'platform/network/chromium/AuthenticationChallenge.h',
             'platform/network/chromium/AuthenticationChallengeChromium.cpp',
-            'platform/network/chromium/CookieJarChromium.cpp',
             'platform/network/chromium/DNSChromium.cpp',
             'platform/network/chromium/ResourceError.h',
             'platform/network/chromium/ResourceHandle.cpp',
             'platform/network/curl/SocketStreamHandle.h',
             'platform/network/curl/SocketStreamHandleCurl.cpp',
             'platform/network/mac/AuthenticationMac.mm',
+            'platform/network/mac/CookieJarMac.mm',
             'platform/network/mac/CookieStorageMac.mm',
             'platform/network/mac/CredentialStorageMac.mm',
             'platform/network/mac/FormDataStreamMac.mm',
             'platform/network/mac/ResourceResponseMac.mm',
             'platform/network/mac/WebCoreURLResponse.mm',
             'platform/network/qt/AuthenticationChallenge.h',
+            'platform/network/qt/CookieJarQt.cpp',
             'platform/network/qt/CredentialStorageQt.cpp',
             'platform/network/qt/NetworkStateNotifierPrivate.h',
             'platform/network/qt/NetworkStateNotifierQt.cpp',
             'platform/qt/ClipboardQt.h',
             'platform/qt/ContextMenuItemQt.cpp',
             'platform/qt/ContextMenuQt.cpp',
-            'platform/qt/CookieJarQt.cpp',
             'platform/qt/CursorQt.cpp',
             'platform/qt/DragDataQt.cpp',
             'platform/qt/DragImageQt.cpp',
index b53e715..45df063 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\loader\CookieJar.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\loader\CookieJar.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\loader\CrossOriginAccessControl.cpp"
                                >
                        </File>
                                >
                        </File>
                        <File
-                               RelativePath="..\platform\CookieJar.h"
-                               >
-                       </File>
-                       <File
                                RelativePath="..\platform\CookiesStrategy.h"
                                >
                        </File>
                                        >
                                </File>
                                <File
+                                       RelativePath="..\platform\network\PlatformCookieJar.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\platform\network\ProtectionSpace.cpp"
                                        >
                                </File>
index 1893326..1bcdd18 100644 (file)
                93500F3213FDE3BE0099EC24 /* NSScrollerImpDetails.h in Headers */ = {isa = PBXBuildFile; fileRef = 93500F3113FDE3BE0099EC24 /* NSScrollerImpDetails.h */; };
                935207BE09BD410A00F2038D /* LocalizedStrings.h in Headers */ = {isa = PBXBuildFile; fileRef = 935207BD09BD410A00F2038D /* LocalizedStrings.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9352084509BD43B900F2038D /* Language.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9352084409BD43B900F2038D /* Language.mm */; };
-               9352087709BD453400F2038D /* CookieJar.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9352087609BD453400F2038D /* CookieJar.mm */; };
-               9352088209BD45E900F2038D /* CookieJar.h in Headers */ = {isa = PBXBuildFile; fileRef = 9352088109BD45E900F2038D /* CookieJar.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9353676B09AED88B00D35CD6 /* ScrollViewMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9353676A09AED88B00D35CD6 /* ScrollViewMac.mm */; };
                935C476309AC4CE600A6AAB4 /* MouseEventWithHitTestResults.h in Headers */ = {isa = PBXBuildFile; fileRef = 935C476209AC4CE600A6AAB4 /* MouseEventWithHitTestResults.h */; };
                935C476809AC4D4300A6AAB4 /* PlatformKeyboardEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 935C476609AC4D4300A6AAB4 /* PlatformKeyboardEvent.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E139866315478474001E3F65 /* StyleResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E139866115478474001E3F65 /* StyleResolver.cpp */; };
                E139866415478474001E3F65 /* StyleResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = E139866215478474001E3F65 /* StyleResolver.h */; };
                E13F01F11270E19000DFBA71 /* CookieStorageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E13F01F01270E19000DFBA71 /* CookieStorageMac.mm */; };
+               E1424C8A164B3B4E00F32D40 /* PlatformCookieJar.h in Headers */ = {isa = PBXBuildFile; fileRef = E1424C89164B3B4E00F32D40 /* PlatformCookieJar.h */; };
+               E1424C90164B460B00F32D40 /* CookieJarMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1424C8F164B460B00F32D40 /* CookieJarMac.mm */; };
+               E1424C93164B52C800F32D40 /* CookieJar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1424C91164B52C800F32D40 /* CookieJar.cpp */; };
+               E1424C94164B52C800F32D40 /* CookieJar.h in Headers */ = {isa = PBXBuildFile; fileRef = E1424C92164B52C800F32D40 /* CookieJar.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E14F1C4414B5DAC600EA9009 /* HTMLFormControlElementWithState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E14F1C4214B5DAC600EA9009 /* HTMLFormControlElementWithState.cpp */; };
                E14F1C4514B5DAC600EA9009 /* HTMLFormControlElementWithState.h in Headers */ = {isa = PBXBuildFile; fileRef = E14F1C4314B5DAC600EA9009 /* HTMLFormControlElementWithState.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E15A36D71104572000B7B639 /* XMLNSNames.h in Headers */ = {isa = PBXBuildFile; fileRef = E15A36D61104572000B7B639 /* XMLNSNames.h */; };
                93500F3113FDE3BE0099EC24 /* NSScrollerImpDetails.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSScrollerImpDetails.h; sourceTree = "<group>"; };
                935207BD09BD410A00F2038D /* LocalizedStrings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalizedStrings.h; sourceTree = "<group>"; };
                9352084409BD43B900F2038D /* Language.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Language.mm; sourceTree = "<group>"; };
-               9352087609BD453400F2038D /* CookieJar.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieJar.mm; sourceTree = "<group>"; };
-               9352088109BD45E900F2038D /* CookieJar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CookieJar.h; sourceTree = "<group>"; };
                9353676A09AED88B00D35CD6 /* ScrollViewMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollViewMac.mm; sourceTree = "<group>"; };
                935C476209AC4CE600A6AAB4 /* MouseEventWithHitTestResults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MouseEventWithHitTestResults.h; sourceTree = "<group>"; };
                935C476609AC4D4300A6AAB4 /* PlatformKeyboardEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformKeyboardEvent.h; sourceTree = "<group>"; };
                E139866215478474001E3F65 /* StyleResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleResolver.h; sourceTree = "<group>"; };
                E13F01EA1270E10D00DFBA71 /* CookieStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CookieStorage.h; sourceTree = "<group>"; };
                E13F01F01270E19000DFBA71 /* CookieStorageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieStorageMac.mm; sourceTree = "<group>"; };
+               E1424C89164B3B4E00F32D40 /* PlatformCookieJar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformCookieJar.h; path = network/PlatformCookieJar.h; sourceTree = "<group>"; };
+               E1424C8F164B460B00F32D40 /* CookieJarMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieJarMac.mm; sourceTree = "<group>"; };
+               E1424C91164B52C800F32D40 /* CookieJar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CookieJar.cpp; sourceTree = "<group>"; };
+               E1424C92164B52C800F32D40 /* CookieJar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CookieJar.h; sourceTree = "<group>"; };
                E14F1C4214B5DAC600EA9009 /* HTMLFormControlElementWithState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLFormControlElementWithState.cpp; sourceTree = "<group>"; };
                E14F1C4314B5DAC600EA9009 /* HTMLFormControlElementWithState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLFormControlElementWithState.h; sourceTree = "<group>"; };
                E15A36D61104572000B7B639 /* XMLNSNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLNSNames.h; sourceTree = "<group>"; };
                                514C76440CE9234E007EF3CD /* FormDataStreamMac.h */,
                                514C76450CE9234E007EF3CD /* FormDataStreamMac.mm */,
                                1A7FA6470DDA3CBA0028F8A5 /* NetworkStateNotifierMac.cpp */,
+                               E1424C8F164B460B00F32D40 /* CookieJarMac.mm */,
                                514C76460CE9234E007EF3CD /* ResourceErrorMac.mm */,
                                514C76470CE9234E007EF3CD /* ResourceHandleMac.mm */,
                                514C76490CE9234E007EF3CD /* ResourceRequestMac.mm */,
                                2D90660C0665D937006B6F1A /* ClipboardMac.mm */,
                                06027CB20B1CC03D00884B2D /* ContextMenuItemMac.mm */,
                                93B6A0E90B0BCA8400F5027A /* ContextMenuMac.mm */,
-                               9352087609BD453400F2038D /* CookieJar.mm */,
                                F58784F002DE375901EA4122 /* CursorMac.mm */,
                                5D8C4DBD1428222C0026CE72 /* DisplaySleepDisabler.cpp */,
                                5D8C4DBE1428222C0026CE72 /* DisplaySleepDisabler.h */,
                                E1C416160F6563180092D2FB /* CrossOriginAccessControl.cpp */,
                                4FC853491644271B00D1C275 /* CachedMetadata.cpp */,
                                4FC8534A1644271B00D1C275 /* CachedMetadata.h */,
+                               E1424C91164B52C800F32D40 /* CookieJar.cpp */,
+                               E1424C92164B52C800F32D40 /* CookieJar.h */,
                                E1C416110F6562FD0092D2FB /* CrossOriginAccessControl.h */,
                                E1C415DD0F655D7C0092D2FB /* CrossOriginPreflightResultCache.cpp */,
                                E1C415D90F655D6F0092D2FB /* CrossOriginPreflightResultCache.h */,
                                93B6A0E50B0BCA5C00F5027A /* ContextMenu.h */,
                                06027CAC0B1CBFC000884B2D /* ContextMenuItem.h */,
                                D8B6152E1032495100C8554A /* Cookie.h */,
-                               9352088109BD45E900F2038D /* CookieJar.h */,
                                339B5B62131DAA3200F48D02 /* CookiesStrategy.h */,
                                2E4346560F546A9900B0F1BA /* CrossThreadCopier.cpp */,
                                2E4346570F546A9900B0F1BA /* CrossThreadCopier.h */,
                                98EB1F941313FE0500D0E1EA /* NotImplemented.h */,
                                4B2708C50AF19EE40065127F /* Pasteboard.h */,
                                C5F765B414E1D414006C899B /* PasteboardStrategy.h */,
+                               E1424C89164B3B4E00F32D40 /* PlatformCookieJar.h */,
                                BC5C76281497FE1400BC4775 /* PlatformEvent.cpp */,
                                BC5C76291497FE1400BC4775 /* PlatformEvent.h */,
                                A723F77A1484CA4C008C6DBE /* PlatformExportMacros.h */,
                                7ADE722610CBBB9B006B3B3A /* ContextMenuProvider.h in Headers */,
                                FD31602912B0267600C1A359 /* ConvolverNode.h in Headers */,
                                D8B6152F1032495100C8554A /* Cookie.h in Headers */,
-                               9352088209BD45E900F2038D /* CookieJar.h in Headers */,
                                339B5B63131DAA3200F48D02 /* CookiesStrategy.h in Headers */,
                                33D0212D131DB37B004091A8 /* CookieStorage.h in Headers */,
                                7EE6846412D26E3800E79415 /* CookieStorageCFNet.h in Headers */,
                                3FFFF9A9159D9A550020BBD5 /* WebKitCSSViewportRule.h in Headers */,
                                93C38BFF164473C700091EB2 /* ScrollingStateFixedNode.h in Headers */,
                                93C38C03164473DD00091EB2 /* ScrollingTreeFixedNode.h in Headers */,
+                               E1424C8A164B3B4E00F32D40 /* PlatformCookieJar.h in Headers */,
+                               E1424C94164B52C800F32D40 /* CookieJar.h in Headers */,
                                1411DCB1164C39A800D49BC1 /* WidthCache.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                                06027CB30B1CC03D00884B2D /* ContextMenuItemMac.mm in Sources */,
                                93B6A0EA0B0BCA8400F5027A /* ContextMenuMac.mm in Sources */,
                                FD31602812B0267600C1A359 /* ConvolverNode.cpp in Sources */,
-                               9352087709BD453400F2038D /* CookieJar.mm in Sources */,
                                7EE6846212D26E3800E79415 /* CookieJarCFNet.cpp in Sources */,
                                7EE6846312D26E3800E79415 /* CookieStorageCFNet.cpp in Sources */,
                                E13F01F11270E19000DFBA71 /* CookieStorageMac.mm in Sources */,
                                93C38BFE164473C700091EB2 /* ScrollingStateFixedNode.cpp in Sources */,
                                93C38C04164473DD00091EB2 /* ScrollingTreeFixedNode.mm in Sources */,
                                4FC8534C1644272300D1C275 /* CachedMetadata.cpp in Sources */,
+                               E1424C90164B460B00F32D40 /* CookieJarMac.mm in Sources */,
+                               E1424C93164B52C800F32D40 /* CookieJar.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/Source/WebCore/loader/CookieJar.cpp b/Source/WebCore/loader/CookieJar.cpp
new file mode 100644 (file)
index 0000000..56077dc
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2012 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#include "config.h"
+#include "CookieJar.h"
+
+#include "Document.h"
+#include "Frame.h"
+#include "PlatformCookieJar.h"
+
+#if PLATFORM(CHROMIUM) || PLATFORM(BLACKBERRY)
+#error Chromium and Blackberry currently use a fork of this file because of layering violations
+#endif
+
+namespace WebCore {
+
+static NetworkingContext* networkingContext(const Document* document)
+{
+    if (!document)
+        return 0;
+    Frame* frame = document->frame();
+    if (!frame)
+        return 0;
+    FrameLoader* loader = frame->loader();
+    if (!loader)
+        return 0;
+    return loader->networkingContext();
+}
+
+String cookies(const Document* document, const KURL& url)
+{
+    return cookiesForDOM(networkingContext(document), document->firstPartyForCookies(), url);
+}
+
+void setCookies(Document* document, const KURL& url, const String& cookieString)
+{
+    setCookiesFromDOM(networkingContext(document), document->firstPartyForCookies(), url, cookieString);
+}
+
+bool cookiesEnabled(const Document* document)
+{
+    return cookiesEnabled(networkingContext(document));
+}
+
+String cookieRequestHeaderFieldValue(const Document* document, const KURL& url)
+{
+    return cookieRequestHeaderFieldValue(networkingContext(document), url);
+}
+
+bool getRawCookies(const Document* document, const KURL& url, Vector<Cookie>& cookies)
+{
+    return getRawCookies(networkingContext(document), url, cookies);
+}
+
+void deleteCookie(const Document* document, const KURL& url, const String& cookieName)
+{
+    deleteCookie(networkingContext(document), url, cookieName);
+}
+
+void getHostnamesWithCookies(HashSet<String>& hostnames)
+{
+    getHostnamesWithCookies(0, hostnames);
+}
+
+void deleteCookiesForHostname(const String& hostname)
+{
+    deleteCookiesForHostname(0, hostname);
+}
+
+void deleteAllCookies()
+{
+    deleteAllCookies(0);
+}
+
+}
similarity index 90%
rename from Source/WebCore/platform/CookieJar.h
rename to Source/WebCore/loader/CookieJar.h
index f4cfd86..1562265 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2006, 2008, 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,8 +28,8 @@
 
 #include <wtf/Forward.h>
 #include <wtf/HashSet.h>
-#include <wtf/text/WTFString.h>
 #include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -39,13 +39,13 @@ struct Cookie;
 
 // These two functions implement document.cookie API, with special rules for HttpOnly cookies.
 String cookies(const Document*, const KURL&);
-void setCookies(Document*, const KURL&, const String&);
+void setCookies(Document*, const KURL&, const String& cookieString);
 
 // These methods use current cookie storage, thus taking private browsing mode into account.
 bool cookiesEnabled(const Document*);
 String cookieRequestHeaderFieldValue(const Document*, const KURL&);
 bool getRawCookies(const Document*, const KURL&, Vector<Cookie>&);
-void deleteCookie(const Document*, const KURL&, const String&);
+void deleteCookie(const Document*, const KURL&, const String& cookieName);
 
 // These functions always access default cookie storage, not taking private browsing mode into account.
 void getHostnamesWithCookies(HashSet<String>& hostnames);
@@ -35,6 +35,8 @@
 
 namespace WebCore {
 
+// FIXME: Unfork. This file is forked because all other platforms use NetworkingContext to access cookie jar, not Document or Frame.
+
 String cookies(Document const* document, KURL const& url)
 {
     Frame* frame = document->frame();
@@ -37,6 +37,8 @@
 
 namespace WebCore {
 
+// FIXME: Unfork. This file is forked because all other platforms use NetworkingContext to access cookie jar, not Document or Frame.
+
 void setCookies(Document* document, const KURL& url, const String& value)
 {
     PlatformSupport::setCookies(document, url, value);
diff --git a/Source/WebCore/platform/network/PlatformCookieJar.h b/Source/WebCore/platform/network/PlatformCookieJar.h
new file mode 100644 (file)
index 0000000..deb7a79
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2003, 2006, 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 PlatformCookieJar_h
+#define PlatformCookieJar_h
+
+#include <wtf/Forward.h>
+#include <wtf/HashSet.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class KURL;
+class NetworkingContext;
+struct Cookie;
+
+// If networking context is null, default cookie storage is used.
+String cookiesForDOM(NetworkingContext*, const KURL& firstParty, const KURL&);
+void setCookiesFromDOM(NetworkingContext*, const KURL& firstParty, const KURL&, const String&);
+bool cookiesEnabled(NetworkingContext*);
+String cookieRequestHeaderFieldValue(NetworkingContext*, const KURL&);
+bool getRawCookies(NetworkingContext*, const KURL&, Vector<Cookie>&);
+void deleteCookie(NetworkingContext*, const KURL&, const String&);
+void getHostnamesWithCookies(NetworkingContext*, HashSet<String>& hostnames);
+void deleteCookiesForHostname(NetworkingContext*, const String& hostname);
+void deleteAllCookies(NetworkingContext*);
+
+}
+
+#endif
index 10dfbc6..9c86d05 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #include "config.h"
-#include "CookieJar.h"
+#include "PlatformCookieJar.h"
 
 #if USE(CFNETWORK)
 
 #include "Cookie.h"
 #include "CookieStorageCFNet.h"
-#include "Document.h"
 #include "KURL.h"
 #include "ResourceHandle.h"
 #include "SoftLinking.h"
@@ -95,18 +94,18 @@ static RetainPtr<CFArrayRef> filterCookies(CFArrayRef unfilteredCookies)
     return filteredCookies;
 }
 
-void setCookies(Document* document, const KURL& url, const String& value)
+void setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& value)
 {
     // <rdar://problem/5632883> CFHTTPCookieStorage stores an empty cookie, which would be sent as "Cookie: =".
     if (value.isEmpty())
         return;
 
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = currentCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
     if (!cookieStorage)
         return;
 
     RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL());
-    RetainPtr<CFURLRef> firstPartyForCookiesCF(AdoptCF, document->firstPartyForCookies().createCFURL());
+    RetainPtr<CFURLRef> firstPartyForCookiesCF(AdoptCF, firstParty.createCFURL());
 
     // <http://bugs.webkit.org/show_bug.cgi?id=6531>, <rdar://4409034>
     // cookiesWithResponseHeaderFields doesn't parse cookies without a value
@@ -123,9 +122,9 @@ void setCookies(Document* document, const KURL& url, const String& value)
     CFHTTPCookieStorageSetCookies(cookieStorage.get(), filterCookies(cookiesCF.get()).get(), urlCF.get(), firstPartyForCookiesCF.get());
 }
 
-String cookies(const Document* /*document*/, const KURL& url)
+String cookiesForDOM(NetworkingContext* context, const KURL&, const KURL& url)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = currentCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
     if (!cookieStorage)
         return String();
 
@@ -137,9 +136,9 @@ String cookies(const Document* /*document*/, const KURL& url)
     return (CFStringRef)CFDictionaryGetValue(headerCF.get(), s_cookieCF);
 }
 
-String cookieRequestHeaderFieldValue(const Document* /*document*/, const KURL& url)
+String cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& url)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = currentCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
     if (!cookieStorage)
         return String();
 
@@ -151,18 +150,19 @@ String cookieRequestHeaderFieldValue(const Document* /*document*/, const KURL& u
     return (CFStringRef)CFDictionaryGetValue(headerCF.get(), s_cookieCF);
 }
 
-bool cookiesEnabled(const Document* /*document*/)
+bool cookiesEnabled(NetworkingContext* context)
 {
     CFHTTPCookieStorageAcceptPolicy policy = CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain;
-    if (RetainPtr<CFHTTPCookieStorageRef> cookieStorage = currentCFHTTPCookieStorage())
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
+    if (cookieStorage)
         policy = CFHTTPCookieStorageGetCookieAcceptPolicy(cookieStorage.get());
     return policy == CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain || policy == CFHTTPCookieStorageAcceptPolicyAlways;
 }
 
-bool getRawCookies(const Document*, const KURL& url, Vector<Cookie>& rawCookies)
+bool getRawCookies(NetworkingContext* context, const KURL& url, Vector<Cookie>& rawCookies)
 {
     rawCookies.clear();
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = currentCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
     if (!cookieStorage)
         return false;
 
@@ -193,9 +193,9 @@ bool getRawCookies(const Document*, const KURL& url, Vector<Cookie>& rawCookies)
     return true;
 }
 
-void deleteCookie(const Document*, const KURL& url, const String& name)
+void deleteCookie(NetworkingContext* context, const KURL& url, const String& name)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = currentCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
     if (!cookieStorage)
         return;
 
@@ -214,9 +214,9 @@ void deleteCookie(const Document*, const KURL& url, const String& name)
     }
 }
 
-void getHostnamesWithCookies(HashSet<String>& hostnames)
+void getHostnamesWithCookies(NetworkingContext* context, HashSet<String>& hostnames)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = defaultCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
     if (!cookieStorage)
         return;
 
@@ -232,9 +232,9 @@ void getHostnamesWithCookies(HashSet<String>& hostnames)
     }
 }
 
-void deleteCookiesForHostname(const String& hostname)
+void deleteCookiesForHostname(NetworkingContext* context, const String& hostname)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = defaultCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
     if (!cookieStorage)
         return;
 
@@ -251,9 +251,9 @@ void deleteCookiesForHostname(const String& hostname)
     }
 }
 
-void deleteAllCookies()
+void deleteAllCookies(NetworkingContext* context)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = defaultCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
     if (!cookieStorage)
         return;
 
index b522dbc..e03bd1d 100644 (file)
  */
 
 #include "config.h"
-#include "CookieJar.h"
+#include "PlatformCookieJar.h"
 
 #include "Cookie.h"
-#include "Document.h"
 #include "KURL.h"
 #include <wtf/HashMap.h>
 #include <wtf/text/StringHash.h>
@@ -28,50 +27,50 @@ namespace WebCore {
 
 static HashMap<String, String> cookieJar;
 
-void setCookies(Document* /*document*/, const KURL& url, const String& value)
+void setCookiesFromDOM(NetworkingContext*, const KURL&, const KURL& url, const String& value)
 {
     cookieJar.set(url.string(), value);
 }
 
-String cookies(const Document* /*document*/, const KURL& url)
+String cookiesForDOM(NetworkingContext*, const KURL&, const KURL& url)
 {
     return cookieJar.get(url.string());
 }
 
-String cookieRequestHeaderFieldValue(const Document* /*document*/, const KURL& url)
+String cookieRequestHeaderFieldValue(NetworkingContext*, const KURL& url)
 {
     // FIXME: include HttpOnly cookie.
     return cookieJar.get(url.string());
 }
 
-bool cookiesEnabled(const Document* /*document*/)
+bool cookiesEnabled(NetworkingContext*)
 {
     return true;
 }
 
-bool getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies)
+bool getRawCookies(NetworkingContext*, const KURL&, Vector<Cookie>& rawCookies)
 {
     // FIXME: Not yet implemented
     rawCookies.clear();
     return false; // return true when implemented
 }
 
-void deleteCookie(const Document*, const KURL&, const String&)
+void deleteCookie(NetworkingContext*, const KURL&, const String&)
 {
     // FIXME: Not yet implemented
 }
 
-void getHostnamesWithCookies(HashSet<String>& hostnames)
+void getHostnamesWithCookies(NetworkingContext*, HashSet<String>& hostnames)
 {
     // FIXME: Not yet implemented
 }
 
-void deleteCookiesForHostname(const String& hostname)
+void deleteCookiesForHostname(NetworkingContext*, const String& hostname)
 {
     // FIXME: Not yet implemented
 }
 
-void deleteAllCookies()
+void deleteAllCookies(NetworkingContext*)
 {
     // FIXME: Not yet implemented
 }
@@ -24,7 +24,7 @@
  */
 
 #import "config.h"
-#import "CookieJar.h"
+#import "PlatformCookieJar.h"
 
 #if !USE(CFNETWORK)
 
@@ -32,7 +32,7 @@
 #import "Cookie.h"
 #import "CookieStorage.h"
 #import "CookieStorageCFNet.h"
-#import "Document.h"
+#import "KURL.h"
 #import "WebCoreSystemInterface.h"
 
 namespace WebCore {
@@ -61,29 +61,31 @@ static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies)
     return filteredCookies;
 }
 
-String cookies(const Document*, const KURL& url)
+String cookiesForDOM(NetworkingContext* context, const KURL&, const KURL& url)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    NSArray *cookies = wkHTTPCookiesForURL(currentCFHTTPCookieStorage().get(), url);
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
+    NSArray *cookies = wkHTTPCookiesForURL(cookieStorage.get(), url);
     return [[NSHTTPCookie requestHeaderFieldsWithCookies:filterCookies(cookies).get()] objectForKey:@"Cookie"];
 
     END_BLOCK_OBJC_EXCEPTIONS;
     return String();
 }
 
-String cookieRequestHeaderFieldValue(const Document*, const KURL& url)
+String cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& url)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    NSArray *cookies = wkHTTPCookiesForURL(currentCFHTTPCookieStorage().get(), url);
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
+    NSArray *cookies = wkHTTPCookiesForURL(cookieStorage.get(), url);
     return [[NSHTTPCookie requestHeaderFieldsWithCookies:cookies] objectForKey:@"Cookie"];
 
     END_BLOCK_OBJC_EXCEPTIONS;
     return String();
 }
 
-void setCookies(Document* document, const KURL& url, const String& cookieStr)
+void setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& cookieStr)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
@@ -100,28 +102,31 @@ void setCookies(Document* document, const KURL& url, const String& cookieStr)
     RetainPtr<NSArray> filteredCookies = filterCookies([NSHTTPCookie cookiesWithResponseHeaderFields:[NSDictionary dictionaryWithObject:cookieString forKey:@"Set-Cookie"] forURL:cookieURL]);
     ASSERT([filteredCookies.get() count] <= 1);
 
-    wkSetHTTPCookiesForURL(currentCFHTTPCookieStorage().get(), filteredCookies.get(), cookieURL, document->firstPartyForCookies());
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
+    wkSetHTTPCookiesForURL(cookieStorage.get(), filteredCookies.get(), cookieURL, firstParty);
 
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-bool cookiesEnabled(const Document*)
+bool cookiesEnabled(NetworkingContext* context)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    NSHTTPCookieAcceptPolicy cookieAcceptPolicy = static_cast<NSHTTPCookieAcceptPolicy>(wkGetHTTPCookieAcceptPolicy(currentCFHTTPCookieStorage().get()));
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
+    NSHTTPCookieAcceptPolicy cookieAcceptPolicy = static_cast<NSHTTPCookieAcceptPolicy>(wkGetHTTPCookieAcceptPolicy(cookieStorage.get()));
     return cookieAcceptPolicy == NSHTTPCookieAcceptPolicyAlways || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
 
     END_BLOCK_OBJC_EXCEPTIONS;
     return false;
 }
 
-bool getRawCookies(const Document*, const KURL& url, Vector<Cookie>& rawCookies)
+bool getRawCookies(NetworkingContext* context, const KURL& url, Vector<Cookie>& rawCookies)
 {
     rawCookies.clear();
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    NSArray *cookies = wkHTTPCookiesForURL(currentCFHTTPCookieStorage().get(), url);
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
+    NSArray *cookies = wkHTTPCookiesForURL(cookieStorage.get(), url);
     NSUInteger count = [cookies count];
     rawCookies.reserveCapacity(count);
     for (NSUInteger i = 0; i < count; ++i) {
@@ -135,12 +140,12 @@ bool getRawCookies(const Document*, const KURL& url, Vector<Cookie>& rawCookies)
     return true;
 }
 
-void deleteCookie(const Document*, const KURL& url, const String& cookieName)
+void deleteCookie(NetworkingContext* context, const KURL& url, const String& cookieName)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
     NSURL *cookieURL = url;
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = currentCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
     NSArray *cookies = wkHTTPCookiesForURL(cookieStorage.get(), cookieURL);
 
     NSString *cookieNameString = cookieName;
@@ -155,11 +160,12 @@ void deleteCookie(const Document*, const KURL& url, const String& cookieName)
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-void getHostnamesWithCookies(HashSet<String>& hostnames)
+void getHostnamesWithCookies(NetworkingContext* context, HashSet<String>& hostnames)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    NSArray *cookies = wkHTTPCookies(defaultCFHTTPCookieStorage().get());
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
+    NSArray *cookies = wkHTTPCookies(cookieStorage.get());
     
     for (NSHTTPCookie* cookie in cookies)
         hostnames.add([cookie domain]);
@@ -167,11 +173,11 @@ void getHostnamesWithCookies(HashSet<String>& hostnames)
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-void deleteCookiesForHostname(const String& hostname)
+void deleteCookiesForHostname(NetworkingContext* context, const String& hostname)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = defaultCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
     NSArray *cookies = wkHTTPCookies(cookieStorage.get());
     if (!cookies)
         return;
@@ -184,9 +190,10 @@ void deleteCookiesForHostname(const String& hostname)
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-void deleteAllCookies()
+void deleteAllCookies(NetworkingContext* context)
 {
-    wkDeleteAllHTTPCookies(defaultCFHTTPCookieStorage().get());
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage();
+    wkDeleteAllHTTPCookies(cookieStorage.get());
 }
 
 }
 #include "CookieJarQt.h"
 
 #include "Cookie.h"
-#include "CookieJar.h"
-#include "Document.h"
-#include "Frame.h"
-#include "FrameLoader.h"
 #include "KURL.h"
 #include "NetworkingContext.h"
+#include "PlatformCookieJar.h"
 #include "ThirdPartyCookiesQt.h"
 #include <QDateTime>
 #include <QNetworkAccessManager>
@@ -49,30 +46,14 @@ namespace WebCore {
 
 static SharedCookieJarQt* s_sharedCookieJarQt = 0;
 
-static NetworkingContext* networkingContext(const Document* document)
+void setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& value)
 {
-    if (!document)
-        return 0;
-    Frame* frame = document->frame();
-    if (!frame)
-        return 0;
-    FrameLoader* loader = frame->loader();
-    if (!loader)
-        return 0;
-    return loader->networkingContext();
-}
-
-void setCookies(Document* document, const KURL& url, const String& value)
-{
-    NetworkingContext* context = networkingContext(document);
-    if (!context)
-        return;
-    QNetworkCookieJar* jar = context->networkAccessManager()->cookieJar();
+    QNetworkCookieJar* jar = context ? context->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared();
     if (!jar)
         return;
 
     QUrl urlForCookies(url);
-    QUrl firstPartyUrl(document->firstPartyForCookies());
+    QUrl firstPartyUrl(firstParty);
     if (!thirdPartyCookiePolicyPermits(context, urlForCookies, firstPartyUrl))
         return;
 
@@ -88,15 +69,14 @@ void setCookies(Document* document, const KURL& url, const String& value)
     jar->setCookiesFromUrl(cookies, urlForCookies);
 }
 
-String cookies(const Document* document, const KURL& url)
+String cookiesForDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url)
 {
-    NetworkingContext* context = networkingContext(document);
-    if (!context)
+    QNetworkCookieJar* jar = context ? context->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared();
+    if (!jar)
         return String();
-    QNetworkCookieJar* jar = context->networkAccessManager()->cookieJar();
 
     QUrl urlForCookies(url);
-    QUrl firstPartyUrl(document->firstPartyForCookies());
+    QUrl firstPartyUrl(firstParty);
     if (!thirdPartyCookiePolicyPermits(context, urlForCookies, firstPartyUrl))
         return String();
 
@@ -114,12 +94,11 @@ String cookies(const Document* document, const KURL& url)
     return resultCookies.join(QLatin1String("; "));
 }
 
-String cookieRequestHeaderFieldValue(const Document* document, const KURL &url)
+String cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL &url)
 {
-    NetworkingContext* context = networkingContext(document);
-    if (!context)
+    QNetworkCookieJar* jar = context ? context->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared();
+    if (!jar)
         return String();
-    QNetworkCookieJar* jar = context->networkAccessManager()->cookieJar();
 
     QList<QNetworkCookie> cookies = jar->cookiesForUrl(QUrl(url));
     if (cookies.isEmpty())
@@ -132,42 +111,43 @@ String cookieRequestHeaderFieldValue(const Document* document, const KURL &url)
     return resultCookies.join(QLatin1String("; "));
 }
 
-bool cookiesEnabled(const Document* document)
+bool cookiesEnabled(NetworkingContext* context)
 {
-    NetworkingContext* context = networkingContext(document);
-    if (!context)
-        return false;
-    return context->networkAccessManager()->cookieJar();
+    QNetworkCookieJar* jar = context ? context->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared();
+    return !!jar;
 }
 
-bool getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies)
+bool getRawCookies(NetworkingContext*, const KURL&, Vector<Cookie>& rawCookies)
 {
     // FIXME: Not yet implemented
     rawCookies.clear();
     return false; // return true when implemented
 }
 
-void deleteCookie(const Document*, const KURL&, const String&)
+void deleteCookie(NetworkingContext*, const KURL&, const String&)
 {
     // FIXME: Not yet implemented
 }
 
-void getHostnamesWithCookies(HashSet<String>& hostnames)
+void getHostnamesWithCookies(NetworkingContext* context, HashSet<String>& hostnames)
 {
+    ASSERT_UNUSED(context, !context); // Not yet implemented for cookie jars other than the shared one.
     SharedCookieJarQt* jar = SharedCookieJarQt::shared();
     if (jar)
         jar->getHostnamesWithCookies(hostnames);
 }
 
-void deleteCookiesForHostname(const String& hostname)
+void deleteCookiesForHostname(NetworkingContext* context, const String& hostname)
 {
+    ASSERT_UNUSED(context, !context); // Not yet implemented for cookie jars other than the shared one.
     SharedCookieJarQt* jar = SharedCookieJarQt::shared();
     if (jar)
         jar->deleteCookiesForHostname(hostname);
 }
 
-void deleteAllCookies()
+void deleteAllCookies(NetworkingContext* context)
 {
+    ASSERT_UNUSED(context, !context); // Not yet implemented for cookie jars other than the shared one.
     SharedCookieJarQt* jar = SharedCookieJarQt::shared();
     if (jar)
         jar->deleteAllCookies();
index cea1156..7194df1 100644 (file)
 #include "CookieJarSoup.h"
 
 #include "Cookie.h"
-#include "Document.h"
-#include "Frame.h"
-#include "FrameLoader.h"
 #include "GOwnPtrSoup.h"
 #include "KURL.h"
 #include "NetworkingContext.h"
+#include "PlatformCookieJar.h"
 #include "ResourceHandle.h"
 #include <wtf/gobject/GRefPtr.h>
 #include <wtf/text/CString.h>
 
 namespace WebCore {
 
-static SoupCookieJar* cookieJarForDocument(const Document* document)
+static SoupCookieJar* cookieJarForContext(NetworkingContext* context)
 {
-    if (!document)
-        return 0;
-    const Frame* frame = document->frame();
-    if (!frame)
-        return 0;
-    const FrameLoader* loader = frame->loader();
-    if (!loader)
-        return 0;
-    const NetworkingContext* context = loader->networkingContext();
-    if (!context)
-        return 0;
     return SOUP_COOKIE_JAR(soup_session_get_feature(context->soupSession(), SOUP_TYPE_COOKIE_JAR));
 }
 
@@ -86,14 +73,14 @@ static inline bool httpOnlyCookieExists(const GSList* cookies, const gchar* name
     return false;
 }
 
-void setCookies(Document* document, const KURL& url, const String& value)
+void setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& value)
 {
-    SoupCookieJar* jar = cookieJarForDocument(document);
+    SoupCookieJar* jar = context ? cookieJarForContext(context) : soupCookieJar();
     if (!jar)
         return;
 
     GOwnPtr<SoupURI> origin(soup_uri_new(url.string().utf8().data()));
-    GOwnPtr<SoupURI> firstParty(soup_uri_new(document->firstPartyForCookies().string().utf8().data()));
+    GOwnPtr<SoupURI> firstPartyURI(soup_uri_new(firstParty.string().utf8().data()));
 
     // Get existing cookies for this origin.
     GSList* existingCookies = soup_cookie_jar_get_cookie_list(jar, origin.get(), TRUE);
@@ -114,15 +101,15 @@ void setCookies(Document* document, const KURL& url, const String& value)
         if (httpOnlyCookieExists(existingCookies, soup_cookie_get_name(cookie.get()), soup_cookie_get_path(cookie.get())))
             continue;
 
-        soup_cookie_jar_add_cookie_with_first_party(jar, firstParty.get(), cookie.release());
+        soup_cookie_jar_add_cookie_with_first_party(jar, firstPartyURI.get(), cookie.release());
     }
 
     soup_cookies_free(existingCookies);
 }
 
-static String cookiesForDocument(const Document* document, const KURL& url, bool forHTTPHeader)
+static String cookiesForContext(NetworkingContext* context, const KURL& url, bool forHTTPHeader)
 {
-    SoupCookieJar* jar = cookieJarForDocument(document);
+    SoupCookieJar* jar = context ? cookieJarForContext(context) : soupCookieJar();
     if (!jar)
         return String();
 
@@ -131,25 +118,25 @@ static String cookiesForDocument(const Document* document, const KURL& url, bool
     return String::fromUTF8(cookies.get());
 }
 
-String cookies(const Document* document, const KURL& url)
+String cookiesForDOM(NetworkingContext* context, const KURL&, const KURL& url)
 {
-    return cookiesForDocument(document, url, false);
+    return cookiesForContext(context, url, false);
 }
 
-String cookieRequestHeaderFieldValue(const Document* document, const KURL& url)
+String cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& url)
 {
-    return cookiesForDocument(document, url, true);
+    return cookiesForContext(context, url, true);
 }
 
-bool cookiesEnabled(const Document* document)
+bool cookiesEnabled(NetworkingContext* context)
 {
-    return !!cookieJarForDocument(document);
+    return !!cookieJarForContext(context);
 }
 
-bool getRawCookies(const Document* document, const KURL& url, Vector<Cookie>& rawCookies)
+bool getRawCookies(NetworkingContext* context, const KURL& url, Vector<Cookie>& rawCookies)
 {
     rawCookies.clear();
-    SoupCookieJar* jar = cookieJarForDocument(document);
+    SoupCookieJar* jar = context ? cookieJarForContext(context) : soupCookieJar();
     if (!jar)
         return false;
 
@@ -170,9 +157,9 @@ bool getRawCookies(const Document* document, const KURL& url, Vector<Cookie>& ra
     return true;
 }
 
-void deleteCookie(const Document* document, const KURL& url, const String& name)
+void deleteCookie(NetworkingContext* context, const KURL& url, const String& name)
 {
-    SoupCookieJar* jar = cookieJarForDocument(document);
+    SoupCookieJar* jar = context ? cookieJarForContext(context) : soupCookieJar();
     if (!jar)
         return;
 
@@ -191,9 +178,9 @@ void deleteCookie(const Document* document, const KURL& url, const String& name)
     }
 }
 
-void getHostnamesWithCookies(HashSet<String>& hostnames)
+void getHostnamesWithCookies(NetworkingContext* context, HashSet<String>& hostnames)
 {
-    SoupCookieJar* cookieJar = soupCookieJar();
+    SoupCookieJar* cookieJar = context ? cookieJarForContext(context) : soupCookieJar();
     GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar));
     for (GSList* item = cookies.get(); item; item = g_slist_next(item)) {
         GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(item->data));
@@ -203,10 +190,10 @@ void getHostnamesWithCookies(HashSet<String>& hostnames)
     }
 }
 
-void deleteCookiesForHostname(const String& hostname)
+void deleteCookiesForHostname(NetworkingContext* context, const String& hostname)
 {
     CString hostNameString = hostname.utf8();
-    SoupCookieJar* cookieJar = soupCookieJar();
+    SoupCookieJar* cookieJar = context ? cookieJarForContext(context) : soupCookieJar();
     GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar));
     for (GSList* item = cookies.get(); item; item = g_slist_next(item)) {
         SoupCookie* cookie = static_cast<SoupCookie*>(item->data);
@@ -216,9 +203,9 @@ void deleteCookiesForHostname(const String& hostname)
     }
 }
 
-void deleteAllCookies()
+void deleteAllCookies(NetworkingContext* context)
 {
-    SoupCookieJar* cookieJar = soupCookieJar();
+    SoupCookieJar* cookieJar = context ? cookieJarForContext(context) : soupCookieJar();
     GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar));
     for (GSList* item = cookies.get(); item; item = g_slist_next(item)) {
         SoupCookie* cookie = static_cast<SoupCookie*>(item->data);
index 251b136..28930ce 100644 (file)
@@ -27,7 +27,6 @@
 #ifndef CookieJarSoup_h
 #define CookieJarSoup_h
 
-#include "CookieJar.h"
 #include <libsoup/soup.h>
 
 namespace WebCore {
index 089fd41..98096de 100644 (file)
  */
 
 #include "config.h"
-#include "CookieJar.h"
+#include "PlatformCookieJar.h"
 
 #include "Cookie.h"
 #include "KURL.h"
-#include "Document.h"
 #include "ResourceHandle.h"
 #include <windows.h>
 #include <Wininet.h>
 
 namespace WebCore {
 
-void setCookies(Document* /*document*/, const KURL& url, const String& value)
+void setCookiesFromDOM(NetworkingContext*, const KURL&, const KURL& url, const String& value)
 {
-    // FIXME: Deal with document->firstPartyForCookies().
+    // FIXME: Deal with firstParty argument.
     String str = url.string();
     String val = value;
     InternetSetCookie(str.charactersWithNullTermination(), 0, val.charactersWithNullTermination());
 }
 
-String cookies(const Document* /*document*/, const KURL& url)
+String cookiesForDOM(NetworkingContext*, const KURL&, const KURL& url)
 {
+    // FIXME: Deal with firstParty argument.
+
     String str = url.string();
 
     DWORD count = 0;
@@ -63,40 +64,40 @@ String cookies(const Document* /*document*/, const KURL& url)
     return String::adopt(buffer);
 }
 
-String cookieRequestHeaderFieldValue(const Document* document, const KURL& url)
+String cookieRequestHeaderFieldValue(NetworkingContext*, const KURL& url)
 {
     // FIXME: include HttpOnly cookie
-    return cookies(document, url);
+    return cookiesForDOM(context, url);
 }
 
-bool cookiesEnabled(const Document* /*document*/)
+bool cookiesEnabled(NetworkingContext*)
 {
     return true;
 }
 
-bool getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies)
+bool getRawCookies(NetworkingContext*, const KURL&, Vector<Cookie>& rawCookies)
 {
     // FIXME: Not yet implemented
     rawCookies.clear();
     return false; // return true when implemented
 }
 
-void deleteCookie(const Document*, const KURL&, const String&)
+void deleteCookie(NetworkingContext*, const KURL&, const String&)
 {
     // FIXME: Not yet implemented
 }
 
-void getHostnamesWithCookies(HashSet<String>& hostnames)
+void getHostnamesWithCookies(NetworkingContext*, HashSet<String>& hostnames)
 {
     // FIXME: Not yet implemented
 }
 
-void deleteCookiesForHostname(const String& hostname)
+void deleteCookiesForHostname(NetworkingContext*, const String& hostname)
 {
     // FIXME: Not yet implemented
 }
 
-void deleteAllCookies()
+void deleteAllCookies(NetworkingContext*)
 {
     // FIXME: Not yet implemented
 }
index 899505c..8928654 100644 (file)
@@ -1,3 +1,12 @@
+2012-11-09  Alexey Proskuryakov  <ap@apple.com>
+
+        CookieJar uses Document class, which is a layering violation
+        https://bugs.webkit.org/show_bug.cgi?id=101621
+
+        Reviewed by Brady Eidson.
+
+        * UIProcess/API/C/WKAPICast.h: Don't include CookieJar.h, its completely unnecessary.
+
 2012-11-09  peavo@outlook.com  <peavo@outlook.com>
 
         WinCairo build fails to link
index 713b4f8..3c0584c 100644 (file)
@@ -42,7 +42,6 @@
 #include "WKProtectionSpaceTypes.h"
 #include "WKResourceCacheManager.h"
 #include "WKSharedAPICast.h"
-#include <WebCore/CookieJar.h>
 #include <WebCore/Credential.h>
 #include <WebCore/FrameLoaderTypes.h>
 #include <WebCore/ProtectionSpace.h>