WebKit2: Need to be able to set and get the Cookie Storage Policy.
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Mar 2011 19:16:27 +0000 (19:16 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Mar 2011 19:16:27 +0000 (19:16 +0000)
commit69fab5676650ebfb6595f3d40653598d50425a1e
tree785e63969ef9eabe5c5fda5d2b024985f1f73db5
parent254800406b685c7b5011909953d03f2e1215cb23
WebKit2: Need to be able to set and get the Cookie Storage Policy.
https://bugs.webkit.org/show_bug.cgi?id=50780

Reviewed by Sam Weinig.

Source/WebCore:

* platform/network/cf/CookieStorageCFNet.cpp:
(WebCore::privateCookieStorage):
Rename privateBrowsingCookieStorage to privateCookieStorage.
(WebCore::currentCookieStorage):
Ditto.
(WebCore::setCurrentCookieStorage):
Ditto.
(WebCore::setCookieStoragePrivateBrowsingEnabled):
Ditto.
(WebCore::defaultCookieStorage):
Return the default cookie storage.
(WebCore::privateBrowsingCookieStorage):
Return privateCookieStorage().get()
* platform/network/cf/CookieStorageCFNet.h:

Source/WebKit2:

* Shared/HTTPCookieAcceptPolicy.h: Added.

* UIProcess/API/C/WKAPICast.h:
(WebKit::toHTTPCookieAcceptPolicy):
(WebKit::toAPI):

* UIProcess/API/C/WKCookieManager.cpp:
(WKCookieManagerSetHTTPCookieAcceptPolicy):
Call through to WebCookieManagerProxy.
(WKCookieManagerGetHTTPCookieAcceptPolicy):
Ditto.
* UIProcess/API/C/WKCookieManager.h:

* UIProcess/WebCookieManagerProxy.cpp:
(WebKit::WebCookieManagerProxy::invalidate):
Invalidate the get http cookie accept policy callbacks.
(WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy):
Send a message to the Web Process with the new value.
(WebKit::WebCookieManagerProxy::getHTTPCookieAcceptPolicy):
Keep track of the callback and send a message to the Web Process.
(WebKit::WebCookieManagerProxy::didGetHTTPCookieAcceptPolicy):
Invoke the callback.
* UIProcess/mac/WebCookieManagerProxyMac.mm: Added.
(WebKit::WebCookieManagerProxy::persistHTTPCookieAcceptPolicy):
On Mac, also set the policy in the UI Process because the sandboxed Web Process cannot
persist the policy.
* UIProcess/WebCookieManagerProxy.h:
* UIProcess/WebCookieManagerProxy.messages.in:

* WebKit2.pri:
* WebKit2.pro:
* WebKit2.xcodeproj/project.pbxproj:
* win/WebKit2.vcproj:
* win/WebKit2Common.vsprops:

* WebProcess/Cookies/WebCookieManager.cpp:
(WebKit::WebCookieManager::setHTTPCookieAcceptPolicy):
Call platformSetHTTPCookieAcceptPolicy.
(WebKit::WebCookieManager::getHTTPCookieAcceptPolicy):
Send the result of platformGetHTTPCookieAcceptPolicy to the UI Process.
* WebProcess/Cookies/WebCookieManager.h:
* WebProcess/Cookies/WebCookieManager.messages.in:

* WebProcess/Cookies/cf: Added.
* WebProcess/Cookies/cf/WebCookieManagerCFNet.cpp: Added.
(WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):
Set the policy on both the default cookie storage and any Private Browsing cookie storage.
(WebKit::WebCookieManager::platformGetHTTPCookieAcceptPolicy):
* WebProcess/Cookies/mac: Added.
* WebProcess/Cookies/mac/WebCookieManagerMac.mm: Added.
(WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):
Set the policy on the default cookie storage and add a FIXME to set it on any Private
Browsing cookie storage.
(WebKit::WebCookieManager::platformGetHTTPCookieAcceptPolicy):

* WebProcess/Cookies/gtk: Added.
* WebProcess/Cookies/gtk/WebCookieManagerGtk.cpp: Added.
(WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):
(WebKit::WebCookieManager::platformGetHTTPCookieAcceptPolicy):
* WebProcess/Cookies/qt: Added.
* WebProcess/Cookies/qt/WebCookieManagerQt.cpp: Added.
(WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):
(WebKit::WebCookieManager::platformGetHTTPCookieAcceptPolicy):

Tools:

Add a test for getting and setting the HTTP Cookie Accept Policy in WebKit2.

The test is named "CookieManager" so that we can eventually exercise more of the
CookieManager functionality in the test.

* TestWebKitAPI/Tests/WebKit2/CookieManager.cpp: Added.
(TestWebKitAPI::didGetTestHTTPCookieAcceptPolicy):
Assert that the policy returned is equal to the policy set in
didGetUserHTTPCookieAcceptPolicy, and then restore the user's policy.
(TestWebKitAPI::didGetUserHTTPCookieAcceptPolicy):
Set the policy to something different than the user's policy and get the policy again.
(TestWebKitAPI::didFinishLoadForFrame):
Get the user's policy so that it can be restored at the end of the test.
(TestWebKitAPI::TEST):
Load about:blank so that the Web Process gets instatiated (needed to get the
CookieManager).

* TestWebKitAPI/win/TestWebKitAPI.vcproj:
Add CookieManager.cpp.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@81980 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/network/cf/CookieStorageCFNet.cpp
Source/WebCore/platform/network/cf/CookieStorageCFNet.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/HTTPCookieAcceptPolicy.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKAPICast.h
Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp
Source/WebKit2/UIProcess/API/C/WKCookieManager.h
Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp
Source/WebKit2/UIProcess/WebCookieManagerProxy.h
Source/WebKit2/UIProcess/WebCookieManagerProxy.messages.in
Source/WebKit2/UIProcess/mac/WebCookieManagerProxyMac.mm [new file with mode: 0644]
Source/WebKit2/WebKit2.pri
Source/WebKit2/WebKit2.pro
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp
Source/WebKit2/WebProcess/Cookies/WebCookieManager.h
Source/WebKit2/WebProcess/Cookies/WebCookieManager.messages.in
Source/WebKit2/WebProcess/Cookies/cf/WebCookieManagerCFNet.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/Cookies/gtk/WebCookieManagerGtk.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/Cookies/mac/WebCookieManagerMac.mm [new file with mode: 0644]
Source/WebKit2/WebProcess/Cookies/qt/WebCookieManagerQt.cpp [new file with mode: 0644]
Source/WebKit2/win/WebKit2.vcproj
Source/WebKit2/win/WebKit2Common.vsprops
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/CookieManager.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj