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