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