2
* Copyright (C) 2011 Apple Inc. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
13
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
* THE POSSIBILITY OF SUCH DAMAGE.
27
#include "WebCookieManagerProxy.h"
29
#include "SecurityOriginData.h"
30
#include "WebCookieManagerMessages.h"
31
#include "WebContext.h"
32
#include "WebSecurityOrigin.h"
36
PassRefPtr<WebCookieManagerProxy> WebCookieManagerProxy::create(WebContext* context)
38
return adoptRef(new WebCookieManagerProxy(context));
41
WebCookieManagerProxy::WebCookieManagerProxy(WebContext* context)
42
: m_webContext(context)
46
WebCookieManagerProxy::~WebCookieManagerProxy()
50
void WebCookieManagerProxy::invalidate()
52
invalidateCallbackMap(m_arrayCallbacks);
55
void WebCookieManagerProxy::initializeClient(const WKCookieManagerClient* client)
57
m_client.initialize(client);
60
void WebCookieManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
62
didReceiveWebCookieManagerProxyMessage(connection, messageID, arguments);
65
void WebCookieManagerProxy::getHostnamesWithCookies(PassRefPtr<ArrayCallback> prpCallback)
69
RefPtr<ArrayCallback> callback = prpCallback;
70
if (!m_webContext->hasValidProcess()) {
71
callback->invalidate();
75
uint64_t callbackID = callback->callbackID();
76
m_arrayCallbacks.set(callbackID, callback.release());
77
m_webContext->process()->send(Messages::WebCookieManager::GetHostnamesWithCookies(callbackID), 0);
80
void WebCookieManagerProxy::didGetHostnamesWithCookies(const Vector<String>& hostnameList, uint64_t callbackID)
82
RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
84
// FIXME: Log error or assert.
88
size_t hostnameCount = hostnameList.size();
89
Vector<RefPtr<APIObject> > hostnames(hostnameCount);
91
for (size_t i = 0; i < hostnameCount; ++i)
92
hostnames[i] = WebString::create(hostnameList[i]);
94
callback->performCallbackWithReturnValue(ImmutableArray::adopt(hostnames).get());
97
void WebCookieManagerProxy::deleteCookiesForHostname(const String& hostname)
100
if (!m_webContext->hasValidProcess())
102
m_webContext->process()->send(Messages::WebCookieManager::DeleteCookiesForHostname(hostname), 0);
105
void WebCookieManagerProxy::deleteAllCookies()
107
ASSERT(m_webContext);
108
if (!m_webContext->hasValidProcess())
110
m_webContext->process()->send(Messages::WebCookieManager::DeleteAllCookies(), 0);
113
void WebCookieManagerProxy::startObservingCookieChanges()
115
ASSERT(m_webContext);
116
if (!m_webContext->hasValidProcess())
118
m_webContext->process()->send(Messages::WebCookieManager::StartObservingCookieChanges(), 0);
121
void WebCookieManagerProxy::stopObservingCookieChanges()
123
ASSERT(m_webContext);
124
if (!m_webContext->hasValidProcess())
126
m_webContext->process()->send(Messages::WebCookieManager::StopObservingCookieChanges(), 0);
129
void WebCookieManagerProxy::cookiesDidChange()
131
m_client.cookiesDidChange(this);
134
} // namespace WebKit