77e3a82ec8ec6b22c00a928d0d23348a86f3b417
[WebKit.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 "WebProcessCreationParameters.h"
27
28 #include "ArgumentCoders.h"
29
30 namespace WebKit {
31
32 WebProcessCreationParameters::WebProcessCreationParameters()
33     : shouldTrackVisitedLinks(false)
34     , shouldAlwaysUseComplexTextCodePath(false)
35 #if PLATFORM(MAC)
36     , nsURLCacheMemoryCapacity(0)
37     , nsURLCacheDiskCapacity(0)
38 #elif PLATFORM(WIN)
39     , shouldPaintNativeControls(false)
40 #endif
41 {
42 }
43
44 void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) const
45 {
46     encoder->encode(injectedBundlePath);
47     encoder->encode(injectedBundlePathExtensionHandle);
48     encoder->encode(applicationCacheDirectory);
49     encoder->encode(urlSchemesRegistererdAsEmptyDocument);
50     encoder->encode(urlSchemesRegisteredAsSecure);
51     encoder->encode(urlSchemesForWhichDomainRelaxationIsForbidden);
52     encoder->encode(mimeTypesWithCustomRepresentation);
53     encoder->encodeEnum(cacheModel);
54     encoder->encode(shouldTrackVisitedLinks);
55     encoder->encode(shouldAlwaysUseComplexTextCodePath);
56     encoder->encode(languageCode);
57     encoder->encode(textCheckerState);
58 #if PLATFORM(MAC)
59     encoder->encode(parentProcessName);
60     encoder->encode(presenterApplicationPid);
61     encoder->encode(nsURLCachePath);
62     encoder->encode(nsURLCacheMemoryCapacity);
63     encoder->encode(nsURLCacheDiskCapacity);
64     encoder->encode(acceleratedCompositingPort);
65     encoder->encode(uiProcessBundleResourcePath);
66 #elif PLATFORM(WIN)
67     encoder->encode(shouldPaintNativeControls);
68 #endif
69 }
70
71 bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, WebProcessCreationParameters& parameters)
72 {
73     if (!decoder->decode(parameters.injectedBundlePath))
74         return false;
75     if (!decoder->decode(parameters.injectedBundlePathExtensionHandle))
76         return false;
77     if (!decoder->decode(parameters.applicationCacheDirectory))
78         return false;
79     if (!decoder->decode(parameters.urlSchemesRegistererdAsEmptyDocument))
80         return false;
81     if (!decoder->decode(parameters.urlSchemesRegisteredAsSecure))
82         return false;
83     if (!decoder->decode(parameters.urlSchemesForWhichDomainRelaxationIsForbidden))
84         return false;
85     if (!decoder->decode(parameters.mimeTypesWithCustomRepresentation))
86         return false;
87     if (!decoder->decodeEnum(parameters.cacheModel))
88         return false;
89     if (!decoder->decode(parameters.shouldTrackVisitedLinks))
90         return false;
91     if (!decoder->decode(parameters.shouldAlwaysUseComplexTextCodePath))
92         return false;
93     if (!decoder->decode(parameters.languageCode))
94         return false;
95     if (!decoder->decode(parameters.textCheckerState))
96         return false;
97
98 #if PLATFORM(MAC)
99     if (!decoder->decode(parameters.parentProcessName))
100         return false;
101     if (!decoder->decode(parameters.presenterApplicationPid))
102         return false;
103     if (!decoder->decode(parameters.nsURLCachePath))
104         return false;
105     if (!decoder->decode(parameters.nsURLCacheMemoryCapacity))
106         return false;
107     if (!decoder->decode(parameters.nsURLCacheDiskCapacity))
108         return false;
109     if (!decoder->decode(parameters.acceleratedCompositingPort))
110         return false;
111     if (!decoder->decode(parameters.uiProcessBundleResourcePath))
112         return false;
113 #elif PLATFORM(WIN)
114     if (!decoder->decode(parameters.shouldPaintNativeControls))
115         return false;
116 #endif
117
118     return true;
119 }
120
121 } // namespace WebKit