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