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 "SandboxExtension.h"
30#include "UserContentControllerIdentifier.h"
31#include "WebsiteDataFetchOption.h"
32#include "WebsiteDataType.h"
33#include <WebCore/RegistrableDomain.h>
34#include <wtf/Forward.h>
35#include <wtf/HashSet.h>
36#include <wtf/OptionSet.h>
37#include <wtf/Optional.h>
38#include <wtf/ThreadSafeRefCounted.h>
39#include <wtf/Vector.h>
40#include <wtf/text/WTFString.h>
41
42namespace IPC {
43class Attachment;
44}
45
46namespace PAL {
47class SessionID;
48}
49
50namespace WebCore {
51class RegistrableDomain;
52struct ClientOrigin;
53enum class ShouldSample : bool;
54class AuthenticationChallenge;
55}
56
57namespace WebKit {
58struct WebsiteData;
59}
60
61namespace Messages {
62namespace NetworkProcessProxy {
63
64static inline IPC::StringReference messageReceiverName()
65{
66 return IPC::StringReference("NetworkProcessProxy");
67}
68
69class DidCreateNetworkConnectionToWebProcess {
70public:
71 typedef std::tuple<const IPC::Attachment&> Arguments;
72
73 static IPC::StringReference receiverName() { return messageReceiverName(); }
74 static IPC::StringReference name() { return IPC::StringReference("DidCreateNetworkConnectionToWebProcess"); }
75 static const bool isSync = false;
76
77 explicit DidCreateNetworkConnectionToWebProcess(const IPC::Attachment& connectionIdentifier)
78 : m_arguments(connectionIdentifier)
79 {
80 }
81
82 const Arguments& arguments() const
83 {
84 return m_arguments;
85 }
86
87private:
88 Arguments m_arguments;
89};
90
91class DidReceiveAuthenticationChallenge {
92public:
93 typedef std::tuple<uint64_t, uint64_t, const WebCore::AuthenticationChallenge&, uint64_t> Arguments;
94
95 static IPC::StringReference receiverName() { return messageReceiverName(); }
96 static IPC::StringReference name() { return IPC::StringReference("DidReceiveAuthenticationChallenge"); }
97 static const bool isSync = false;
98
99 DidReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge& challenge, uint64_t challengeID)
100 : m_arguments(pageID, frameID, challenge, challengeID)
101 {
102 }
103
104 const Arguments& arguments() const
105 {
106 return m_arguments;
107 }
108
109private:
110 Arguments m_arguments;
111};
112
113class DidFetchWebsiteData {
114public:
115 typedef std::tuple<uint64_t, const WebKit::WebsiteData&> Arguments;
116
117 static IPC::StringReference receiverName() { return messageReceiverName(); }
118 static IPC::StringReference name() { return IPC::StringReference("DidFetchWebsiteData"); }
119 static const bool isSync = false;
120
121 DidFetchWebsiteData(uint64_t callbackID, const WebKit::WebsiteData& websiteData)
122 : m_arguments(callbackID, websiteData)
123 {
124 }
125
126 const Arguments& arguments() const
127 {
128 return m_arguments;
129 }
130
131private:
132 Arguments m_arguments;
133};
134
135class DidDeleteWebsiteData {
136public:
137 typedef std::tuple<uint64_t> Arguments;
138
139 static IPC::StringReference receiverName() { return messageReceiverName(); }
140 static IPC::StringReference name() { return IPC::StringReference("DidDeleteWebsiteData"); }
141 static const bool isSync = false;
142
143 explicit DidDeleteWebsiteData(uint64_t callbackID)
144 : m_arguments(callbackID)
145 {
146 }
147
148 const Arguments& arguments() const
149 {
150 return m_arguments;
151 }
152
153private:
154 Arguments m_arguments;
155};
156
157class DidDeleteWebsiteDataForOrigins {
158public:
159 typedef std::tuple<uint64_t> Arguments;
160
161 static IPC::StringReference receiverName() { return messageReceiverName(); }
162 static IPC::StringReference name() { return IPC::StringReference("DidDeleteWebsiteDataForOrigins"); }
163 static const bool isSync = false;
164
165 explicit DidDeleteWebsiteDataForOrigins(uint64_t callbackID)
166 : m_arguments(callbackID)
167 {
168 }
169
170 const Arguments& arguments() const
171 {
172 return m_arguments;
173 }
174
175private:
176 Arguments m_arguments;
177};
178
179class DidSyncAllCookies {
180public:
181 typedef std::tuple<> Arguments;
182
183 static IPC::StringReference receiverName() { return messageReceiverName(); }
184 static IPC::StringReference name() { return IPC::StringReference("DidSyncAllCookies"); }
185 static const bool isSync = false;
186
187 const Arguments& arguments() const
188 {
189 return m_arguments;
190 }
191
192private:
193 Arguments m_arguments;
194};
195
196class ProcessReadyToSuspend {
197public:
198 typedef std::tuple<> Arguments;
199
200 static IPC::StringReference receiverName() { return messageReceiverName(); }
201 static IPC::StringReference name() { return IPC::StringReference("ProcessReadyToSuspend"); }
202 static const bool isSync = false;
203
204 const Arguments& arguments() const
205 {
206 return m_arguments;
207 }
208
209private:
210 Arguments m_arguments;
211};
212
213class SetIsHoldingLockedFiles {
214public:
215 typedef std::tuple<bool> Arguments;
216
217 static IPC::StringReference receiverName() { return messageReceiverName(); }
218 static IPC::StringReference name() { return IPC::StringReference("SetIsHoldingLockedFiles"); }
219 static const bool isSync = false;
220
221 explicit SetIsHoldingLockedFiles(bool isHoldingLockedFiles)
222 : m_arguments(isHoldingLockedFiles)
223 {
224 }
225
226 const Arguments& arguments() const
227 {
228 return m_arguments;
229 }
230
231private:
232 Arguments m_arguments;
233};
234
235class LogDiagnosticMessage {
236public:
237 typedef std::tuple<uint64_t, const String&, const String&, WebCore::ShouldSample> Arguments;
238
239 static IPC::StringReference receiverName() { return messageReceiverName(); }
240 static IPC::StringReference name() { return IPC::StringReference("LogDiagnosticMessage"); }
241 static const bool isSync = false;
242
243 LogDiagnosticMessage(uint64_t pageID, const String& message, const String& description, WebCore::ShouldSample shouldSample)
244 : m_arguments(pageID, message, description, shouldSample)
245 {
246 }
247
248 const Arguments& arguments() const
249 {
250 return m_arguments;
251 }
252
253private:
254 Arguments m_arguments;
255};
256
257class LogDiagnosticMessageWithResult {
258public:
259 typedef std::tuple<uint64_t, const String&, const String&, uint32_t, WebCore::ShouldSample> Arguments;
260
261 static IPC::StringReference receiverName() { return messageReceiverName(); }
262 static IPC::StringReference name() { return IPC::StringReference("LogDiagnosticMessageWithResult"); }
263 static const bool isSync = false;
264
265 LogDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result, WebCore::ShouldSample shouldSample)
266 : m_arguments(pageID, message, description, result, shouldSample)
267 {
268 }
269
270 const Arguments& arguments() const
271 {
272 return m_arguments;
273 }
274
275private:
276 Arguments m_arguments;
277};
278
279class LogDiagnosticMessageWithValue {
280public:
281 typedef std::tuple<uint64_t, const String&, const String&, double, const unsigned&, WebCore::ShouldSample> Arguments;
282
283 static IPC::StringReference receiverName() { return messageReceiverName(); }
284 static IPC::StringReference name() { return IPC::StringReference("LogDiagnosticMessageWithValue"); }
285 static const bool isSync = false;
286
287 LogDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, double value, const unsigned& significantFigures, WebCore::ShouldSample shouldSample)
288 : m_arguments(pageID, message, description, value, significantFigures, shouldSample)
289 {
290 }
291
292 const Arguments& arguments() const
293 {
294 return m_arguments;
295 }
296
297private:
298 Arguments m_arguments;
299};
300
301class LogGlobalDiagnosticMessageWithValue {
302public:
303 typedef std::tuple<const String&, const String&, double, const unsigned&, WebCore::ShouldSample> Arguments;
304
305 static IPC::StringReference receiverName() { return messageReceiverName(); }
306 static IPC::StringReference name() { return IPC::StringReference("LogGlobalDiagnosticMessageWithValue"); }
307 static const bool isSync = false;
308
309 LogGlobalDiagnosticMessageWithValue(const String& message, const String& description, double value, const unsigned& significantFigures, WebCore::ShouldSample shouldSample)
310 : m_arguments(message, description, value, significantFigures, shouldSample)
311 {
312 }
313
314 const Arguments& arguments() const
315 {
316 return m_arguments;
317 }
318
319private:
320 Arguments m_arguments;
321};
322
323#if ENABLE(RESOURCE_LOAD_STATISTICS)
324class LogTestingEvent {
325public:
326 typedef std::tuple<const PAL::SessionID&, const String&> Arguments;
327
328 static IPC::StringReference receiverName() { return messageReceiverName(); }
329 static IPC::StringReference name() { return IPC::StringReference("LogTestingEvent"); }
330 static const bool isSync = false;
331
332 LogTestingEvent(const PAL::SessionID& sessionID, const String& event)
333 : m_arguments(sessionID, event)
334 {
335 }
336
337 const Arguments& arguments() const
338 {
339 return m_arguments;
340 }
341
342private:
343 Arguments m_arguments;
344};
345#endif
346
347#if ENABLE(RESOURCE_LOAD_STATISTICS)
348class NotifyResourceLoadStatisticsProcessed {
349public:
350 typedef std::tuple<> Arguments;
351
352 static IPC::StringReference receiverName() { return messageReceiverName(); }
353 static IPC::StringReference name() { return IPC::StringReference("NotifyResourceLoadStatisticsProcessed"); }
354 static const bool isSync = false;
355
356 const Arguments& arguments() const
357 {
358 return m_arguments;
359 }
360
361private:
362 Arguments m_arguments;
363};
364#endif
365
366#if ENABLE(RESOURCE_LOAD_STATISTICS)
367class NotifyWebsiteDataDeletionForRegistrableDomainsFinished {
368public:
369 typedef std::tuple<> Arguments;
370
371 static IPC::StringReference receiverName() { return messageReceiverName(); }
372 static IPC::StringReference name() { return IPC::StringReference("NotifyWebsiteDataDeletionForRegistrableDomainsFinished"); }
373 static const bool isSync = false;
374
375 const Arguments& arguments() const
376 {
377 return m_arguments;
378 }
379
380private:
381 Arguments m_arguments;
382};
383#endif
384
385#if ENABLE(RESOURCE_LOAD_STATISTICS)
386class NotifyWebsiteDataScanForRegistrableDomainsFinished {
387public:
388 typedef std::tuple<> Arguments;
389
390 static IPC::StringReference receiverName() { return messageReceiverName(); }
391 static IPC::StringReference name() { return IPC::StringReference("NotifyWebsiteDataScanForRegistrableDomainsFinished"); }
392 static const bool isSync = false;
393
394 const Arguments& arguments() const
395 {
396 return m_arguments;
397 }
398
399private:
400 Arguments m_arguments;
401};
402#endif
403
404#if ENABLE(RESOURCE_LOAD_STATISTICS)
405class NotifyResourceLoadStatisticsTelemetryFinished {
406public:
407 typedef std::tuple<const unsigned&, const unsigned&, const unsigned&> Arguments;
408
409 static IPC::StringReference receiverName() { return messageReceiverName(); }
410 static IPC::StringReference name() { return IPC::StringReference("NotifyResourceLoadStatisticsTelemetryFinished"); }
411 static const bool isSync = false;
412
413 NotifyResourceLoadStatisticsTelemetryFinished(const unsigned& totalPrevalentResources, const unsigned& totalPrevalentResourcesWithUserInteraction, const unsigned& top3SubframeUnderTopFrameOrigins)
414 : m_arguments(totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins)
415 {
416 }
417
418 const Arguments& arguments() const
419 {
420 return m_arguments;
421 }
422
423private:
424 Arguments m_arguments;
425};
426#endif
427
428#if ENABLE(RESOURCE_LOAD_STATISTICS)
429class RequestStorageAccessConfirm {
430public:
431 typedef std::tuple<uint64_t, uint64_t, const WebCore::RegistrableDomain&, const WebCore::RegistrableDomain&> Arguments;
432
433 static IPC::StringReference receiverName() { return messageReceiverName(); }
434 static IPC::StringReference name() { return IPC::StringReference("RequestStorageAccessConfirm"); }
435 static const bool isSync = false;
436
437 static void callReply(IPC::Decoder&, CompletionHandler<void(bool&&)>&&);
438 static void cancelReply(CompletionHandler<void(bool&&)>&&);
439 static IPC::StringReference asyncMessageReplyName() { return { "RequestStorageAccessConfirmReply" }; }
440 using AsyncReply = CompletionHandler<void(bool userDidGrantAccess)>;
441 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, bool userDidGrantAccess);
442 using Reply = std::tuple<bool&>;
443 using ReplyArguments = std::tuple<bool>;
444 RequestStorageAccessConfirm(uint64_t pageID, uint64_t frameID, const WebCore::RegistrableDomain& subFrameDomain, const WebCore::RegistrableDomain& topFrameDomain)
445 : m_arguments(pageID, frameID, subFrameDomain, topFrameDomain)
446 {
447 }
448
449 const Arguments& arguments() const
450 {
451 return m_arguments;
452 }
453
454private:
455 Arguments m_arguments;
456};
457#endif
458
459#if ENABLE(RESOURCE_LOAD_STATISTICS)
460class DeleteWebsiteDataInUIProcessForRegistrableDomains {
461public:
462 typedef std::tuple<const PAL::SessionID&, const OptionSet<WebKit::WebsiteDataType>&, const OptionSet<WebKit::WebsiteDataFetchOption>&, const Vector<WebCore::RegistrableDomain>&> Arguments;
463
464 static IPC::StringReference receiverName() { return messageReceiverName(); }
465 static IPC::StringReference name() { return IPC::StringReference("DeleteWebsiteDataInUIProcessForRegistrableDomains"); }
466 static const bool isSync = false;
467
468 static void callReply(IPC::Decoder&, CompletionHandler<void(HashSet<WebCore::RegistrableDomain>&&)>&&);
469 static void cancelReply(CompletionHandler<void(HashSet<WebCore::RegistrableDomain>&&)>&&);
470 static IPC::StringReference asyncMessageReplyName() { return { "DeleteWebsiteDataInUIProcessForRegistrableDomainsReply" }; }
471 using AsyncReply = CompletionHandler<void(const HashSet<WebCore::RegistrableDomain>& domainsWithMatchingDataRecords)>;
472 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const HashSet<WebCore::RegistrableDomain>& domainsWithMatchingDataRecords);
473 using Reply = std::tuple<HashSet<WebCore::RegistrableDomain>&>;
474 using ReplyArguments = std::tuple<HashSet<WebCore::RegistrableDomain>>;
475 DeleteWebsiteDataInUIProcessForRegistrableDomains(const PAL::SessionID& sessionID, const OptionSet<WebKit::WebsiteDataType>& dataTypes, const OptionSet<WebKit::WebsiteDataFetchOption>& fetchOptions, const Vector<WebCore::RegistrableDomain>& domains)
476 : m_arguments(sessionID, dataTypes, fetchOptions, domains)
477 {
478 }
479
480 const Arguments& arguments() const
481 {
482 return m_arguments;
483 }
484
485private:
486 Arguments m_arguments;
487};
488#endif
489
490#if ENABLE(CONTENT_EXTENSIONS)
491class ContentExtensionRules {
492public:
493 typedef std::tuple<const WebKit::UserContentControllerIdentifier&> Arguments;
494
495 static IPC::StringReference receiverName() { return messageReceiverName(); }
496 static IPC::StringReference name() { return IPC::StringReference("ContentExtensionRules"); }
497 static const bool isSync = false;
498
499 explicit ContentExtensionRules(const WebKit::UserContentControllerIdentifier& identifier)
500 : m_arguments(identifier)
501 {
502 }
503
504 const Arguments& arguments() const
505 {
506 return m_arguments;
507 }
508
509private:
510 Arguments m_arguments;
511};
512#endif
513
514class RetrieveCacheStorageParameters {
515public:
516 typedef std::tuple<const PAL::SessionID&> Arguments;
517
518 static IPC::StringReference receiverName() { return messageReceiverName(); }
519 static IPC::StringReference name() { return IPC::StringReference("RetrieveCacheStorageParameters"); }
520 static const bool isSync = false;
521
522 explicit RetrieveCacheStorageParameters(const PAL::SessionID& sessionID)
523 : m_arguments(sessionID)
524 {
525 }
526
527 const Arguments& arguments() const
528 {
529 return m_arguments;
530 }
531
532private:
533 Arguments m_arguments;
534};
535
536#if ENABLE(SANDBOX_EXTENSIONS)
537class GetSandboxExtensionsForBlobFiles {
538public:
539 typedef std::tuple<const Vector<String>&> Arguments;
540
541 static IPC::StringReference receiverName() { return messageReceiverName(); }
542 static IPC::StringReference name() { return IPC::StringReference("GetSandboxExtensionsForBlobFiles"); }
543 static const bool isSync = false;
544
545 static void callReply(IPC::Decoder&, CompletionHandler<void(WebKit::SandboxExtension::HandleArray&&)>&&);
546 static void cancelReply(CompletionHandler<void(WebKit::SandboxExtension::HandleArray&&)>&&);
547 static IPC::StringReference asyncMessageReplyName() { return { "GetSandboxExtensionsForBlobFilesReply" }; }
548 using AsyncReply = CompletionHandler<void(const WebKit::SandboxExtension::HandleArray& extensions)>;
549 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const WebKit::SandboxExtension::HandleArray& extensions);
550 using Reply = std::tuple<WebKit::SandboxExtension::HandleArray&>;
551 using ReplyArguments = std::tuple<WebKit::SandboxExtension::HandleArray>;
552 explicit GetSandboxExtensionsForBlobFiles(const Vector<String>& paths)
553 : m_arguments(paths)
554 {
555 }
556
557 const Arguments& arguments() const
558 {
559 return m_arguments;
560 }
561
562private:
563 Arguments m_arguments;
564};
565#endif
566
567#if ENABLE(SERVICE_WORKER)
568class EstablishWorkerContextConnectionToNetworkProcess {
569public:
570 typedef std::tuple<const WebCore::RegistrableDomain&> Arguments;
571
572 static IPC::StringReference receiverName() { return messageReceiverName(); }
573 static IPC::StringReference name() { return IPC::StringReference("EstablishWorkerContextConnectionToNetworkProcess"); }
574 static const bool isSync = false;
575
576 explicit EstablishWorkerContextConnectionToNetworkProcess(const WebCore::RegistrableDomain& registrableDomain)
577 : m_arguments(registrableDomain)
578 {
579 }
580
581 const Arguments& arguments() const
582 {
583 return m_arguments;
584 }
585
586private:
587 Arguments m_arguments;
588};
589#endif
590
591#if ENABLE(SERVICE_WORKER)
592class EstablishWorkerContextConnectionToNetworkProcessForExplicitSession {
593public:
594 typedef std::tuple<const WebCore::RegistrableDomain&, const PAL::SessionID&> Arguments;
595
596 static IPC::StringReference receiverName() { return messageReceiverName(); }
597 static IPC::StringReference name() { return IPC::StringReference("EstablishWorkerContextConnectionToNetworkProcessForExplicitSession"); }
598 static const bool isSync = false;
599
600 EstablishWorkerContextConnectionToNetworkProcessForExplicitSession(const WebCore::RegistrableDomain& registrableDomain, const PAL::SessionID& explicitSession)
601 : m_arguments(registrableDomain, explicitSession)
602 {
603 }
604
605 const Arguments& arguments() const
606 {
607 return m_arguments;
608 }
609
610private:
611 Arguments m_arguments;
612};
613#endif
614
615class RequestStorageSpace {
616public:
617 typedef std::tuple<const PAL::SessionID&, const WebCore::ClientOrigin&, uint64_t, uint64_t, uint64_t> Arguments;
618
619 static IPC::StringReference receiverName() { return messageReceiverName(); }
620 static IPC::StringReference name() { return IPC::StringReference("RequestStorageSpace"); }
621 static const bool isSync = false;
622
623 static void callReply(IPC::Decoder&, CompletionHandler<void(Optional<uint64_t>&&)>&&);
624 static void cancelReply(CompletionHandler<void(Optional<uint64_t>&&)>&&);
625 static IPC::StringReference asyncMessageReplyName() { return { "RequestStorageSpaceReply" }; }
626 using AsyncReply = CompletionHandler<void(const Optional<uint64_t>& newQuota)>;
627 static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const Optional<uint64_t>& newQuota);
628 using Reply = std::tuple<Optional<uint64_t>&>;
629 using ReplyArguments = std::tuple<Optional<uint64_t>>;
630 RequestStorageSpace(const PAL::SessionID& sessionID, const WebCore::ClientOrigin& origin, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired)
631 : m_arguments(sessionID, origin, quota, currentSize, spaceRequired)
632 {
633 }
634
635 const Arguments& arguments() const
636 {
637 return m_arguments;
638 }
639
640private:
641 Arguments m_arguments;
642};
643
644} // namespace NetworkProcessProxy
645} // namespace Messages
646