REGRESSION(r235484) _WKPreferencesGetWebRTCLegacyAPIEnabled symbol not found when...
[WebKit-https.git] / Source / WebKit / UIProcess / API / Cocoa / WKPreferences.mm
1 /*
2  * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #import "config.h"
27 #import "WKPreferencesInternal.h"
28
29 #if WK_API_ENABLED
30
31 #import "APIArray.h"
32 #import "PluginProcessManager.h"
33 #import "WKNSArray.h"
34 #import "WebPreferences.h"
35 #import "_WKExperimentalFeature.h"
36 #import "_WKExperimentalFeatureInternal.h"
37 #import <WebCore/SecurityOrigin.h>
38 #import <WebCore/Settings.h>
39 #import <wtf/RetainPtr.h>
40
41 @implementation WKPreferences
42
43 - (instancetype)init
44 {
45     if (!(self = [super init]))
46         return nil;
47
48     API::Object::constructInWrapper<WebKit::WebPreferences>(self, String(), "WebKit", "WebKitDebug");
49     return self;
50 }
51
52 - (void)dealloc
53 {
54     _preferences->~WebPreferences();
55
56     [super dealloc];
57 }
58
59 + (BOOL)supportsSecureCoding
60 {
61     return YES;
62 }
63
64 // FIXME: We currently only encode/decode API preferences. We should consider whether we should
65 // encode/decode SPI preferences as well.
66
67 - (void)encodeWithCoder:(NSCoder *)coder
68 {
69     [coder encodeDouble:self.minimumFontSize forKey:@"minimumFontSize"];
70     [coder encodeBool:self.javaScriptEnabled forKey:@"javaScriptEnabled"];
71     [coder encodeBool:self.javaScriptCanOpenWindowsAutomatically forKey:@"javaScriptCanOpenWindowsAutomatically"];
72
73 #if PLATFORM(MAC)
74     [coder encodeBool:self.javaEnabled forKey:@"javaEnabled"];
75     [coder encodeBool:self.plugInsEnabled forKey:@"plugInsEnabled"];
76     [coder encodeBool:self.tabFocusesLinks forKey:@"tabFocusesLinks"];
77 #endif
78 }
79
80 - (instancetype)initWithCoder:(NSCoder *)coder
81 {
82     if (!(self = [self init]))
83         return nil;
84
85     self.minimumFontSize = [coder decodeDoubleForKey:@"minimumFontSize"];
86     self.javaScriptEnabled = [coder decodeBoolForKey:@"javaScriptEnabled"];
87     self.javaScriptCanOpenWindowsAutomatically = [coder decodeBoolForKey:@"javaScriptCanOpenWindowsAutomatically"];
88
89 #if PLATFORM(MAC)
90     self.javaEnabled = [coder decodeBoolForKey:@"javaEnabled"];
91     self.plugInsEnabled = [coder decodeBoolForKey:@"plugInsEnabled"];
92     self.tabFocusesLinks = [coder decodeBoolForKey:@"tabFocusesLinks"];
93 #endif
94
95     return self;
96 }
97
98 - (id)copyWithZone:(NSZone *)zone
99 {
100     return [wrapper(_preferences->copy()) 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<_WKExperimentalFeature *> *)_experimentalFeatures
531 {
532     auto features = WebKit::WebPreferences::experimentalFeatures();
533     return wrapper(API::Array::create(WTFMove(features)));
534 }
535
536 - (BOOL)_isEnabledForFeature:(_WKExperimentalFeature *)feature
537 {
538     return _preferences->isEnabledForFeature(*feature->_experimentalFeature);
539 }
540
541 - (void)_setEnabled:(BOOL)value forFeature:(_WKExperimentalFeature *)feature
542 {
543     _preferences->setEnabledForFeature(value, *feature->_experimentalFeature);
544 }
545
546 - (BOOL)_applePayCapabilityDisclosureAllowed
547 {
548 #if ENABLE(APPLE_PAY)
549     return _preferences->applePayCapabilityDisclosureAllowed();
550 #else
551     return NO;
552 #endif
553 }
554
555 - (void)_setApplePayCapabilityDisclosureAllowed:(BOOL)applePayCapabilityDisclosureAllowed
556 {
557 #if ENABLE(APPLE_PAY)
558     _preferences->setApplePayCapabilityDisclosureAllowed(applePayCapabilityDisclosureAllowed);
559 #endif
560 }
561
562 - (BOOL)_shouldSuppressKeyboardInputDuringProvisionalNavigation
563 {
564     return _preferences->shouldSuppressTextInputFromEditingDuringProvisionalNavigation();
565 }
566
567 - (void)_setShouldSuppressKeyboardInputDuringProvisionalNavigation:(BOOL)shouldSuppress
568 {
569     _preferences->setShouldSuppressTextInputFromEditingDuringProvisionalNavigation(shouldSuppress);
570 }
571
572 - (BOOL)_loadsImagesAutomatically
573 {
574     return _preferences->loadsImagesAutomatically();
575 }
576
577 - (void)_setLoadsImagesAutomatically:(BOOL)loadsImagesAutomatically
578 {
579     _preferences->setLoadsImagesAutomatically(loadsImagesAutomatically);
580 }
581
582 - (BOOL)_peerConnectionEnabled
583 {
584     return _preferences->peerConnectionEnabled();
585 }
586
587 - (void)_setPeerConnectionEnabled:(BOOL)enabled
588 {
589     _preferences->setPeerConnectionEnabled(enabled);
590 }
591
592 - (BOOL)_mediaDevicesEnabled
593 {
594     return _preferences->mediaDevicesEnabled();
595 }
596
597 - (void)_setMediaDevicesEnabled:(BOOL)enabled
598 {
599     _preferences->setMediaDevicesEnabled(enabled);
600 }
601
602 - (BOOL)_screenCaptureEnabled
603 {
604     return _preferences->screenCaptureEnabled();
605 }
606
607 - (void)_setScreenCaptureEnabled:(BOOL)enabled
608 {
609     _preferences->setScreenCaptureEnabled(enabled);
610 }
611
612 - (BOOL)_mockCaptureDevicesEnabled
613 {
614     return _preferences->mockCaptureDevicesEnabled();
615 }
616
617 - (void)_setMockCaptureDevicesEnabled:(BOOL)enabled
618 {
619     _preferences->setMockCaptureDevicesEnabled(enabled);
620 }
621
622 - (BOOL)_mockCaptureDevicesPromptEnabled
623 {
624     return _preferences->mockCaptureDevicesPromptEnabled();
625 }
626
627 - (void)_setMockCaptureDevicesPromptEnabled:(BOOL)enabled
628 {
629     _preferences->setMockCaptureDevicesPromptEnabled(enabled);
630 }
631
632 - (BOOL)_mediaCaptureRequiresSecureConnection
633 {
634     return _preferences->mediaCaptureRequiresSecureConnection();
635 }
636
637 - (void)_setMediaCaptureRequiresSecureConnection:(BOOL)requiresSecureConnection
638 {
639     _preferences->setMediaCaptureRequiresSecureConnection(requiresSecureConnection);
640 }
641
642 - (double)_inactiveMediaCaptureSteamRepromptIntervalInMinutes
643 {
644     return _preferences->inactiveMediaCaptureSteamRepromptIntervalInMinutes();
645 }
646
647 - (void)_setInactiveMediaCaptureSteamRepromptIntervalInMinutes:(double)interval
648 {
649     _preferences->setInactiveMediaCaptureSteamRepromptIntervalInMinutes(interval);
650 }
651
652 - (BOOL)_enumeratingAllNetworkInterfacesEnabled
653 {
654     return _preferences->enumeratingAllNetworkInterfacesEnabled();
655 }
656
657 - (void)_setEnumeratingAllNetworkInterfacesEnabled:(BOOL)enabled
658 {
659     _preferences->setEnumeratingAllNetworkInterfacesEnabled(enabled);
660 }
661
662 - (BOOL)_iceCandidateFilteringEnabled
663 {
664     return _preferences->iceCandidateFilteringEnabled();
665 }
666
667 - (void)_setICECandidateFilteringEnabled:(BOOL)enabled
668 {
669     _preferences->setICECandidateFilteringEnabled(enabled);
670 }
671
672 - (BOOL)_webRTCLegacyAPIEnabled
673 {
674     return NO;
675 }
676
677 - (void)_setWebRTCLegacyAPIEnabled:(BOOL)enabled
678 {
679 }
680
681 - (void)_setJavaScriptCanAccessClipboard:(BOOL)javaScriptCanAccessClipboard
682 {
683     _preferences->setJavaScriptCanAccessClipboard(javaScriptCanAccessClipboard);
684 }
685
686 - (BOOL)_shouldAllowUserInstalledFonts
687 {
688     return _preferences->shouldAllowUserInstalledFonts();
689 }
690
691 - (void)_setShouldAllowUserInstalledFonts:(BOOL)_shouldAllowUserInstalledFonts
692 {
693     _preferences->setShouldAllowUserInstalledFonts(_shouldAllowUserInstalledFonts);
694 }
695
696 static _WKEditableLinkBehavior toAPI(WebCore::EditableLinkBehavior behavior)
697 {
698     switch (behavior) {
699     case WebCore::EditableLinkDefaultBehavior:
700         return _WKEditableLinkBehaviorDefault;
701     case WebCore::EditableLinkAlwaysLive:
702         return _WKEditableLinkBehaviorAlwaysLive;
703     case WebCore::EditableLinkOnlyLiveWithShiftKey:
704         return _WKEditableLinkBehaviorOnlyLiveWithShiftKey;
705     case WebCore::EditableLinkLiveWhenNotFocused:
706         return _WKEditableLinkBehaviorLiveWhenNotFocused;
707     case WebCore::EditableLinkNeverLive:
708         return _WKEditableLinkBehaviorNeverLive;
709     }
710     
711     ASSERT_NOT_REACHED();
712     return _WKEditableLinkBehaviorNeverLive;
713 }
714
715 static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehavior wkBehavior)
716 {
717     switch (wkBehavior) {
718     case _WKEditableLinkBehaviorDefault:
719         return WebCore::EditableLinkDefaultBehavior;
720     case _WKEditableLinkBehaviorAlwaysLive:
721         return WebCore::EditableLinkAlwaysLive;
722     case _WKEditableLinkBehaviorOnlyLiveWithShiftKey:
723         return WebCore::EditableLinkOnlyLiveWithShiftKey;
724     case _WKEditableLinkBehaviorLiveWhenNotFocused:
725         return WebCore::EditableLinkLiveWhenNotFocused;
726     case _WKEditableLinkBehaviorNeverLive:
727         return WebCore::EditableLinkNeverLive;
728     }
729     
730     ASSERT_NOT_REACHED();
731     return WebCore::EditableLinkNeverLive;
732 }
733
734 - (_WKEditableLinkBehavior)_editableLinkBehavior
735 {
736     return toAPI(static_cast<WebCore::EditableLinkBehavior>(_preferences->editableLinkBehavior()));
737 }
738
739 - (void)_setEditableLinkBehavior:(_WKEditableLinkBehavior)editableLinkBehavior
740 {
741     _preferences->setEditableLinkBehavior(toEditableLinkBehavior(editableLinkBehavior));
742 }
743
744 - (void)_setAVFoundationEnabled:(BOOL)enabled
745 {
746     _preferences->setAVFoundationEnabled(enabled);
747 }
748
749 - (BOOL)_avFoundationEnabled
750 {
751     return _preferences->isAVFoundationEnabled();
752 }
753
754 - (void)_setColorFilterEnabled:(BOOL)enabled
755 {
756     _preferences->setColorFilterEnabled(enabled);
757 }
758
759 - (BOOL)_colorFilterEnabled
760 {
761     return _preferences->colorFilterEnabled();
762 }
763
764 - (void)_setPunchOutWhiteBackgroundsInDarkMode:(BOOL)punches
765 {
766     _preferences->setPunchOutWhiteBackgroundsInDarkMode(punches);
767 }
768
769 - (BOOL)_punchOutWhiteBackgroundsInDarkMode
770 {
771     return _preferences->punchOutWhiteBackgroundsInDarkMode();
772 }
773
774 - (void)_setLowPowerVideoAudioBufferSizeEnabled:(BOOL)enabled
775 {
776     _preferences->setLowPowerVideoAudioBufferSizeEnabled(enabled);
777 }
778
779 - (BOOL)_lowPowerVideoAudioBufferSizeEnabled
780 {
781     return _preferences->lowPowerVideoAudioBufferSizeEnabled();
782 }
783
784 #if PLATFORM(MAC)
785 - (void)_setJavaEnabledForLocalFiles:(BOOL)enabled
786 {
787     _preferences->setJavaEnabledForLocalFiles(enabled);
788 }
789
790 - (BOOL)_javaEnabledForLocalFiles
791 {
792     return _preferences->javaEnabledForLocalFiles();
793 }
794
795 - (void)_setCanvasUsesAcceleratedDrawing:(BOOL)enabled
796 {
797     _preferences->setCanvasUsesAcceleratedDrawing(enabled);
798 }
799
800 - (BOOL)_canvasUsesAcceleratedDrawing
801 {
802     return _preferences->canvasUsesAcceleratedDrawing();
803 }
804
805 - (void)_setAcceleratedCompositingEnabled:(BOOL)enabled
806 {
807     _preferences->setAcceleratedCompositingEnabled(enabled);
808 }
809
810 - (BOOL)_acceleratedCompositingEnabled
811 {
812     return _preferences->acceleratedCompositingEnabled();
813 }
814
815 - (void)_setDefaultTextEncodingName:(NSString *)name
816 {
817     _preferences->setDefaultTextEncodingName(name);
818 }
819
820 - (NSString *)_defaultTextEncodingName
821 {
822     return _preferences->defaultTextEncodingName();
823 }
824
825 - (void)_setNeedsSiteSpecificQuirks:(BOOL)enabled
826 {
827     _preferences->setNeedsSiteSpecificQuirks(enabled);
828 }
829
830 - (BOOL)_needsSiteSpecificQuirks
831 {
832     return _preferences->needsSiteSpecificQuirks();
833 }
834
835 - (void)_setAuthorAndUserStylesEnabled:(BOOL)enabled
836 {
837     _preferences->setAuthorAndUserStylesEnabled(enabled);
838 }
839
840 - (BOOL)_authorAndUserStylesEnabled
841 {
842     return _preferences->authorAndUserStylesEnabled();
843 }
844
845 - (void)_setDOMTimersThrottlingEnabled:(BOOL)enabled
846 {
847     _preferences->setDOMTimersThrottlingEnabled(enabled);
848 }
849
850 - (BOOL)_domTimersThrottlingEnabled
851 {
852     return _preferences->domTimersThrottlingEnabled();
853 }
854
855 - (void)_setWebArchiveDebugModeEnabled:(BOOL)enabled
856 {
857     _preferences->setWebArchiveDebugModeEnabled(enabled);
858 }
859
860 - (BOOL)_webArchiveDebugModeEnabled
861 {
862     return _preferences->webArchiveDebugModeEnabled();
863 }
864
865 - (void)_setLocalFileContentSniffingEnabled:(BOOL)enabled
866 {
867     _preferences->setLocalFileContentSniffingEnabled(enabled);
868 }
869
870 - (BOOL)_localFileContentSniffingEnabled
871 {
872     return _preferences->localFileContentSniffingEnabled();
873 }
874
875 - (void)_setUsesPageCache:(BOOL)enabled
876 {
877     _preferences->setUsesPageCache(enabled);
878 }
879
880 - (BOOL)_usesPageCache
881 {
882     return _preferences->usesPageCache();
883 }
884
885 - (void)_setPageCacheSupportsPlugins:(BOOL)enabled
886 {
887     _preferences->setPageCacheSupportsPlugins(enabled);
888 }
889
890 - (BOOL)_pageCacheSupportsPlugins
891 {
892     return _preferences->pageCacheSupportsPlugins();
893 }
894
895 - (void)_setShouldPrintBackgrounds:(BOOL)enabled
896 {
897     _preferences->setShouldPrintBackgrounds(enabled);
898 }
899
900 - (BOOL)_shouldPrintBackgrounds
901 {
902     return _preferences->shouldPrintBackgrounds();
903 }
904
905 - (void)_setWebSecurityEnabled:(BOOL)enabled
906 {
907     _preferences->setWebSecurityEnabled(enabled);
908 }
909
910 - (BOOL)_webSecurityEnabled
911 {
912     return _preferences->webSecurityEnabled();
913 }
914
915 - (void)_setUniversalAccessFromFileURLsAllowed:(BOOL)enabled
916 {
917     _preferences->setAllowUniversalAccessFromFileURLs(enabled);
918 }
919
920 - (BOOL)_universalAccessFromFileURLsAllowed
921 {
922     return _preferences->allowUniversalAccessFromFileURLs();
923 }
924
925 - (void)_setSuppressesIncrementalRendering:(BOOL)enabled
926 {
927     _preferences->setSuppressesIncrementalRendering(enabled);
928 }
929
930 - (BOOL)_suppressesIncrementalRendering
931 {
932     return _preferences->suppressesIncrementalRendering();
933 }
934
935 - (void)_setAsynchronousPluginInitializationEnabled:(BOOL)enabled
936 {
937     _preferences->setAsynchronousPluginInitializationEnabled(enabled);
938 }
939
940 - (BOOL)_asynchronousPluginInitializationEnabled
941 {
942     return _preferences->asynchronousPluginInitializationEnabled();
943 }
944
945 - (void)_setArtificialPluginInitializationDelayEnabled:(BOOL)enabled
946 {
947     _preferences->setArtificialPluginInitializationDelayEnabled(enabled);
948 }
949
950 - (BOOL)_artificialPluginInitializationDelayEnabled
951 {
952     return _preferences->artificialPluginInitializationDelayEnabled();
953 }
954
955 - (void)_setExperimentalPlugInSandboxProfilesEnabled:(BOOL)enabled
956 {
957 #if ENABLE(NETSCAPE_PLUGIN_API)
958     WebKit::PluginProcessManager::singleton().setExperimentalPlugInSandboxProfilesEnabled(enabled);
959 #endif
960     _preferences->setExperimentalPlugInSandboxProfilesEnabled(enabled);
961 }
962
963 - (BOOL)_experimentalPlugInSandboxProfilesEnabled
964 {
965     return _preferences->experimentalPlugInSandboxProfilesEnabled();
966 }
967
968 - (void)_setCookieEnabled:(BOOL)enabled
969 {
970     _preferences->setCookieEnabled(enabled);
971 }
972
973 - (BOOL)_cookieEnabled
974 {
975     return _preferences->cookieEnabled();
976 }
977
978 - (void)_setPlugInSnapshottingEnabled:(BOOL)enabled
979 {
980     _preferences->setPlugInSnapshottingEnabled(enabled);
981 }
982
983 - (BOOL)_plugInSnapshottingEnabled
984 {
985     return _preferences->plugInSnapshottingEnabled();
986 }
987
988 - (void)_setSubpixelCSSOMElementMetricsEnabled:(BOOL)enabled
989 {
990     _preferences->setSubpixelCSSOMElementMetricsEnabled(enabled);
991 }
992
993 - (BOOL)_subpixelCSSOMElementMetricsEnabled
994 {
995     return _preferences->subpixelCSSOMElementMetricsEnabled();
996 }
997
998 - (void)_setMediaSourceEnabled:(BOOL)enabled
999 {
1000     _preferences->setMediaSourceEnabled(enabled);
1001 }
1002
1003 - (BOOL)_mediaSourceEnabled
1004 {
1005     return _preferences->mediaSourceEnabled();
1006 }
1007
1008 - (void)_setViewGestureDebuggingEnabled:(BOOL)enabled
1009 {
1010     _preferences->setViewGestureDebuggingEnabled(enabled);
1011 }
1012
1013 - (BOOL)_viewGestureDebuggingEnabled
1014 {
1015     return _preferences->viewGestureDebuggingEnabled();
1016 }
1017
1018 - (void)_setCSSAnimationTriggersEnabled:(BOOL)enabled
1019 {
1020     _preferences->setCSSAnimationTriggersEnabled(enabled);
1021 }
1022
1023 - (BOOL)_cssAnimationTriggersEnabled
1024 {
1025     return _preferences->cssAnimationTriggersEnabled();
1026 }
1027
1028 - (void)_setWebAnimationsCSSIntegrationEnabled:(BOOL)enabled
1029 {
1030     _preferences->setWebAnimationsCSSIntegrationEnabled(enabled);
1031 }
1032
1033 - (BOOL)_webAnimationsCSSIntegrationEnabled
1034 {
1035     return _preferences->webAnimationsCSSIntegrationEnabled();
1036 }
1037
1038 - (void)_setStandardFontFamily:(NSString *)family
1039 {
1040     _preferences->setStandardFontFamily(family);
1041 }
1042
1043 - (NSString *)_standardFontFamily
1044 {
1045     return _preferences->standardFontFamily();
1046 }
1047
1048 - (void)_setNotificationsEnabled:(BOOL)enabled
1049 {
1050     _preferences->setNotificationsEnabled(enabled);
1051 }
1052
1053 - (BOOL)_notificationsEnabled
1054 {
1055     return _preferences->notificationsEnabled();
1056 }
1057
1058 - (void)_setBackspaceKeyNavigationEnabled:(BOOL)enabled
1059 {
1060     _preferences->setBackspaceKeyNavigationEnabled(enabled);
1061 }
1062
1063 - (BOOL)_backspaceKeyNavigationEnabled
1064 {
1065     return _preferences->backspaceKeyNavigationEnabled();
1066 }
1067
1068 - (void)_setWebGLEnabled:(BOOL)enabled
1069 {
1070     _preferences->setWebGLEnabled(enabled);
1071 }
1072
1073 - (BOOL)_webGLEnabled
1074 {
1075     return _preferences->webGLEnabled();
1076 }
1077
1078 - (void)_setAllowsInlineMediaPlayback:(BOOL)enabled
1079 {
1080     _preferences->setAllowsInlineMediaPlayback(enabled);
1081 }
1082
1083 - (BOOL)_allowsInlineMediaPlayback
1084 {
1085     return _preferences->allowsInlineMediaPlayback();
1086 }
1087
1088 - (void)_setApplePayEnabled:(BOOL)enabled
1089 {
1090     _preferences->setApplePayEnabled(enabled);
1091 }
1092
1093 - (BOOL)_applePayEnabled
1094 {
1095     return _preferences->applePayEnabled();
1096 }
1097
1098 - (void)_setDNSPrefetchingEnabled:(BOOL)enabled
1099 {
1100     _preferences->setDNSPrefetchingEnabled(enabled);
1101 }
1102
1103 - (BOOL)_dnsPrefetchingEnabled
1104 {
1105     return _preferences->dnsPrefetchingEnabled();
1106 }
1107
1108 - (void)_setInlineMediaPlaybackRequiresPlaysInlineAttribute:(BOOL)enabled
1109 {
1110     _preferences->setInlineMediaPlaybackRequiresPlaysInlineAttribute(enabled);
1111 }
1112
1113 - (BOOL)_inlineMediaPlaybackRequiresPlaysInlineAttribute
1114 {
1115     return _preferences->inlineMediaPlaybackRequiresPlaysInlineAttribute();
1116 }
1117
1118 - (void)_setInvisibleMediaAutoplayNotPermitted:(BOOL)enabled
1119 {
1120     _preferences->setInvisibleAutoplayNotPermitted(enabled);
1121 }
1122
1123 - (BOOL)_invisibleMediaAutoplayNotPermitted
1124 {
1125     return _preferences->invisibleAutoplayNotPermitted();
1126 }
1127
1128 - (void)_setLegacyEncryptedMediaAPIEnabled:(BOOL)enabled
1129 {
1130     _preferences->setLegacyEncryptedMediaAPIEnabled(enabled);
1131 }
1132
1133 - (BOOL)_legacyEncryptedMediaAPIEnabled
1134 {
1135     return _preferences->legacyEncryptedMediaAPIEnabled();
1136 }
1137
1138 - (void)_setMainContentUserGestureOverrideEnabled:(BOOL)enabled
1139 {
1140     _preferences->setMainContentUserGestureOverrideEnabled(enabled);
1141 }
1142
1143 - (BOOL)_mainContentUserGestureOverrideEnabled
1144 {
1145     return _preferences->mainContentUserGestureOverrideEnabled();
1146 }
1147
1148 - (void)_setMediaStreamEnabled:(BOOL)enabled
1149 {
1150     _preferences->setMediaStreamEnabled(enabled);
1151 }
1152
1153 - (BOOL)_mediaStreamEnabled
1154 {
1155     return _preferences->mediaStreamEnabled();
1156 }
1157
1158 - (void)_setNeedsStorageAccessFromFileURLsQuirk:(BOOL)enabled
1159 {
1160     _preferences->setNeedsStorageAccessFromFileURLsQuirk(enabled);
1161 }
1162
1163 - (BOOL)_needsStorageAccessFromFileURLsQuirk
1164 {
1165     return _preferences->needsStorageAccessFromFileURLsQuirk();
1166 }
1167
1168 - (void)_setPDFPluginEnabled:(BOOL)enabled
1169 {
1170     _preferences->setPDFPluginEnabled(enabled);
1171 }
1172
1173 - (BOOL)_pdfPluginEnabled
1174 {
1175     return _preferences->pdfPluginEnabled();
1176 }
1177
1178 - (void)_setRequiresUserGestureForAudioPlayback:(BOOL)enabled
1179 {
1180     _preferences->setRequiresUserGestureForAudioPlayback(enabled);
1181 }
1182
1183 - (BOOL)_requiresUserGestureForAudioPlayback
1184 {
1185     return _preferences->requiresUserGestureForAudioPlayback();
1186 }
1187
1188 - (void)_setRequiresUserGestureForVideoPlayback:(BOOL)enabled
1189 {
1190     _preferences->setRequiresUserGestureForVideoPlayback(enabled);
1191 }
1192
1193 - (BOOL)_requiresUserGestureForVideoPlayback
1194 {
1195     return _preferences->requiresUserGestureForVideoPlayback();
1196 }
1197
1198 - (void)_setServiceControlsEnabled:(BOOL)enabled
1199 {
1200     _preferences->setServiceControlsEnabled(enabled);
1201 }
1202
1203 - (BOOL)_serviceControlsEnabled
1204 {
1205     return _preferences->serviceControlsEnabled();
1206 }
1207
1208 - (void)_setShowsToolTipOverTruncatedText:(BOOL)enabled
1209 {
1210     _preferences->setShowsToolTipOverTruncatedText(enabled);
1211 }
1212
1213 - (BOOL)_showsToolTipOverTruncatedText
1214 {
1215     return _preferences->showsToolTipOverTruncatedText();
1216 }
1217
1218 - (void)_setTextAreasAreResizable:(BOOL)enabled
1219 {
1220     _preferences->setTextAreasAreResizable(enabled);
1221 }
1222
1223 - (BOOL)_textAreasAreResizable
1224 {
1225     return _preferences->textAreasAreResizable();
1226 }
1227
1228 - (void)_setUseGiantTiles:(BOOL)enabled
1229 {
1230     _preferences->setUseGiantTiles(enabled);
1231 }
1232
1233 - (BOOL)_useGiantTiles
1234 {
1235     return _preferences->useGiantTiles();
1236 }
1237
1238 - (void)_setWantsBalancedSetDefersLoadingBehavior:(BOOL)enabled
1239 {
1240     _preferences->setWantsBalancedSetDefersLoadingBehavior(enabled);
1241 }
1242
1243 - (BOOL)_wantsBalancedSetDefersLoadingBehavior
1244 {
1245     return _preferences->wantsBalancedSetDefersLoadingBehavior();
1246 }
1247
1248 - (void)_setWebAudioEnabled:(BOOL)enabled
1249 {
1250     _preferences->setWebAudioEnabled(enabled);
1251 }
1252
1253 - (BOOL)_webAudioEnabled
1254 {
1255     return _preferences->webAudioEnabled();
1256 }
1257
1258 - (void)_setAggressiveTileRetentionEnabled:(BOOL)enabled
1259 {
1260     _preferences->setAggressiveTileRetentionEnabled(enabled);
1261 }
1262
1263 - (BOOL)_aggressiveTileRetentionEnabled
1264 {
1265     return _preferences->aggressiveTileRetentionEnabled();
1266 }
1267
1268 #endif // PLATFORM(MAC)
1269
1270 - (BOOL)_javaScriptCanAccessClipboard
1271 {
1272     return _preferences->javaScriptCanAccessClipboard();
1273 }
1274
1275 - (void)_setDOMPasteAllowed:(BOOL)domPasteAllowed
1276 {
1277     _preferences->setDOMPasteAllowed(domPasteAllowed);
1278 }
1279
1280 - (BOOL)_domPasteAllowed
1281 {
1282     return _preferences->domPasteAllowed();
1283 }
1284
1285 - (void)_setShouldEnableTextAutosizingBoost:(BOOL)shouldEnableTextAutosizingBoost
1286 {
1287 #if ENABLE(TEXT_AUTOSIZING)
1288     _preferences->setShouldEnableTextAutosizingBoost(shouldEnableTextAutosizingBoost);
1289 #endif
1290 }
1291
1292 - (BOOL)_shouldEnableTextAutosizingBoost
1293 {
1294 #if ENABLE(TEXT_AUTOSIZING)
1295     return _preferences->shouldEnableTextAutosizingBoost();
1296 #else
1297     return NO;
1298 #endif
1299 }
1300
1301 @end
1302
1303 #endif // WK_API_ENABLED