~jconti/ubuntu/oneiric/webkit/fix_doc_path

« back to all changes in this revision

Viewing changes to Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2011-04-07 09:14:12 UTC
  • mfrom: (1.1.22 upstream)
  • Revision ID: james.westby@ubuntu.com-20110407091412-m259xj2i5mub8u1g
Tags: 1.3.13-0ubuntu1
* New upstream release
* debian/patches/03_fixing_jit_arm_crashes.patch:
  - Applied upstream
* debian/patches/03_gtk_doc.patch:
  - Fix documentation build

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
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.
 
12
 *
 
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.
 
24
 */
 
25
 
 
26
#include "config.h"
 
27
#include "WebCookieManagerProxy.h"
 
28
 
 
29
#include "SecurityOriginData.h"
 
30
#include "WebCookieManagerMessages.h"
 
31
#include "WebContext.h"
 
32
#include "WebSecurityOrigin.h"
 
33
 
 
34
namespace WebKit {
 
35
 
 
36
PassRefPtr<WebCookieManagerProxy> WebCookieManagerProxy::create(WebContext* context)
 
37
{
 
38
    return adoptRef(new WebCookieManagerProxy(context));
 
39
}
 
40
 
 
41
WebCookieManagerProxy::WebCookieManagerProxy(WebContext* context)
 
42
    : m_webContext(context)
 
43
{
 
44
}
 
45
 
 
46
WebCookieManagerProxy::~WebCookieManagerProxy()
 
47
{
 
48
}
 
49
 
 
50
void WebCookieManagerProxy::invalidate()
 
51
{
 
52
    invalidateCallbackMap(m_arrayCallbacks);
 
53
}
 
54
 
 
55
void WebCookieManagerProxy::initializeClient(const WKCookieManagerClient* client)
 
56
{
 
57
    m_client.initialize(client);
 
58
}
 
59
 
 
60
void WebCookieManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
 
61
{
 
62
    didReceiveWebCookieManagerProxyMessage(connection, messageID, arguments);
 
63
}
 
64
 
 
65
void WebCookieManagerProxy::getHostnamesWithCookies(PassRefPtr<ArrayCallback> prpCallback)
 
66
{
 
67
    ASSERT(m_webContext);
 
68
 
 
69
    RefPtr<ArrayCallback> callback = prpCallback;
 
70
    if (!m_webContext->hasValidProcess()) {
 
71
        callback->invalidate();
 
72
        return;
 
73
    }
 
74
    
 
75
    uint64_t callbackID = callback->callbackID();
 
76
    m_arrayCallbacks.set(callbackID, callback.release());
 
77
    m_webContext->process()->send(Messages::WebCookieManager::GetHostnamesWithCookies(callbackID), 0);
 
78
}
 
79
    
 
80
void WebCookieManagerProxy::didGetHostnamesWithCookies(const Vector<String>& hostnameList, uint64_t callbackID)
 
81
{
 
82
    RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
 
83
    if (!callback) {
 
84
        // FIXME: Log error or assert.
 
85
        return;
 
86
    }
 
87
 
 
88
    size_t hostnameCount = hostnameList.size();
 
89
    Vector<RefPtr<APIObject> > hostnames(hostnameCount);
 
90
 
 
91
    for (size_t i = 0; i < hostnameCount; ++i)
 
92
        hostnames[i] = WebString::create(hostnameList[i]);
 
93
 
 
94
    callback->performCallbackWithReturnValue(ImmutableArray::adopt(hostnames).get());
 
95
}
 
96
 
 
97
void WebCookieManagerProxy::deleteCookiesForHostname(const String& hostname)
 
98
{
 
99
    ASSERT(m_webContext);
 
100
    if (!m_webContext->hasValidProcess())
 
101
        return;
 
102
    m_webContext->process()->send(Messages::WebCookieManager::DeleteCookiesForHostname(hostname), 0);
 
103
}
 
104
 
 
105
void WebCookieManagerProxy::deleteAllCookies()
 
106
{
 
107
    ASSERT(m_webContext);
 
108
    if (!m_webContext->hasValidProcess())
 
109
        return;
 
110
    m_webContext->process()->send(Messages::WebCookieManager::DeleteAllCookies(), 0);
 
111
}
 
112
 
 
113
void WebCookieManagerProxy::startObservingCookieChanges()
 
114
{
 
115
    ASSERT(m_webContext);
 
116
    if (!m_webContext->hasValidProcess())
 
117
        return;
 
118
    m_webContext->process()->send(Messages::WebCookieManager::StartObservingCookieChanges(), 0);
 
119
}
 
120
 
 
121
void WebCookieManagerProxy::stopObservingCookieChanges()
 
122
{
 
123
    ASSERT(m_webContext);
 
124
    if (!m_webContext->hasValidProcess())
 
125
        return;
 
126
    m_webContext->process()->send(Messages::WebCookieManager::StopObservingCookieChanges(), 0);
 
127
}
 
128
 
 
129
void WebCookieManagerProxy::cookiesDidChange()
 
130
{
 
131
    m_client.cookiesDidChange(this);
 
132
}
 
133
 
 
134
} // namespace WebKit