1/*
2 * Copyright (C) 2012 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 "NetworkProcessCreationParameters.h"
28
29#if ENABLE(NETWORK_PROCESS)
30
31#include "ArgumentCoders.h"
32
33namespace WebKit {
34
35NetworkProcessCreationParameters::NetworkProcessCreationParameters()
36{
37}
38
39void NetworkProcessCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
40{
41    encoder << privateBrowsingEnabled;
42    encoder.encodeEnum(cacheModel);
43    encoder << diskCacheDirectory;
44    encoder << diskCacheDirectoryExtensionHandle;
45    encoder << cookieStorageDirectory;
46#if PLATFORM(IOS)
47    encoder << cookieStorageDirectoryExtensionHandle;
48    encoder << hstsDatabasePathExtensionHandle;
49    encoder << parentBundleDirectoryExtensionHandle;
50#endif
51    encoder << shouldUseTestingNetworkSession;
52#if ENABLE(CUSTOM_PROTOCOLS)
53    encoder << urlSchemesRegisteredForCustomProtocols;
54#endif
55#if PLATFORM(COCOA)
56    encoder << parentProcessName;
57    encoder << uiProcessBundleIdentifier;
58    encoder << nsURLCacheMemoryCapacity;
59    encoder << nsURLCacheDiskCapacity;
60    encoder << httpProxy;
61    encoder << httpsProxy;
62#endif
63#if USE(SOUP)
64    encoder << cookiePersistentStoragePath;
65    encoder << cookiePersistentStorageType;
66    encoder.encodeEnum(cookieAcceptPolicy);
67    encoder << ignoreTLSErrors;
68    encoder << languages;
69#endif
70}
71
72bool NetworkProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, NetworkProcessCreationParameters& result)
73{
74    if (!decoder.decode(result.privateBrowsingEnabled))
75        return false;
76    if (!decoder.decodeEnum(result.cacheModel))
77        return false;
78    if (!decoder.decode(result.diskCacheDirectory))
79        return false;
80    if (!decoder.decode(result.diskCacheDirectoryExtensionHandle))
81        return false;
82    if (!decoder.decode(result.cookieStorageDirectory))
83        return false;
84#if PLATFORM(IOS)
85    if (!decoder.decode(result.cookieStorageDirectoryExtensionHandle))
86        return false;
87    if (!decoder.decode(result.hstsDatabasePathExtensionHandle))
88        return false;
89    if (!decoder.decode(result.parentBundleDirectoryExtensionHandle))
90        return false;
91#endif
92    if (!decoder.decode(result.shouldUseTestingNetworkSession))
93        return false;
94#if ENABLE(CUSTOM_PROTOCOLS)
95    if (!decoder.decode(result.urlSchemesRegisteredForCustomProtocols))
96        return false;
97#endif
98#if PLATFORM(COCOA)
99    if (!decoder.decode(result.parentProcessName))
100        return false;
101    if (!decoder.decode(result.uiProcessBundleIdentifier))
102        return false;
103    if (!decoder.decode(result.nsURLCacheMemoryCapacity))
104        return false;
105    if (!decoder.decode(result.nsURLCacheDiskCapacity))
106        return false;
107    if (!decoder.decode(result.httpProxy))
108        return false;
109    if (!decoder.decode(result.httpsProxy))
110        return false;
111#endif
112
113#if USE(SOUP)
114    if (!decoder.decode(result.cookiePersistentStoragePath))
115        return false;
116    if (!decoder.decode(result.cookiePersistentStorageType))
117        return false;
118    if (!decoder.decodeEnum(result.cookieAcceptPolicy))
119        return false;
120    if (!decoder.decode(result.ignoreTLSErrors))
121        return false;
122    if (!decoder.decode(result.languages))
123        return false;
124#endif
125
126    return true;
127}
128
129} // namespace WebKit
130
131#endif // ENABLE(NETWORK_PROCESS)
132