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