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 <wtf/Forward.h>
30#include <wtf/ThreadSafeRefCounted.h>
31#include <wtf/Vector.h>
32#include <wtf/text/WTFString.h>
33
34
35namespace Messages {
36namespace WebNotificationManager {
37
38static inline IPC::StringReference messageReceiverName()
39{
40 return IPC::StringReference("WebNotificationManager");
41}
42
43class DidShowNotification {
44public:
45 typedef std::tuple<uint64_t> Arguments;
46
47 static IPC::StringReference receiverName() { return messageReceiverName(); }
48 static IPC::StringReference name() { return IPC::StringReference("DidShowNotification"); }
49 static const bool isSync = false;
50
51 explicit DidShowNotification(uint64_t notificationID)
52 : m_arguments(notificationID)
53 {
54 }
55
56 const Arguments& arguments() const
57 {
58 return m_arguments;
59 }
60
61private:
62 Arguments m_arguments;
63};
64
65class DidClickNotification {
66public:
67 typedef std::tuple<uint64_t> Arguments;
68
69 static IPC::StringReference receiverName() { return messageReceiverName(); }
70 static IPC::StringReference name() { return IPC::StringReference("DidClickNotification"); }
71 static const bool isSync = false;
72
73 explicit DidClickNotification(uint64_t notificationID)
74 : m_arguments(notificationID)
75 {
76 }
77
78 const Arguments& arguments() const
79 {
80 return m_arguments;
81 }
82
83private:
84 Arguments m_arguments;
85};
86
87class DidCloseNotifications {
88public:
89 typedef std::tuple<const Vector<uint64_t>&> Arguments;
90
91 static IPC::StringReference receiverName() { return messageReceiverName(); }
92 static IPC::StringReference name() { return IPC::StringReference("DidCloseNotifications"); }
93 static const bool isSync = false;
94
95 explicit DidCloseNotifications(const Vector<uint64_t>& notificationIDs)
96 : m_arguments(notificationIDs)
97 {
98 }
99
100 const Arguments& arguments() const
101 {
102 return m_arguments;
103 }
104
105private:
106 Arguments m_arguments;
107};
108
109class DidUpdateNotificationDecision {
110public:
111 typedef std::tuple<const String&, bool> Arguments;
112
113 static IPC::StringReference receiverName() { return messageReceiverName(); }
114 static IPC::StringReference name() { return IPC::StringReference("DidUpdateNotificationDecision"); }
115 static const bool isSync = false;
116
117 DidUpdateNotificationDecision(const String& originString, bool allowed)
118 : m_arguments(originString, allowed)
119 {
120 }
121
122 const Arguments& arguments() const
123 {
124 return m_arguments;
125 }
126
127private:
128 Arguments m_arguments;
129};
130
131class DidRemoveNotificationDecisions {
132public:
133 typedef std::tuple<const Vector<String>&> Arguments;
134
135 static IPC::StringReference receiverName() { return messageReceiverName(); }
136 static IPC::StringReference name() { return IPC::StringReference("DidRemoveNotificationDecisions"); }
137 static const bool isSync = false;
138
139 explicit DidRemoveNotificationDecisions(const Vector<String>& originStrings)
140 : m_arguments(originStrings)
141 {
142 }
143
144 const Arguments& arguments() const
145 {
146 return m_arguments;
147 }
148
149private:
150 Arguments m_arguments;
151};
152
153} // namespace WebNotificationManager
154} // namespace Messages
155