initial import
[vuplus_webkit] / 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(databaseDirectory);
55     encoder->encode(localStorageDirectory);
56     encoder->encode(urlSchemesRegistererdAsEmptyDocument);
57     encoder->encode(urlSchemesRegisteredAsSecure);
58     encoder->encode(urlSchemesForWhichDomainRelaxationIsForbidden);
59     encoder->encode(mimeTypesWithCustomRepresentation);
60     encoder->encodeEnum(cacheModel);
61     encoder->encode(shouldTrackVisitedLinks);
62     encoder->encode(shouldAlwaysUseComplexTextCodePath);
63     encoder->encode(iconDatabaseEnabled);
64 #if ENABLE(PLUGIN_PROCESS)
65     encoder->encode(disablePluginProcessMessageTimeout);
66 #endif
67     encoder->encode(languageCode);
68     encoder->encode(textCheckerState);
69     encoder->encode(defaultRequestTimeoutInterval);
70 #if USE(CFURLSTORAGESESSIONS)
71     encoder->encode(uiProcessBundleIdentifier);
72 #endif
73 #if PLATFORM(MAC)
74     encoder->encode(parentProcessName);
75     encoder->encode(presenterApplicationPid);
76     encoder->encode(nsURLCachePath);
77     encoder->encode(nsURLCacheMemoryCapacity);
78     encoder->encode(nsURLCacheDiskCapacity);
79     encoder->encode(acceleratedCompositingPort);
80     encoder->encode(uiProcessBundleResourcePath);
81 #elif PLATFORM(WIN)
82     encoder->encode(shouldPaintNativeControls);
83     encoder->encode(cfURLCachePath);
84     encoder->encode(cfURLCacheDiskCapacity);
85     encoder->encode(cfURLCacheMemoryCapacity);
86     encoder->encode(initialHTTPCookieAcceptPolicy);
87 #if USE(CFURLSTORAGESESSIONS)
88     CFDataRef storageSession = serializedDefaultStorageSession.get();
89     encoder->encodeBool(storageSession);
90     if (storageSession)
91         CoreIPC::encode(encoder, storageSession);
92 #endif // USE(CFURLSTORAGESESSIONS)
93 #endif
94 }
95
96 bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, WebProcessCreationParameters& parameters)
97 {
98     if (!decoder->decode(parameters.injectedBundlePath))
99         return false;
100     if (!decoder->decode(parameters.injectedBundlePathExtensionHandle))
101         return false;
102     if (!decoder->decode(parameters.applicationCacheDirectory))
103         return false;
104     if (!decoder->decode(parameters.databaseDirectory))
105         return false;
106     if (!decoder->decode(parameters.localStorageDirectory))
107         return false;
108     if (!decoder->decode(parameters.urlSchemesRegistererdAsEmptyDocument))
109         return false;
110     if (!decoder->decode(parameters.urlSchemesRegisteredAsSecure))
111         return false;
112     if (!decoder->decode(parameters.urlSchemesForWhichDomainRelaxationIsForbidden))
113         return false;
114     if (!decoder->decode(parameters.mimeTypesWithCustomRepresentation))
115         return false;
116     if (!decoder->decodeEnum(parameters.cacheModel))
117         return false;
118     if (!decoder->decode(parameters.shouldTrackVisitedLinks))
119         return false;
120     if (!decoder->decode(parameters.shouldAlwaysUseComplexTextCodePath))
121         return false;
122     if (!decoder->decode(parameters.iconDatabaseEnabled))
123         return false;
124 #if ENABLE(PLUGIN_PROCESS)
125     if (!decoder->decode(parameters.disablePluginProcessMessageTimeout))
126         return false;
127 #endif
128
129     if (!decoder->decode(parameters.languageCode))
130         return false;
131     if (!decoder->decode(parameters.textCheckerState))
132         return false;
133     if (!decoder->decode(parameters.defaultRequestTimeoutInterval))
134         return false;
135 #if USE(CFURLSTORAGESESSIONS)
136     if (!decoder->decode(parameters.uiProcessBundleIdentifier))
137         return false;
138 #endif
139
140 #if PLATFORM(MAC)
141     if (!decoder->decode(parameters.parentProcessName))
142         return false;
143     if (!decoder->decode(parameters.presenterApplicationPid))
144         return false;
145     if (!decoder->decode(parameters.nsURLCachePath))
146         return false;
147     if (!decoder->decode(parameters.nsURLCacheMemoryCapacity))
148         return false;
149     if (!decoder->decode(parameters.nsURLCacheDiskCapacity))
150         return false;
151     if (!decoder->decode(parameters.acceleratedCompositingPort))
152         return false;
153     if (!decoder->decode(parameters.uiProcessBundleResourcePath))
154         return false;
155 #elif PLATFORM(WIN)
156     if (!decoder->decode(parameters.shouldPaintNativeControls))
157         return false;
158     if (!decoder->decode(parameters.cfURLCachePath))
159         return false;
160     if (!decoder->decode(parameters.cfURLCacheDiskCapacity))
161         return false;
162     if (!decoder->decode(parameters.cfURLCacheMemoryCapacity))
163         return false;
164     if (!decoder->decode(parameters.initialHTTPCookieAcceptPolicy))
165         return false;
166 #if USE(CFURLSTORAGESESSIONS)
167     bool hasStorageSession = false;
168     if (!decoder->decode(hasStorageSession))
169         return false;
170     if (hasStorageSession && !CoreIPC::decode(decoder, parameters.serializedDefaultStorageSession))
171         return false;
172 #endif // USE(CFURLSTORAGESESSIONS)
173 #endif
174
175     return true;
176 }
177
178 } // namespace WebKit