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 | #include "config.h" |
26 | |
27 | #if ENABLE(NETSCAPE_PLUGIN_API) |
28 | |
29 | #include "PluginProcessProxy.h" |
30 | |
31 | #include "ArgumentCoders.h" |
32 | #include "Attachment.h" |
33 | #include "Decoder.h" |
34 | #include "HandleMessage.h" |
35 | #include "PluginProcessProxyMessages.h" |
36 | #include <wtf/Vector.h> |
37 | #include <wtf/text/WTFString.h> |
38 | |
39 | namespace Messages { |
40 | |
41 | namespace PluginProcessProxy { |
42 | |
43 | #if PLATFORM(COCOA) |
44 | |
45 | void LaunchProcess::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool result) |
46 | { |
47 | *encoder << result; |
48 | connection.sendSyncReply(WTFMove(encoder)); |
49 | } |
50 | |
51 | #endif |
52 | |
53 | #if PLATFORM(COCOA) |
54 | |
55 | void LaunchApplicationAtURL::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool result) |
56 | { |
57 | *encoder << result; |
58 | connection.sendSyncReply(WTFMove(encoder)); |
59 | } |
60 | |
61 | #endif |
62 | |
63 | #if PLATFORM(COCOA) |
64 | |
65 | void OpenURL::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool result, int32_t status, const String& launchedURLString) |
66 | { |
67 | *encoder << result; |
68 | *encoder << status; |
69 | *encoder << launchedURLString; |
70 | connection.sendSyncReply(WTFMove(encoder)); |
71 | } |
72 | |
73 | #endif |
74 | |
75 | #if PLATFORM(COCOA) |
76 | |
77 | void OpenFile::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection, bool result) |
78 | { |
79 | *encoder << result; |
80 | connection.sendSyncReply(WTFMove(encoder)); |
81 | } |
82 | |
83 | #endif |
84 | |
85 | } // namespace PluginProcessProxy |
86 | |
87 | } // namespace Messages |
88 | |
89 | namespace WebKit { |
90 | |
91 | void PluginProcessProxy::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder) |
92 | { |
93 | if (decoder.messageName() == Messages::PluginProcessProxy::DidCreateWebProcessConnection::name()) { |
94 | IPC::handleMessage<Messages::PluginProcessProxy::DidCreateWebProcessConnection>(decoder, this, &PluginProcessProxy::didCreateWebProcessConnection); |
95 | return; |
96 | } |
97 | if (decoder.messageName() == Messages::PluginProcessProxy::DidGetSitesWithData::name()) { |
98 | IPC::handleMessage<Messages::PluginProcessProxy::DidGetSitesWithData>(decoder, this, &PluginProcessProxy::didGetSitesWithData); |
99 | return; |
100 | } |
101 | if (decoder.messageName() == Messages::PluginProcessProxy::DidDeleteWebsiteData::name()) { |
102 | IPC::handleMessage<Messages::PluginProcessProxy::DidDeleteWebsiteData>(decoder, this, &PluginProcessProxy::didDeleteWebsiteData); |
103 | return; |
104 | } |
105 | if (decoder.messageName() == Messages::PluginProcessProxy::DidDeleteWebsiteDataForHostNames::name()) { |
106 | IPC::handleMessage<Messages::PluginProcessProxy::DidDeleteWebsiteDataForHostNames>(decoder, this, &PluginProcessProxy::didDeleteWebsiteDataForHostNames); |
107 | return; |
108 | } |
109 | #if PLATFORM(COCOA) |
110 | if (decoder.messageName() == Messages::PluginProcessProxy::SetModalWindowIsShowing::name()) { |
111 | IPC::handleMessage<Messages::PluginProcessProxy::SetModalWindowIsShowing>(decoder, this, &PluginProcessProxy::setModalWindowIsShowing); |
112 | return; |
113 | } |
114 | #endif |
115 | #if PLATFORM(COCOA) |
116 | if (decoder.messageName() == Messages::PluginProcessProxy::SetFullscreenWindowIsShowing::name()) { |
117 | IPC::handleMessage<Messages::PluginProcessProxy::SetFullscreenWindowIsShowing>(decoder, this, &PluginProcessProxy::setFullscreenWindowIsShowing); |
118 | return; |
119 | } |
120 | #endif |
121 | UNUSED_PARAM(connection); |
122 | UNUSED_PARAM(decoder); |
123 | ASSERT_NOT_REACHED(); |
124 | } |
125 | |
126 | void PluginProcessProxy::didReceiveSyncMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder) |
127 | { |
128 | #if PLATFORM(COCOA) |
129 | if (decoder.messageName() == Messages::PluginProcessProxy::LaunchProcess::name()) { |
130 | IPC::handleMessageSynchronous<Messages::PluginProcessProxy::LaunchProcess>(connection, decoder, replyEncoder, this, &PluginProcessProxy::launchProcess); |
131 | return; |
132 | } |
133 | #endif |
134 | #if PLATFORM(COCOA) |
135 | if (decoder.messageName() == Messages::PluginProcessProxy::LaunchApplicationAtURL::name()) { |
136 | IPC::handleMessageSynchronous<Messages::PluginProcessProxy::LaunchApplicationAtURL>(connection, decoder, replyEncoder, this, &PluginProcessProxy::launchApplicationAtURL); |
137 | return; |
138 | } |
139 | #endif |
140 | #if PLATFORM(COCOA) |
141 | if (decoder.messageName() == Messages::PluginProcessProxy::OpenURL::name()) { |
142 | IPC::handleMessageSynchronous<Messages::PluginProcessProxy::OpenURL>(connection, decoder, replyEncoder, this, &PluginProcessProxy::openURL); |
143 | return; |
144 | } |
145 | #endif |
146 | #if PLATFORM(COCOA) |
147 | if (decoder.messageName() == Messages::PluginProcessProxy::OpenFile::name()) { |
148 | IPC::handleMessageSynchronous<Messages::PluginProcessProxy::OpenFile>(connection, decoder, replyEncoder, this, &PluginProcessProxy::openFile); |
149 | return; |
150 | } |
151 | #endif |
152 | UNUSED_PARAM(connection); |
153 | UNUSED_PARAM(decoder); |
154 | UNUSED_PARAM(replyEncoder); |
155 | ASSERT_NOT_REACHED(); |
156 | } |
157 | |
158 | } // namespace WebKit |
159 | |
160 | |
161 | #endif // ENABLE(NETSCAPE_PLUGIN_API) |
162 | |