From e70df65f180f4296d450becf3d63d7524315fd11 Mon Sep 17 00:00:00 2001 From: "ap@apple.com" Date: Fri, 9 Nov 2012 18:08:04 +0000 Subject: [PATCH] CookieJar uses Document class, which is a layering violation 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 --- Source/WebCore/CMakeLists.txt | 1 + Source/WebCore/ChangeLog | 116 +++++++++++++++++++++ Source/WebCore/GNUmakefile.list.am | 4 +- Source/WebCore/PlatformBlackBerry.cmake | 2 +- Source/WebCore/Target.pri | 7 +- Source/WebCore/WebCore.gyp/WebCore.gyp | 1 + Source/WebCore/WebCore.gypi | 10 +- Source/WebCore/WebCore.vcproj/WebCore.vcproj | 16 ++- Source/WebCore/WebCore.xcodeproj/project.pbxproj | 24 +++-- Source/WebCore/loader/CookieJar.cpp | 97 +++++++++++++++++ Source/WebCore/{platform => loader}/CookieJar.h | 8 +- .../blackberry/CookieJarBlackBerry.cpp | 2 + .../chromium/CookieJarChromium.cpp | 2 + .../WebCore/platform/network/PlatformCookieJar.h | 53 ++++++++++ .../WebCore/platform/network/cf/CookieJarCFNet.cpp | 44 ++++---- .../platform/network/curl/CookieJarCurl.cpp | 21 ++-- .../CookieJar.mm => network/mac/CookieJarMac.mm} | 47 +++++---- .../platform/{ => network}/qt/CookieJarQt.cpp | 64 ++++-------- .../platform/{ => network}/qt/CookieJarQt.h | 0 .../platform/network/soup/CookieJarSoup.cpp | 61 +++++------ .../WebCore/platform/network/soup/CookieJarSoup.h | 1 - .../WebCore/platform/network/win/CookieJarWin.cpp | 27 ++--- Source/WebKit2/ChangeLog | 9 ++ Source/WebKit2/UIProcess/API/C/WKAPICast.h | 1 - 24 files changed, 447 insertions(+), 171 deletions(-) create mode 100644 Source/WebCore/loader/CookieJar.cpp rename Source/WebCore/{platform => loader}/CookieJar.h (90%) rename Source/WebCore/{platform => loader}/blackberry/CookieJarBlackBerry.cpp (96%) rename Source/WebCore/{platform/network => loader}/chromium/CookieJarChromium.cpp (95%) create mode 100644 Source/WebCore/platform/network/PlatformCookieJar.h rename Source/WebCore/platform/{mac/CookieJar.mm => network/mac/CookieJarMac.mm} (69%) rename Source/WebCore/platform/{ => network}/qt/CookieJarQt.cpp (83%) rename Source/WebCore/platform/{ => network}/qt/CookieJarQt.h (100%) diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt index d0d5688..9abb139 100644 --- a/Source/WebCore/CMakeLists.txt +++ b/Source/WebCore/CMakeLists.txt @@ -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 diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index b22b4d3..43da99e 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,119 @@ +2012-11-09 Alexey Proskuryakov + + 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 [css] Text decoration's "blink" not valid when CSS3_TEXT is enabled diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am index 3df9dd9..76b68fb 100644 --- a/Source/WebCore/GNUmakefile.list.am +++ b/Source/WebCore/GNUmakefile.list.am @@ -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 \ diff --git a/Source/WebCore/PlatformBlackBerry.cmake b/Source/WebCore/PlatformBlackBerry.cmake index 622d0ee..161c1c6 100644 --- a/Source/WebCore/PlatformBlackBerry.cmake +++ b/Source/WebCore/PlatformBlackBerry.cmake @@ -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 diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri index 74665e1..6e16eb1 100644 --- a/Source/WebCore/Target.pri +++ b/Source/WebCore/Target.pri @@ -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 \ diff --git a/Source/WebCore/WebCore.gyp/WebCore.gyp b/Source/WebCore/WebCore.gyp/WebCore.gyp index 2190572..ed29453 100644 --- a/Source/WebCore/WebCore.gyp/WebCore.gyp +++ b/Source/WebCore/WebCore.gyp/WebCore.gyp @@ -2075,6 +2075,7 @@ ['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$'], diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi index c465606..0c9635b 100644 --- a/Source/WebCore/WebCore.gypi +++ b/Source/WebCore/WebCore.gypi @@ -159,6 +159,7 @@ 'inspector/InspectorValues.h', 'inspector/ScriptBreakpoint.h', 'inspector/ScriptDebugListener.h', + 'loader/CookieJar.h', 'loader/CrossOriginPreflightResultCache.h', 'loader/DocumentLoadTiming.h', 'loader/DocumentLoader.h', @@ -273,7 +274,6 @@ 'platform/ContextMenu.h', 'platform/ContextMenuItem.h', 'platform/Cookie.h', - 'platform/CookieJar.h', 'platform/CookiesStrategy.h', 'platform/Cursor.h', 'platform/DateComponents.h', @@ -312,6 +312,7 @@ 'platform/PlatformMouseEvent.h', 'platform/PlatformScreen.h', 'platform/PlatformStrategies.h', + 'platform/PlatformCookieJar.h', 'platform/PlatformWheelEvent.h', 'platform/PopupMenu.h', 'platform/PopupMenuClient.h', @@ -2955,6 +2956,7 @@ 'inspector/WorkerRuntimeAgent.h', 'loader/CachedMetadata.cpp', 'loader/CachedMetadata.h', + 'loader/CookieJar.cpp', 'loader/CrossOriginAccessControl.cpp', 'loader/CrossOriginAccessControl.h', 'loader/CrossOriginPreflightResultCache.cpp', @@ -3062,6 +3064,7 @@ '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', @@ -5466,7 +5469,6 @@ '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', @@ -5584,7 +5586,6 @@ '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', @@ -5612,6 +5613,7 @@ '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', @@ -5622,6 +5624,7 @@ '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', @@ -5672,7 +5675,6 @@ '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', diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj index b53e715..45df063 100755 --- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj +++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj @@ -27415,6 +27415,14 @@ > + + + + @@ -28287,10 +28295,6 @@ > - - @@ -32518,6 +32522,10 @@ > + + diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj index 1893326..1bcdd18 100644 --- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj @@ -3271,8 +3271,6 @@ 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, ); }; }; @@ -6047,6 +6045,10 @@ 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 */; }; @@ -10496,8 +10498,6 @@ 93500F3113FDE3BE0099EC24 /* NSScrollerImpDetails.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSScrollerImpDetails.h; sourceTree = ""; }; 935207BD09BD410A00F2038D /* LocalizedStrings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalizedStrings.h; sourceTree = ""; }; 9352084409BD43B900F2038D /* Language.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Language.mm; sourceTree = ""; }; - 9352087609BD453400F2038D /* CookieJar.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieJar.mm; sourceTree = ""; }; - 9352088109BD45E900F2038D /* CookieJar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CookieJar.h; sourceTree = ""; }; 9353676A09AED88B00D35CD6 /* ScrollViewMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollViewMac.mm; sourceTree = ""; }; 935C476209AC4CE600A6AAB4 /* MouseEventWithHitTestResults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MouseEventWithHitTestResults.h; sourceTree = ""; }; 935C476609AC4D4300A6AAB4 /* PlatformKeyboardEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformKeyboardEvent.h; sourceTree = ""; }; @@ -13448,6 +13448,10 @@ E139866215478474001E3F65 /* StyleResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleResolver.h; sourceTree = ""; }; E13F01EA1270E10D00DFBA71 /* CookieStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CookieStorage.h; sourceTree = ""; }; E13F01F01270E19000DFBA71 /* CookieStorageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieStorageMac.mm; sourceTree = ""; }; + E1424C89164B3B4E00F32D40 /* PlatformCookieJar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformCookieJar.h; path = network/PlatformCookieJar.h; sourceTree = ""; }; + E1424C8F164B460B00F32D40 /* CookieJarMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieJarMac.mm; sourceTree = ""; }; + E1424C91164B52C800F32D40 /* CookieJar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CookieJar.cpp; sourceTree = ""; }; + E1424C92164B52C800F32D40 /* CookieJar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CookieJar.h; sourceTree = ""; }; E14F1C4214B5DAC600EA9009 /* HTMLFormControlElementWithState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLFormControlElementWithState.cpp; sourceTree = ""; }; E14F1C4314B5DAC600EA9009 /* HTMLFormControlElementWithState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLFormControlElementWithState.h; sourceTree = ""; }; E15A36D61104572000B7B639 /* XMLNSNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLNSNames.h; sourceTree = ""; }; @@ -15713,6 +15717,7 @@ 514C76440CE9234E007EF3CD /* FormDataStreamMac.h */, 514C76450CE9234E007EF3CD /* FormDataStreamMac.mm */, 1A7FA6470DDA3CBA0028F8A5 /* NetworkStateNotifierMac.cpp */, + E1424C8F164B460B00F32D40 /* CookieJarMac.mm */, 514C76460CE9234E007EF3CD /* ResourceErrorMac.mm */, 514C76470CE9234E007EF3CD /* ResourceHandleMac.mm */, 514C76490CE9234E007EF3CD /* ResourceRequestMac.mm */, @@ -15735,7 +15740,6 @@ 2D90660C0665D937006B6F1A /* ClipboardMac.mm */, 06027CB20B1CC03D00884B2D /* ContextMenuItemMac.mm */, 93B6A0E90B0BCA8400F5027A /* ContextMenuMac.mm */, - 9352087609BD453400F2038D /* CookieJar.mm */, F58784F002DE375901EA4122 /* CursorMac.mm */, 5D8C4DBD1428222C0026CE72 /* DisplaySleepDisabler.cpp */, 5D8C4DBE1428222C0026CE72 /* DisplaySleepDisabler.h */, @@ -20696,6 +20700,8 @@ E1C416160F6563180092D2FB /* CrossOriginAccessControl.cpp */, 4FC853491644271B00D1C275 /* CachedMetadata.cpp */, 4FC8534A1644271B00D1C275 /* CachedMetadata.h */, + E1424C91164B52C800F32D40 /* CookieJar.cpp */, + E1424C92164B52C800F32D40 /* CookieJar.h */, E1C416110F6562FD0092D2FB /* CrossOriginAccessControl.h */, E1C415DD0F655D7C0092D2FB /* CrossOriginPreflightResultCache.cpp */, E1C415D90F655D6F0092D2FB /* CrossOriginPreflightResultCache.h */, @@ -20860,7 +20866,6 @@ 93B6A0E50B0BCA5C00F5027A /* ContextMenu.h */, 06027CAC0B1CBFC000884B2D /* ContextMenuItem.h */, D8B6152E1032495100C8554A /* Cookie.h */, - 9352088109BD45E900F2038D /* CookieJar.h */, 339B5B62131DAA3200F48D02 /* CookiesStrategy.h */, 2E4346560F546A9900B0F1BA /* CrossThreadCopier.cpp */, 2E4346570F546A9900B0F1BA /* CrossThreadCopier.h */, @@ -20923,6 +20928,7 @@ 98EB1F941313FE0500D0E1EA /* NotImplemented.h */, 4B2708C50AF19EE40065127F /* Pasteboard.h */, C5F765B414E1D414006C899B /* PasteboardStrategy.h */, + E1424C89164B3B4E00F32D40 /* PlatformCookieJar.h */, BC5C76281497FE1400BC4775 /* PlatformEvent.cpp */, BC5C76291497FE1400BC4775 /* PlatformEvent.h */, A723F77A1484CA4C008C6DBE /* PlatformExportMacros.h */, @@ -22627,7 +22633,6 @@ 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 */, @@ -25687,6 +25692,8 @@ 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; @@ -26206,7 +26213,6 @@ 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 */, @@ -28774,6 +28780,8 @@ 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 index 0000000..56077dc --- /dev/null +++ b/Source/WebCore/loader/CookieJar.cpp @@ -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& 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& hostnames) +{ + getHostnamesWithCookies(0, hostnames); +} + +void deleteCookiesForHostname(const String& hostname) +{ + deleteCookiesForHostname(0, hostname); +} + +void deleteAllCookies() +{ + deleteAllCookies(0); +} + +} diff --git a/Source/WebCore/platform/CookieJar.h b/Source/WebCore/loader/CookieJar.h similarity index 90% rename from Source/WebCore/platform/CookieJar.h rename to Source/WebCore/loader/CookieJar.h index f4cfd86..1562265 100644 --- a/Source/WebCore/platform/CookieJar.h +++ b/Source/WebCore/loader/CookieJar.h @@ -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 #include -#include #include +#include 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&); -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& hostnames); diff --git a/Source/WebCore/platform/blackberry/CookieJarBlackBerry.cpp b/Source/WebCore/loader/blackberry/CookieJarBlackBerry.cpp similarity index 96% rename from Source/WebCore/platform/blackberry/CookieJarBlackBerry.cpp rename to Source/WebCore/loader/blackberry/CookieJarBlackBerry.cpp index f47e789..7812022 100644 --- a/Source/WebCore/platform/blackberry/CookieJarBlackBerry.cpp +++ b/Source/WebCore/loader/blackberry/CookieJarBlackBerry.cpp @@ -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(); diff --git a/Source/WebCore/platform/network/chromium/CookieJarChromium.cpp b/Source/WebCore/loader/chromium/CookieJarChromium.cpp similarity index 95% rename from Source/WebCore/platform/network/chromium/CookieJarChromium.cpp rename to Source/WebCore/loader/chromium/CookieJarChromium.cpp index b71a0a6..cb7cae7 100644 --- a/Source/WebCore/platform/network/chromium/CookieJarChromium.cpp +++ b/Source/WebCore/loader/chromium/CookieJarChromium.cpp @@ -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 index 0000000..deb7a79 --- /dev/null +++ b/Source/WebCore/platform/network/PlatformCookieJar.h @@ -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 +#include +#include +#include + +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&); +void deleteCookie(NetworkingContext*, const KURL&, const String&); +void getHostnamesWithCookies(NetworkingContext*, HashSet& hostnames); +void deleteCookiesForHostname(NetworkingContext*, const String& hostname); +void deleteAllCookies(NetworkingContext*); + +} + +#endif diff --git a/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp b/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp index 10dfbc6..9c86d05 100644 --- a/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp +++ b/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp @@ -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 @@ -24,13 +24,12 @@ */ #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 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) { // CFHTTPCookieStorage stores an empty cookie, which would be sent as "Cookie: =". if (value.isEmpty()) return; - RetainPtr cookieStorage = currentCFHTTPCookieStorage(); + RetainPtr cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage(); if (!cookieStorage) return; RetainPtr urlCF(AdoptCF, url.createCFURL()); - RetainPtr firstPartyForCookiesCF(AdoptCF, document->firstPartyForCookies().createCFURL()); + RetainPtr firstPartyForCookiesCF(AdoptCF, firstParty.createCFURL()); // , // 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 cookieStorage = currentCFHTTPCookieStorage(); + RetainPtr 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 cookieStorage = currentCFHTTPCookieStorage(); + RetainPtr 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 cookieStorage = currentCFHTTPCookieStorage()) + RetainPtr cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage(); + if (cookieStorage) policy = CFHTTPCookieStorageGetCookieAcceptPolicy(cookieStorage.get()); return policy == CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain || policy == CFHTTPCookieStorageAcceptPolicyAlways; } -bool getRawCookies(const Document*, const KURL& url, Vector& rawCookies) +bool getRawCookies(NetworkingContext* context, const KURL& url, Vector& rawCookies) { rawCookies.clear(); - RetainPtr cookieStorage = currentCFHTTPCookieStorage(); + RetainPtr cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage(); if (!cookieStorage) return false; @@ -193,9 +193,9 @@ bool getRawCookies(const Document*, const KURL& url, Vector& rawCookies) return true; } -void deleteCookie(const Document*, const KURL& url, const String& name) +void deleteCookie(NetworkingContext* context, const KURL& url, const String& name) { - RetainPtr cookieStorage = currentCFHTTPCookieStorage(); + RetainPtr cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage(); if (!cookieStorage) return; @@ -214,9 +214,9 @@ void deleteCookie(const Document*, const KURL& url, const String& name) } } -void getHostnamesWithCookies(HashSet& hostnames) +void getHostnamesWithCookies(NetworkingContext* context, HashSet& hostnames) { - RetainPtr cookieStorage = defaultCFHTTPCookieStorage(); + RetainPtr cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage(); if (!cookieStorage) return; @@ -232,9 +232,9 @@ void getHostnamesWithCookies(HashSet& hostnames) } } -void deleteCookiesForHostname(const String& hostname) +void deleteCookiesForHostname(NetworkingContext* context, const String& hostname) { - RetainPtr cookieStorage = defaultCFHTTPCookieStorage(); + RetainPtr cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage(); if (!cookieStorage) return; @@ -251,9 +251,9 @@ void deleteCookiesForHostname(const String& hostname) } } -void deleteAllCookies() +void deleteAllCookies(NetworkingContext* context) { - RetainPtr cookieStorage = defaultCFHTTPCookieStorage(); + RetainPtr cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage(); if (!cookieStorage) return; diff --git a/Source/WebCore/platform/network/curl/CookieJarCurl.cpp b/Source/WebCore/platform/network/curl/CookieJarCurl.cpp index b522dbc..e03bd1d 100644 --- a/Source/WebCore/platform/network/curl/CookieJarCurl.cpp +++ b/Source/WebCore/platform/network/curl/CookieJarCurl.cpp @@ -15,10 +15,9 @@ */ #include "config.h" -#include "CookieJar.h" +#include "PlatformCookieJar.h" #include "Cookie.h" -#include "Document.h" #include "KURL.h" #include #include @@ -28,50 +27,50 @@ namespace WebCore { static HashMap 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& rawCookies) +bool getRawCookies(NetworkingContext*, const KURL&, Vector& 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& hostnames) +void getHostnamesWithCookies(NetworkingContext*, HashSet& 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 } diff --git a/Source/WebCore/platform/mac/CookieJar.mm b/Source/WebCore/platform/network/mac/CookieJarMac.mm similarity index 69% rename from Source/WebCore/platform/mac/CookieJar.mm rename to Source/WebCore/platform/network/mac/CookieJarMac.mm index b6d82ae..7acbc75 100644 --- a/Source/WebCore/platform/mac/CookieJar.mm +++ b/Source/WebCore/platform/network/mac/CookieJarMac.mm @@ -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 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 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 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 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 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(wkGetHTTPCookieAcceptPolicy(currentCFHTTPCookieStorage().get())); + RetainPtr cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage(); + NSHTTPCookieAcceptPolicy cookieAcceptPolicy = static_cast(wkGetHTTPCookieAcceptPolicy(cookieStorage.get())); return cookieAcceptPolicy == NSHTTPCookieAcceptPolicyAlways || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain; END_BLOCK_OBJC_EXCEPTIONS; return false; } -bool getRawCookies(const Document*, const KURL& url, Vector& rawCookies) +bool getRawCookies(NetworkingContext* context, const KURL& url, Vector& rawCookies) { rawCookies.clear(); BEGIN_BLOCK_OBJC_EXCEPTIONS; - NSArray *cookies = wkHTTPCookiesForURL(currentCFHTTPCookieStorage().get(), url); + RetainPtr 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& 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 cookieStorage = currentCFHTTPCookieStorage(); + RetainPtr 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& hostnames) +void getHostnamesWithCookies(NetworkingContext* context, HashSet& hostnames) { BEGIN_BLOCK_OBJC_EXCEPTIONS; - NSArray *cookies = wkHTTPCookies(defaultCFHTTPCookieStorage().get()); + RetainPtr 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& hostnames) END_BLOCK_OBJC_EXCEPTIONS; } -void deleteCookiesForHostname(const String& hostname) +void deleteCookiesForHostname(NetworkingContext* context, const String& hostname) { BEGIN_BLOCK_OBJC_EXCEPTIONS; - RetainPtr cookieStorage = defaultCFHTTPCookieStorage(); + RetainPtr 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 cookieStorage = context ? currentCFHTTPCookieStorage() : defaultCFHTTPCookieStorage(); + wkDeleteAllHTTPCookies(cookieStorage.get()); } } diff --git a/Source/WebCore/platform/qt/CookieJarQt.cpp b/Source/WebCore/platform/network/qt/CookieJarQt.cpp similarity index 83% rename from Source/WebCore/platform/qt/CookieJarQt.cpp rename to Source/WebCore/platform/network/qt/CookieJarQt.cpp index 68665b3..d4f1a68 100644 --- a/Source/WebCore/platform/qt/CookieJarQt.cpp +++ b/Source/WebCore/platform/network/qt/CookieJarQt.cpp @@ -30,12 +30,9 @@ #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 #include @@ -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 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& rawCookies) +bool getRawCookies(NetworkingContext*, const KURL&, Vector& 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& hostnames) +void getHostnamesWithCookies(NetworkingContext* context, HashSet& 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(); diff --git a/Source/WebCore/platform/qt/CookieJarQt.h b/Source/WebCore/platform/network/qt/CookieJarQt.h similarity index 100% rename from Source/WebCore/platform/qt/CookieJarQt.h rename to Source/WebCore/platform/network/qt/CookieJarQt.h diff --git a/Source/WebCore/platform/network/soup/CookieJarSoup.cpp b/Source/WebCore/platform/network/soup/CookieJarSoup.cpp index cea1156..7194df1 100644 --- a/Source/WebCore/platform/network/soup/CookieJarSoup.cpp +++ b/Source/WebCore/platform/network/soup/CookieJarSoup.cpp @@ -22,31 +22,18 @@ #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 #include 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 origin(soup_uri_new(url.string().utf8().data())); - GOwnPtr firstParty(soup_uri_new(document->firstPartyForCookies().string().utf8().data())); + GOwnPtr 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& rawCookies) +bool getRawCookies(NetworkingContext* context, const KURL& url, Vector& 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& 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& hostnames) +void getHostnamesWithCookies(NetworkingContext* context, HashSet& hostnames) { - SoupCookieJar* cookieJar = soupCookieJar(); + SoupCookieJar* cookieJar = context ? cookieJarForContext(context) : soupCookieJar(); GOwnPtr cookies(soup_cookie_jar_all_cookies(cookieJar)); for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { GOwnPtr cookie(static_cast(item->data)); @@ -203,10 +190,10 @@ void getHostnamesWithCookies(HashSet& 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 cookies(soup_cookie_jar_all_cookies(cookieJar)); for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { SoupCookie* cookie = static_cast(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 cookies(soup_cookie_jar_all_cookies(cookieJar)); for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { SoupCookie* cookie = static_cast(item->data); diff --git a/Source/WebCore/platform/network/soup/CookieJarSoup.h b/Source/WebCore/platform/network/soup/CookieJarSoup.h index 251b136..28930ce 100644 --- a/Source/WebCore/platform/network/soup/CookieJarSoup.h +++ b/Source/WebCore/platform/network/soup/CookieJarSoup.h @@ -27,7 +27,6 @@ #ifndef CookieJarSoup_h #define CookieJarSoup_h -#include "CookieJar.h" #include namespace WebCore { diff --git a/Source/WebCore/platform/network/win/CookieJarWin.cpp b/Source/WebCore/platform/network/win/CookieJarWin.cpp index 089fd41..98096de 100644 --- a/Source/WebCore/platform/network/win/CookieJarWin.cpp +++ b/Source/WebCore/platform/network/win/CookieJarWin.cpp @@ -24,11 +24,10 @@ */ #include "config.h" -#include "CookieJar.h" +#include "PlatformCookieJar.h" #include "Cookie.h" #include "KURL.h" -#include "Document.h" #include "ResourceHandle.h" #include #include @@ -36,16 +35,18 @@ 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& rawCookies) +bool getRawCookies(NetworkingContext*, const KURL&, Vector& 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& hostnames) +void getHostnamesWithCookies(NetworkingContext*, HashSet& 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 } diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index 899505c..8928654 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,12 @@ +2012-11-09 Alexey Proskuryakov + + 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 WinCairo build fails to link diff --git a/Source/WebKit2/UIProcess/API/C/WKAPICast.h b/Source/WebKit2/UIProcess/API/C/WKAPICast.h index 713b4f8..3c0584c 100644 --- a/Source/WebKit2/UIProcess/API/C/WKAPICast.h +++ b/Source/WebKit2/UIProcess/API/C/WKAPICast.h @@ -42,7 +42,6 @@ #include "WKProtectionSpaceTypes.h" #include "WKResourceCacheManager.h" #include "WKSharedAPICast.h" -#include #include #include #include -- 1.8.3.1