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'' |
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 "WebPageCreationParameters.h" |
28 | |
29 | #include "WebCoreArgumentCoders.h" |
30 | |
31 | namespace WebKit { |
32 | |
33 | void WebPageCreationParameters::encode(IPC::Encoder& encoder) const |
34 | { |
35 | encoder << viewSize; |
36 | encoder << activityState; |
37 | |
38 | encoder << store; |
39 | encoder.encodeEnum(drawingAreaType); |
40 | encoder << drawingAreaIdentifier; |
41 | encoder << pageGroupData; |
42 | encoder << isEditable; |
43 | encoder << underlayColor; |
44 | encoder << useFixedLayout; |
45 | encoder << fixedLayoutSize; |
46 | encoder << alwaysShowsHorizontalScroller; |
47 | encoder << alwaysShowsVerticalScroller; |
48 | encoder.encodeEnum(paginationMode); |
49 | encoder << paginationBehavesLikeColumns; |
50 | encoder << pageLength; |
51 | encoder << gapBetweenPages; |
52 | encoder << paginationLineGridEnabled; |
53 | encoder << userAgent; |
54 | encoder << itemStates; |
55 | encoder << sessionID; |
56 | encoder << userContentControllerID.toUInt64(); |
57 | encoder << visitedLinkTableID; |
58 | encoder << websiteDataStoreID; |
59 | encoder << canRunBeforeUnloadConfirmPanel; |
60 | encoder << canRunModal; |
61 | encoder << deviceScaleFactor; |
62 | encoder << viewScaleFactor; |
63 | encoder << textZoomFactor; |
64 | encoder << pageZoomFactor; |
65 | encoder << topContentInset; |
66 | encoder << mediaVolume; |
67 | encoder << muted; |
68 | encoder << mayStartMediaWhenInWindow; |
69 | encoder << viewLayoutSize; |
70 | encoder << autoSizingShouldExpandToViewHeight; |
71 | encoder << viewportSizeForCSSViewportUnits; |
72 | encoder.encodeEnum(scrollPinningBehavior); |
73 | encoder << scrollbarOverlayStyle; |
74 | encoder << backgroundExtendsBeyondPage; |
75 | encoder.encodeEnum(layerHostingMode); |
76 | encoder << mimeTypesWithCustomContentProviders; |
77 | encoder << controlledByAutomation; |
78 | encoder << isProcessSwap; |
79 | encoder << useDarkAppearance; |
80 | encoder << useInactiveAppearance; |
81 | |
82 | #if PLATFORM(MAC) |
83 | encoder << colorSpace; |
84 | encoder << useSystemAppearance; |
85 | #endif |
86 | #if PLATFORM(IOS_FAMILY) |
87 | encoder << screenSize; |
88 | encoder << availableScreenSize; |
89 | encoder << overrideScreenSize; |
90 | encoder << textAutosizingWidth; |
91 | encoder << ignoresViewportScaleLimits; |
92 | encoder << viewportConfigurationViewLayoutSize; |
93 | encoder << viewportConfigurationLayoutSizeScaleFactor; |
94 | encoder << viewportConfigurationMinimumEffectiveDeviceWidth; |
95 | encoder << viewportConfigurationViewSize; |
96 | encoder << maximumUnobscuredSize; |
97 | encoder << deviceOrientation; |
98 | encoder << keyboardIsAttached; |
99 | encoder << canShowWhileLocked; |
100 | encoder << overrideViewportArguments; |
101 | #endif |
102 | #if PLATFORM(COCOA) |
103 | encoder << smartInsertDeleteEnabled; |
104 | encoder << additionalSupportedImageTypes; |
105 | #endif |
106 | #if PLATFORM(WPE) |
107 | encoder << hostFileDescriptor; |
108 | #endif |
109 | encoder << appleMailPaginationQuirkEnabled; |
110 | encoder << appleMailLinesClampEnabled; |
111 | encoder << shouldScaleViewToFitDocument; |
112 | encoder.encodeEnum(userInterfaceLayoutDirection); |
113 | encoder << observedLayoutMilestones; |
114 | encoder << overrideContentSecurityPolicy; |
115 | encoder << cpuLimit; |
116 | encoder << urlSchemeHandlers; |
117 | #if ENABLE(APPLICATION_MANIFEST) |
118 | encoder << applicationManifest; |
119 | #endif |
120 | #if ENABLE(SERVICE_WORKER) |
121 | encoder << hasRegisteredServiceWorkers; |
122 | #endif |
123 | encoder << needsFontAttributes; |
124 | encoder << iceCandidateFilteringEnabled; |
125 | encoder << enumeratingAllNetworkInterfacesEnabled; |
126 | encoder << userContentWorlds; |
127 | encoder << userScripts; |
128 | encoder << userStyleSheets; |
129 | encoder << messageHandlers; |
130 | #if ENABLE(CONTENT_EXTENSIONS) |
131 | encoder << contentRuleLists; |
132 | #endif |
133 | encoder << backgroundColor; |
134 | } |
135 | |
136 | Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decoder& decoder) |
137 | { |
138 | WebPageCreationParameters parameters; |
139 | if (!decoder.decode(parameters.viewSize)) |
140 | return WTF::nullopt; |
141 | if (!decoder.decode(parameters.activityState)) |
142 | return WTF::nullopt; |
143 | if (!decoder.decode(parameters.store)) |
144 | return WTF::nullopt; |
145 | if (!decoder.decodeEnum(parameters.drawingAreaType)) |
146 | return WTF::nullopt; |
147 | Optional<DrawingAreaIdentifier> drawingAreaIdentifier; |
148 | decoder >> drawingAreaIdentifier; |
149 | if (!drawingAreaIdentifier) |
150 | return WTF::nullopt; |
151 | parameters.drawingAreaIdentifier = *drawingAreaIdentifier; |
152 | Optional<WebPageGroupData> pageGroupData; |
153 | decoder >> pageGroupData; |
154 | if (!pageGroupData) |
155 | return WTF::nullopt; |
156 | parameters.pageGroupData = WTFMove(*pageGroupData); |
157 | if (!decoder.decode(parameters.isEditable)) |
158 | return WTF::nullopt; |
159 | if (!decoder.decode(parameters.underlayColor)) |
160 | return WTF::nullopt; |
161 | if (!decoder.decode(parameters.useFixedLayout)) |
162 | return WTF::nullopt; |
163 | if (!decoder.decode(parameters.fixedLayoutSize)) |
164 | return WTF::nullopt; |
165 | if (!decoder.decode(parameters.alwaysShowsHorizontalScroller)) |
166 | return WTF::nullopt; |
167 | if (!decoder.decode(parameters.alwaysShowsVerticalScroller)) |
168 | return WTF::nullopt; |
169 | if (!decoder.decodeEnum(parameters.paginationMode)) |
170 | return WTF::nullopt; |
171 | if (!decoder.decode(parameters.paginationBehavesLikeColumns)) |
172 | return WTF::nullopt; |
173 | if (!decoder.decode(parameters.pageLength)) |
174 | return WTF::nullopt; |
175 | if (!decoder.decode(parameters.gapBetweenPages)) |
176 | return WTF::nullopt; |
177 | if (!decoder.decode(parameters.paginationLineGridEnabled)) |
178 | return WTF::nullopt; |
179 | |
180 | Optional<String> userAgent; |
181 | decoder >> userAgent; |
182 | if (!userAgent) |
183 | return WTF::nullopt; |
184 | parameters.userAgent = WTFMove(*userAgent); |
185 | |
186 | Optional<Vector<BackForwardListItemState>> itemStates; |
187 | decoder >> itemStates; |
188 | if (!itemStates) |
189 | return WTF::nullopt; |
190 | parameters.itemStates = WTFMove(*itemStates); |
191 | |
192 | if (!decoder.decode(parameters.sessionID)) |
193 | return WTF::nullopt; |
194 | |
195 | Optional<uint64_t> userContentControllerIdentifier; |
196 | decoder >> userContentControllerIdentifier; |
197 | if (!userContentControllerIdentifier) |
198 | return WTF::nullopt; |
199 | parameters.userContentControllerID = makeObjectIdentifier<UserContentControllerIdentifierType>(*userContentControllerIdentifier); |
200 | |
201 | if (!decoder.decode(parameters.visitedLinkTableID)) |
202 | return WTF::nullopt; |
203 | if (!decoder.decode(parameters.websiteDataStoreID)) |
204 | return WTF::nullopt; |
205 | if (!decoder.decode(parameters.canRunBeforeUnloadConfirmPanel)) |
206 | return WTF::nullopt; |
207 | if (!decoder.decode(parameters.canRunModal)) |
208 | return WTF::nullopt; |
209 | if (!decoder.decode(parameters.deviceScaleFactor)) |
210 | return WTF::nullopt; |
211 | if (!decoder.decode(parameters.viewScaleFactor)) |
212 | return WTF::nullopt; |
213 | if (!decoder.decode(parameters.textZoomFactor)) |
214 | return WTF::nullopt; |
215 | if (!decoder.decode(parameters.pageZoomFactor)) |
216 | return WTF::nullopt; |
217 | if (!decoder.decode(parameters.topContentInset)) |
218 | return WTF::nullopt; |
219 | if (!decoder.decode(parameters.mediaVolume)) |
220 | return WTF::nullopt; |
221 | if (!decoder.decode(parameters.muted)) |
222 | return WTF::nullopt; |
223 | if (!decoder.decode(parameters.mayStartMediaWhenInWindow)) |
224 | return WTF::nullopt; |
225 | if (!decoder.decode(parameters.viewLayoutSize)) |
226 | return WTF::nullopt; |
227 | if (!decoder.decode(parameters.autoSizingShouldExpandToViewHeight)) |
228 | return WTF::nullopt; |
229 | if (!decoder.decode(parameters.viewportSizeForCSSViewportUnits)) |
230 | return WTF::nullopt; |
231 | if (!decoder.decodeEnum(parameters.scrollPinningBehavior)) |
232 | return WTF::nullopt; |
233 | |
234 | Optional<Optional<uint32_t>> scrollbarOverlayStyle; |
235 | decoder >> scrollbarOverlayStyle; |
236 | if (!scrollbarOverlayStyle) |
237 | return WTF::nullopt; |
238 | parameters.scrollbarOverlayStyle = WTFMove(*scrollbarOverlayStyle); |
239 | |
240 | if (!decoder.decode(parameters.backgroundExtendsBeyondPage)) |
241 | return WTF::nullopt; |
242 | if (!decoder.decodeEnum(parameters.layerHostingMode)) |
243 | return WTF::nullopt; |
244 | if (!decoder.decode(parameters.mimeTypesWithCustomContentProviders)) |
245 | return WTF::nullopt; |
246 | if (!decoder.decode(parameters.controlledByAutomation)) |
247 | return WTF::nullopt; |
248 | if (!decoder.decode(parameters.isProcessSwap)) |
249 | return WTF::nullopt; |
250 | if (!decoder.decode(parameters.useDarkAppearance)) |
251 | return WTF::nullopt; |
252 | if (!decoder.decode(parameters.useInactiveAppearance)) |
253 | return WTF::nullopt; |
254 | |
255 | #if PLATFORM(MAC) |
256 | if (!decoder.decode(parameters.colorSpace)) |
257 | return WTF::nullopt; |
258 | if (!decoder.decode(parameters.useSystemAppearance)) |
259 | return WTF::nullopt; |
260 | #endif |
261 | |
262 | #if PLATFORM(IOS_FAMILY) |
263 | if (!decoder.decode(parameters.screenSize)) |
264 | return WTF::nullopt; |
265 | if (!decoder.decode(parameters.availableScreenSize)) |
266 | return WTF::nullopt; |
267 | if (!decoder.decode(parameters.overrideScreenSize)) |
268 | return WTF::nullopt; |
269 | if (!decoder.decode(parameters.textAutosizingWidth)) |
270 | return WTF::nullopt; |
271 | if (!decoder.decode(parameters.ignoresViewportScaleLimits)) |
272 | return WTF::nullopt; |
273 | if (!decoder.decode(parameters.viewportConfigurationViewLayoutSize)) |
274 | return WTF::nullopt; |
275 | if (!decoder.decode(parameters.viewportConfigurationLayoutSizeScaleFactor)) |
276 | return WTF::nullopt; |
277 | if (!decoder.decode(parameters.viewportConfigurationMinimumEffectiveDeviceWidth)) |
278 | return WTF::nullopt; |
279 | if (!decoder.decode(parameters.viewportConfigurationViewSize)) |
280 | return WTF::nullopt; |
281 | if (!decoder.decode(parameters.maximumUnobscuredSize)) |
282 | return WTF::nullopt; |
283 | if (!decoder.decode(parameters.deviceOrientation)) |
284 | return WTF::nullopt; |
285 | if (!decoder.decode(parameters.keyboardIsAttached)) |
286 | return WTF::nullopt; |
287 | if (!decoder.decode(parameters.canShowWhileLocked)) |
288 | return WTF::nullopt; |
289 | |
290 | Optional<Optional<WebCore::ViewportArguments>> overrideViewportArguments; |
291 | decoder >> overrideViewportArguments; |
292 | if (!overrideViewportArguments) |
293 | return WTF::nullopt; |
294 | parameters.overrideViewportArguments = WTFMove(*overrideViewportArguments); |
295 | #endif |
296 | |
297 | #if PLATFORM(COCOA) |
298 | if (!decoder.decode(parameters.smartInsertDeleteEnabled)) |
299 | return WTF::nullopt; |
300 | if (!decoder.decode(parameters.additionalSupportedImageTypes)) |
301 | return WTF::nullopt; |
302 | #endif |
303 | |
304 | #if PLATFORM(WPE) |
305 | if (!decoder.decode(parameters.hostFileDescriptor)) |
306 | return WTF::nullopt; |
307 | #endif |
308 | |
309 | if (!decoder.decode(parameters.appleMailPaginationQuirkEnabled)) |
310 | return WTF::nullopt; |
311 | |
312 | if (!decoder.decode(parameters.appleMailLinesClampEnabled)) |
313 | return WTF::nullopt; |
314 | |
315 | if (!decoder.decode(parameters.shouldScaleViewToFitDocument)) |
316 | return WTF::nullopt; |
317 | |
318 | if (!decoder.decodeEnum(parameters.userInterfaceLayoutDirection)) |
319 | return WTF::nullopt; |
320 | if (!decoder.decode(parameters.observedLayoutMilestones)) |
321 | return WTF::nullopt; |
322 | |
323 | if (!decoder.decode(parameters.overrideContentSecurityPolicy)) |
324 | return WTF::nullopt; |
325 | |
326 | Optional<Optional<double>> cpuLimit; |
327 | decoder >> cpuLimit; |
328 | if (!cpuLimit) |
329 | return WTF::nullopt; |
330 | parameters.cpuLimit = WTFMove(*cpuLimit); |
331 | |
332 | if (!decoder.decode(parameters.urlSchemeHandlers)) |
333 | return WTF::nullopt; |
334 | |
335 | #if ENABLE(APPLICATION_MANIFEST) |
336 | Optional<Optional<WebCore::ApplicationManifest>> applicationManifest; |
337 | decoder >> applicationManifest; |
338 | if (!applicationManifest) |
339 | return WTF::nullopt; |
340 | parameters.applicationManifest = WTFMove(*applicationManifest); |
341 | #endif |
342 | #if ENABLE(SERVICE_WORKER) |
343 | if (!decoder.decode(parameters.hasRegisteredServiceWorkers)) |
344 | return WTF::nullopt; |
345 | #endif |
346 | |
347 | if (!decoder.decode(parameters.needsFontAttributes)) |
348 | return WTF::nullopt; |
349 | |
350 | if (!decoder.decode(parameters.iceCandidateFilteringEnabled)) |
351 | return WTF::nullopt; |
352 | |
353 | if (!decoder.decode(parameters.enumeratingAllNetworkInterfacesEnabled)) |
354 | return WTF::nullopt; |
355 | |
356 | Optional<Vector<std::pair<uint64_t, String>>> userContentWorlds; |
357 | decoder >> userContentWorlds; |
358 | if (!userContentWorlds) |
359 | return WTF::nullopt; |
360 | parameters.userContentWorlds = WTFMove(*userContentWorlds); |
361 | |
362 | Optional<Vector<WebUserScriptData>> userScripts; |
363 | decoder >> userScripts; |
364 | if (!userScripts) |
365 | return WTF::nullopt; |
366 | parameters.userScripts = WTFMove(*userScripts); |
367 | |
368 | Optional<Vector<WebUserStyleSheetData>> userStyleSheets; |
369 | decoder >> userStyleSheets; |
370 | if (!userStyleSheets) |
371 | return WTF::nullopt; |
372 | parameters.userStyleSheets = WTFMove(*userStyleSheets); |
373 | |
374 | Optional<Vector<WebScriptMessageHandlerData>> messageHandlers; |
375 | decoder >> messageHandlers; |
376 | if (!messageHandlers) |
377 | return WTF::nullopt; |
378 | parameters.messageHandlers = WTFMove(*messageHandlers); |
379 | |
380 | #if ENABLE(CONTENT_EXTENSIONS) |
381 | Optional<Vector<std::pair<String, WebCompiledContentRuleListData>>> contentRuleLists; |
382 | decoder >> contentRuleLists; |
383 | if (!contentRuleLists) |
384 | return WTF::nullopt; |
385 | parameters.contentRuleLists = WTFMove(*contentRuleLists); |
386 | #endif |
387 | |
388 | Optional<Optional<WebCore::Color>> backgroundColor; |
389 | decoder >> backgroundColor; |
390 | if (!backgroundColor) |
391 | return WTF::nullopt; |
392 | parameters.backgroundColor = WTFMove(*backgroundColor); |
393 | |
394 | return parameters; |
395 | } |
396 | |
397 | } // namespace WebKit |
398 | |