1/*
2 * Copyright (C) 2010 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 "WebProcessCreationParameters.h"
28
29#include "ArgumentCoders.h"
30
31namespace WebKit {
32
33WebProcessCreationParameters::WebProcessCreationParameters()
34    : shouldTrackVisitedLinks(false)
35    , shouldAlwaysUseComplexTextCodePath(false)
36    , defaultRequestTimeoutInterval(INT_MAX)
37#if PLATFORM(MAC)
38    , nsURLCacheMemoryCapacity(0)
39    , nsURLCacheDiskCapacity(0)
40#elif PLATFORM(WIN)
41    , shouldPaintNativeControls(false)
42#endif
43{
44}
45
46void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) const
47{
48    encoder->encode(injectedBundlePath);
49    encoder->encode(injectedBundlePathExtensionHandle);
50    encoder->encode(applicationCacheDirectory);
51    encoder->encode(databaseDirectory);
52    encoder->encode(localStorageDirectory);
53    encoder->encode(urlSchemesRegistererdAsEmptyDocument);
54    encoder->encode(urlSchemesRegisteredAsSecure);
55    encoder->encode(urlSchemesForWhichDomainRelaxationIsForbidden);
56    encoder->encode(mimeTypesWithCustomRepresentation);
57    encoder->encodeEnum(cacheModel);
58    encoder->encode(shouldTrackVisitedLinks);
59    encoder->encode(shouldAlwaysUseComplexTextCodePath);
60    encoder->encode(iconDatabaseEnabled);
61    encoder->encode(languageCode);
62    encoder->encode(textCheckerState);
63    encoder->encode(defaultRequestTimeoutInterval);
64#if USE(CFURLSTORAGESESSIONS)
65    encoder->encode(uiProcessBundleIdentifier);
66#endif
67#if PLATFORM(MAC)
68    encoder->encode(parentProcessName);
69    encoder->encode(presenterApplicationPid);
70    encoder->encode(nsURLCachePath);
71    encoder->encode(nsURLCacheMemoryCapacity);
72    encoder->encode(nsURLCacheDiskCapacity);
73    encoder->encode(acceleratedCompositingPort);
74    encoder->encode(uiProcessBundleResourcePath);
75#elif PLATFORM(WIN)
76    encoder->encode(shouldPaintNativeControls);
77    encoder->encode(cfURLCachePath);
78    encoder->encode(cfURLCacheDiskCapacity);
79    encoder->encode(cfURLCacheMemoryCapacity);
80    encoder->encode(initialHTTPCookieAcceptPolicy);
81#endif
82}
83
84bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, WebProcessCreationParameters& parameters)
85{
86    if (!decoder->decode(parameters.injectedBundlePath))
87        return false;
88    if (!decoder->decode(parameters.injectedBundlePathExtensionHandle))
89        return false;
90    if (!decoder->decode(parameters.applicationCacheDirectory))
91        return false;
92    if (!decoder->decode(parameters.databaseDirectory))
93        return false;
94    if (!decoder->decode(parameters.localStorageDirectory))
95        return false;
96    if (!decoder->decode(parameters.urlSchemesRegistererdAsEmptyDocument))
97        return false;
98    if (!decoder->decode(parameters.urlSchemesRegisteredAsSecure))
99        return false;
100    if (!decoder->decode(parameters.urlSchemesForWhichDomainRelaxationIsForbidden))
101        return false;
102    if (!decoder->decode(parameters.mimeTypesWithCustomRepresentation))
103        return false;
104    if (!decoder->decodeEnum(parameters.cacheModel))
105        return false;
106    if (!decoder->decode(parameters.shouldTrackVisitedLinks))
107        return false;
108    if (!decoder->decode(parameters.shouldAlwaysUseComplexTextCodePath))
109        return false;
110    if (!decoder->decode(parameters.iconDatabaseEnabled))
111        return false;
112    if (!decoder->decode(parameters.languageCode))
113        return false;
114    if (!decoder->decode(parameters.textCheckerState))
115        return false;
116    if (!decoder->decode(parameters.defaultRequestTimeoutInterval))
117        return false;
118#if USE(CFURLSTORAGESESSIONS)
119    if (!decoder->decode(parameters.uiProcessBundleIdentifier))
120        return false;
121#endif
122
123#if PLATFORM(MAC)
124    if (!decoder->decode(parameters.parentProcessName))
125        return false;
126    if (!decoder->decode(parameters.presenterApplicationPid))
127        return false;
128    if (!decoder->decode(parameters.nsURLCachePath))
129        return false;
130    if (!decoder->decode(parameters.nsURLCacheMemoryCapacity))
131        return false;
132    if (!decoder->decode(parameters.nsURLCacheDiskCapacity))
133        return false;
134    if (!decoder->decode(parameters.acceleratedCompositingPort))
135        return false;
136    if (!decoder->decode(parameters.uiProcessBundleResourcePath))
137        return false;
138#elif PLATFORM(WIN)
139    if (!decoder->decode(parameters.shouldPaintNativeControls))
140        return false;
141    if (!decoder->decode(parameters.cfURLCachePath))
142        return false;
143    if (!decoder->decode(parameters.cfURLCacheDiskCapacity))
144        return false;
145    if (!decoder->decode(parameters.cfURLCacheMemoryCapacity))
146        return false;
147    if (!decoder->decode(parameters.initialHTTPCookieAcceptPolicy))
148        return false;
149#endif
150
151    return true;
152}
153
154} // namespace WebKit
155