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