1/*
2 * Copyright (C) 2010-2018 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'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#pragma once
26
27#include "ArgumentCoders.h"
28#include "Connection.h"
29#include <WebCore/Cookie.h>
30#include <wtf/Forward.h>
31#include <wtf/ThreadSafeRefCounted.h>
32#include <wtf/Vector.h>
33#include <wtf/text/WTFString.h>
34
35namespace PAL {
36class SessionID;
37}
38
39namespace WebCore {
40struct Cookie;
41}
42
43namespace WebKit {
44class OptionalCallbackID;
45enum class SoupCookiePersistentStorageType : bool;
46class CallbackID;
47}
48
49namespace Messages {
50namespace WebCookieManager {
51
52static inline IPC::StringReference messageReceiverName()
53{
54 return IPC::StringReference("WebCookieManager");
55}
56
57class GetHostnamesWithCookies {
58public:
59 typedef std::tuple<const PAL::SessionID&, const WebKit::CallbackID&> Arguments;
60
61 static IPC::StringReference receiverName() { return messageReceiverName(); }
62 static IPC::StringReference name() { return IPC::StringReference("GetHostnamesWithCookies"); }
63 static const bool isSync = false;
64
65 GetHostnamesWithCookies(const PAL::SessionID& sessionID, const WebKit::CallbackID& callbackID)
66 : m_arguments(sessionID, callbackID)
67 {
68 }
69
70 const Arguments& arguments() const
71 {
72 return m_arguments;
73 }
74
75private:
76 Arguments m_arguments;
77};
78
79class DeleteCookiesForHostnames {
80public:
81 typedef std::tuple<const PAL::SessionID&, const Vector<String>&> Arguments;
82
83 static IPC::StringReference receiverName() { return messageReceiverName(); }
84 static IPC::StringReference name() { return IPC::StringReference("DeleteCookiesForHostnames"); }
85 static const bool isSync = false;
86
87 DeleteCookiesForHostnames(const PAL::SessionID& sessionID, const Vector<String>& hostnames)
88 : m_arguments(sessionID, hostnames)
89 {
90 }
91
92 const Arguments& arguments() const
93 {
94 return m_arguments;
95 }
96
97private:
98 Arguments m_arguments;
99};
100
101class DeleteAllCookies {
102public:
103 typedef std::tuple<const PAL::SessionID&> Arguments;
104
105 static IPC::StringReference receiverName() { return messageReceiverName(); }
106 static IPC::StringReference name() { return IPC::StringReference("DeleteAllCookies"); }
107 static const bool isSync = false;
108
109 explicit DeleteAllCookies(const PAL::SessionID& sessionID)
110 : m_arguments(sessionID)
111 {
112 }
113
114 const Arguments& arguments() const
115 {
116 return m_arguments;
117 }
118
119private:
120 Arguments m_arguments;
121};
122
123class SetCookie {
124public:
125 typedef std::tuple<const PAL::SessionID&, const Vector<WebCore::Cookie>&, const WebKit::CallbackID&> Arguments;
126
127 static IPC::StringReference receiverName() { return messageReceiverName(); }
128 static IPC::StringReference name() { return IPC::StringReference("SetCookie"); }
129 static const bool isSync = false;
130
131 SetCookie(const PAL::SessionID& sessionID, const Vector<WebCore::Cookie>& cookie, const WebKit::CallbackID& callbackID)
132 : m_arguments(sessionID, cookie, callbackID)
133 {
134 }
135
136 const Arguments& arguments() const
137 {
138 return m_arguments;
139 }
140
141private:
142 Arguments m_arguments;
143};
144
145class SetCookies {
146public:
147 typedef std::tuple<const PAL::SessionID&, const Vector<WebCore::Cookie>&, const URL&, const URL&, const WebKit::CallbackID&> Arguments;
148
149 static IPC::StringReference receiverName() { return messageReceiverName(); }
150 static IPC::StringReference name() { return IPC::StringReference("SetCookies"); }
151 static const bool isSync = false;
152
153 SetCookies(const PAL::SessionID& sessionID, const Vector<WebCore::Cookie>& cookies, const URL& url, const URL& mainDocumentURL, const WebKit::CallbackID& callbackID)
154 : m_arguments(sessionID, cookies, url, mainDocumentURL, callbackID)
155 {
156 }
157
158 const Arguments& arguments() const
159 {
160 return m_arguments;
161 }
162
163private:
164 Arguments m_arguments;
165};
166
167class GetAllCookies {
168public:
169 typedef std::tuple<const PAL::SessionID&, const WebKit::CallbackID&> Arguments;
170
171 static IPC::StringReference receiverName() { return messageReceiverName(); }
172 static IPC::StringReference name() { return IPC::StringReference("GetAllCookies"); }
173 static const bool isSync = false;
174
175 GetAllCookies(const PAL::SessionID& sessionID, const WebKit::CallbackID& callbackID)
176 : m_arguments(sessionID, callbackID)
177 {
178 }
179
180 const Arguments& arguments() const
181 {
182 return m_arguments;
183 }
184
185private:
186 Arguments m_arguments;
187};
188
189class GetCookies {
190public:
191 typedef std::tuple<const PAL::SessionID&, const URL&, const WebKit::CallbackID&> Arguments;
192
193 static IPC::StringReference receiverName() { return messageReceiverName(); }
194 static IPC::StringReference name() { return IPC::StringReference("GetCookies"); }
195 static const bool isSync = false;
196
197 GetCookies(const PAL::SessionID& sessionID, const URL& url, const WebKit::CallbackID& callbackID)
198 : m_arguments(sessionID, url, callbackID)
199 {
200 }
201
202 const Arguments& arguments() const
203 {
204 return m_arguments;
205 }
206
207private:
208 Arguments m_arguments;
209};
210
211class DeleteCookie {
212public:
213 typedef std::tuple<const PAL::SessionID&, const WebCore::Cookie&, const WebKit::CallbackID&> Arguments;
214
215 static IPC::StringReference receiverName() { return messageReceiverName(); }
216 static IPC::StringReference name() { return IPC::StringReference("DeleteCookie"); }
217 static const bool isSync = false;
218
219 DeleteCookie(const PAL::SessionID& sessionID, const WebCore::Cookie& cookie, const WebKit::CallbackID& callbackID)
220 : m_arguments(sessionID, cookie, callbackID)
221 {
222 }
223
224 const Arguments& arguments() const
225 {
226 return m_arguments;
227 }
228
229private:
230 Arguments m_arguments;
231};
232
233class DeleteAllCookiesModifiedSince {
234public:
235 typedef std::tuple<const PAL::SessionID&, const WallTime&, const WebKit::CallbackID&> Arguments;
236
237 static IPC::StringReference receiverName() { return messageReceiverName(); }
238 static IPC::StringReference name() { return IPC::StringReference("DeleteAllCookiesModifiedSince"); }
239 static const bool isSync = false;
240
241 DeleteAllCookiesModifiedSince(const PAL::SessionID& sessionID, const WallTime& time, const WebKit::CallbackID& callbackID)
242 : m_arguments(sessionID, time, callbackID)
243 {
244 }
245
246 const Arguments& arguments() const
247 {
248 return m_arguments;
249 }
250
251private:
252 Arguments m_arguments;
253};
254
255class SetHTTPCookieAcceptPolicy {
256public:
257 typedef std::tuple<uint32_t, const WebKit::OptionalCallbackID&> Arguments;
258
259 static IPC::StringReference receiverName() { return messageReceiverName(); }
260 static IPC::StringReference name() { return IPC::StringReference("SetHTTPCookieAcceptPolicy"); }
261 static const bool isSync = false;
262
263 SetHTTPCookieAcceptPolicy(uint32_t policy, const WebKit::OptionalCallbackID& callbackID)
264 : m_arguments(policy, callbackID)
265 {
266 }
267
268 const Arguments& arguments() const
269 {
270 return m_arguments;
271 }
272
273private:
274 Arguments m_arguments;
275};
276
277class GetHTTPCookieAcceptPolicy {
278public:
279 typedef std::tuple<const WebKit::CallbackID&> Arguments;
280
281 static IPC::StringReference receiverName() { return messageReceiverName(); }
282 static IPC::StringReference name() { return IPC::StringReference("GetHTTPCookieAcceptPolicy"); }
283 static const bool isSync = false;
284
285 explicit GetHTTPCookieAcceptPolicy(const WebKit::CallbackID& callbackID)
286 : m_arguments(callbackID)
287 {
288 }
289
290 const Arguments& arguments() const
291 {
292 return m_arguments;
293 }
294
295private:
296 Arguments m_arguments;
297};
298
299class StartObservingCookieChanges {
300public:
301 typedef std::tuple<const PAL::SessionID&> Arguments;
302
303 static IPC::StringReference receiverName() { return messageReceiverName(); }
304 static IPC::StringReference name() { return IPC::StringReference("StartObservingCookieChanges"); }
305 static const bool isSync = false;
306
307 explicit StartObservingCookieChanges(const PAL::SessionID& sessionID)
308 : m_arguments(sessionID)
309 {
310 }
311
312 const Arguments& arguments() const
313 {
314 return m_arguments;
315 }
316
317private:
318 Arguments m_arguments;
319};
320
321class StopObservingCookieChanges {
322public:
323 typedef std::tuple<const PAL::SessionID&> Arguments;
324
325 static IPC::StringReference receiverName() { return messageReceiverName(); }
326 static IPC::StringReference name() { return IPC::StringReference("StopObservingCookieChanges"); }
327 static const bool isSync = false;
328
329 explicit StopObservingCookieChanges(const PAL::SessionID& sessionID)
330 : m_arguments(sessionID)
331 {
332 }
333
334 const Arguments& arguments() const
335 {
336 return m_arguments;
337 }
338
339private:
340 Arguments m_arguments;
341};
342
343#if USE(SOUP)
344class SetCookiePersistentStorage {
345public:
346 typedef std::tuple<const PAL::SessionID&, const String&, WebKit::SoupCookiePersistentStorageType> Arguments;
347
348 static IPC::StringReference receiverName() { return messageReceiverName(); }
349 static IPC::StringReference name() { return IPC::StringReference("SetCookiePersistentStorage"); }
350 static const bool isSync = false;
351
352 SetCookiePersistentStorage(const PAL::SessionID& sessionID, const String& storagePath, WebKit::SoupCookiePersistentStorageType storageType)
353 : m_arguments(sessionID, storagePath, storageType)
354 {
355 }
356
357 const Arguments& arguments() const
358 {
359 return m_arguments;
360 }
361
362private:
363 Arguments m_arguments;
364};
365#endif
366
367} // namespace WebCookieManager
368} // namespace Messages
369