WKPreferences doesn’t expose editable link behavior
[WebKit-https.git] / Source / WebKit / UIProcess / API / Cocoa / WKPreferences.mm
1 /*
2  * Copyright (C) 2014-2016 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 "WKNSArray.h"
33 #import "WebPreferences.h"
34 #import "_WKExperimentalFeature.h"
35 #import "_WKExperimentalFeatureInternal.h"
36 #import <WebCore/SecurityOrigin.h>
37 #import <WebCore/Settings.h>
38 #import <wtf/RetainPtr.h>
39
40 @implementation WKPreferences
41
42 - (instancetype)init
43 {
44     if (!(self = [super init]))
45         return nil;
46
47     API::Object::constructInWrapper<WebKit::WebPreferences>(self, String(), "WebKit", "WebKitDebug");
48     return self;
49 }
50
51 - (void)dealloc
52 {
53     _preferences->~WebPreferences();
54
55     [super dealloc];
56 }
57
58 // FIXME: We currently only encode/decode API preferences. We should consider whether we should
59 // encode/decode SPI preferences as well.
60
61 - (void)encodeWithCoder:(NSCoder *)coder
62 {
63     [coder encodeDouble:self.minimumFontSize forKey:@"minimumFontSize"];
64     [coder encodeBool:self.javaScriptEnabled forKey:@"javaScriptEnabled"];
65     [coder encodeBool:self.javaScriptCanOpenWindowsAutomatically forKey:@"javaScriptCanOpenWindowsAutomatically"];
66
67 #if PLATFORM(MAC)
68     [coder encodeBool:self.javaEnabled forKey:@"javaEnabled"];
69     [coder encodeBool:self.plugInsEnabled forKey:@"plugInsEnabled"];
70     [coder encodeBool:self.tabFocusesLinks forKey:@"tabFocusesLinks"];
71 #endif
72 }
73
74 - (instancetype)initWithCoder:(NSCoder *)coder
75 {
76     if (!(self = [self init]))
77         return nil;
78
79     self.minimumFontSize = [coder decodeDoubleForKey:@"minimumFontSize"];
80     self.javaScriptEnabled = [coder decodeBoolForKey:@"javaScriptEnabled"];
81     self.javaScriptCanOpenWindowsAutomatically = [coder decodeBoolForKey:@"javaScriptCanOpenWindowsAutomatically"];
82
83 #if PLATFORM(MAC)
84     self.javaEnabled = [coder decodeBoolForKey:@"javaEnabled"];
85     self.plugInsEnabled = [coder decodeBoolForKey:@"plugInsEnabled"];
86     self.tabFocusesLinks = [coder decodeBoolForKey:@"tabFocusesLinks"];
87 #endif
88
89     return self;
90 }
91
92 - (id)copyWithZone:(NSZone *)zone
93 {
94     return wrapper(_preferences->copy().leakRef());
95 }
96
97 - (CGFloat)minimumFontSize
98 {
99     return _preferences->minimumFontSize();
100 }
101
102 - (void)setMinimumFontSize:(CGFloat)minimumFontSize
103 {
104     _preferences->setMinimumFontSize(minimumFontSize);
105 }
106
107 - (BOOL)javaScriptEnabled
108 {
109     return _preferences->javaScriptEnabled();
110 }
111
112 - (void)setJavaScriptEnabled:(BOOL)javaScriptEnabled
113 {
114     _preferences->setJavaScriptEnabled(javaScriptEnabled);
115 }
116
117 - (BOOL)javaScriptCanOpenWindowsAutomatically
118 {
119     return _preferences->javaScriptCanOpenWindowsAutomatically();
120 }
121
122 - (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)javaScriptCanOpenWindowsAutomatically
123 {
124     _preferences->setJavaScriptCanOpenWindowsAutomatically(javaScriptCanOpenWindowsAutomatically);
125 }
126
127 #pragma mark OS X-specific methods
128
129 #if PLATFORM(MAC)
130
131 - (BOOL)javaEnabled
132 {
133     return _preferences->javaEnabled();
134 }
135
136 - (void)setJavaEnabled:(BOOL)javaEnabled
137 {
138     _preferences->setJavaEnabled(javaEnabled);
139 }
140
141 - (BOOL)plugInsEnabled
142 {
143     return _preferences->pluginsEnabled();
144 }
145
146 - (void)setPlugInsEnabled:(BOOL)plugInsEnabled
147 {
148     _preferences->setPluginsEnabled(plugInsEnabled);
149 }
150
151 - (BOOL)tabFocusesLinks
152 {
153     return _preferences->tabsToLinks();
154 }
155
156 - (void)setTabFocusesLinks:(BOOL)tabFocusesLinks
157 {
158     _preferences->setTabsToLinks(tabFocusesLinks);
159 }
160
161 #endif
162
163 #pragma mark WKObject protocol implementation
164
165 - (API::Object&)_apiObject
166 {
167     return *_preferences;
168 }
169
170 @end
171
172 @implementation WKPreferences (WKPrivate)
173
174 - (BOOL)_telephoneNumberDetectionIsEnabled
175 {
176     return _preferences->telephoneNumberParsingEnabled();
177 }
178
179 - (void)_setTelephoneNumberDetectionIsEnabled:(BOOL)telephoneNumberDetectionIsEnabled
180 {
181     _preferences->setTelephoneNumberParsingEnabled(telephoneNumberDetectionIsEnabled);
182 }
183
184 static WebCore::SecurityOrigin::StorageBlockingPolicy toStorageBlockingPolicy(_WKStorageBlockingPolicy policy)
185 {
186     switch (policy) {
187     case _WKStorageBlockingPolicyAllowAll:
188         return WebCore::SecurityOrigin::AllowAllStorage;
189     case _WKStorageBlockingPolicyBlockThirdParty:
190         return WebCore::SecurityOrigin::BlockThirdPartyStorage;
191     case _WKStorageBlockingPolicyBlockAll:
192         return WebCore::SecurityOrigin::BlockAllStorage;
193     }
194
195     ASSERT_NOT_REACHED();
196     return WebCore::SecurityOrigin::AllowAllStorage;
197 }
198
199 static _WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPolicy policy)
200 {
201     switch (policy) {
202     case WebCore::SecurityOrigin::AllowAllStorage:
203         return _WKStorageBlockingPolicyAllowAll;
204     case WebCore::SecurityOrigin::BlockThirdPartyStorage:
205         return _WKStorageBlockingPolicyBlockThirdParty;
206     case WebCore::SecurityOrigin::BlockAllStorage:
207         return _WKStorageBlockingPolicyBlockAll;
208     }
209
210     ASSERT_NOT_REACHED();
211     return _WKStorageBlockingPolicyAllowAll;
212 }
213
214 - (_WKStorageBlockingPolicy)_storageBlockingPolicy
215 {
216     return toAPI(static_cast<WebCore::SecurityOrigin::StorageBlockingPolicy>(_preferences->storageBlockingPolicy()));
217 }
218
219 - (void)_setStorageBlockingPolicy:(_WKStorageBlockingPolicy)policy
220 {
221     _preferences->setStorageBlockingPolicy(toStorageBlockingPolicy(policy));
222 }
223
224 - (BOOL)_offlineApplicationCacheIsEnabled
225 {
226     return _preferences->offlineWebApplicationCacheEnabled();
227 }
228
229 - (void)_setOfflineApplicationCacheIsEnabled:(BOOL)offlineApplicationCacheIsEnabled
230 {
231     _preferences->setOfflineWebApplicationCacheEnabled(offlineApplicationCacheIsEnabled);
232 }
233
234 - (BOOL)_fullScreenEnabled
235 {
236     return _preferences->fullScreenEnabled();
237 }
238
239 - (void)_setFullScreenEnabled:(BOOL)fullScreenEnabled
240 {
241     _preferences->setFullScreenEnabled(fullScreenEnabled);
242 }
243
244 - (BOOL)_allowsPictureInPictureMediaPlayback
245 {
246     return _preferences->allowsPictureInPictureMediaPlayback();
247 }
248
249 - (void)_setAllowsPictureInPictureMediaPlayback:(BOOL)allowed
250 {
251     _preferences->setAllowsPictureInPictureMediaPlayback(allowed);
252 }
253
254 - (BOOL)_compositingBordersVisible
255 {
256     return _preferences->compositingBordersVisible();
257 }
258
259 - (void)_setCompositingBordersVisible:(BOOL)compositingBordersVisible
260 {
261     _preferences->setCompositingBordersVisible(compositingBordersVisible);
262 }
263
264 - (BOOL)_compositingRepaintCountersVisible
265 {
266     return _preferences->compositingRepaintCountersVisible();
267 }
268
269 - (void)_setCompositingRepaintCountersVisible:(BOOL)repaintCountersVisible
270 {
271     _preferences->setCompositingRepaintCountersVisible(repaintCountersVisible);
272 }
273
274 - (BOOL)_tiledScrollingIndicatorVisible
275 {
276     return _preferences->tiledScrollingIndicatorVisible();
277 }
278
279 - (void)_setTiledScrollingIndicatorVisible:(BOOL)tiledScrollingIndicatorVisible
280 {
281     _preferences->setTiledScrollingIndicatorVisible(tiledScrollingIndicatorVisible);
282 }
283
284 - (BOOL)_resourceUsageOverlayVisible
285 {
286     return _preferences->resourceUsageOverlayVisible();
287 }
288
289 - (void)_setResourceUsageOverlayVisible:(BOOL)resourceUsageOverlayVisible
290 {
291     _preferences->setResourceUsageOverlayVisible(resourceUsageOverlayVisible);
292 }
293
294 - (_WKDebugOverlayRegions)_visibleDebugOverlayRegions
295 {
296     return _preferences->visibleDebugOverlayRegions();
297 }
298
299 - (void)_setVisibleDebugOverlayRegions:(_WKDebugOverlayRegions)regionFlags
300 {
301     _preferences->setVisibleDebugOverlayRegions(regionFlags);
302 }
303
304 - (BOOL)_simpleLineLayoutEnabled
305 {
306     return _preferences->simpleLineLayoutEnabled();
307 }
308
309 - (void)_setSimpleLineLayoutEnabled:(BOOL)simpleLineLayoutEnabled
310 {
311     _preferences->setSimpleLineLayoutEnabled(simpleLineLayoutEnabled);
312 }
313
314 - (BOOL)_simpleLineLayoutDebugBordersEnabled
315 {
316     return _preferences->simpleLineLayoutDebugBordersEnabled();
317 }
318
319 - (void)_setSimpleLineLayoutDebugBordersEnabled:(BOOL)simpleLineLayoutDebugBordersEnabled
320 {
321     _preferences->setSimpleLineLayoutDebugBordersEnabled(simpleLineLayoutDebugBordersEnabled);
322 }
323
324 - (BOOL)_acceleratedDrawingEnabled
325 {
326     return _preferences->acceleratedDrawingEnabled();
327 }
328
329 - (void)_setAcceleratedDrawingEnabled:(BOOL)acceleratedDrawingEnabled
330 {
331     _preferences->setAcceleratedDrawingEnabled(acceleratedDrawingEnabled);
332 }
333
334 - (BOOL)_displayListDrawingEnabled
335 {
336     return _preferences->displayListDrawingEnabled();
337 }
338
339 - (void)_setDisplayListDrawingEnabled:(BOOL)displayListDrawingEnabled
340 {
341     _preferences->setDisplayListDrawingEnabled(displayListDrawingEnabled);
342 }
343
344 - (BOOL)_visualViewportEnabled
345 {
346     return _preferences->visualViewportEnabled();
347 }
348
349 - (void)_setVisualViewportEnabled:(BOOL)_visualViewportEnabled
350 {
351     _preferences->setVisualViewportEnabled(_visualViewportEnabled);
352 }
353
354 - (BOOL)_largeImageAsyncDecodingEnabled
355 {
356     return _preferences->largeImageAsyncDecodingEnabled();
357 }
358
359 - (void)_setLargeImageAsyncDecodingEnabled:(BOOL)_largeImageAsyncDecodingEnabled
360 {
361     _preferences->setLargeImageAsyncDecodingEnabled(_largeImageAsyncDecodingEnabled);
362 }
363
364 - (BOOL)_animatedImageAsyncDecodingEnabled
365 {
366     return _preferences->animatedImageAsyncDecodingEnabled();
367 }
368
369 - (void)_setAnimatedImageAsyncDecodingEnabled:(BOOL)_animatedImageAsyncDecodingEnabled
370 {
371     _preferences->setAnimatedImageAsyncDecodingEnabled(_animatedImageAsyncDecodingEnabled);
372 }
373
374 - (BOOL)_textAutosizingEnabled
375 {
376     return _preferences->textAutosizingEnabled();
377 }
378
379 - (void)_setTextAutosizingEnabled:(BOOL)enabled
380 {
381     _preferences->setTextAutosizingEnabled(enabled);
382 }
383
384 - (BOOL)_subpixelAntialiasedLayerTextEnabled
385 {
386     return _preferences->subpixelAntialiasedLayerTextEnabled();
387 }
388
389 - (void)_setSubpixelAntialiasedLayerTextEnabled:(BOOL)enabled
390 {
391     _preferences->setSubpixelAntialiasedLayerTextEnabled(enabled);
392 }
393
394 - (BOOL)_developerExtrasEnabled
395 {
396     return _preferences->developerExtrasEnabled();
397 }
398
399 - (void)_setDeveloperExtrasEnabled:(BOOL)developerExtrasEnabled
400 {
401     _preferences->setDeveloperExtrasEnabled(developerExtrasEnabled);
402 }
403
404 - (BOOL)_logsPageMessagesToSystemConsoleEnabled
405 {
406     return _preferences->logsPageMessagesToSystemConsoleEnabled();
407 }
408
409 - (void)_setLogsPageMessagesToSystemConsoleEnabled:(BOOL)logsPageMessagesToSystemConsoleEnabled
410 {
411     _preferences->setLogsPageMessagesToSystemConsoleEnabled(logsPageMessagesToSystemConsoleEnabled);
412 }
413
414 - (BOOL)_hiddenPageDOMTimerThrottlingEnabled
415 {
416     return _preferences->hiddenPageDOMTimerThrottlingEnabled();
417 }
418
419 - (void)_setHiddenPageDOMTimerThrottlingEnabled:(BOOL)hiddenPageDOMTimerThrottlingEnabled
420 {
421     _preferences->setHiddenPageDOMTimerThrottlingEnabled(hiddenPageDOMTimerThrottlingEnabled);
422 }
423
424 - (BOOL)_hiddenPageDOMTimerThrottlingAutoIncreases
425 {
426     return _preferences->hiddenPageDOMTimerThrottlingAutoIncreases();
427 }
428
429 - (void)_setHiddenPageDOMTimerThrottlingAutoIncreases:(BOOL)hiddenPageDOMTimerThrottlingAutoIncreases
430 {
431     _preferences->setHiddenPageDOMTimerThrottlingAutoIncreases(hiddenPageDOMTimerThrottlingAutoIncreases);
432 }
433
434 - (BOOL)_pageVisibilityBasedProcessSuppressionEnabled
435 {
436     return _preferences->pageVisibilityBasedProcessSuppressionEnabled();
437 }
438
439 - (void)_setPageVisibilityBasedProcessSuppressionEnabled:(BOOL)pageVisibilityBasedProcessSuppressionEnabled
440 {
441     _preferences->setPageVisibilityBasedProcessSuppressionEnabled(pageVisibilityBasedProcessSuppressionEnabled);
442 }
443
444 - (BOOL)_allowFileAccessFromFileURLs
445 {
446     return _preferences->allowFileAccessFromFileURLs();
447 }
448
449 - (void)_setAllowFileAccessFromFileURLs:(BOOL)allowFileAccessFromFileURLs
450 {
451     _preferences->setAllowFileAccessFromFileURLs(allowFileAccessFromFileURLs);
452 }
453
454 - (_WKJavaScriptRuntimeFlags)_javaScriptRuntimeFlags
455 {
456     return _preferences->javaScriptRuntimeFlags();
457 }
458
459 - (void)_setJavaScriptRuntimeFlags:(_WKJavaScriptRuntimeFlags)javaScriptRuntimeFlags
460 {
461     _preferences->setJavaScriptRuntimeFlags(javaScriptRuntimeFlags);
462 }
463
464 - (BOOL)_isStandalone
465 {
466     return _preferences->standalone();
467 }
468
469 - (void)_setStandalone:(BOOL)standalone
470 {
471     _preferences->setStandalone(standalone);
472 }
473
474 - (BOOL)_diagnosticLoggingEnabled
475 {
476     return _preferences->diagnosticLoggingEnabled();
477 }
478
479 - (void)_setDiagnosticLoggingEnabled:(BOOL)diagnosticLoggingEnabled
480 {
481     _preferences->setDiagnosticLoggingEnabled(diagnosticLoggingEnabled);
482 }
483
484 - (NSUInteger)_defaultFontSize
485 {
486     return _preferences->defaultFontSize();
487 }
488
489 - (void)_setDefaultFontSize:(NSUInteger)defaultFontSize
490 {
491     _preferences->setDefaultFontSize(defaultFontSize);
492 }
493
494 - (NSUInteger)_defaultFixedPitchFontSize
495 {
496     return _preferences->defaultFixedFontSize();
497 }
498
499 - (void)_setDefaultFixedPitchFontSize:(NSUInteger)defaultFixedPitchFontSize
500 {
501     _preferences->setDefaultFixedFontSize(defaultFixedPitchFontSize);
502 }
503
504 - (NSString *)_fixedPitchFontFamily
505 {
506     return _preferences->fixedFontFamily();
507 }
508
509 - (void)_setFixedPitchFontFamily:(NSString *)fixedPitchFontFamily
510 {
511     _preferences->setFixedFontFamily(fixedPitchFontFamily);
512 }
513
514 + (NSArray<_WKExperimentalFeature *> *)_experimentalFeatures
515 {
516     auto features = WebKit::WebPreferences::experimentalFeatures();
517     return [wrapper(API::Array::create(WTFMove(features)).leakRef()) autorelease];
518 }
519
520 - (BOOL)_isEnabledForFeature:(_WKExperimentalFeature *)feature
521 {
522     return _preferences->isEnabledForFeature(*feature->_experimentalFeature);
523 }
524
525 - (void)_setEnabled:(BOOL)value forFeature:(_WKExperimentalFeature *)feature
526 {
527     _preferences->setEnabledForFeature(value, *feature->_experimentalFeature);
528 }
529
530 - (BOOL)_applePayCapabilityDisclosureAllowed
531 {
532 #if ENABLE(APPLE_PAY)
533     return _preferences->applePayCapabilityDisclosureAllowed();
534 #else
535     return NO;
536 #endif
537 }
538
539 - (void)_setApplePayCapabilityDisclosureAllowed:(BOOL)applePayCapabilityDisclosureAllowed
540 {
541 #if ENABLE(APPLE_PAY)
542     _preferences->setApplePayCapabilityDisclosureAllowed(applePayCapabilityDisclosureAllowed);
543 #endif
544 }
545
546 - (BOOL)_shouldSuppressKeyboardInputDuringProvisionalNavigation
547 {
548     return _preferences->shouldSuppressTextInputFromEditingDuringProvisionalNavigation();
549 }
550
551 - (void)_setShouldSuppressKeyboardInputDuringProvisionalNavigation:(BOOL)shouldSuppress
552 {
553     _preferences->setShouldSuppressTextInputFromEditingDuringProvisionalNavigation(shouldSuppress);
554 }
555
556 - (BOOL)_loadsImagesAutomatically
557 {
558     return _preferences->loadsImagesAutomatically();
559 }
560
561 - (void)_setLoadsImagesAutomatically:(BOOL)loadsImagesAutomatically
562 {
563     _preferences->setLoadsImagesAutomatically(loadsImagesAutomatically);
564 }
565
566 - (BOOL)_peerConnectionEnabled
567 {
568     return _preferences->peerConnectionEnabled();
569 }
570
571 - (void)_setPeerConnectionEnabled:(BOOL)enabled
572 {
573     _preferences->setPeerConnectionEnabled(enabled);
574 }
575
576 - (BOOL)_mediaDevicesEnabled
577 {
578     return _preferences->mediaDevicesEnabled();
579 }
580
581 - (void)_setMediaDevicesEnabled:(BOOL)enabled
582 {
583     _preferences->setMediaDevicesEnabled(enabled);
584 }
585
586 - (BOOL)_screenCaptureEnabled
587 {
588     return _preferences->screenCaptureEnabled();
589 }
590
591 - (void)_setScreenCaptureEnabled:(BOOL)enabled
592 {
593     _preferences->setScreenCaptureEnabled(enabled);
594 }
595
596 - (BOOL)_mockCaptureDevicesEnabled
597 {
598     return _preferences->mockCaptureDevicesEnabled();
599 }
600
601 - (void)_setMockCaptureDevicesEnabled:(BOOL)enabled
602 {
603     _preferences->setMockCaptureDevicesEnabled(enabled);
604 }
605
606 - (BOOL)_mockCaptureDevicesPromptEnabled
607 {
608     return _preferences->mockCaptureDevicesPromptEnabled();
609 }
610
611 - (void)_setMockCaptureDevicesPromptEnabled:(BOOL)enabled
612 {
613     _preferences->setMockCaptureDevicesPromptEnabled(enabled);
614 }
615
616 - (BOOL)_mediaCaptureRequiresSecureConnection
617 {
618     return _preferences->mediaCaptureRequiresSecureConnection();
619 }
620
621 - (void)_setMediaCaptureRequiresSecureConnection:(BOOL)requiresSecureConnection
622 {
623     _preferences->setMediaCaptureRequiresSecureConnection(requiresSecureConnection);
624 }
625
626 - (double)_inactiveMediaCaptureSteamRepromptIntervalInMinutes
627 {
628     return _preferences->inactiveMediaCaptureSteamRepromptIntervalInMinutes();
629 }
630
631 - (void)_setInactiveMediaCaptureSteamRepromptIntervalInMinutes:(double)interval
632 {
633     _preferences->setInactiveMediaCaptureSteamRepromptIntervalInMinutes(interval);
634 }
635
636 - (BOOL)_enumeratingAllNetworkInterfacesEnabled
637 {
638     return _preferences->enumeratingAllNetworkInterfacesEnabled();
639 }
640
641 - (void)_setEnumeratingAllNetworkInterfacesEnabled:(BOOL)enabled
642 {
643     _preferences->setEnumeratingAllNetworkInterfacesEnabled(enabled);
644 }
645
646 - (BOOL)_iceCandidateFilteringEnabled
647 {
648     return _preferences->iceCandidateFilteringEnabled();
649 }
650
651 - (void)_setICECandidateFilteringEnabled:(BOOL)enabled
652 {
653     _preferences->setICECandidateFilteringEnabled(enabled);
654 }
655
656 - (BOOL)_webRTCLegacyAPIEnabled
657 {
658     return !_preferences->webRTCLegacyAPIDisabled();
659 }
660
661 - (void)_setWebRTCLegacyAPIEnabled:(BOOL)enabled
662 {
663     _preferences->setWebRTCLegacyAPIDisabled(!enabled);
664 }
665
666 - (void)_setJavaScriptCanAccessClipboard:(BOOL)javaScriptCanAccessClipboard
667 {
668     _preferences->setJavaScriptCanAccessClipboard(javaScriptCanAccessClipboard);
669 }
670
671 - (BOOL)_shouldAllowUserInstalledFonts
672 {
673     return _preferences->shouldAllowUserInstalledFonts();
674 }
675
676 - (void)_setShouldAllowUserInstalledFonts:(BOOL)_shouldAllowUserInstalledFonts
677 {
678     _preferences->setShouldAllowUserInstalledFonts(_shouldAllowUserInstalledFonts);
679 }
680
681 static _WKEditableLinkBehavior toAPI(WebCore::EditableLinkBehavior behavior)
682 {
683     switch (behavior) {
684     case WebCore::EditableLinkDefaultBehavior:
685         return _WKEditableLinkBehaviorDefault;
686     case WebCore::EditableLinkAlwaysLive:
687         return _WKEditableLinkBehaviorAlwaysLive;
688     case WebCore::EditableLinkOnlyLiveWithShiftKey:
689         return _WKEditableLinkBehaviorOnlyLiveWithShiftKey;
690     case WebCore::EditableLinkLiveWhenNotFocused:
691         return _WKEditableLinkBehaviorLiveWhenNotFocused;
692     case WebCore::EditableLinkNeverLive:
693         return _WKEditableLinkBehaviorNeverLive;
694     }
695     
696     ASSERT_NOT_REACHED();
697     return _WKEditableLinkBehaviorNeverLive;
698 }
699
700 static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehavior wkBehavior)
701 {
702     switch (wkBehavior) {
703     case _WKEditableLinkBehaviorDefault:
704         return WebCore::EditableLinkDefaultBehavior;
705     case _WKEditableLinkBehaviorAlwaysLive:
706         return WebCore::EditableLinkAlwaysLive;
707     case _WKEditableLinkBehaviorOnlyLiveWithShiftKey:
708         return WebCore::EditableLinkOnlyLiveWithShiftKey;
709     case _WKEditableLinkBehaviorLiveWhenNotFocused:
710         return WebCore::EditableLinkLiveWhenNotFocused;
711     case _WKEditableLinkBehaviorNeverLive:
712         return WebCore::EditableLinkNeverLive;
713     }
714     
715     ASSERT_NOT_REACHED();
716     return WebCore::EditableLinkNeverLive;
717 }
718
719 - (_WKEditableLinkBehavior)_editableLinkBehavior
720 {
721     return toAPI(static_cast<WebCore::EditableLinkBehavior>(_preferences->editableLinkBehavior()));
722 }
723
724 - (void)_setEditableLinkBehavior:(_WKEditableLinkBehavior)editableLinkBehavior
725 {
726     _preferences->setEditableLinkBehavior(toEditableLinkBehavior(editableLinkBehavior));
727 }
728
729 #if PLATFORM(MAC)
730 - (void)_setJavaEnabledForLocalFiles:(BOOL)enabled
731 {
732     _preferences->setJavaEnabledForLocalFiles(enabled);
733 }
734
735 - (BOOL)_javaEnabledForLocalFiles
736 {
737     return _preferences->javaEnabledForLocalFiles();
738 }
739
740 - (void)_setCanvasUsesAcceleratedDrawing:(BOOL)enabled
741 {
742     _preferences->setCanvasUsesAcceleratedDrawing(enabled);
743 }
744
745 - (BOOL)_canvasUsesAcceleratedDrawing
746 {
747     return _preferences->canvasUsesAcceleratedDrawing();
748 }
749
750 - (void)_setAcceleratedCompositingEnabled:(BOOL)enabled
751 {
752     _preferences->setAcceleratedCompositingEnabled(enabled);
753 }
754
755 - (BOOL)_acceleratedCompositingEnabled
756 {
757     return _preferences->acceleratedCompositingEnabled();
758 }
759
760 - (void)_setDefaultTextEncodingName:(NSString *)name
761 {
762     _preferences->setDefaultTextEncodingName(name);
763 }
764
765 - (NSString *)_defaultTextEncodingName
766 {
767     return _preferences->defaultTextEncodingName();
768 }
769
770 - (void)_setNeedsSiteSpecificQuirks:(BOOL)enabled
771 {
772     _preferences->setNeedsSiteSpecificQuirks(enabled);
773 }
774
775 - (BOOL)_needsSiteSpecificQuirks
776 {
777     return _preferences->needsSiteSpecificQuirks();
778 }
779
780 - (void)_setAuthorAndUserStylesEnabled:(BOOL)enabled
781 {
782     _preferences->setAuthorAndUserStylesEnabled(enabled);
783 }
784
785 - (BOOL)_authorAndUserStylesEnabled
786 {
787     return _preferences->authorAndUserStylesEnabled();
788 }
789
790 - (void)_setDOMTimersThrottlingEnabled:(BOOL)enabled
791 {
792     _preferences->setDOMTimersThrottlingEnabled(enabled);
793 }
794
795 - (BOOL)_domTimersThrottlingEnabled
796 {
797     return _preferences->domTimersThrottlingEnabled();
798 }
799
800 - (void)_setWebArchiveDebugModeEnabled:(BOOL)enabled
801 {
802     _preferences->setWebArchiveDebugModeEnabled(enabled);
803 }
804
805 - (BOOL)_webArchiveDebugModeEnabled
806 {
807     return _preferences->webArchiveDebugModeEnabled();
808 }
809
810 - (void)_setLocalFileContentSniffingEnabled:(BOOL)enabled
811 {
812     _preferences->setLocalFileContentSniffingEnabled(enabled);
813 }
814
815 - (BOOL)_localFileContentSniffingEnabled
816 {
817     return _preferences->localFileContentSniffingEnabled();
818 }
819
820 - (void)_setUsesPageCache:(BOOL)enabled
821 {
822     _preferences->setUsesPageCache(enabled);
823 }
824
825 - (BOOL)_usesPageCache
826 {
827     return _preferences->usesPageCache();
828 }
829
830 - (void)_setPageCacheSupportsPlugins:(BOOL)enabled
831 {
832     _preferences->setPageCacheSupportsPlugins(enabled);
833 }
834
835 - (BOOL)_pageCacheSupportsPlugins
836 {
837     return _preferences->pageCacheSupportsPlugins();
838 }
839
840 - (void)_setShouldPrintBackgrounds:(BOOL)enabled
841 {
842     _preferences->setShouldPrintBackgrounds(enabled);
843 }
844
845 - (BOOL)_shouldPrintBackgrounds
846 {
847     return _preferences->shouldPrintBackgrounds();
848 }
849
850 - (void)_setWebSecurityEnabled:(BOOL)enabled
851 {
852     _preferences->setWebSecurityEnabled(enabled);
853 }
854
855 - (BOOL)_webSecurityEnabled
856 {
857     return _preferences->webSecurityEnabled();
858 }
859
860 - (void)_setUniversalAccessFromFileURLsAllowed:(BOOL)enabled
861 {
862     _preferences->setAllowUniversalAccessFromFileURLs(enabled);
863 }
864
865 - (BOOL)_universalAccessFromFileURLsAllowed
866 {
867     return _preferences->allowUniversalAccessFromFileURLs();
868 }
869
870 - (void)_setAVFoundationEnabled:(BOOL)enabled
871 {
872     _preferences->setAVFoundationEnabled(enabled);
873 }
874
875 - (BOOL)_avFoundationEnabled
876 {
877     return _preferences->isAVFoundationEnabled();
878 }
879
880 - (void)_setSuppressesIncrementalRendering:(BOOL)enabled
881 {
882     _preferences->setSuppressesIncrementalRendering(enabled);
883 }
884
885 - (BOOL)_suppressesIncrementalRendering
886 {
887     return _preferences->suppressesIncrementalRendering();
888 }
889
890 - (void)_setAsynchronousPluginInitializationEnabled:(BOOL)enabled
891 {
892     _preferences->setAsynchronousPluginInitializationEnabled(enabled);
893 }
894
895 - (BOOL)_asynchronousPluginInitializationEnabled
896 {
897     return _preferences->asynchronousPluginInitializationEnabled();
898 }
899
900 - (void)_setArtificialPluginInitializationDelayEnabled:(BOOL)enabled
901 {
902     _preferences->setArtificialPluginInitializationDelayEnabled(enabled);
903 }
904
905 - (BOOL)_artificialPluginInitializationDelayEnabled
906 {
907     return _preferences->artificialPluginInitializationDelayEnabled();
908 }
909
910 - (void)_setCookieEnabled:(BOOL)enabled
911 {
912     _preferences->setCookieEnabled(enabled);
913 }
914
915 - (BOOL)_cookieEnabled
916 {
917     return _preferences->cookieEnabled();
918 }
919
920 - (void)_setPlugInSnapshottingEnabled:(BOOL)enabled
921 {
922     _preferences->setPlugInSnapshottingEnabled(enabled);
923 }
924
925 - (BOOL)_plugInSnapshottingEnabled
926 {
927     return _preferences->plugInSnapshottingEnabled();
928 }
929
930 - (void)_setQTKitEnabled:(BOOL)enabled
931 {
932     _preferences->setQTKitEnabled(enabled);
933 }
934
935 - (BOOL)_qtKitEnabled
936 {
937     return _preferences->isQTKitEnabled();
938 }
939
940 - (void)_setSubpixelCSSOMElementMetricsEnabled:(BOOL)enabled
941 {
942     _preferences->setSubpixelCSSOMElementMetricsEnabled(enabled);
943 }
944
945 - (BOOL)_subpixelCSSOMElementMetricsEnabled
946 {
947     return _preferences->subpixelCSSOMElementMetricsEnabled();
948 }
949
950 - (void)_setMediaSourceEnabled:(BOOL)enabled
951 {
952     _preferences->setMediaSourceEnabled(enabled);
953 }
954
955 - (BOOL)_mediaSourceEnabled
956 {
957     return _preferences->mediaSourceEnabled();
958 }
959
960 - (void)_setViewGestureDebuggingEnabled:(BOOL)enabled
961 {
962     _preferences->setViewGestureDebuggingEnabled(enabled);
963 }
964
965 - (BOOL)_viewGestureDebuggingEnabled
966 {
967     return _preferences->viewGestureDebuggingEnabled();
968 }
969
970 - (void)_setCSSAnimationTriggersEnabled:(BOOL)enabled
971 {
972     _preferences->setCSSAnimationTriggersEnabled(enabled);
973 }
974
975 - (BOOL)_cssAnimationTriggersEnabled
976 {
977     return _preferences->cssAnimationTriggersEnabled();
978 }
979
980 - (void)_setStandardFontFamily:(NSString *)family
981 {
982     _preferences->setStandardFontFamily(family);
983 }
984
985 - (NSString *)_standardFontFamily
986 {
987     return _preferences->standardFontFamily();
988 }
989
990 - (void)_setNotificationsEnabled:(BOOL)enabled
991 {
992     _preferences->setNotificationsEnabled(enabled);
993 }
994
995 - (BOOL)_notificationsEnabled
996 {
997     return _preferences->notificationsEnabled();
998 }
999
1000 - (void)_setBackspaceKeyNavigationEnabled:(BOOL)enabled
1001 {
1002     _preferences->setBackspaceKeyNavigationEnabled(enabled);
1003 }
1004
1005 - (BOOL)_backspaceKeyNavigationEnabled
1006 {
1007     return _preferences->backspaceKeyNavigationEnabled();
1008 }
1009
1010 - (void)_setWebGLEnabled:(BOOL)enabled
1011 {
1012     _preferences->setWebGLEnabled(enabled);
1013 }
1014
1015 - (BOOL)_webGLEnabled
1016 {
1017     return _preferences->webGLEnabled();
1018 }
1019 #endif // PLATFORM(MAC)
1020
1021 - (BOOL)_javaScriptCanAccessClipboard
1022 {
1023     return _preferences->javaScriptCanAccessClipboard();
1024 }
1025
1026 - (void)_setDOMPasteAllowed:(BOOL)domPasteAllowed
1027 {
1028     _preferences->setDOMPasteAllowed(domPasteAllowed);
1029 }
1030
1031 - (BOOL)_domPasteAllowed
1032 {
1033     return _preferences->domPasteAllowed();
1034 }
1035
1036 @end
1037
1038 #endif // WK_API_ENABLED