Allow override of viewport configuration.
[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 #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<_WKInternalDebugFeature *> *)_internalDebugFeatures
531 {
532     auto features = WebKit::WebPreferences::internalDebugFeatures();
533     return wrapper(API::Array::create(WTFMove(features)));
534 }
535
536 - (BOOL)_isEnabledForInternalDebugFeature:(_WKInternalDebugFeature *)feature
537 {
538     return _preferences->isFeatureEnabled(*feature->_internalDebugFeature);
539 }
540
541 - (void)_setEnabled:(BOOL)value forInternalDebugFeature:(_WKInternalDebugFeature *)feature
542 {
543     _preferences->setFeatureEnabled(*feature->_internalDebugFeature, value);
544 }
545
546 + (NSArray<_WKExperimentalFeature *> *)_experimentalFeatures
547 {
548     auto features = WebKit::WebPreferences::experimentalFeatures();
549     return wrapper(API::Array::create(WTFMove(features)));
550 }
551
552 // FIXME: Remove this once Safari has adopted the new API.
553 - (BOOL)_isEnabledForFeature:(_WKExperimentalFeature *)feature
554 {
555     return [self _isEnabledForExperimentalFeature:feature];
556 }
557
558 // FIXME: Remove this once Safari has adopted the new API.
559 - (void)_setEnabled:(BOOL)value forFeature:(_WKExperimentalFeature *)feature
560 {
561     [self _setEnabled:value forExperimentalFeature:feature];
562 }
563
564 - (BOOL)_isEnabledForExperimentalFeature:(_WKExperimentalFeature *)feature
565 {
566     return _preferences->isFeatureEnabled(*feature->_experimentalFeature);
567 }
568
569 - (void)_setEnabled:(BOOL)value forExperimentalFeature:(_WKExperimentalFeature *)feature
570 {
571     _preferences->setFeatureEnabled(*feature->_experimentalFeature, value);
572 }
573
574 - (BOOL)_applePayCapabilityDisclosureAllowed
575 {
576 #if ENABLE(APPLE_PAY)
577     return _preferences->applePayCapabilityDisclosureAllowed();
578 #else
579     return NO;
580 #endif
581 }
582
583 - (void)_setApplePayCapabilityDisclosureAllowed:(BOOL)applePayCapabilityDisclosureAllowed
584 {
585 #if ENABLE(APPLE_PAY)
586     _preferences->setApplePayCapabilityDisclosureAllowed(applePayCapabilityDisclosureAllowed);
587 #endif
588 }
589
590 - (BOOL)_shouldSuppressKeyboardInputDuringProvisionalNavigation
591 {
592     return _preferences->shouldSuppressTextInputFromEditingDuringProvisionalNavigation();
593 }
594
595 - (void)_setShouldSuppressKeyboardInputDuringProvisionalNavigation:(BOOL)shouldSuppress
596 {
597     _preferences->setShouldSuppressTextInputFromEditingDuringProvisionalNavigation(shouldSuppress);
598 }
599
600 - (BOOL)_loadsImagesAutomatically
601 {
602     return _preferences->loadsImagesAutomatically();
603 }
604
605 - (void)_setLoadsImagesAutomatically:(BOOL)loadsImagesAutomatically
606 {
607     _preferences->setLoadsImagesAutomatically(loadsImagesAutomatically);
608 }
609
610 - (BOOL)_peerConnectionEnabled
611 {
612     return _preferences->peerConnectionEnabled();
613 }
614
615 - (void)_setPeerConnectionEnabled:(BOOL)enabled
616 {
617     _preferences->setPeerConnectionEnabled(enabled);
618 }
619
620 - (BOOL)_mediaDevicesEnabled
621 {
622     return _preferences->mediaDevicesEnabled();
623 }
624
625 - (void)_setMediaDevicesEnabled:(BOOL)enabled
626 {
627     _preferences->setMediaDevicesEnabled(enabled);
628 }
629
630 - (BOOL)_screenCaptureEnabled
631 {
632     return _preferences->screenCaptureEnabled();
633 }
634
635 - (void)_setScreenCaptureEnabled:(BOOL)enabled
636 {
637     _preferences->setScreenCaptureEnabled(enabled);
638 }
639
640 - (BOOL)_mockCaptureDevicesEnabled
641 {
642     return _preferences->mockCaptureDevicesEnabled();
643 }
644
645 - (void)_setMockCaptureDevicesEnabled:(BOOL)enabled
646 {
647     _preferences->setMockCaptureDevicesEnabled(enabled);
648 }
649
650 - (BOOL)_mockCaptureDevicesPromptEnabled
651 {
652     return _preferences->mockCaptureDevicesPromptEnabled();
653 }
654
655 - (void)_setMockCaptureDevicesPromptEnabled:(BOOL)enabled
656 {
657     _preferences->setMockCaptureDevicesPromptEnabled(enabled);
658 }
659
660 - (BOOL)_mediaCaptureRequiresSecureConnection
661 {
662     return _preferences->mediaCaptureRequiresSecureConnection();
663 }
664
665 - (void)_setMediaCaptureRequiresSecureConnection:(BOOL)requiresSecureConnection
666 {
667     _preferences->setMediaCaptureRequiresSecureConnection(requiresSecureConnection);
668 }
669
670 - (double)_inactiveMediaCaptureSteamRepromptIntervalInMinutes
671 {
672     return _preferences->inactiveMediaCaptureSteamRepromptIntervalInMinutes();
673 }
674
675 - (void)_setInactiveMediaCaptureSteamRepromptIntervalInMinutes:(double)interval
676 {
677     _preferences->setInactiveMediaCaptureSteamRepromptIntervalInMinutes(interval);
678 }
679
680 - (BOOL)_enumeratingAllNetworkInterfacesEnabled
681 {
682     return _preferences->enumeratingAllNetworkInterfacesEnabled();
683 }
684
685 - (void)_setEnumeratingAllNetworkInterfacesEnabled:(BOOL)enabled
686 {
687     _preferences->setEnumeratingAllNetworkInterfacesEnabled(enabled);
688 }
689
690 - (BOOL)_iceCandidateFilteringEnabled
691 {
692     return _preferences->iceCandidateFilteringEnabled();
693 }
694
695 - (void)_setICECandidateFilteringEnabled:(BOOL)enabled
696 {
697     _preferences->setICECandidateFilteringEnabled(enabled);
698 }
699
700 - (BOOL)_webRTCLegacyAPIEnabled
701 {
702     return NO;
703 }
704
705 - (void)_setWebRTCLegacyAPIEnabled:(BOOL)enabled
706 {
707 }
708
709 - (void)_setJavaScriptCanAccessClipboard:(BOOL)javaScriptCanAccessClipboard
710 {
711     _preferences->setJavaScriptCanAccessClipboard(javaScriptCanAccessClipboard);
712 }
713
714 - (BOOL)_shouldAllowUserInstalledFonts
715 {
716     return _preferences->shouldAllowUserInstalledFonts();
717 }
718
719 - (void)_setShouldAllowUserInstalledFonts:(BOOL)_shouldAllowUserInstalledFonts
720 {
721     _preferences->setShouldAllowUserInstalledFonts(_shouldAllowUserInstalledFonts);
722 }
723
724 static _WKEditableLinkBehavior toAPI(WebCore::EditableLinkBehavior behavior)
725 {
726     switch (behavior) {
727     case WebCore::EditableLinkDefaultBehavior:
728         return _WKEditableLinkBehaviorDefault;
729     case WebCore::EditableLinkAlwaysLive:
730         return _WKEditableLinkBehaviorAlwaysLive;
731     case WebCore::EditableLinkOnlyLiveWithShiftKey:
732         return _WKEditableLinkBehaviorOnlyLiveWithShiftKey;
733     case WebCore::EditableLinkLiveWhenNotFocused:
734         return _WKEditableLinkBehaviorLiveWhenNotFocused;
735     case WebCore::EditableLinkNeverLive:
736         return _WKEditableLinkBehaviorNeverLive;
737     }
738     
739     ASSERT_NOT_REACHED();
740     return _WKEditableLinkBehaviorNeverLive;
741 }
742
743 static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehavior wkBehavior)
744 {
745     switch (wkBehavior) {
746     case _WKEditableLinkBehaviorDefault:
747         return WebCore::EditableLinkDefaultBehavior;
748     case _WKEditableLinkBehaviorAlwaysLive:
749         return WebCore::EditableLinkAlwaysLive;
750     case _WKEditableLinkBehaviorOnlyLiveWithShiftKey:
751         return WebCore::EditableLinkOnlyLiveWithShiftKey;
752     case _WKEditableLinkBehaviorLiveWhenNotFocused:
753         return WebCore::EditableLinkLiveWhenNotFocused;
754     case _WKEditableLinkBehaviorNeverLive:
755         return WebCore::EditableLinkNeverLive;
756     }
757     
758     ASSERT_NOT_REACHED();
759     return WebCore::EditableLinkNeverLive;
760 }
761
762 - (_WKEditableLinkBehavior)_editableLinkBehavior
763 {
764     return toAPI(static_cast<WebCore::EditableLinkBehavior>(_preferences->editableLinkBehavior()));
765 }
766
767 - (void)_setEditableLinkBehavior:(_WKEditableLinkBehavior)editableLinkBehavior
768 {
769     _preferences->setEditableLinkBehavior(toEditableLinkBehavior(editableLinkBehavior));
770 }
771
772 - (void)_setAVFoundationEnabled:(BOOL)enabled
773 {
774     _preferences->setAVFoundationEnabled(enabled);
775 }
776
777 - (BOOL)_avFoundationEnabled
778 {
779     return _preferences->isAVFoundationEnabled();
780 }
781
782 - (void)_setColorFilterEnabled:(BOOL)enabled
783 {
784     _preferences->setColorFilterEnabled(enabled);
785 }
786
787 - (BOOL)_colorFilterEnabled
788 {
789     return _preferences->colorFilterEnabled();
790 }
791
792 - (void)_setPunchOutWhiteBackgroundsInDarkMode:(BOOL)punches
793 {
794     _preferences->setPunchOutWhiteBackgroundsInDarkMode(punches);
795 }
796
797 - (BOOL)_punchOutWhiteBackgroundsInDarkMode
798 {
799     return _preferences->punchOutWhiteBackgroundsInDarkMode();
800 }
801
802 - (void)_setLowPowerVideoAudioBufferSizeEnabled:(BOOL)enabled
803 {
804     _preferences->setLowPowerVideoAudioBufferSizeEnabled(enabled);
805 }
806
807 - (BOOL)_lowPowerVideoAudioBufferSizeEnabled
808 {
809     return _preferences->lowPowerVideoAudioBufferSizeEnabled();
810 }
811
812 - (void)_setShouldIgnoreMetaViewport:(BOOL)ignoreMetaViewport
813 {
814     return _preferences->setShouldIgnoreMetaViewport(ignoreMetaViewport);
815 }
816
817 - (BOOL)_shouldIgnoreMetaViewport
818 {
819     return _preferences->shouldIgnoreMetaViewport();
820 }
821
822 #if PLATFORM(MAC)
823 - (void)_setJavaEnabledForLocalFiles:(BOOL)enabled
824 {
825     _preferences->setJavaEnabledForLocalFiles(enabled);
826 }
827
828 - (BOOL)_javaEnabledForLocalFiles
829 {
830     return _preferences->javaEnabledForLocalFiles();
831 }
832
833 - (void)_setCanvasUsesAcceleratedDrawing:(BOOL)enabled
834 {
835     _preferences->setCanvasUsesAcceleratedDrawing(enabled);
836 }
837
838 - (BOOL)_canvasUsesAcceleratedDrawing
839 {
840     return _preferences->canvasUsesAcceleratedDrawing();
841 }
842
843 - (void)_setAcceleratedCompositingEnabled:(BOOL)enabled
844 {
845     _preferences->setAcceleratedCompositingEnabled(enabled);
846 }
847
848 - (BOOL)_acceleratedCompositingEnabled
849 {
850     return _preferences->acceleratedCompositingEnabled();
851 }
852
853 - (void)_setDefaultTextEncodingName:(NSString *)name
854 {
855     _preferences->setDefaultTextEncodingName(name);
856 }
857
858 - (NSString *)_defaultTextEncodingName
859 {
860     return _preferences->defaultTextEncodingName();
861 }
862
863 - (void)_setNeedsSiteSpecificQuirks:(BOOL)enabled
864 {
865     _preferences->setNeedsSiteSpecificQuirks(enabled);
866 }
867
868 - (BOOL)_needsSiteSpecificQuirks
869 {
870     return _preferences->needsSiteSpecificQuirks();
871 }
872
873 - (void)_setAuthorAndUserStylesEnabled:(BOOL)enabled
874 {
875     _preferences->setAuthorAndUserStylesEnabled(enabled);
876 }
877
878 - (BOOL)_authorAndUserStylesEnabled
879 {
880     return _preferences->authorAndUserStylesEnabled();
881 }
882
883 - (void)_setDOMTimersThrottlingEnabled:(BOOL)enabled
884 {
885     _preferences->setDOMTimersThrottlingEnabled(enabled);
886 }
887
888 - (BOOL)_domTimersThrottlingEnabled
889 {
890     return _preferences->domTimersThrottlingEnabled();
891 }
892
893 - (void)_setWebArchiveDebugModeEnabled:(BOOL)enabled
894 {
895     _preferences->setWebArchiveDebugModeEnabled(enabled);
896 }
897
898 - (BOOL)_webArchiveDebugModeEnabled
899 {
900     return _preferences->webArchiveDebugModeEnabled();
901 }
902
903 - (void)_setLocalFileContentSniffingEnabled:(BOOL)enabled
904 {
905     _preferences->setLocalFileContentSniffingEnabled(enabled);
906 }
907
908 - (BOOL)_localFileContentSniffingEnabled
909 {
910     return _preferences->localFileContentSniffingEnabled();
911 }
912
913 - (void)_setUsesPageCache:(BOOL)enabled
914 {
915     _preferences->setUsesPageCache(enabled);
916 }
917
918 - (BOOL)_usesPageCache
919 {
920     return _preferences->usesPageCache();
921 }
922
923 - (void)_setPageCacheSupportsPlugins:(BOOL)enabled
924 {
925     _preferences->setPageCacheSupportsPlugins(enabled);
926 }
927
928 - (BOOL)_pageCacheSupportsPlugins
929 {
930     return _preferences->pageCacheSupportsPlugins();
931 }
932
933 - (void)_setShouldPrintBackgrounds:(BOOL)enabled
934 {
935     _preferences->setShouldPrintBackgrounds(enabled);
936 }
937
938 - (BOOL)_shouldPrintBackgrounds
939 {
940     return _preferences->shouldPrintBackgrounds();
941 }
942
943 - (void)_setWebSecurityEnabled:(BOOL)enabled
944 {
945     _preferences->setWebSecurityEnabled(enabled);
946 }
947
948 - (BOOL)_webSecurityEnabled
949 {
950     return _preferences->webSecurityEnabled();
951 }
952
953 - (void)_setUniversalAccessFromFileURLsAllowed:(BOOL)enabled
954 {
955     _preferences->setAllowUniversalAccessFromFileURLs(enabled);
956 }
957
958 - (BOOL)_universalAccessFromFileURLsAllowed
959 {
960     return _preferences->allowUniversalAccessFromFileURLs();
961 }
962
963 - (void)_setSuppressesIncrementalRendering:(BOOL)enabled
964 {
965     _preferences->setSuppressesIncrementalRendering(enabled);
966 }
967
968 - (BOOL)_suppressesIncrementalRendering
969 {
970     return _preferences->suppressesIncrementalRendering();
971 }
972
973 - (void)_setAsynchronousPluginInitializationEnabled:(BOOL)enabled
974 {
975     _preferences->setAsynchronousPluginInitializationEnabled(enabled);
976 }
977
978 - (BOOL)_asynchronousPluginInitializationEnabled
979 {
980     return _preferences->asynchronousPluginInitializationEnabled();
981 }
982
983 - (void)_setArtificialPluginInitializationDelayEnabled:(BOOL)enabled
984 {
985     _preferences->setArtificialPluginInitializationDelayEnabled(enabled);
986 }
987
988 - (BOOL)_artificialPluginInitializationDelayEnabled
989 {
990     return _preferences->artificialPluginInitializationDelayEnabled();
991 }
992
993 - (void)_setExperimentalPlugInSandboxProfilesEnabled:(BOOL)enabled
994 {
995 #if ENABLE(NETSCAPE_PLUGIN_API)
996     WebKit::PluginProcessManager::singleton().setExperimentalPlugInSandboxProfilesEnabled(enabled);
997 #endif
998     _preferences->setExperimentalPlugInSandboxProfilesEnabled(enabled);
999 }
1000
1001 - (BOOL)_experimentalPlugInSandboxProfilesEnabled
1002 {
1003     return _preferences->experimentalPlugInSandboxProfilesEnabled();
1004 }
1005
1006 - (void)_setCookieEnabled:(BOOL)enabled
1007 {
1008     _preferences->setCookieEnabled(enabled);
1009 }
1010
1011 - (BOOL)_cookieEnabled
1012 {
1013     return _preferences->cookieEnabled();
1014 }
1015
1016 - (void)_setPlugInSnapshottingEnabled:(BOOL)enabled
1017 {
1018     _preferences->setPlugInSnapshottingEnabled(enabled);
1019 }
1020
1021 - (BOOL)_plugInSnapshottingEnabled
1022 {
1023     return _preferences->plugInSnapshottingEnabled();
1024 }
1025
1026 - (void)_setSubpixelCSSOMElementMetricsEnabled:(BOOL)enabled
1027 {
1028     _preferences->setSubpixelCSSOMElementMetricsEnabled(enabled);
1029 }
1030
1031 - (BOOL)_subpixelCSSOMElementMetricsEnabled
1032 {
1033     return _preferences->subpixelCSSOMElementMetricsEnabled();
1034 }
1035
1036 - (void)_setMediaSourceEnabled:(BOOL)enabled
1037 {
1038     _preferences->setMediaSourceEnabled(enabled);
1039 }
1040
1041 - (BOOL)_mediaSourceEnabled
1042 {
1043     return _preferences->mediaSourceEnabled();
1044 }
1045
1046 - (void)_setViewGestureDebuggingEnabled:(BOOL)enabled
1047 {
1048     _preferences->setViewGestureDebuggingEnabled(enabled);
1049 }
1050
1051 - (BOOL)_viewGestureDebuggingEnabled
1052 {
1053     return _preferences->viewGestureDebuggingEnabled();
1054 }
1055
1056 - (void)_setCSSAnimationTriggersEnabled:(BOOL)enabled
1057 {
1058     _preferences->setCSSAnimationTriggersEnabled(enabled);
1059 }
1060
1061 - (BOOL)_cssAnimationTriggersEnabled
1062 {
1063     return _preferences->cssAnimationTriggersEnabled();
1064 }
1065
1066 - (void)_setWebAnimationsCSSIntegrationEnabled:(BOOL)enabled
1067 {
1068     _preferences->setWebAnimationsCSSIntegrationEnabled(enabled);
1069 }
1070
1071 - (BOOL)_webAnimationsCSSIntegrationEnabled
1072 {
1073     return _preferences->webAnimationsCSSIntegrationEnabled();
1074 }
1075
1076 - (void)_setStandardFontFamily:(NSString *)family
1077 {
1078     _preferences->setStandardFontFamily(family);
1079 }
1080
1081 - (NSString *)_standardFontFamily
1082 {
1083     return _preferences->standardFontFamily();
1084 }
1085
1086 - (void)_setNotificationsEnabled:(BOOL)enabled
1087 {
1088     _preferences->setNotificationsEnabled(enabled);
1089 }
1090
1091 - (BOOL)_notificationsEnabled
1092 {
1093     return _preferences->notificationsEnabled();
1094 }
1095
1096 - (void)_setBackspaceKeyNavigationEnabled:(BOOL)enabled
1097 {
1098     _preferences->setBackspaceKeyNavigationEnabled(enabled);
1099 }
1100
1101 - (BOOL)_backspaceKeyNavigationEnabled
1102 {
1103     return _preferences->backspaceKeyNavigationEnabled();
1104 }
1105
1106 - (void)_setWebGLEnabled:(BOOL)enabled
1107 {
1108     _preferences->setWebGLEnabled(enabled);
1109 }
1110
1111 - (BOOL)_webGLEnabled
1112 {
1113     return _preferences->webGLEnabled();
1114 }
1115
1116 - (void)_setAllowsInlineMediaPlayback:(BOOL)enabled
1117 {
1118     _preferences->setAllowsInlineMediaPlayback(enabled);
1119 }
1120
1121 - (BOOL)_allowsInlineMediaPlayback
1122 {
1123     return _preferences->allowsInlineMediaPlayback();
1124 }
1125
1126 - (void)_setApplePayEnabled:(BOOL)enabled
1127 {
1128     _preferences->setApplePayEnabled(enabled);
1129 }
1130
1131 - (BOOL)_applePayEnabled
1132 {
1133     return _preferences->applePayEnabled();
1134 }
1135
1136 - (void)_setDNSPrefetchingEnabled:(BOOL)enabled
1137 {
1138     _preferences->setDNSPrefetchingEnabled(enabled);
1139 }
1140
1141 - (BOOL)_dnsPrefetchingEnabled
1142 {
1143     return _preferences->dnsPrefetchingEnabled();
1144 }
1145
1146 - (void)_setInlineMediaPlaybackRequiresPlaysInlineAttribute:(BOOL)enabled
1147 {
1148     _preferences->setInlineMediaPlaybackRequiresPlaysInlineAttribute(enabled);
1149 }
1150
1151 - (BOOL)_inlineMediaPlaybackRequiresPlaysInlineAttribute
1152 {
1153     return _preferences->inlineMediaPlaybackRequiresPlaysInlineAttribute();
1154 }
1155
1156 - (void)_setInvisibleMediaAutoplayNotPermitted:(BOOL)enabled
1157 {
1158     _preferences->setInvisibleAutoplayNotPermitted(enabled);
1159 }
1160
1161 - (BOOL)_invisibleMediaAutoplayNotPermitted
1162 {
1163     return _preferences->invisibleAutoplayNotPermitted();
1164 }
1165
1166 - (void)_setLegacyEncryptedMediaAPIEnabled:(BOOL)enabled
1167 {
1168     _preferences->setLegacyEncryptedMediaAPIEnabled(enabled);
1169 }
1170
1171 - (BOOL)_legacyEncryptedMediaAPIEnabled
1172 {
1173     return _preferences->legacyEncryptedMediaAPIEnabled();
1174 }
1175
1176 - (void)_setMainContentUserGestureOverrideEnabled:(BOOL)enabled
1177 {
1178     _preferences->setMainContentUserGestureOverrideEnabled(enabled);
1179 }
1180
1181 - (BOOL)_mainContentUserGestureOverrideEnabled
1182 {
1183     return _preferences->mainContentUserGestureOverrideEnabled();
1184 }
1185
1186 - (void)_setMediaStreamEnabled:(BOOL)enabled
1187 {
1188     _preferences->setMediaStreamEnabled(enabled);
1189 }
1190
1191 - (BOOL)_mediaStreamEnabled
1192 {
1193     return _preferences->mediaStreamEnabled();
1194 }
1195
1196 - (void)_setNeedsStorageAccessFromFileURLsQuirk:(BOOL)enabled
1197 {
1198     _preferences->setNeedsStorageAccessFromFileURLsQuirk(enabled);
1199 }
1200
1201 - (BOOL)_needsStorageAccessFromFileURLsQuirk
1202 {
1203     return _preferences->needsStorageAccessFromFileURLsQuirk();
1204 }
1205
1206 - (void)_setPDFPluginEnabled:(BOOL)enabled
1207 {
1208     _preferences->setPDFPluginEnabled(enabled);
1209 }
1210
1211 - (BOOL)_pdfPluginEnabled
1212 {
1213     return _preferences->pdfPluginEnabled();
1214 }
1215
1216 - (void)_setRequiresUserGestureForAudioPlayback:(BOOL)enabled
1217 {
1218     _preferences->setRequiresUserGestureForAudioPlayback(enabled);
1219 }
1220
1221 - (BOOL)_requiresUserGestureForAudioPlayback
1222 {
1223     return _preferences->requiresUserGestureForAudioPlayback();
1224 }
1225
1226 - (void)_setRequiresUserGestureForVideoPlayback:(BOOL)enabled
1227 {
1228     _preferences->setRequiresUserGestureForVideoPlayback(enabled);
1229 }
1230
1231 - (BOOL)_requiresUserGestureForVideoPlayback
1232 {
1233     return _preferences->requiresUserGestureForVideoPlayback();
1234 }
1235
1236 - (void)_setServiceControlsEnabled:(BOOL)enabled
1237 {
1238     _preferences->setServiceControlsEnabled(enabled);
1239 }
1240
1241 - (BOOL)_serviceControlsEnabled
1242 {
1243     return _preferences->serviceControlsEnabled();
1244 }
1245
1246 - (void)_setShowsToolTipOverTruncatedText:(BOOL)enabled
1247 {
1248     _preferences->setShowsToolTipOverTruncatedText(enabled);
1249 }
1250
1251 - (BOOL)_showsToolTipOverTruncatedText
1252 {
1253     return _preferences->showsToolTipOverTruncatedText();
1254 }
1255
1256 - (void)_setTextAreasAreResizable:(BOOL)enabled
1257 {
1258     _preferences->setTextAreasAreResizable(enabled);
1259 }
1260
1261 - (BOOL)_textAreasAreResizable
1262 {
1263     return _preferences->textAreasAreResizable();
1264 }
1265
1266 - (void)_setUseGiantTiles:(BOOL)enabled
1267 {
1268     _preferences->setUseGiantTiles(enabled);
1269 }
1270
1271 - (BOOL)_useGiantTiles
1272 {
1273     return _preferences->useGiantTiles();
1274 }
1275
1276 - (void)_setWantsBalancedSetDefersLoadingBehavior:(BOOL)enabled
1277 {
1278     _preferences->setWantsBalancedSetDefersLoadingBehavior(enabled);
1279 }
1280
1281 - (BOOL)_wantsBalancedSetDefersLoadingBehavior
1282 {
1283     return _preferences->wantsBalancedSetDefersLoadingBehavior();
1284 }
1285
1286 - (void)_setWebAudioEnabled:(BOOL)enabled
1287 {
1288     _preferences->setWebAudioEnabled(enabled);
1289 }
1290
1291 - (BOOL)_webAudioEnabled
1292 {
1293     return _preferences->webAudioEnabled();
1294 }
1295
1296 - (void)_setAggressiveTileRetentionEnabled:(BOOL)enabled
1297 {
1298     _preferences->setAggressiveTileRetentionEnabled(enabled);
1299 }
1300
1301 - (BOOL)_aggressiveTileRetentionEnabled
1302 {
1303     return _preferences->aggressiveTileRetentionEnabled();
1304 }
1305
1306 #endif // PLATFORM(MAC)
1307
1308 - (BOOL)_javaScriptCanAccessClipboard
1309 {
1310     return _preferences->javaScriptCanAccessClipboard();
1311 }
1312
1313 - (void)_setDOMPasteAllowed:(BOOL)domPasteAllowed
1314 {
1315     _preferences->setDOMPasteAllowed(domPasteAllowed);
1316 }
1317
1318 - (BOOL)_domPasteAllowed
1319 {
1320     return _preferences->domPasteAllowed();
1321 }
1322
1323 - (void)_setShouldEnableTextAutosizingBoost:(BOOL)shouldEnableTextAutosizingBoost
1324 {
1325 #if ENABLE(TEXT_AUTOSIZING)
1326     _preferences->setShouldEnableTextAutosizingBoost(shouldEnableTextAutosizingBoost);
1327 #endif
1328 }
1329
1330 - (BOOL)_shouldEnableTextAutosizingBoost
1331 {
1332 #if ENABLE(TEXT_AUTOSIZING)
1333     return _preferences->shouldEnableTextAutosizingBoost();
1334 #else
1335     return NO;
1336 #endif
1337 }
1338
1339 @end
1340
1341 #endif // WK_API_ENABLED