Add WebProcessPool option for process swapping on navigation.
[WebKit-https.git] / Source / WebKit / UIProcess / API / C / WKContextConfigurationRef.cpp
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
33 using namespace WebKit;
34
35 WKContextConfigurationRef 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
46 WKContextConfigurationRef WKContextConfigurationCreateWithLegacyOptions()
47 {
48     return toAPI(&API::ProcessPoolConfiguration::createWithLegacyOptions().leakRef());
49 }
50
51 WKStringRef WKContextConfigurationCopyDiskCacheDirectory(WKContextConfigurationRef configuration)
52 {
53     return toCopiedAPI(toImpl(configuration)->diskCacheDirectory());
54 }
55
56 void WKContextConfigurationSetDiskCacheDirectory(WKContextConfigurationRef configuration, WKStringRef diskCacheDirectory)
57 {
58     toImpl(configuration)->setDiskCacheDirectory(toImpl(diskCacheDirectory)->string());
59 }
60
61 WKStringRef WKContextConfigurationCopyApplicationCacheDirectory(WKContextConfigurationRef configuration)
62 {
63     return toCopiedAPI(toImpl(configuration)->applicationCacheDirectory());
64 }
65
66 void WKContextConfigurationSetApplicationCacheDirectory(WKContextConfigurationRef configuration, WKStringRef applicationCacheDirectory)
67 {
68     toImpl(configuration)->setApplicationCacheDirectory(toImpl(applicationCacheDirectory)->string());
69 }
70
71 WKStringRef WKContextConfigurationCopyIndexedDBDatabaseDirectory(WKContextConfigurationRef configuration)
72 {
73     return toCopiedAPI(toImpl(configuration)->indexedDBDatabaseDirectory());
74 }
75
76 void WKContextConfigurationSetIndexedDBDatabaseDirectory(WKContextConfigurationRef configuration, WKStringRef indexedDBDatabaseDirectory)
77 {
78     toImpl(configuration)->setIndexedDBDatabaseDirectory(toImpl(indexedDBDatabaseDirectory)->string());
79 }
80
81 WKStringRef WKContextConfigurationCopyInjectedBundlePath(WKContextConfigurationRef configuration)
82 {
83     return toCopiedAPI(toImpl(configuration)->injectedBundlePath());
84 }
85
86 void WKContextConfigurationSetInjectedBundlePath(WKContextConfigurationRef configuration, WKStringRef injectedBundlePath)
87 {
88     toImpl(configuration)->setInjectedBundlePath(toImpl(injectedBundlePath)->string());
89 }
90
91 WKStringRef WKContextConfigurationCopyLocalStorageDirectory(WKContextConfigurationRef configuration)
92 {
93     return toCopiedAPI(toImpl(configuration)->localStorageDirectory());
94 }
95
96 void WKContextConfigurationSetLocalStorageDirectory(WKContextConfigurationRef configuration, WKStringRef localStorageDirectory)
97 {
98     toImpl(configuration)->setLocalStorageDirectory(toImpl(localStorageDirectory)->string());
99 }
100
101 WKStringRef WKContextConfigurationCopyWebSQLDatabaseDirectory(WKContextConfigurationRef configuration)
102 {
103     return toCopiedAPI(toImpl(configuration)->webSQLDatabaseDirectory());
104 }
105
106 void WKContextConfigurationSetWebSQLDatabaseDirectory(WKContextConfigurationRef configuration, WKStringRef webSQLDatabaseDirectory)
107 {
108     toImpl(configuration)->setWebSQLDatabaseDirectory(toImpl(webSQLDatabaseDirectory)->string());
109 }
110
111 WKStringRef WKContextConfigurationCopyMediaKeysStorageDirectory(WKContextConfigurationRef configuration)
112 {
113     return toCopiedAPI(toImpl(configuration)->mediaKeysStorageDirectory());
114 }
115
116 void WKContextConfigurationSetMediaKeysStorageDirectory(WKContextConfigurationRef configuration, WKStringRef mediaKeysStorageDirectory)
117 {
118     toImpl(configuration)->setMediaKeysStorageDirectory(toImpl(mediaKeysStorageDirectory)->string());
119 }
120
121 WKStringRef WKContextConfigurationCopyResourceLoadStatisticsDirectory(WKContextConfigurationRef configuration)
122 {
123     return toCopiedAPI(toImpl(configuration)->resourceLoadStatisticsDirectory());
124 }
125
126 void WKContextConfigurationSetResourceLoadStatisticsDirectory(WKContextConfigurationRef configuration, WKStringRef resourceLoadStatisticsDirectory)
127 {
128     toImpl(configuration)->setResourceLoadStatisticsDirectory(toImpl(resourceLoadStatisticsDirectory)->string());
129 }
130
131 bool WKContextConfigurationFullySynchronousModeIsAllowedForTesting(WKContextConfigurationRef configuration)
132 {
133     return toImpl(configuration)->fullySynchronousModeIsAllowedForTesting();
134 }
135
136 void WKContextConfigurationSetFullySynchronousModeIsAllowedForTesting(WKContextConfigurationRef configuration, bool allowed)
137 {
138     toImpl(configuration)->setFullySynchronousModeIsAllowedForTesting(allowed);
139 }
140
141 WKArrayRef WKContextConfigurationCopyOverrideLanguages(WKContextConfigurationRef configuration)
142 {
143     return toAPI(&API::Array::createStringArray(toImpl(configuration)->overrideLanguages()).leakRef());
144 }
145
146 void WKContextConfigurationSetOverrideLanguages(WKContextConfigurationRef configuration, WKArrayRef overrideLanguages)
147 {
148     toImpl(configuration)->setOverrideLanguages(toImpl(overrideLanguages)->toStringVector());
149 }
150
151 bool WKContextConfigurationShouldCaptureAudioInUIProcess(WKContextConfigurationRef configuration)
152 {
153     return toImpl(configuration)->shouldCaptureAudioInUIProcess();
154 }
155
156 void WKContextConfigurationSetShouldCaptureAudioInUIProcess(WKContextConfigurationRef configuration, bool should)
157 {
158     toImpl(configuration)->setShouldCaptureAudioInUIProcess(should);
159 }
160
161 bool WKContextConfigurationProcessSwapsOnNavigation(WKContextConfigurationRef configuration)
162 {
163     return toImpl(configuration)->processSwapsOnNavigation();
164 }
165
166 void WKContextConfigurationSetProcessSwapsOnNavigation(WKContextConfigurationRef configuration, bool swaps)
167 {
168     toImpl(configuration)->setProcessSwapsOnNavigation(swaps);
169 }