http://bugs.webkit.org/show_bug.cgi?id=16589
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2008 11:37:37 +0000 (11:37 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2008 11:37:37 +0000 (11:37 +0000)
Add a document parameter to WebCore::cookies, setCookies and cookiesEnabled.

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

12 files changed:
WebCore/ChangeLog
WebCore/WebCore.pro
WebCore/bindings/js/kjs_navigator.cpp
WebCore/dom/Document.cpp
WebCore/platform/CookieJar.h
WebCore/platform/gtk/CookieJarGtk.cpp
WebCore/platform/mac/CookieJar.mm
WebCore/platform/network/win/CookieJarWin.cpp
WebCore/platform/qt/CookieJarQt.cpp
WebCore/platform/wx/TemporaryLinkStubs.cpp
WebKit/qt/Api/qwebnetworkinterface.cpp
WebKit/qt/ChangeLog

index 6c0735ac353bfa2024e7cee4ba9cd81931b5c6e5..a0b179c4fe9970d444bf7351c051ae140056c4d9 100644 (file)
@@ -1,3 +1,28 @@
+2008-01-17  Simon Hausmann  <hausmann@webkit.org>
+
+        Reviewed by Maciej, Lars, Holger.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16589
+
+        Add a document parameter to WebCore::cookies, setCookies and cookiesEnabled.
+
+        * WebCore.pro:
+        * bindings/js/kjs_navigator.cpp:
+        (KJS::Navigator::getValueProperty):
+        * dom/Document.cpp:
+        (WebCore::Document::cookie):
+        * platform/CookieJar.h:
+        * platform/gtk/CookieJarGtk.cpp:
+        (WebCore::setCookies):
+        (WebCore::cookies):
+        * platform/mac/CookieJar.mm:
+        * platform/network/win/CookieJarWin.cpp:
+        * platform/qt/CookieJarQt.cpp:
+        (WebCore::setCookies):
+        (WebCore::cookies):
+        (WebCore::cookiesEnabled):
+        * platform/wx/TemporaryLinkStubs.cpp:
+
 2008-01-17  Simon Hausmann  <hausmann@webkit.org>
 
         Reviewed by Holger.
index d6d39047e76ce5bb4477e8f451f86ba41fe481ea..88c678372d68a3cec9de7e7c98d0801dd398528e 100644 (file)
@@ -880,7 +880,6 @@ qt-port {
     $$PWD/../WebKit/qt/Api/qwebpage.h \
     $$PWD/../WebKit/qt/Api/qwebview.h \
     $$PWD/../WebKit/qt/Api/qwebhistoryinterface.h \
-    $$PWD/../WebKit/qt/Api/qcookiejar.h \
     $$PWD/../WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h \
     $$PWD/platform/network/qt/QNetworkReplyHandler.h
 
@@ -952,7 +951,6 @@ qt-port {
     ../WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp \
     ../WebKit/qt/WebCoreSupport/InspectorClientQt.cpp \
     ../WebKit/qt/Api/qwebframe.cpp \
-    ../WebKit/qt/Api/qcookiejar.cpp \
     ../WebKit/qt/Api/qwebpage.cpp \
     ../WebKit/qt/Api/qwebview.cpp \
     ../WebKit/qt/Api/qwebhistory.cpp \
@@ -970,12 +968,14 @@ qt-port {
             $$PWD/../WebKit/qt/Api/qwebnetworkinterface_p.h \
             $$PWD/../WebKit/qt/Api/qwebobjectplugin.h \
             $$PWD/../WebKit/qt/Api/qwebobjectplugin_p.h \
-            $$PWD/../WebKit/qt/Api/qwebobjectpluginconnector.h
+            $$PWD/../WebKit/qt/Api/qwebobjectpluginconnector.h \
+            $$PWD/../WebKit/qt/Api/qcookiejar.h
 
         SOURCES += \
             ../WebKit/qt/Api/qwebnetworkinterface.cpp \
             ../WebKit/qt/Api/qwebobjectplugin.cpp \
-            ../WebKit/qt/Api/qwebobjectpluginconnector.cpp
+            ../WebKit/qt/Api/qwebobjectpluginconnector.cpp \
+            ../WebKit/qt/Api/qcookiejar.cpp
 
      }
 }
index d4005e9eeeb6788869a97610410634e628f68b29..32cea7d58c933250c6ca76479eed2799e6c69699 100644 (file)
@@ -217,7 +217,7 @@ JSValue* Navigator::getValueProperty(ExecState* exec, int token) const
   case _MimeTypes:
     return new MimeTypes(exec);
   case CookieEnabled:
-    return jsBoolean(cookiesEnabled());
+    return jsBoolean(cookiesEnabled(m_frame->document()));
   }
   return 0;
 }
