1/*
2 * Copyright (C) 2014 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 "WKContextConfigurationRef.h"
28
29#include "APIArray.h"
30#include "APIProcessPoolConfiguration.h"
31#include "WKAPICast.h"
32
33using namespace WebKit;
34
35WKContextConfigurationRef WKContextConfigurationCreate()
36{
37 auto configuration = API::ProcessPoolConfiguration::create();
38
39 // FIXME: A context created like this shouldn't have a data store,
40 // instead there should be a WKPageConfigurationRef object that specifies the data store.
41 configuration->setShouldHaveLegacyDataStore(true);
42
43 return toAPI(&configuration.leakRef());
44}
45
46WKContextConfigurationRef WKContextConfigurationCreateWithLegacyOptions()
47{
48 return toAPI(&API::ProcessPoolConfiguration::createWithLegacyOptions().leakRef());
49}
50
51WKStringRef WKContextConfigurationCopyDiskCacheDirectory(WKContextConfigurationRef configuration)
52{
53 return toCopiedAPI(toImpl(configuration)->diskCacheDirectory());
54}
55
56void WKContextConfigurationSetDiskCacheDirectory(WKContextConfigurationRef configuration, WKStringRef diskCacheDirectory)
57{
58 toImpl(configuration)->setDiskCacheDirectory(toImpl(diskCacheDirectory)->string());
59}
60
61WKStringRef WKContextConfigurationCopyApplicationCacheDirectory(WKContextConfigurationRef configuration)
62{
63 return toCopiedAPI(toImpl(configuration)->applicationCacheDirectory());
64}
65
66void WKContextConfigurationSetApplicationCacheDirectory(WKContextConfigurationRef configuration, WKStringRef applicationCacheDirectory)
67{
68 toImpl(configuration)->setApplicationCacheDirectory(toImpl(applicationCacheDirectory)->string());
69}
70
71WKStringRef WKContextConfigurationCopyIndexedDBDatabaseDirectory(WKContextConfigurationRef configuration)
72{
73 return toCopiedAPI(toImpl(configuration)->indexedDBDatabaseDirectory());
74}
75
76void WKContextConfigurationSetIndexedDBDatabaseDirectory(WKContextConfigurationRef configuration, WKStringRef indexedDBDatabaseDirectory)
77{
78 toImpl(configuration)->setIndexedDBDatabaseDirectory(toImpl(indexedDBDatabaseDirectory)->string());
79}
80
81WKStringRef WKContextConfigurationCopyInjectedBundlePath(WKContextConfigurationRef configuration)
82{
83 return toCopiedAPI(toImpl(configuration)->injectedBundlePath());
84}
85
86void WKContextConfigurationSetInjectedBundlePath(WKContextConfigurationRef configuration, WKStringRef injectedBundlePath)
87{
88 toImpl(configuration)->setInjectedBundlePath(toImpl(injectedBundlePath)->string());
89}
90
91WKStringRef WKContextConfigurationCopyLocalStorageDirectory(WKContextConfigurationRef configuration)
92{
93 return toCopiedAPI(toImpl(configuration)->localStorageDirectory());
94}
95
96void WKContextConfigurationSetLocalStorageDirectory(WKContextConfigurationRef configuration, WKStringRef localStorageDirectory)
97{
98 toImpl(configuration)->setLocalStorageDirectory(toImpl(localStorageDirectory)->string());
99}
100
101WKStringRef WKContextConfigurationCopyWebSQLDatabaseDirectory(WKContextConfigurationRef configuration)
102{
103 return toCopiedAPI(toImpl(configuration)->webSQLDatabaseDirectory());
104}
105
106void WKContextConfigurationSetWebSQLDatabaseDirectory(WKContextConfigurationRef configuration, WKStringRef webSQLDatabaseDirectory)
107{
108 toImpl(configuration)->setWebSQLDatabaseDirectory(toImpl(webSQLDatabaseDirectory)->string());
109}
110
111WKStringRef WKContextConfigurationCopyMediaKeysStorageDirectory(WKContextConfigurationRef configuration)
112{
113 return toCopiedAPI(toImpl(configuration)->mediaKeysStorageDirectory());
114}
115
116void WKContextConfigurationSetMediaKeysStorageDirectory(WKContextConfigurationRef configuration, WKStringRef mediaKeysStorageDirectory)
117{
118 toImpl(configuration)->setMediaKeysStorageDirectory(toImpl(mediaKeysStorageDirectory)->string());
119}
120
121WKStringRef WKContextConfigurationCopyResourceLoadStatisticsDirectory(WKContextConfigurationRef configuration)
122{
123 return toCopiedAPI(toImpl(configuration)->resourceLoadStatisticsDirectory());
124}
125
126void WKContextConfigurationSetResourceLoadStatisticsDirectory(WKContextConfigurationRef configuration, WKStringRef resourceLoadStatisticsDirectory)
127{
128 toImpl(configuration)->setResourceLoadStatisticsDirectory(toImpl(resourceLoadStatisticsDirectory)->string());
129}
130
131bool WKContextConfigurationFullySynchronousModeIsAllowedForTesting(WKContextConfigurationRef configuration)
132{
133 return toImpl(configuration)->fullySynchronousModeIsAllowedForTesting();
134}
135
136void WKContextConfigurationSetFullySynchronousModeIsAllowedForTesting(WKContextConfigurationRef configuration, bool allowed)
137{
138 toImpl(configuration)->setFullySynchronousModeIsAllowedForTesting(allowed);
139}
140
141bool WKContextConfigurationIgnoreSynchronousMessagingTimeoutsForTesting(WKContextConfigurationRef configuration)
142{
143 return toImpl(configuration)->ignoreSynchronousMessagingTimeoutsForTesting();
144}
145
146void WKContextConfigurationSetIgnoreSynchronousMessagingTimeoutsForTesting(WKContextConfigurationRef configuration, bool ignore)
147{
148 toImpl(configuration)->setIgnoreSynchronousMessagingTimeoutsForTesting(ignore);
149}
150
151WKArrayRef WKContextConfigurationCopyOverrideLanguages(WKContextConfigurationRef configuration)
152{
153 return toAPI(&API::Array::createStringArray(toImpl(configuration)->overrideLanguages()).leakRef());
154}
155
156void WKContextConfigurationSetOverrideLanguages(WKContextConfigurationRef configuration, WKArrayRef overrideLanguages)
157{
158 toImpl(configuration)->setOverrideLanguages(toImpl(overrideLanguages)->toStringVector());
159}
160
161bool WKContextConfigurationShouldCaptureAudioInUIProcess(WKContextConfigurationRef configuration)
162{
163 return toImpl(configuration)->shouldCaptureAudioInUIProcess();
164}
165
166void WKContextConfigurationSetShouldCaptureAudioInUIProcess(WKContextConfigurationRef configuration, bool should)
167{
168 toImpl(configuration)->setShouldCaptureAudioInUIProcess(should);
169}
170
171bool WKContextConfigurationProcessSwapsOnNavigation(WKContextConfigurationRef configuration)
172{
173 return toImpl(configuration)->processSwapsOnNavigation();
174}
175
176void WKContextConfigurationSetProcessSwapsOnNavigation(WKContextConfigurationRef configuration, bool swaps)
177{
178 toImpl(configuration)->setProcessSwapsOnNavigation(swaps);
179}
180
181bool WKContextConfigurationPrewarmsProcessesAutomatically(WKContextConfigurationRef configuration)
182{
183 return toImpl(configuration)->isAutomaticProcessWarmingEnabled();
184}
185
186void WKContextConfigurationSetPrewarmsProcessesAutomatically(WKContextConfigurationRef configuration, bool prewarms)
187{
188 toImpl(configuration)->setIsAutomaticProcessWarmingEnabled(prewarms);
189}
190
191bool WKContextConfigurationUsesWebProcessCache(WKContextConfigurationRef configuration)
192{
193 return toImpl(configuration)->usesWebProcessCache();
194}
195
196void WKContextConfigurationSetUsesWebProcessCache(WKContextConfigurationRef configuration, bool uses)
197{
198 toImpl(configuration)->setUsesWebProcessCache(uses);
199}
200
201bool WKContextConfigurationAlwaysKeepAndReuseSwappedProcesses(WKContextConfigurationRef configuration)
202{
203 return toImpl(configuration)->alwaysKeepAndReuseSwappedProcesses();
204}
205
206void WKContextConfigurationSetAlwaysKeepAndReuseSwappedProcesses(WKContextConfigurationRef configuration, bool keepAndReuse)
207{
208 toImpl(configuration)->setAlwaysKeepAndReuseSwappedProcesses(keepAndReuse);
209}
210
211bool WKContextConfigurationProcessSwapsOnWindowOpenWithOpener(WKContextConfigurationRef configuration)
212{
213 return toImpl(configuration)->processSwapsOnWindowOpenWithOpener();
214}
215
216void WKContextConfigurationSetProcessSwapsOnWindowOpenWithOpener(WKContextConfigurationRef configuration, bool swaps)
217{
218 toImpl(configuration)->setProcessSwapsOnWindowOpenWithOpener(swaps);
219}
220
221int64_t WKContextConfigurationDiskCacheSizeOverride(WKContextConfigurationRef configuration)
222{
223 return 0;
224}
225
226void WKContextConfigurationSetDiskCacheSizeOverride(WKContextConfigurationRef configuration, int64_t size)
227{
228}
229
230