b8bf4fea519955b75c938ba0cba0804ccdaa7a3c
[WebKit-https.git] / Source / WebKit / UIProcess / API / Cocoa / WKPreferences.mm
1 /*
2  * Copyright (C) 2014-2017 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 #import "config.h"
27 #import "WKPreferencesInternal.h"
28
29 #if WK_API_ENABLED
30
31 #import "APIArray.h"
32 #import "WKNSArray.h"
33 #import "WebPreferences.h"
34 #import "_WKExperimentalFeature.h"
35 #import "_WKExperimentalFeatureInternal.h"
36 #import <WebCore/SecurityOrigin.h>
37 #import <WebCore/Settings.h>
38 #import <wtf/RetainPtr.h>
39
40 @implementation WKPreferences
41
42 - (instancetype)init
43 {
44     if (!(self = [super init]))
45         return nil;
46
47     API::Object::constructInWrapper<WebKit::WebPreferences>(self, String(), "WebKit", "WebKitDebug");
48     return self;
49 }
50
51 - (void)dealloc
52 {
53     _preferences->~WebPreferences();
54
55     [super dealloc];
56 }
57
58 + (BOOL)supportsSecureCoding
59 {
60     return YES;
61 }
62
63 // FIXME: We currently only encode/decode API preferences. We should consider whether we should
64 // encode/decode SPI preferences as well.
65
66 - (void)encodeWithCoder:(NSCoder *)coder
67 {
68     [coder encodeDouble:self.minimumFontSize forKey:@"minimumFontSize"];
69     [coder encodeBool:self.javaScriptEnabled forKey:@"javaScriptEnabled"];
70     [coder encodeBool:self.javaScriptCanOpenWindowsAutomatically forKey:@"javaScriptCanOpenWindowsAutomatically"];
71
72 #if PLATFORM(MAC)
73     [coder encodeBool:self.javaEnabled forKey:@"javaEnabled"];
74     [coder encodeBool:self.plugInsEnabled forKey:@"plugInsEnabled"];
75     [coder encodeBool:self.tabFocusesLinks forKey:@"tabFocusesLinks"];
76 #endif
77 }
78
79 - (instancetype)initWithCoder:(NSCoder *)coder
80 {
81     if (!(self = [self init]))
82         return nil;
83
84     self.minimumFontSize = [coder decodeDoubleForKey:@"minimumFontSize"];
85     self.javaScriptEnabled = [coder decodeBoolForKey:@"javaScriptEnabled"];
86     self.javaScriptCanOpenWindowsAutomatically = [coder decodeBoolForKey:@"javaScriptCanOpenWindowsAutomatically"];
87
88 #if PLATFORM(MAC)
89     self.javaEnabled = [coder decodeBoolForKey:@"javaEnabled"];
90     self.plugInsEnabled = [coder decodeBoolForKey:@"plugInsEnabled"];
91     self.tabFocusesLinks = [coder decodeBoolForKey:@"tabFocusesLinks"];
92 #endif
93
94     return self;
95 }
96
97 - (id)copyWithZone:(NSZone *)zone
98 {
99     return wrapper(_preferences->copy().leakRef());
100 }
101
102 - (CGFloat)minimumFontSize
103 {
104     return _preferences->minimumFontSize();
105 }
106
107 - (void)setMinimumFontSize:(CGFloat)minimumFontSize
108 {
109     _preferences->setMinimumFontSize(minimumFontSize);
110 }
111
112 - (BOOL)javaScriptEnabled
113 {
114     return _preferences->javaScriptEnabled();
115 }
116
117 - (void)setJavaScriptEnabled:(BOOL)javaScriptEnabled
118 {
119     _preferences->setJavaScriptEnabled(javaScriptEnabled);
120 }
121
122 - (BOOL)javaScriptCanOpenWindowsAutomatically
123 {
124     return _preferences->javaScriptCanOpenWindowsAutomatically();
125 }
126
127 - (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)javaScriptCanOpenWindowsAutomatically
128 {
129     _preferences->setJavaScriptCanOpenWindowsAutomatically(javaScriptCanOpenWindowsAutomatically);
130 }
131
132 #pragma mark OS X-specific methods
133
134 #if PLATFORM(MAC)
135
136 - (BOOL)javaEnabled
137 {
138     return _preferences->javaEnabled();
139 }
140
141 - (void)setJavaEnabled:(BOOL)javaEnabled
142 {
143     _preferences->setJavaEnabled(javaEnabled);
144 }
145
146 - (BOOL)plugInsEnabled
147 {
148     return _preferences->pluginsEnabled();
149 }
150
151 - (void)setPlugInsEnabled:(BOOL)plugInsEnabled
152 {
153     _preferences->setPluginsEnabled(plugInsEnabled);
154 }
155
156 - (BOOL)tabFocusesLinks
157 {
158     return _preferences->tabsToLinks();
159 }
160
161 - (void)setTabFocusesLinks:(BOOL)tabFocusesLinks
162 {
163     _preferences->setTabsToLinks(tabFocusesLinks);
164 }
165
166 #endif
167
168 #pragma mark WKObject protocol implementation
169
170 - (API::Object&)_apiObject
171 {
172     return *_preferences;
173 }
174
175 @end
176
177 @implementation WKPreferences (WKPrivate)
178
179 - (BOOL)_telephoneNumberDetectionIsEnabled
180 {
181     return _preferences->telephoneNumberParsingEnabled();
182 }
183
184 - (void)_setTelephoneNumberDetectionIsEnabled:(BOOL)telephoneNumberDetectionIsEnabled
185 {
186     _preferences->setTelephoneNumberParsingEnabled(telephoneNumberDetectionIsEnabled);
187 }
188
189 static WebCore::SecurityOrigin::StorageBlockingPolicy toStorageBlockingPolicy(_WKStorageBlockingPolicy policy)
190 {
191     switch (policy) {
192     case _WKStorageBlockingPolicyAllowAll:
193         return WebCore::SecurityOrigin::AllowAllStorage;
194     case _WKStorageBlockingPolicyBlockThirdParty:
195         return WebCore::SecurityOrigin::BlockThirdPartyStorage;
196     case _WKStorageBlockingPolicyBlockAll:
197         return WebCore::SecurityOrigin::BlockAllStorage;
198     }
199
200     ASSERT_NOT_REACHED();
201     return WebCore::SecurityOrigin::AllowAllStorage;
202 }
203
204 static _WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPolicy policy)
205 {
206     switch (policy) {
207     case WebCore::SecurityOrigin::AllowAllStorage:
208         return _WKStorageBlockingPolicyAllowAll;
209     case WebCore::SecurityOrigin::BlockThirdPartyStorage:
210         return _WKStorageBlockingPolicyBlockThirdParty;
211     case WebCore::SecurityOrigin::BlockAllStorage:
212         return _WKStorageBlockingPolicyBlockAll;
213     }
214
215     ASSERT_NOT_REACHED();
216     return _WKStorageBlockingPolicyAllowAll;
217 }
218
219 - (_WKStorageBlockingPolicy)_storageBlockingPolicy
220 {
221     return toAPI(static_cast<WebCore::SecurityOrigin::StorageBlockingPolicy>(_preferences->storageBlockingPolicy()));
222 }
223
224 - (void)_setStorageBlockingPolicy:(_WKStorageBlockingPolicy)policy
225 {
226     _preferences->setStorageBlockingPolicy(toStorageBlockingPolicy(policy));
227 }
228
229 - (BOOL)_offlineApplicationCacheIsEnabled
230 {
231     return _preferences->offlineWebApplicationCacheEnabled();
232 }
233
234 - (void)_setOfflineApplicationCacheIsEnabled:(BOOL)offlineApplicationCacheIsEnabled
235 {
236     _preferences->setOfflineWebApplicationCacheEnabled(offlineApplicationCacheIsEnabled);
237 }
238
239 - (BOOL)_fullScreenEnabled
240 {
241     return _preferences->fullScreenEnabled();
242 }
243
244 - (void)_setFullScreenEnabled:(BOOL)fullScreenEnabled
245 {
246     _preferences->setFullScreenEnabled(fullScreenEnabled);
247 }
248
249 - (BOOL)_allowsPictureInPictureMediaPlayback
250 {
251     return _preferences->allowsPictureInPictureMediaPlayback();
252 }
253
254 - (void)_setAllowsPictureInPictureMediaPlayback:(BOOL)allowed
255 {
256     _preferences->setAllowsPictureInPictureMediaPlayback(allowed);
257 }
258
259 - (BOOL)_compositingBordersVisible
260 {
261     return _preferences->compositingBordersVisible();
262 }
263
264 - (void)_setCompositingBordersVisible:(BOOL)compositingBordersVisible
265 {
266     _preferences->setCompositingBordersVisible(compositingBordersVisible);
267 }
268
269 - (BOOL)_compositingRepaintCountersVisible
270 {
271     return _preferences->compositingRepaintCountersVisible();
272 }
273
274 - (void)_setCompositingRepaintCountersVisible:(BOOL)repaintCountersVisible
275 {
276     _preferences->setCompositingRepaintCountersVisible(repaintCountersVisible);
277 }
278
279 - (BOOL)_tiledScrollingIndicatorVisible
280 {
281     return _preferences->tiledScrollingIndicatorVisible();
282 }
283
284 - (void)_setTiledScrollingIndicatorVisible:(BOOL)tiledScrollingIndicatorVisible
285 {
286     _preferences->setTiledScrollingIndicatorVisible(tiledScrollingIndicatorVisible);
287 }
288
289 - (BOOL)_resourceUsageOverlayVisible
290 {
291     return _preferences->resourceUsageOverlayVisible();
292 }
293
294 - (void)_setResourceUsageOverlayVisible:(BOOL)resourceUsageOverlayVisible
295 {
296     _preferences->setResourceUsageOverlayVisible(resourceUsageOverlayVisible);
297 }
298
299 - (_WKDebugOverlayRegions)_visibleDebugOverlayRegions
300 {
301     return _preferences->visibleDebugOverlayRegions();
302 }
303
304 - (void)_setVisibleDebugOverlayRegions:(_WKDebugOverlayRegions)regionFlags
305 {
306     _preferences->setVisibleDebugOverlayRegions(regionFlags);
307 }
308
309 - (BOOL)_simpleLineLayoutEnabled
310 {
311     return _preferences->simpleLineLayoutEnabled();
312 }
313
314 - (void)_setSimpleLineLayoutEnabled:(BOOL)simpleLineLayoutEnabled
315 {
316     _preferences->setSimpleLineLayoutEnabled(simpleLineLayoutEnabled);
317 }
318
319 - (BOOL)_simpleLineLayoutDebugBordersEnabled
320 {
321     return _preferences->simpleLineLayoutDebugBordersEnabled();
322 }
323
324 - (void)_setSimpleLineLayoutDebugBordersEnabled:(BOOL)simpleLineLayoutDebugBordersEnabled
325 {
326     _preferences->setSimpleLineLayoutDebugBordersEnabled(simpleLineLayoutDebugBordersEnabled);
327 }
328
329 - (BOOL)_acceleratedDrawingEnabled
330 {
331     return _preferences->acceleratedDrawingEnabled();
332 }
333
334 - (void)_setAcceleratedDrawingEnabled:(BOOL)acceleratedDrawingEnabled
335 {
336     _preferences->setAcceleratedDrawingEnabled(acceleratedDrawingEnabled);
337 }
338
339 - (BOOL)_displayListDrawingEnabled
340 {
341     return _preferences->displayListDrawingEnabled();
342 }
343
344 - (void)_setDisplayListDrawingEnabled:(BOOL)displayListDrawingEnabled
345 {
346     _preferences->setDisplayListDrawingEnabled(displayListDrawingEnabled);
347 }
348
349 - (BOOL)_visualViewportEnabled
350 {
351     return _preferences->visualViewportEnabled();
352 }
353
354 - (void)_setVisualViewportEnabled:(BOOL)_visualViewportEnabled
355 {
356     _preferences->setVisualViewportEnabled(_visualViewportEnabled);
357 }
358
359 - (BOOL)_largeImageAsyncDecodingEnabled
360 {
361     return _preferences->largeImageAsyncDecodingEnabled();
362 }
363
364 - (void)_setLargeImageAsyncDecodingEnabled:(BOOL)_largeImageAsyncDecodingEnabled
365 {
366     _preferences->setLargeImageAsyncDecodingEnabled(_largeImageAsyncDecodingEnabled);
367 }
368
369 - (BOOL)_animatedImageAsyncDecodingEnabled
370 {
371     return _preferences->animatedImageAsyncDecodingEnabled();
372 }
373
374 - (void)_setAnimatedImageAsyncDecodingEnabled:(BOOL)_animatedImageAsyncDecodingEnabled
375 {
376     _preferences->setAnimatedImageAsyncDecodingEnabled(_animatedImageAsyncDecodingEnabled);
377 }
378
379 - (BOOL)_textAutosizingEnabled
380 {
381     return _preferences->textAutosizingEnabled();
382 }
383
384 - (void)_setTextAutosizingEnabled:(BOOL)enabled
385 {
386     _preferences->setTextAutosizingEnabled(enabled);
387 }
388
389 - (BOOL)_subpixelAntialiasedLayerTextEnabled
390 {
391     return _preferences->subpixelAntialiasedLayerTextEnabled();
392 }
393
394 - (void)_setSubpixelAntialiasedLayerTextEnabled:(BOOL)enabled
395 {
396     _preferences->setSubpixelAntialiasedLayerTextEnabled(enabled);
397 }
398
399 - (BOOL)_developerExtrasEnabled
400 {
401     return _preferences->developerExtrasEnabled();
402 }
403
404 - (void)_setDeveloperExtrasEnabled:(BOOL)developerExtrasEnabled
405 {
406     _preferences->setDeveloperExtrasEnabled(developerExtrasEnabled);
407 }
408
409 - (BOOL)_logsPageMessagesToSystemConsoleEnabled
410 {
411     return _preferences->logsPageMessagesToSystemConsoleEnabled();
412 }
413
414 - (void)_setLogsPageMessagesToSystemConsoleEnabled:(BOOL)logsPageMessagesToSystemConsoleEnabled
415 {
416     _preferences->setLogsPageMessagesToSystemConsoleEnabled(logsPageMessagesToSystemConsoleEnabled);
417 }
418
419 - (BOOL)_hiddenPageDOMTimerThrottlingEnabled
420 {
421     return _preferences->hiddenPageDOMTimerThrottlingEnabled();
422 }
423
424 - (void)_setHiddenPageDOMTimerThrottlingEnabled:(BOOL)hiddenPageDOMTimerThrottlingEnabled
425 {
426     _preferences->setHiddenPageDOMTimerThrottlingEnabled(hiddenPageDOMTimerThrottlingEnabled);
427 }
428
429 - (BOOL)_hiddenPageDOMTimerThrottlingAutoIncreases
430 {
431     return _preferences->hiddenPageDOMTimerThrottlingAutoIncreases();
432 }
433
434 - (void)_setHiddenPageDOMTimerThrottlingAutoIncreases:(BOOL)hiddenPageDOMTimerThrottlingAutoIncreases
435 {
436     _preferences->setHiddenPageDOMTimerThrottlingAutoIncreases(hiddenPageDOMTimerThrottlingAutoIncreases);
437 }
438
439 - (BOOL)_pageVisibilityBasedProcessSuppressionEnabled
440 {
441     return _preferences->pageVisibilityBasedProcessSuppressionEnabled();
442 }
443
444 - (void)_setPageVisibilityBasedProcessSuppressionEnabled:(BOOL)pageVisibilityBasedProcessSuppressionEnabled
445 {
446     _preferences->setPageVisibilityBasedProcessSuppressionEnabled(pageVisibilityBasedProcessSuppressionEnabled);
447 }
448
449 - (BOOL)_allowFileAccessFromFileURLs
450 {
451     return _preferences->allowFileAccessFromFileURLs();
452 }
453
454 - (void)_setAllowFileAccessFromFileURLs:(BOOL)allowFileAccessFromFileURLs
455 {
456     _preferences->setAllowFileAccessFromFileURLs(allowFileAccessFromFileURLs);
457 }
458
459 - (_WKJavaScriptRuntimeFlags)_javaScriptRuntimeFlags
460 {
461     return _preferences->javaScriptRuntimeFlags();
462 }
463
464 - (void)_setJavaScriptRuntimeFlags:(_WKJavaScriptRuntimeFlags)javaScriptRuntimeFlags
465 {
466     _preferences->setJavaScriptRuntimeFlags(javaScriptRuntimeFlags);
467 }
468
469 - (BOOL)_isStandalone
470 {
471     return _preferences->standalone();
472 }
473
474 - (void)_setStandalone:(BOOL)standalone
475 {
476     _preferences->setStandalone(standalone);
477 }
478
479 - (BOOL)_diagnosticLoggingEnabled
480 {
481     return _preferences->diagnosticLoggingEnabled();
482 }
483
484 - (void)_setDiagnosticLoggingEnabled:(BOOL)diagnosticLoggingEnabled
485 {
486     _preferences->setDiagnosticLoggingEnabled(diagnosticLoggingEnabled);
487 }
488
489 - (NSUInteger)_defaultFontSize
490 {
491     return _preferences->defaultFontSize();
492 }
493
494 - (void)_setDefaultFontSize:(NSUInteger)defaultFontSize
495 {
496     _preferences->setDefaultFontSize(defaultFontSize);
497 }
498
499 - (NSUInteger)_defaultFixedPitchFontSize
500 {
501     return _preferences->defaultFixedFontSize();
502 }
503
504 - (void)_setDefaultFixedPitchFontSize:(NSUInteger)defaultFixedPitchFontSize
505 {
506     _preferences->setDefaultFixedFontSize(defaultFixedPitchFontSize);
507 }
508
509 - (NSString *)_fixedPitchFontFamily
510 {
511     return _preferences->fixedFontFamily();
512 }
513
514 - (void)_setFixedPitchFontFamily:(NSString *)fixedPitchFontFamily
515 {
516     _preferences->setFixedFontFamily(fixedPitchFontFamily);
517 }
518
519 + (NSArray<_WKExperimentalFeature *> *)_experimentalFeatures
520 {
521     auto features = WebKit::WebPreferences::experimentalFeatures();
522     return [wrapper(API::Array::create(WTFMove(features)).leakRef()) autorelease];
523 }
524
525 - (BOOL)_isEnabledForFeature:(_WKExperimentalFeature *)feature
526 {
527     return _preferences->isEnabledForFeature(*feature->_experimentalFeature);
528 }
529
530 - (void)_setEnabled:(BOOL)value forFeature:(_WKExperimentalFeature *)feature
531 {
532     _preferences->setEnabledForFeature(value, *feature->_experimentalFeature);
533 }
534
535 - (BOOL)_applePayCapabilityDisclosureAllowed
536 {
537 #if ENABLE(APPLE_PAY)
538     return _preferences->applePayCapabilityDisclosureAllowed();
539 #else
540     return NO;
541 #endif
542 }
543
544 - (void)_setApplePayCapabilityDisclosureAllowed:(BOOL)applePayCapabilityDisclosureAllowed
545 {
546 #if ENABLE(APPLE_PAY)
547     _preferences->setApplePayCapabilityDisclosureAllowed(applePayCapabilityDisclosureAllowed);
548 #endif
549 }
550
551 - (BOOL)_shouldSuppressKeyboardInputDuringProvisionalNavigation
552 {
553     return _preferences->shouldSuppressTextInputFromEditingDuringProvisionalNavigation();
554 }
555
556 - (void)_setShouldSuppressKeyboardInputDuringProvisionalNavigation:(BOOL)shouldSuppress
557 {
558     _preferences->setShouldSuppressTextInputFromEditingDuringProvisionalNavigation(shouldSuppress);
559 }
560
561 - (BOOL)_loadsImagesAutomatically
562 {
563     return _preferences->loadsImagesAutomatically();
564 }
565
566 - (void)_setLoadsImagesAutomatically:(BOOL)loadsImagesAutomatically
567 {
568     _preferences->setLoadsImagesAutomatically(loadsImagesAutomatically);
569 }
570
571 - (BOOL)_peerConnectionEnabled
572 {
573     return _preferences->peerConnectionEnabled();
574 }
575
576 - (void)_setPeerConnectionEnabled:(BOOL)enabled
577 {
578     _preferences->setPeerConnectionEnabled(enabled);
579 }
580
581 - (BOOL)_mediaDevicesEnabled
582 {
583     return _preferences->mediaDevicesEnabled();
584 }
585
586 - (void)_setMediaDevicesEnabled:(BOOL)enabled
587 {
588     _preferences->setMediaDevicesEnabled(enabled);
589 }
590
591 - (BOOL)_screenCaptureEnabled
592 {
593     return _preferences->screenCaptureEnabled();
594 }
595
596 - (void)_setScreenCaptureEnabled:(BOOL)enabled
597 {
598     _preferences->setScreenCaptureEnabled(enabled);
599 }
600
601 - (BOOL)_mockCaptureDevicesEnabled
602 {
603     return _preferences->mockCaptureDevicesEnabled();
604 }
605
606 - (void)_setMockCaptureDevicesEnabled:(BOOL)enabled
607 {
608     _preferences->setMockCaptureDevicesEnabled(enabled);
609 }
610
611 - (BOOL)_mockCaptureDevicesPromptEnabled
612 {
613     return _preferences->mockCaptureDevicesPromptEnabled();
614 }
615
616 - (void)_setMockCaptureDevicesPromptEnabled:(BOOL)enabled
617 {
618     _preferences->setMockCaptureDevicesPromptEnabled(enabled);
619 }
620
621 - (BOOL)_mediaCaptureRequiresSecureConnection
622 {
623     return _preferences->mediaCaptureRequiresSecureConnection();
624 }
625
626 - (void)_setMediaCaptureRequiresSecureConnection:(BOOL)requiresSecureConnection
627 {
628     _preferences->setMediaCaptureRequiresSecureConnection(requiresSecureConnection);
629 }
630
631 - (double)_inactiveMediaCaptureSteamRepromptIntervalInMinutes
632 {
633     return _preferences->inactiveMediaCaptureSteamRepromptIntervalInMinutes();
634 }
635
636 - (void)_setInactiveMediaCaptureSteamRepromptIntervalInMinutes:(double)interval
637 {
638     _preferences->setInactiveMediaCaptureSteamRepromptIntervalInMinutes(interval);
639 }
640
641 - (BOOL)_enumeratingAllNetworkInterfacesEnabled
642 {
643     return _preferences->enumeratingAllNetworkInterfacesEnabled();
644 }
645
646 - (void)_setEnumeratingAllNetworkInterfacesEnabled:(BOOL)enabled
647 {
648     _preferences->setEnumeratingAllNetworkInterfacesEnabled(enabled);
649 }
650
651 - (BOOL)_iceCandidateFilteringEnabled
652 {
653     return _preferences->iceCandidateFilteringEnabled();
654 }
655
656 - (void)_setICECandidateFilteringEnabled:(BOOL)enabled
657 {
658     _preferences->setICECandidateFilteringEnabled(enabled);
659 }
660
661 - (BOOL)_webRTCLegacyAPIEnabled
662 {
663     return _preferences->webRTCLegacyAPIEnabled();
664 }
665
666 - (void)_setWebRTCLegacyAPIEnabled:(BOOL)enabled
667 {
668     _preferences->setWebRTCLegacyAPIEnabled(enabled);
669 }
670
671 - (void)_setJavaScriptCanAccessClipboard:(BOOL)javaScriptCanAccessClipboard
672 {
673     _preferences->setJavaScriptCanAccessClipboard(javaScriptCanAccessClipboard);
674 }
675
676 - (BOOL)_shouldAllowUserInstalledFonts
677 {
678     return _preferences->shouldAllowUserInstalledFonts();
679 }
680
681 - (void)_setShouldAllowUserInstalledFonts:(BOOL)_shouldAllowUserInstalledFonts
682 {
683     _preferences->setShouldAllowUserInstalledFonts(_shouldAllowUserInstalledFonts);
684 }
685
686 static _WKEditableLinkBehavior toAPI(WebCore::EditableLinkBehavior behavior)
687 {
688     switch (behavior) {
689     case WebCore::EditableLinkDefaultBehavior:
690         return _WKEditableLinkBehaviorDefault;
691     case WebCore::EditableLinkAlwaysLive:
692         return _WKEditableLinkBehaviorAlwaysLive;
693     case WebCore::EditableLinkOnlyLiveWithShiftKey:
694         return _WKEditableLinkBehaviorOnlyLiveWithShiftKey;
695     case WebCore::EditableLinkLiveWhenNotFocused:
696         return _WKEditableLinkBehaviorLiveWhenNotFocused;
697     case WebCore::EditableLinkNeverLive:
698         return _WKEditableLinkBehaviorNeverLive;
699     }
700     
701     ASSERT_NOT_REACHED();
702     return _WKEditableLinkBehaviorNeverLive;
703 }
704
705 static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehavior wkBehavior)
706 {
707     switch (wkBehavior) {
708     case _WKEditableLinkBehaviorDefault:
709         return WebCore::EditableLinkDefaultBehavior;
710     case _WKEditableLinkBehaviorAlwaysLive:
711         return WebCore::EditableLinkAlwaysLive;
712     case _WKEditableLinkBehaviorOnlyLiveWithShiftKey:
713         return WebCore::EditableLinkOnlyLiveWithShiftKey;
714     case _WKEditableLinkBehaviorLiveWhenNotFocused:
715         return WebCore::EditableLinkLiveWhenNotFocused;
716     case _WKEditableLinkBehaviorNeverLive:
717         return WebCore::EditableLinkNeverLive;
718     }
719     
720     ASSERT_NOT_REACHED();
721     return WebCore::EditableLinkNeverLive;
722 }
723
724 - (_WKEditableLinkBehavior)_editableLinkBehavior
725 {
726     return toAPI(static_cast<WebCore::EditableLinkBehavior>(_preferences->editableLinkBehavior()));
727 }
728
729 - (void)_setEditableLinkBehavior:(_WKEditableLinkBehavior)editableLinkBehavior
730 {
731     _preferences->setEditableLinkBehavior(toEditableLinkBehavior(editableLinkBehavior));
732 }
733
734 #if PLATFORM(MAC)
735 - (void)_setJavaEnabledForLocalFiles:(BOOL)enabled
736 {
737     _preferences->setJavaEnabledForLocalFiles(enabled);
738 }
739
740 - (BOOL)_javaEnabledForLocalFiles
741 {
742     return _preferences->javaEnabledForLocalFiles();
743 }
744
745 - (void)_setCanvasUsesAcceleratedDrawing:(BOOL)enabled
746 {
747     _preferences->setCanvasUsesAcceleratedDrawing(enabled);
748 }
749
750 - (BOOL)_canvasUsesAcceleratedDrawing
751 {
752     return _preferences->canvasUsesAcceleratedDrawing();
753 }
754
755 - (void)_setAcceleratedCompositingEnabled:(BOOL)enabled
756 {
757     _preferences->setAcceleratedCompositingEnabled(enabled);
758 }
759
760 - (BOOL)_acceleratedCompositingEnabled
761 {
762     return _preferences->acceleratedCompositingEnabled();
763 }
764
765 - (void)_setDefaultTextEncodingName:(NSString *)name
766 {
767     _preferences->setDefaultTextEncodingName(name);
768 }
769
770 - (NSString *)_defaultTextEncodingName
771 {
772     return _preferences->defaultTextEncodingName();
773 }
774
775 - (void)_setNeedsSiteSpecificQuirks:(BOOL)enabled
776 {
777     _preferences->setNeedsSiteSpecificQuirks(enabled);
778 }
779
780 - (BOOL)_needsSiteSpecificQuirks
781 {
782     return _preferences->needsSiteSpecificQuirks();
783 }
784
785 - (void)_setAuthorAndUserStylesEnabled:(BOOL)enabled
786 {
787     _preferences->setAuthorAndUserStylesEnabled(enabled);
788 }
789
790 - (BOOL)_authorAndUserStylesEnabled
791 {
792     return _preferences->authorAndUserStylesEnabled();
793 }
794
795 - (void)_setDOMTimersThrottlingEnabled:(BOOL)enabled
796 {
797     _preferences->setDOMTimersThrottlingEnabled(enabled);
798 }
799
800 - (BOOL)_domTimersThrottlingEnabled
801 {
802     return _preferences->domTimersThrottlingEnabled();
803 }
804
805 - (void)_setWebArchiveDebugModeEnabled:(BOOL)enabled
806 {
807     _preferences->setWebArchiveDebugModeEnabled(enabled);
808 }
809
810 - (BOOL)_webArchiveDebugModeEnabled
811 {
812     return _preferences->webArchiveDebugModeEnabled();
813 }
814
815 - (void)_setLocalFileContentSniffingEnabled:(BOOL)enabled
816 {
817     _preferences->setLocalFileContentSniffingEnabled(enabled);
818 }
819
820 - (BOOL)_localFileContentSniffingEnabled
821 {
822     return _preferences->localFileContentSniffingEnabled();
823 }
824
825 - (void)_setUsesPageCache:(BOOL)enabled
826 {
827     _preferences->setUsesPageCache(enabled);
828 }
829
830 - (BOOL)_usesPageCache
831 {
832     return _preferences->usesPageCache();
833 }
834
835 - (void)_setPageCacheSupportsPlugins:(BOOL)enabled
836 {
837     _preferences->setPageCacheSupportsPlugins(enabled);
838 }
839
840 - (BOOL)_pageCacheSupportsPlugins
841 {
842     return _preferences->pageCacheSupportsPlugins();
843 }
844
845 - (void)_setShouldPrintBackgrounds:(BOOL)enabled
846 {
847     _preferences->setShouldPrintBackgrounds(enabled);
848 }
849
850 - (BOOL)_shouldPrintBackgrounds
851 {
852     return _preferences->shouldPrintBackgrounds();
853 }
854
855 - (void)_setWebSecurityEnabled:(BOOL)enabled
856 {
857     _preferences->setWebSecurityEnabled(enabled);
858 }
859
860 - (BOOL)_webSecurityEnabled
861 {
862     return _preferences->webSecurityEnabled();
863 }
864
865 - (void)_setUniversalAccessFromFileURLsAllowed:(BOOL)enabled
866 {
867     _preferences->setAllowUniversalAccessFromFileURLs(enabled);
868 }
869
870 - (BOOL)_universalAccessFromFileURLsAllowed
871 {
872     return _preferences->allowUniversalAccessFromFileURLs();
873 }
874
875 - (void)_setAVFoundationEnabled:(BOOL)enabled
876 {
877     _preferences->setAVFoundationEnabled(enabled);
878 }
879
880 - (BOOL)_avFoundationEnabled
881 {
882     return _preferences->isAVFoundationEnabled();
883 }
884
885 - (void)_setSuppressesIncrementalRendering:(BOOL)enabled
886 {
887     _preferences->setSuppressesIncrementalRendering(enabled);
888 }
889
890 - (BOOL)_suppressesIncrementalRendering
891 {
892     return _preferences->suppressesIncrementalRendering();
893 }
894
895 - (void)_setAsynchronousPluginInitializationEnabled:(BOOL)enabled
896 {
897     _preferences->setAsynchronousPluginInitializationEnabled(enabled);
898 }
899
900 - (BOOL)_asynchronousPluginInitializationEnabled
901 {
902     return _preferences->asynchronousPluginInitializationEnabled();
903 }
904
905 - (void)_setArtificialPluginInitializationDelayEnabled:(BOOL)enabled
906 {
907     _preferences->setArtificialPluginInitializationDelayEnabled(enabled);
908 }
909
910 - (BOOL)_artificialPluginInitializationDelayEnabled
911 {
912     return _preferences->artificialPluginInitializationDelayEnabled();
913 }
914
915 - (void)_setCookieEnabled:(BOOL)enabled
916 {
917     _preferences->setCookieEnabled(enabled);
918 }
919
920 - (BOOL)_cookieEnabled
921 {
922     return _preferences->cookieEnabled();
923 }
924
925 - (void)_setPlugInSnapshottingEnabled:(BOOL)enabled
926 {
927     _preferences->setPlugInSnapshottingEnabled(enabled);
928 }
929
930 - (BOOL)_plugInSnapshottingEnabled
931 {
932     return _preferences->plugInSnapshottingEnabled();
933 }
934
935 - (void)_setSubpixelCSSOMElementMetricsEnabled:(BOOL)enabled
936 {
937     _preferences->setSubpixelCSSOMElementMetricsEnabled(enabled);
938 }
939
940 - (BOOL)_subpixelCSSOMElementMetricsEnabled
941 {
942     return _preferences->subpixelCSSOMElementMetricsEnabled();
943 }
944
945 - (void)_setMediaSourceEnabled:(BOOL)enabled
946 {
947     _preferences->setMediaSourceEnabled(enabled);
948 }
949
950 - (BOOL)_mediaSourceEnabled
951 {
952     return _preferences->mediaSourceEnabled();
953 }
954
955 - (void)_setViewGestureDebuggingEnabled:(BOOL)enabled
956 {
957     _preferences->setViewGestureDebuggingEnabled(enabled);
958 }
959
960 - (BOOL)_viewGestureDebuggingEnabled
961 {
962     return _preferences->viewGestureDebuggingEnabled();
963 }
964
965 - (void)_setCSSAnimationTriggersEnabled:(BOOL)enabled
966 {
967     _preferences->setCSSAnimationTriggersEnabled(enabled);
968 }
969
970 - (BOOL)_cssAnimationTriggersEnabled
971 {
972     return _preferences->cssAnimationTriggersEnabled();
973 }
974
975 - (void)_setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:(BOOL)enabled
976 {
977     _preferences->setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled(enabled);
978 }
979
980 - (BOOL)_cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled
981 {
982     return _preferences->cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled();
983 }
984
985 - (void)_setStandardFontFamily:(NSString *)family
986 {
987     _preferences->setStandardFontFamily(family);
988 }
989
990 - (NSString *)_standardFontFamily
991 {
992     return _preferences->standardFontFamily();
993 }
994
995 - (void)_setNotificationsEnabled:(BOOL)enabled
996 {
997     _preferences->setNotificationsEnabled(enabled);
998 }
999
1000 - (BOOL)_notificationsEnabled
1001 {
1002     return _preferences->notificationsEnabled();
1003 }
1004
1005 - (void)_setBackspaceKeyNavigationEnabled:(BOOL)enabled
1006 {
1007     _preferences->setBackspaceKeyNavigationEnabled(enabled);
1008 }
1009
1010 - (BOOL)_backspaceKeyNavigationEnabled
1011 {
1012     return _preferences->backspaceKeyNavigationEnabled();
1013 }
1014
1015 - (void)_setWebGLEnabled:(BOOL)enabled
1016 {
1017     _preferences->setWebGLEnabled(enabled);
1018 }
1019
1020 - (BOOL)_webGLEnabled
1021 {
1022     return _preferences->webGLEnabled();
1023 }
1024
1025 - (void)_setAllowsInlineMediaPlayback:(BOOL)enabled
1026 {
1027     _preferences->setAllowsInlineMediaPlayback(enabled);
1028 }
1029
1030 - (BOOL)_allowsInlineMediaPlayback
1031 {
1032     return _preferences->allowsInlineMediaPlayback();
1033 }
1034
1035 - (void)_setApplePayEnabled:(BOOL)enabled
1036 {
1037     _preferences->setApplePayEnabled(enabled);
1038 }
1039
1040 - (BOOL)_applePayEnabled
1041 {
1042     return _preferences->applePayEnabled();
1043 }
1044
1045 - (void)_setDNSPrefetchingEnabled:(BOOL)enabled
1046 {
1047     _preferences->setDNSPrefetchingEnabled(enabled);
1048 }
1049
1050 - (BOOL)_dnsPrefetchingEnabled
1051 {
1052     return _preferences->dnsPrefetchingEnabled();
1053 }
1054
1055 - (void)_setInlineMediaPlaybackRequiresPlaysInlineAttribute:(BOOL)enabled
1056 {
1057     _preferences->setInlineMediaPlaybackRequiresPlaysInlineAttribute(enabled);
1058 }
1059
1060 - (BOOL)_inlineMediaPlaybackRequiresPlaysInlineAttribute
1061 {
1062     return _preferences->inlineMediaPlaybackRequiresPlaysInlineAttribute();
1063 }
1064
1065 - (void)_setInvisibleMediaAutoplayNotPermitted:(BOOL)enabled
1066 {
1067     _preferences->setInvisibleAutoplayNotPermitted(enabled);
1068 }
1069
1070 - (BOOL)_invisibleMediaAutoplayNotPermitted
1071 {
1072     return _preferences->invisibleAutoplayNotPermitted();
1073 }
1074
1075 - (void)_setLegacyEncryptedMediaAPIEnabled:(BOOL)enabled
1076 {
1077     _preferences->setLegacyEncryptedMediaAPIEnabled(enabled);
1078 }
1079
1080 - (BOOL)_legacyEncryptedMediaAPIEnabled
1081 {
1082     return _preferences->legacyEncryptedMediaAPIEnabled();
1083 }
1084
1085 - (void)_setMainContentUserGestureOverrideEnabled:(BOOL)enabled
1086 {
1087     _preferences->setMainContentUserGestureOverrideEnabled(enabled);
1088 }
1089
1090 - (BOOL)_mainContentUserGestureOverrideEnabled
1091 {
1092     return _preferences->mainContentUserGestureOverrideEnabled();
1093 }
1094
1095 - (void)_setMediaStreamEnabled:(BOOL)enabled
1096 {
1097     _preferences->setMediaStreamEnabled(enabled);
1098 }
1099
1100 - (BOOL)_mediaStreamEnabled
1101 {
1102     return _preferences->mediaStreamEnabled();
1103 }
1104
1105 - (void)_setNeedsStorageAccessFromFileURLsQuirk:(BOOL)enabled
1106 {
1107     _preferences->setNeedsStorageAccessFromFileURLsQuirk(enabled);
1108 }
1109
1110 - (BOOL)_needsStorageAccessFromFileURLsQuirk
1111 {
1112     return _preferences->needsStorageAccessFromFileURLsQuirk();
1113 }
1114
1115 - (void)_setPDFPluginEnabled:(BOOL)enabled
1116 {
1117     _preferences->setPDFPluginEnabled(enabled);
1118 }
1119
1120 - (BOOL)_pdfPluginEnabled
1121 {
1122     return _preferences->pdfPluginEnabled();
1123 }
1124
1125 - (void)_setRequiresUserGestureForAudioPlayback:(BOOL)enabled
1126 {
1127     _preferences->setRequiresUserGestureForAudioPlayback(enabled);
1128 }
1129
1130 - (BOOL)_requiresUserGestureForAudioPlayback
1131 {
1132     return _preferences->requiresUserGestureForAudioPlayback();
1133 }
1134
1135 - (void)_setRequiresUserGestureForVideoPlayback:(BOOL)enabled
1136 {
1137     _preferences->setRequiresUserGestureForVideoPlayback(enabled);
1138 }
1139
1140 - (BOOL)_requiresUserGestureForVideoPlayback
1141 {
1142     return _preferences->requiresUserGestureForVideoPlayback();
1143 }
1144
1145 - (void)_setServiceControlsEnabled:(BOOL)enabled
1146 {
1147     _preferences->setServiceControlsEnabled(enabled);
1148 }
1149
1150 - (BOOL)_serviceControlsEnabled
1151 {
1152     return _preferences->serviceControlsEnabled();
1153 }
1154
1155 - (void)_setShowsToolTipOverTruncatedText:(BOOL)enabled
1156 {
1157     _preferences->setShowsToolTipOverTruncatedText(enabled);
1158 }
1159
1160 - (BOOL)_showsToolTipOverTruncatedText
1161 {
1162     return _preferences->showsToolTipOverTruncatedText();
1163 }
1164
1165 - (void)_setTextAreasAreResizable:(BOOL)enabled
1166 {
1167     _preferences->setTextAreasAreResizable(enabled);
1168 }
1169
1170 - (BOOL)_textAreasAreResizable
1171 {
1172     return _preferences->textAreasAreResizable();
1173 }
1174
1175 - (void)_setUseGiantTiles:(BOOL)enabled
1176 {
1177     _preferences->setUseGiantTiles(enabled);
1178 }
1179
1180 - (BOOL)_useGiantTiles
1181 {
1182     return _preferences->useGiantTiles();
1183 }
1184
1185 - (void)_setWantsBalancedSetDefersLoadingBehavior:(BOOL)enabled
1186 {
1187     _preferences->setWantsBalancedSetDefersLoadingBehavior(enabled);
1188 }
1189
1190 - (BOOL)_wantsBalancedSetDefersLoadingBehavior
1191 {
1192     return _preferences->wantsBalancedSetDefersLoadingBehavior();
1193 }
1194
1195 - (void)_setWebAudioEnabled:(BOOL)enabled
1196 {
1197     _preferences->setWebAudioEnabled(enabled);
1198 }
1199
1200 - (BOOL)_webAudioEnabled
1201 {
1202     return _preferences->webAudioEnabled();
1203 }
1204
1205 #endif // PLATFORM(MAC)
1206
1207 - (BOOL)_javaScriptCanAccessClipboard
1208 {
1209     return _preferences->javaScriptCanAccessClipboard();
1210 }
1211
1212 - (void)_setDOMPasteAllowed:(BOOL)domPasteAllowed
1213 {
1214     _preferences->setDOMPasteAllowed(domPasteAllowed);
1215 }
1216
1217 - (BOOL)_domPasteAllowed
1218 {
1219     return _preferences->domPasteAllowed();
1220 }
1221
1222 @end
1223
1224 #endif // WK_API_ENABLED