index a0b26f869923d1ab0dde57a0e8cd339b1e7c946a..df978415bfd57a7b7ac44bd8663cb2cc4a450497 100644 (file)
@@ -2579,12 +2579,12 @@ Element* Document::ownerElement() const
 
 String Document::cookie() const
 {
-    return cookies(url());
+    return cookies(this, url());
 }
 
 void Document::setCookie(const String& value)
 {
-    setCookies(url(), policyBaseURL().deprecatedString(), value);
+    setCookies(this, url(), policyBaseURL().deprecatedString(), value);
 }
 
 String Document::referrer() const
index 8e3dfaaa1ea4b07927f8676d5f4f95a2e7f2f45b..38efd047e2eae6ccb8cebc9ada816f7255c0cda4 100644 (file)
@@ -30,10 +30,11 @@ namespace WebCore {
 
     class KURL;
     class String;
+    class Document;
 
-    String cookies(const KURL&);
-    void setCookies(const KURL&, const KURL& policyBaseURL, const String&);
-    bool cookiesEnabled();
+    String cookies(const Document* document, const KURL&);
+    void setCookies(Document* document, const KURL&, const KURL& policyBaseURL, const String&);
+    bool cookiesEnabled(const Document* document);
 
 }
 
index e0f090055cc6314b8ee083bdc62f3068c8430717..2813a2ea3e066ab78c7fda46c6cfba4b55ae5ae2 100644 (file)
@@ -28,17 +28,17 @@ namespace WebCore {
 
 static HashMap<String, String> cookieJar;
 
-void setCookies(const KURL& url, const KURL& /*policyURL*/, const String& value)
+void setCookies(Document* /*document*/, const KURL& url, const KURL& /*policyURL*/, const String& value)
 {
     cookieJar.set(url.string(), value);
 }
 
-String cookies(const KURL& url)
+String cookies(const Document* /*document*/, const KURL& url)
 {
     return cookieJar.get(url.string());
 }
 
-bool cookiesEnabled()
+bool cookiesEnabled(const Document* /*document*/)
 {
     return true;
 }
index 2e6d52937d53b363b8f2fbccf909549a29ca7265..7c288adbf589ae81f33018390530ad1c2a0d05d8 100644 (file)
@@ -38,7 +38,7 @@ typedef unsigned int NSUInteger;
 
 namespace WebCore {
 
-String cookies(const KURL& url)
+String cookies(const Document* /*document*/, const KURL& url)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
@@ -62,7 +62,7 @@ String cookies(const KURL& url)
     return String();
 }
 
-void setCookies(const KURL& url, const KURL& policyBaseURL, const String& cookieStr)
+void setCookies(Document* /*document*/, const KURL& url, const KURL& policyBaseURL, const String& cookieStr)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
@@ -82,7 +82,7 @@ void setCookies(const KURL& url, const KURL& policyBaseURL, const String& cookie
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-bool cookiesEnabled()
+bool cookiesEnabled(const Document* /*document*/)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
index d6085f22d9eff1dd4dcd4dcb49001f664128a597..90136af70630c509b0406a395f639aa21b8ccdfb 100644 (file)
@@ -46,7 +46,7 @@ namespace WebCore
 #endif
 
 
-void setCookies(const KURL& url, const KURL& policyURL, const String& value)
+void setCookies(const Document* /*document*/, const KURL& url, const KURL& policyURL, const String& value)
 {
 #if USE(CFNETWORK)
     // <rdar://problem/5632883> CFHTTPCookieStorage happily stores an empty cookie, which would be sent as "Cookie: =".
@@ -82,7 +82,7 @@ void setCookies(const KURL& url, const KURL& policyURL, const String& value)
 #endif
 }
 
-String cookies(const KURL& url)
+String cookies(const Document* /*document*/, const KURL& url)
 {
 #if USE(CFNETWORK)
     CFHTTPCookieStorageRef defaultCookieStorage = wkGetDefaultHTTPCookieStorage();
@@ -125,7 +125,7 @@ String cookies(const KURL& url)
 #endif
 }
 
-bool cookiesEnabled()
+bool cookiesEnabled(const Document* /*document*/)
 {
     CFHTTPCookieStorageAcceptPolicy policy = CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain;
     if (CFHTTPCookieStorageRef defaultCookieStorage = wkGetDefaultHTTPCookieStorage())
index 7c980fe538bdd5dd7b4f12e0cf9b93820e6b1514..00f3e2157e211d53d705afec75a271e8e7af22ab 100644 (file)
 #include "KURL.h"
 #include "PlatformString.h"
 
+#if QT_VERSION >= 0x040400
+#include "Document.h"
+#include "qwebpage.h"
+#include "qwebframe.h"
+#include "FrameLoaderClientQt.h"
+#include <QNetworkAccessManager>
+#include <QNetworkCookie>
+#else
 #include <qcookiejar.h>
+#endif
 
 namespace WebCore {
 
-void setCookies(const KURL& url, const KURL& policyURL, const String& value)
+void setCookies(Document* document, const KURL& url, const KURL& policyURL, const String& value)
 {
-    QUrl u((QString)url.string());
-    QUrl p((QString)policyURL.string());
+    QUrl u(url);
+    QUrl p(policyURL);
+#if QT_VERSION >= 0x040400
+    QWebFrame* frame = static_cast<FrameLoaderClientQt*>(document->frame()->loader()->client())->webFrame();
+    QWebPage* page = frame->page();
+    QNetworkAccessManager* manager = page->networkAccessManager();
+    QNetworkCookieJar* jar = manager->cookieJar();
+
+    QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(QString(value).toAscii());
+    jar->setCookiesFromUrl(cookies, p);
+#else
     QCookieJar::cookieJar()->setCookies(u, p, (QString)value);
+#endif
 }
 
-String cookies(const KURL& url)
+String cookies(const Document* document, const KURL& url)
 {
-    QUrl u((QString)url.string());
+    QUrl u(url);
+#if QT_VERSION >= 0x040400
+    QWebFrame* frame = static_cast<FrameLoaderClientQt*>(document->frame()->loader()->client())->webFrame();
+    QWebPage* page = frame->page();
+    QNetworkAccessManager* manager = page->networkAccessManager();
+    QNetworkCookieJar* jar = manager->cookieJar();
+
+    QList<QNetworkCookie> cookies = jar->cookiesForUrl(u);
+    if (cookies.isEmpty())
+        return String();
+
+    return QString::fromAscii(cookies.first().toRawForm());
+#else
     QString cookies = QCookieJar::cookieJar()->cookies(u);
     int idx = cookies.indexOf(QLatin1Char(';'));
     if (idx > 0)
         cookies = cookies.left(idx);
     return cookies;
+#endif
 }
 
-bool cookiesEnabled()
+bool cookiesEnabled(const Document* document)
 {
+#if QT_VERSION >= 0x040400
+    // ###
+    return true;
+#else
     return QCookieJar::cookieJar()->isEnabled();
+#endif
 }
 
 }
index f69ef0dddee9e42f8e5dc17a20b05a07fa6fb453..adc17c864da3ec5732439a4a773c6af3c3f3ad96 100755 (executable)
@@ -100,9 +100,9 @@ DragImageRef Frame::dragImageForSelection() { notImplemented(); return 0; }
 void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness) { notImplemented(); }
 
 // cookies (we'll need a place to store these
-void WebCore::setCookies(const KURL& url, const KURL& policyURL, const String& value) { notImplemented(); }
-String WebCore::cookies(const KURL& url) { notImplemented(); return String(); }
-bool WebCore::cookiesEnabled() { notImplemented(); return false; }
+void WebCore::setCookies(Document* document, const KURL& url, const KURL& policyURL, const String& value) { notImplemented(); }
+String WebCore::cookies(const Document* document, const KURL& url) { notImplemented(); return String(); }
+bool WebCore::cookiesEnabled(const Document* document) { notImplemented(); return false; }
 
 /********************************************************/
 /* Completely empty stubs (mostly to allow DRT to run): */
index 41b05c3c04b31437746210f267f175dacc42158a..d68140de5d8792dc7d06affe46b7174f4cc32122 100644 (file)
@@ -28,6 +28,7 @@
 #include "qwebnetworkinterface_p.h"
 #include "qwebobjectpluginconnector.h"
 #include "qwebpage.h"
+#include "qcookiejar.h"
 #include <qdebug.h>
 #include <qfile.h>
 #include <qnetworkproxy.h>
@@ -121,7 +122,7 @@ void QWebNetworkRequestPrivate::init(const QString &method, const QUrl &url, con
         httpHeader.setValue(QLatin1String("User-Agent"), resourceRequest->httpUserAgent());
         const QString scheme = url.scheme().toLower();
         if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) {
-            QString cookies = WebCore::cookies(resourceRequest->url());
+            QString cookies = QCookieJar::cookieJar()->cookies(resourceRequest->url());
             if (!cookies.isEmpty())
                 httpHeader.setValue(QLatin1String("Cookie"), cookies);
         }
@@ -504,7 +505,7 @@ void QWebNetworkManager::started(QWebNetworkJob *job)
     QStringList cookies = job->d->response.allValues("Set-Cookie");
     KURL url(job->url());
     foreach (QString c, cookies) {
-        setCookies(url, url, c);
+        QCookieJar::cookieJar()->setCookies(url, url, c);
     }
     QString contentType = job->d->response.value("Content-Type");
     QString encoding;
index f276a5e65c2a08319de45e08f30380e4ea304f6b..04643d31c7b0000e7b83c8edbb8b95be93e93d8a 100644 (file)
@@ -1,3 +1,15 @@
+2008-01-17  Simon Hausmann  <hausmann@webkit.org>
+
+        Reviewed by Maciej, Lars, Holger.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16589
+
+        Add a document parameter to WebCore::cookies, setCookies and cookiesEnabled.
+
+        * Api/qwebnetworkinterface.cpp:
+        (QWebNetworkRequestPrivate::init):
+        (QWebNetworkManager::started):
+
 2008-01-17  Warwick Allison  <warwick@trolltech.com>
 
         Reviewed by Simon Hausmann <hausmann@webkit.org>.