c60cefae6d3a4b50645fedb1d5bd0c89fde27875
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / C / WKPreferences.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 "WKPreferences.h"
28 #include "WKPreferencesPrivate.h"
29
30 #include "WKAPICast.h"
31 #include "WebPreferences.h"
32 #include <wtf/PassRefPtr.h>
33 #include <wtf/RefPtr.h>
34
35 using namespace WebKit;
36
37 WKTypeID WKPreferencesGetTypeID()
38 {
39     return toAPI(WebPreferences::APIType);
40 }
41
42 WKPreferencesRef WKPreferencesCreate()
43 {
44     RefPtr<WebPreferences> preferences = WebPreferences::create();
45     return toAPI(preferences.release().leakRef());
46 }
47
48 WKPreferencesRef WKPreferencesCreateWithIdentifier(WKStringRef identifierRef)
49 {
50     RefPtr<WebPreferences> preferences = WebPreferences::create(toWTFString(identifierRef));
51     return toAPI(preferences.release().releaseRef());
52 }
53
54 void WKPreferencesSetJavaScriptEnabled(WKPreferencesRef preferencesRef, bool javaScriptEnabled)
55 {
56     toImpl(preferencesRef)->setJavaScriptEnabled(javaScriptEnabled);
57 }
58
59 bool WKPreferencesGetJavaScriptEnabled(WKPreferencesRef preferencesRef)
60 {
61     return toImpl(preferencesRef)->javaScriptEnabled();
62 }
63
64 void WKPreferencesSetLoadsImagesAutomatically(WKPreferencesRef preferencesRef, bool loadsImagesAutomatically)
65 {
66     toImpl(preferencesRef)->setLoadsImagesAutomatically(loadsImagesAutomatically);
67 }
68
69 bool WKPreferencesGetLoadsImagesAutomatically(WKPreferencesRef preferencesRef)
70 {
71     return toImpl(preferencesRef)->loadsImagesAutomatically();
72 }
73
74 void WKPreferencesSetLoadsSiteIconsIgnoringImageLoadingPreference(WKPreferencesRef preferencesRef, bool loadsSiteIconsIgnoringImageLoadingPreference)
75 {
76     toImpl(preferencesRef)->setLoadsSiteIconsIgnoringImageLoadingPreference(loadsSiteIconsIgnoringImageLoadingPreference);
77 }
78
79 bool WKPreferencesGetLoadsSiteIconsIgnoringImageLoadingPreference(WKPreferencesRef preferencesRef)
80 {
81     return toImpl(preferencesRef)->loadsSiteIconsIgnoringImageLoadingPreference();
82 }
83
84 void WKPreferencesSetOfflineWebApplicationCacheEnabled(WKPreferencesRef preferencesRef, bool offlineWebApplicationCacheEnabled)
85 {
86     toImpl(preferencesRef)->setOfflineWebApplicationCacheEnabled(offlineWebApplicationCacheEnabled);
87 }
88
89 bool WKPreferencesGetOfflineWebApplicationCacheEnabled(WKPreferencesRef preferencesRef)
90 {
91     return toImpl(preferencesRef)->offlineWebApplicationCacheEnabled();
92 }
93
94 void WKPreferencesSetLocalStorageEnabled(WKPreferencesRef preferencesRef, bool localStorageEnabled)
95 {
96     toImpl(preferencesRef)->setLocalStorageEnabled(localStorageEnabled);
97 }
98
99 bool WKPreferencesGetLocalStorageEnabled(WKPreferencesRef preferencesRef)
100 {
101     return toImpl(preferencesRef)->localStorageEnabled();
102 }
103
104 void WKPreferencesSetDatabasesEnabled(WKPreferencesRef preferencesRef, bool databasesEnabled)
105 {
106     toImpl(preferencesRef)->setDatabasesEnabled(databasesEnabled);
107 }
108
109 bool WKPreferencesGetDatabasesEnabled(WKPreferencesRef preferencesRef)
110 {
111     return toImpl(preferencesRef)->databasesEnabled();
112 }
113
114 void WKPreferencesSetXSSAuditorEnabled(WKPreferencesRef preferencesRef, bool xssAuditorEnabled)
115 {
116     toImpl(preferencesRef)->setXSSAuditorEnabled(xssAuditorEnabled);
117 }
118
119 bool WKPreferencesGetXSSAuditorEnabled(WKPreferencesRef preferencesRef)
120 {
121     return toImpl(preferencesRef)->xssAuditorEnabled();
122 }
123
124 void WKPreferencesSetFrameFlatteningEnabled(WKPreferencesRef preferencesRef, bool frameFlatteningEnabled)
125 {
126     toImpl(preferencesRef)->setFrameFlatteningEnabled(frameFlatteningEnabled);
127 }
128
129 bool WKPreferencesGetFrameFlatteningEnabled(WKPreferencesRef preferencesRef)
130 {
131     return toImpl(preferencesRef)->frameFlatteningEnabled();
132 }
133
134 void WKPreferencesSetPluginsEnabled(WKPreferencesRef preferencesRef, bool pluginsEnabled)
135 {
136     toImpl(preferencesRef)->setPluginsEnabled(pluginsEnabled);
137 }
138
139 bool WKPreferencesGetPluginsEnabled(WKPreferencesRef preferencesRef)
140 {
141     return toImpl(preferencesRef)->pluginsEnabled();
142 }
143
144 void WKPreferencesSetJavaEnabled(WKPreferencesRef preferencesRef, bool javaEnabled)
145 {
146     toImpl(preferencesRef)->setJavaEnabled(javaEnabled);
147 }
148
149 bool WKPreferencesGetJavaEnabled(WKPreferencesRef preferencesRef)
150 {
151     return toImpl(preferencesRef)->javaEnabled();
152 }
153
154 void WKPreferencesSetJavaScriptCanOpenWindowsAutomatically(WKPreferencesRef preferencesRef, bool javaScriptCanOpenWindowsAutomatically)
155 {
156     toImpl(preferencesRef)->setJavaScriptCanOpenWindowsAutomatically(javaScriptCanOpenWindowsAutomatically);
157 }
158
159 bool WKPreferencesGetJavaScriptCanOpenWindowsAutomatically(WKPreferencesRef preferencesRef)
160 {
161     return toImpl(preferencesRef)->javaScriptCanOpenWindowsAutomatically();
162 }
163
164 void WKPreferencesSetHyperlinkAuditingEnabled(WKPreferencesRef preferencesRef, bool hyperlinkAuditingEnabled)
165 {
166     toImpl(preferencesRef)->setHyperlinkAuditingEnabled(hyperlinkAuditingEnabled);
167 }
168
169 bool WKPreferencesGetHyperlinkAuditingEnabled(WKPreferencesRef preferencesRef)
170 {
171     return toImpl(preferencesRef)->hyperlinkAuditingEnabled();
172 }
173
174 void WKPreferencesSetStandardFontFamily(WKPreferencesRef preferencesRef, WKStringRef family)
175 {
176     toImpl(preferencesRef)->setStandardFontFamily(toWTFString(family));
177 }
178
179 WKStringRef WKPreferencesCopyStandardFontFamily(WKPreferencesRef preferencesRef)
180 {
181     return toCopiedAPI(toImpl(preferencesRef)->standardFontFamily());
182 }
183
184 void WKPreferencesSetFixedFontFamily(WKPreferencesRef preferencesRef, WKStringRef family)
185 {
186     toImpl(preferencesRef)->setFixedFontFamily(toWTFString(family));
187 }
188
189 WKStringRef WKPreferencesCopyFixedFontFamily(WKPreferencesRef preferencesRef)
190 {
191     return toCopiedAPI(toImpl(preferencesRef)->fixedFontFamily());
192 }
193
194 void WKPreferencesSetSerifFontFamily(WKPreferencesRef preferencesRef, WKStringRef family)
195 {
196     toImpl(preferencesRef)->setSerifFontFamily(toWTFString(family));
197 }
198
199 WKStringRef WKPreferencesCopySerifFontFamily(WKPreferencesRef preferencesRef)
200 {
201     return toCopiedAPI(toImpl(preferencesRef)->serifFontFamily());
202 }
203
204 void WKPreferencesSetSansSerifFontFamily(WKPreferencesRef preferencesRef, WKStringRef family)
205 {
206     toImpl(preferencesRef)->setSansSerifFontFamily(toWTFString(family));
207 }
208
209 WKStringRef WKPreferencesCopySansSerifFontFamily(WKPreferencesRef preferencesRef)
210 {
211     return toCopiedAPI(toImpl(preferencesRef)->sansSerifFontFamily());
212 }
213
214 void WKPreferencesSetCursiveFontFamily(WKPreferencesRef preferencesRef, WKStringRef family)
215 {
216     toImpl(preferencesRef)->setCursiveFontFamily(toWTFString(family));
217 }
218
219 WKStringRef WKPreferencesCopyCursiveFontFamily(WKPreferencesRef preferencesRef)
220 {
221     return toCopiedAPI(toImpl(preferencesRef)->cursiveFontFamily());
222 }
223
224 void WKPreferencesSetFantasyFontFamily(WKPreferencesRef preferencesRef, WKStringRef family)
225 {
226     toImpl(preferencesRef)->setFantasyFontFamily(toWTFString(family));
227 }
228
229 WKStringRef WKPreferencesCopyFantasyFontFamily(WKPreferencesRef preferencesRef)
230 {
231     return toCopiedAPI(toImpl(preferencesRef)->fantasyFontFamily());
232 }
233
234 void WKPreferencesSetDefaultFontSize(WKPreferencesRef preferencesRef, uint32_t size)
235 {
236     toImpl(preferencesRef)->setDefaultFontSize(size);
237 }
238
239 uint32_t WKPreferencesGetDefaultFontSize(WKPreferencesRef preferencesRef)
240 {
241     return toImpl(preferencesRef)->defaultFontSize();
242 }
243
244 void WKPreferencesSetDefaultFixedFontSize(WKPreferencesRef preferencesRef, uint32_t size)
245 {
246     toImpl(preferencesRef)->setDefaultFixedFontSize(size);
247 }
248
249 uint32_t WKPreferencesGetDefaultFixedFontSize(WKPreferencesRef preferencesRef)
250 {
251     return toImpl(preferencesRef)->defaultFixedFontSize();
252 }
253
254 void WKPreferencesSetMinimumFontSize(WKPreferencesRef preferencesRef, uint32_t size)
255 {
256     toImpl(preferencesRef)->setMinimumFontSize(size);
257 }
258
259 uint32_t WKPreferencesGetMinimumFontSize(WKPreferencesRef preferencesRef)
260 {
261     return toImpl(preferencesRef)->minimumFontSize();
262 }
263
264 void WKPreferencesSetDefaultTextEncodingName(WKPreferencesRef preferencesRef, WKStringRef name)
265 {
266     toImpl(preferencesRef)->setDefaultTextEncodingName(toWTFString(name));
267 }
268
269 WKStringRef WKPreferencesCopyDefaultTextEncodingName(WKPreferencesRef preferencesRef)
270 {
271     return toCopiedAPI(toImpl(preferencesRef)->defaultTextEncodingName());
272 }
273
274 void WKPreferencesSetPrivateBrowsingEnabled(WKPreferencesRef preferencesRef, bool enabled)
275 {
276     toImpl(preferencesRef)->setPrivateBrowsingEnabled(enabled);
277 }
278
279 bool WKPreferencesGetPrivateBrowsingEnabled(WKPreferencesRef preferencesRef)
280 {
281     return toImpl(preferencesRef)->privateBrowsingEnabled();
282 }
283
284 void WKPreferencesSetDeveloperExtrasEnabled(WKPreferencesRef preferencesRef, bool enabled)
285 {
286     toImpl(preferencesRef)->setDeveloperExtrasEnabled(enabled);
287 }
288
289 bool WKPreferencesGetDeveloperExtrasEnabled(WKPreferencesRef preferencesRef)
290 {
291     return toImpl(preferencesRef)->developerExtrasEnabled();
292 }
293
294 void WKPreferencesSetTextAreasAreResizable(WKPreferencesRef preferencesRef, bool resizable)
295 {
296     toImpl(preferencesRef)->setTextAreasAreResizable(resizable);
297 }
298
299 bool WKPreferencesGetTextAreasAreResizable(WKPreferencesRef preferencesRef)
300 {
301     return toImpl(preferencesRef)->textAreasAreResizable();
302 }
303
304 void WKPreferencesSetFontSmoothingLevel(WKPreferencesRef preferencesRef, WKFontSmoothingLevel wkLevel)
305 {
306     toImpl(preferencesRef)->setFontSmoothingLevel(toFontSmoothingLevel(wkLevel));
307 }
308
309 WKFontSmoothingLevel WKPreferencesGetFontSmoothingLevel(WKPreferencesRef preferencesRef)
310 {
311     return toAPI(static_cast<FontSmoothingLevel>(toImpl(preferencesRef)->fontSmoothingLevel()));
312 }
313
314 void WKPreferencesSetAcceleratedDrawingEnabled(WKPreferencesRef preferencesRef, bool flag)
315 {
316     toImpl(preferencesRef)->setAcceleratedDrawingEnabled(flag);
317 }
318
319 bool WKPreferencesGetAcceleratedDrawingEnabled(WKPreferencesRef preferencesRef)
320 {
321     return toImpl(preferencesRef)->acceleratedDrawingEnabled();
322 }
323
324 void WKPreferencesSetCanvasUsesAcceleratedDrawing(WKPreferencesRef preferencesRef, bool flag)
325 {
326     toImpl(preferencesRef)->setCanvasUsesAcceleratedDrawing(flag);
327 }
328
329 bool WKPreferencesGetCanvasUsesAcceleratedDrawing(WKPreferencesRef preferencesRef)
330 {
331     return toImpl(preferencesRef)->canvasUsesAcceleratedDrawing();
332 }
333
334 void WKPreferencesSetAcceleratedCompositingEnabled(WKPreferencesRef preferencesRef, bool flag)
335 {
336     toImpl(preferencesRef)->setAcceleratedCompositingEnabled(flag);
337 }
338
339 bool WKPreferencesGetAcceleratedCompositingEnabled(WKPreferencesRef preferencesRef)
340 {
341     return toImpl(preferencesRef)->acceleratedCompositingEnabled();
342 }
343
344 void WKPreferencesSetCompositingBordersVisible(WKPreferencesRef preferencesRef, bool flag)
345 {
346     toImpl(preferencesRef)->setCompositingBordersVisible(flag);
347 }
348
349 bool WKPreferencesGetCompositingBordersVisible(WKPreferencesRef preferencesRef)
350 {
351     return toImpl(preferencesRef)->compositingBordersVisible();
352 }
353
354 void WKPreferencesSetCompositingRepaintCountersVisible(WKPreferencesRef preferencesRef, bool flag)
355 {
356     toImpl(preferencesRef)->setCompositingRepaintCountersVisible(flag);
357 }
358
359 bool WKPreferencesGetCompositingRepaintCountersVisible(WKPreferencesRef preferencesRef)
360 {
361     return toImpl(preferencesRef)->compositingRepaintCountersVisible();
362 }
363
364 void WKPreferencesSetWebGLEnabled(WKPreferencesRef preferencesRef, bool flag)
365 {
366     toImpl(preferencesRef)->setWebGLEnabled(flag);
367 }
368
369 bool WKPreferencesGetWebGLEnabled(WKPreferencesRef preferencesRef)
370 {
371     return toImpl(preferencesRef)->webGLEnabled();
372 }
373
374 void WKPreferencesSetNeedsSiteSpecificQuirks(WKPreferencesRef preferencesRef, bool flag)
375 {
376     toImpl(preferencesRef)->setNeedsSiteSpecificQuirks(flag);
377 }
378
379 bool WKPreferencesGetNeedsSiteSpecificQuirks(WKPreferencesRef preferencesRef)
380 {
381     return toImpl(preferencesRef)->needsSiteSpecificQuirks();
382 }
383
384 void WKPreferencesSetForceFTPDirectoryListings(WKPreferencesRef preferencesRef, bool flag)
385 {
386     toImpl(preferencesRef)->setForceFTPDirectoryListings(flag);
387 }
388
389 bool WKPreferencesGetForceFTPDirectoryListings(WKPreferencesRef preferencesRef)
390 {
391     return toImpl(preferencesRef)->forceFTPDirectoryListings();
392 }
393
394 void WKPreferencesSetFTPDirectoryTemplatePath(WKPreferencesRef preferencesRef, WKStringRef pathRef)
395 {
396     toImpl(preferencesRef)->setFTPDirectoryTemplatePath(toWTFString(pathRef));
397 }
398
399 WKStringRef WKPreferencesCopyFTPDirectoryTemplatePath(WKPreferencesRef preferencesRef)
400 {
401     return toCopiedAPI(toImpl(preferencesRef)->ftpDirectoryTemplatePath());
402 }
403
404 void WKPreferencesSetTabsToLinks(WKPreferencesRef preferencesRef, bool tabsToLinks)
405 {
406     toImpl(preferencesRef)->setTabsToLinks(tabsToLinks);
407 }
408
409 bool WKPreferencesGetTabsToLinks(WKPreferencesRef preferencesRef)
410 {
411     return toImpl(preferencesRef)->tabsToLinks();
412 }
413
414 void WKPreferencesSetDNSPrefetchingEnabled(WKPreferencesRef preferencesRef, bool enabled)
415 {
416     toImpl(preferencesRef)->setDNSPrefetchingEnabled(enabled);
417 }
418
419 bool WKPreferencesGetDNSPrefetchingEnabled(WKPreferencesRef preferencesRef)
420 {
421     return toImpl(preferencesRef)->dnsPrefetchingEnabled();
422 }
423
424 void WKPreferencesSetAuthorAndUserStylesEnabled(WKPreferencesRef preferencesRef, bool enabled)
425 {
426     toImpl(preferencesRef)->setAuthorAndUserStylesEnabled(enabled);
427 }
428
429 bool WKPreferencesGetAuthorAndUserStylesEnabled(WKPreferencesRef preferencesRef)
430 {
431     return toImpl(preferencesRef)->authorAndUserStylesEnabled();
432 }
433
434 void WKPreferencesSetShouldPrintBackgrounds(WKPreferencesRef preferencesRef, bool flag)
435 {
436     toImpl(preferencesRef)->setShouldPrintBackgrounds(flag);
437 }
438
439 bool WKPreferencesGetShouldPrintBackgrounds(WKPreferencesRef preferencesRef)
440 {
441     return toImpl(preferencesRef)->shouldPrintBackgrounds();
442 }
443
444 void WKPreferencesSetWebArchiveDebugModeEnabled(WKPreferencesRef preferencesRef, bool enabled)
445 {
446     toImpl(preferencesRef)->setWebArchiveDebugModeEnabled(enabled);
447 }
448
449 bool WKPreferencesGetWebArchiveDebugModeEnabled(WKPreferencesRef preferencesRef)
450 {
451     return toImpl(preferencesRef)->webArchiveDebugModeEnabled();
452 }
453
454 void WKPreferencesSetLocalFileContentSniffingEnabled(WKPreferencesRef preferencesRef, bool enabled)
455 {
456     toImpl(preferencesRef)->setLocalFileContentSniffingEnabled(enabled);
457 }
458
459 bool WKPreferencesGetLocalFileContentSniffingEnabled(WKPreferencesRef preferencesRef)
460 {
461     return toImpl(preferencesRef)->localFileContentSniffingEnabled();
462 }
463
464 void WKPreferencesSetPageCacheEnabled(WKPreferencesRef preferencesRef, bool enabled)
465 {
466     toImpl(preferencesRef)->setUsesPageCache(enabled);
467 }
468
469 bool WKPreferencesGetPageCacheEnabled(WKPreferencesRef preferencesRef)
470 {
471     return toImpl(preferencesRef)->usesPageCache();
472 }
473
474 void WKPreferencesSetPaginateDuringLayoutEnabled(WKPreferencesRef preferencesRef, bool enabled)
475 {
476     toImpl(preferencesRef)->setPaginateDuringLayoutEnabled(enabled);
477 }
478
479 bool WKPreferencesGetPaginateDuringLayoutEnabled(WKPreferencesRef preferencesRef)
480 {
481     return toImpl(preferencesRef)->paginateDuringLayoutEnabled();
482 }
483
484 void WKPreferencesSetDOMPasteAllowed(WKPreferencesRef preferencesRef, bool enabled)
485 {
486     toImpl(preferencesRef)->setDOMPasteAllowed(enabled);
487 }
488
489 bool WKPreferencesGetDOMPasteAllowed(WKPreferencesRef preferencesRef)
490 {
491     return toImpl(preferencesRef)->domPasteAllowed();
492 }
493
494 void WKPreferencesSetJavaScriptCanAccessClipboard(WKPreferencesRef preferencesRef, bool enabled)
495 {
496     toImpl(preferencesRef)->setJavaScriptCanAccessClipboard(enabled);
497 }
498
499 bool WKPreferencesGetJavaScriptCanAccessClipboard(WKPreferencesRef preferencesRef)
500 {
501     return toImpl(preferencesRef)->javaScriptCanAccessClipboard();
502 }
503
504 void WKPreferencesSetFullScreenEnabled(WKPreferencesRef preferencesRef, bool enabled)
505 {
506     toImpl(preferencesRef)->setFullScreenEnabled(enabled);
507 }
508
509 bool WKPreferencesGetFullScreenEnabled(WKPreferencesRef preferencesRef)
510 {
511     return toImpl(preferencesRef)->fullScreenEnabled();
512 }
513
514 void WKPreferencesSetWebSecurityEnabled(WKPreferencesRef preferencesRef, bool enabled)
515 {
516     toImpl(preferencesRef)->setWebSecurityEnabled(enabled);
517 }
518
519 bool WKPreferencesGetWebSecurityEnabled(WKPreferencesRef preferencesRef)
520 {
521     return toImpl(preferencesRef)->webSecurityEnabled();
522 }
523
524 void WKPreferencesSetUniversalAccessFromFileURLsAllowed(WKPreferencesRef preferencesRef, bool allowed)
525 {
526     toImpl(preferencesRef)->setAllowUniversalAccessFromFileURLs(allowed);
527 }
528
529 bool WKPreferencesGetUniversalAccessFromFileURLsAllowed(WKPreferencesRef preferencesRef)
530 {
531     return toImpl(preferencesRef)->allowUniversalAccessFromFileURLs();
532 }
533
534 void WKPreferencesSetFileAccessFromFileURLsAllowed(WKPreferencesRef preferencesRef, bool allowed)
535 {
536     toImpl(preferencesRef)->setAllowFileAccessFromFileURLs(allowed);
537 }
538
539 bool WKPreferencesGetFileAccessFromFileURLsAllowed(WKPreferencesRef preferencesRef)
540 {
541     return toImpl(preferencesRef)->allowFileAccessFromFileURLs();
542 }