c3befce190f9a985aa10f716f56c3bb5dff9a582
[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 ALLOW_DEPRECATED_DECLARATIONS_BEGIN
73     [coder encodeBool:self.javaEnabled forKey:@"javaEnabled"];
74     [coder encodeBool:self.plugInsEnabled forKey:@"plugInsEnabled"];
75 ALLOW_DEPRECATED_DECLARATIONS_END
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 ALLOW_DEPRECATED_DECLARATIONS_BEGIN
91     self.javaEnabled = [coder decodeBoolForKey:@"javaEnabled"];
92     self.plugInsEnabled = [coder decodeBoolForKey:@"plugInsEnabled"];
93 ALLOW_DEPRECATED_DECLARATIONS_END
94     self.tabFocusesLinks = [coder decodeBoolForKey:@"tabFocusesLinks"];
95 #endif
96
97     return self;
98 }
99
100 - (id)copyWithZone:(NSZone *)zone
101 {
102     return [wrapper(_preferences->copy()) retain];
103 }
104
105 - (CGFloat)minimumFontSize
106 {
107     return _preferences->minimumFontSize();
108 }
109
110 - (void)setMinimumFontSize:(CGFloat)minimumFontSize
111 {
112     _preferences->setMinimumFontSize(minimumFontSize);
113 }
114
115 - (BOOL)javaScriptEnabled
116 {
117     return _preferences->javaScriptEnabled();
118 }
119
120 - (void)setJavaScriptEnabled:(BOOL)javaScriptEnabled
121 {
122     _preferences->setJavaScriptEnabled(javaScriptEnabled);
123 }
124
125 - (BOOL)javaScriptCanOpenWindowsAutomatically
126 {
127     return _preferences->javaScriptCanOpenWindowsAutomatically();
128 }
129
130 - (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)javaScriptCanOpenWindowsAutomatically
131 {
132     _preferences->setJavaScriptCanOpenWindowsAutomatically(javaScriptCanOpenWindowsAutomatically);
133 }
134
135 #pragma mark OS X-specific methods
136
137 #if PLATFORM(MAC)
138
139 - (BOOL)tabFocusesLinks
140 {
141     return _preferences->tabsToLinks();
142 }
143
144 - (void)setTabFocusesLinks:(BOOL)tabFocusesLinks
145 {
146     _preferences->setTabsToLinks(tabFocusesLinks);
147 }
148
149 #endif
150
151 #pragma mark WKObject protocol implementation
152
153 - (API::Object&)_apiObject
154 {
155     return *_preferences;
156 }
157
158 @end
159
160 @implementation WKPreferences (WKPrivate)
161
162 - (BOOL)_telephoneNumberDetectionIsEnabled
163 {
164     return _preferences->telephoneNumberParsingEnabled();
165 }
166
167 - (void)_setTelephoneNumberDetectionIsEnabled:(BOOL)telephoneNumberDetectionIsEnabled
168 {
169     _preferences->setTelephoneNumberParsingEnabled(telephoneNumberDetectionIsEnabled);
170 }
171
172 static WebCore::SecurityOrigin::StorageBlockingPolicy toStorageBlockingPolicy(_WKStorageBlockingPolicy policy)
173 {
174     switch (policy) {
175     case _WKStorageBlockingPolicyAllowAll:
176         return WebCore::SecurityOrigin::AllowAllStorage;
177     case _WKStorageBlockingPolicyBlockThirdParty:
178         return WebCore::SecurityOrigin::BlockThirdPartyStorage;
179     case _WKStorageBlockingPolicyBlockAll:
180         return WebCore::SecurityOrigin::BlockAllStorage;
181     }
182
183     ASSERT_NOT_REACHED();
184     return WebCore::SecurityOrigin::AllowAllStorage;
185 }
186
187 static _WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPolicy policy)
188 {
189     switch (policy) {
190     case WebCore::SecurityOrigin::AllowAllStorage:
191         return _WKStorageBlockingPolicyAllowAll;
192     case WebCore::SecurityOrigin::BlockThirdPartyStorage:
193         return _WKStorageBlockingPolicyBlockThirdParty;
194     case WebCore::SecurityOrigin::BlockAllStorage:
195         return _WKStorageBlockingPolicyBlockAll;
196     }
197
198     ASSERT_NOT_REACHED();
199     return _WKStorageBlockingPolicyAllowAll;
200 }
201
202 - (_WKStorageBlockingPolicy)_storageBlockingPolicy
203 {
204     return toAPI(static_cast<WebCore::SecurityOrigin::StorageBlockingPolicy>(_preferences->storageBlockingPolicy()));
205 }
206
207 - (void)_setStorageBlockingPolicy:(_WKStorageBlockingPolicy)policy
208 {
209     _preferences->setStorageBlockingPolicy(toStorageBlockingPolicy(policy));
210 }
211
212 - (BOOL)_offlineApplicationCacheIsEnabled
213 {
214     return _preferences->offlineWebApplicationCacheEnabled();
215 }
216
217 - (void)_setOfflineApplicationCacheIsEnabled:(BOOL)offlineApplicationCacheIsEnabled
218 {
219     _preferences->setOfflineWebApplicationCacheEnabled(offlineApplicationCacheIsEnabled);
220 }
221
222 - (BOOL)_fullScreenEnabled
223 {
224     return _preferences->fullScreenEnabled();
225 }
226
227 - (void)_setFullScreenEnabled:(BOOL)fullScreenEnabled
228 {
229     _preferences->setFullScreenEnabled(fullScreenEnabled);
230 }
231
232 - (BOOL)_allowsPictureInPictureMediaPlayback
233 {
234     return _preferences->allowsPictureInPictureMediaPlayback();
235 }
236
237 - (void)_setAllowsPictureInPictureMediaPlayback:(BOOL)allowed
238 {
239     _preferences->setAllowsPictureInPictureMediaPlayback(allowed);
240 }
241
242 - (BOOL)_compositingBordersVisible
243 {
244     return _preferences->compositingBordersVisible();
245 }
246
247 - (void)_setCompositingBordersVisible:(BOOL)compositingBordersVisible
248 {
249     _preferences->setCompositingBordersVisible(compositingBordersVisible);
250 }
251
252 - (BOOL)_compositingRepaintCountersVisible
253 {
254     return _preferences->compositingRepaintCountersVisible();
255 }
256
257 - (void)_setCompositingRepaintCountersVisible:(BOOL)repaintCountersVisible
258 {
259     _preferences->setCompositingRepaintCountersVisible(repaintCountersVisible);
260 }
261
262 - (BOOL)_tiledScrollingIndicatorVisible
263 {
264     return _preferences->tiledScrollingIndicatorVisible();
265 }
266
267 - (void)_setTiledScrollingIndicatorVisible:(BOOL)tiledScrollingIndicatorVisible
268 {
269     _preferences->setTiledScrollingIndicatorVisible(tiledScrollingIndicatorVisible);
270 }
271
272 - (BOOL)_resourceUsageOverlayVisible
273 {
274     return _preferences->resourceUsageOverlayVisible();
275 }
276
277 - (void)_setResourceUsageOverlayVisible:(BOOL)resourceUsageOverlayVisible
278 {
279     _preferences->setResourceUsageOverlayVisible(resourceUsageOverlayVisible);
280 }
281
282 - (_WKDebugOverlayRegions)_visibleDebugOverlayRegions
283 {
284     return _preferences->visibleDebugOverlayRegions();
285 }
286
287 - (void)_setVisibleDebugOverlayRegions:(_WKDebugOverlayRegions)regionFlags
288 {
289     _preferences->setVisibleDebugOverlayRegions(regionFlags);
290 }
291
292 - (BOOL)_simpleLineLayoutEnabled
293 {
294     return _preferences->simpleLineLayoutEnabled();
295 }
296
297 - (void)_setSimpleLineLayoutEnabled:(BOOL)simpleLineLayoutEnabled
298 {
299     _preferences->setSimpleLineLayoutEnabled(simpleLineLayoutEnabled);
300 }
301
302 - (BOOL)_simpleLineLayoutDebugBordersEnabled
303 {
304     return _preferences->simpleLineLayoutDebugBordersEnabled();
305 }
306
307 - (void)_setSimpleLineLayoutDebugBordersEnabled:(BOOL)simpleLineLayoutDebugBordersEnabled
308 {
309     _preferences->setSimpleLineLayoutDebugBordersEnabled(simpleLineLayoutDebugBordersEnabled);
310 }
311
312 - (BOOL)_contentChangeObserverEnabled
313 {
314     return _preferences->contentChangeObserverEnabled();
315 }
316
317 - (void)_setContentChangeObserverEnabled:(BOOL)contentChangeObserverEnabled
318 {
319     _preferences->setContentChangeObserverEnabled(contentChangeObserverEnabled);
320 }
321
322 - (BOOL)_acceleratedDrawingEnabled
323 {
324     return _preferences->acceleratedDrawingEnabled();
325 }
326
327 - (void)_setAcceleratedDrawingEnabled:(BOOL)acceleratedDrawingEnabled
328 {
329     _preferences->setAcceleratedDrawingEnabled(acceleratedDrawingEnabled);
330 }
331
332 - (BOOL)_displayListDrawingEnabled
333 {
334     return _preferences->displayListDrawingEnabled();
335 }
336
337 - (void)_setDisplayListDrawingEnabled:(BOOL)displayListDrawingEnabled
338 {
339     _preferences->setDisplayListDrawingEnabled(displayListDrawingEnabled);
340 }
341
342 - (BOOL)_largeImageAsyncDecodingEnabled
343 {
344     return _preferences->largeImageAsyncDecodingEnabled();
345 }
346
347 - (void)_setLargeImageAsyncDecodingEnabled:(BOOL)_largeImageAsyncDecodingEnabled
348 {
349     _preferences->setLargeImageAsyncDecodingEnabled(_largeImageAsyncDecodingEnabled);
350 }
351
352 - (BOOL)_animatedImageAsyncDecodingEnabled
353 {
354     return _preferences->animatedImageAsyncDecodingEnabled();
355 }
356
357 - (void)_setAnimatedImageAsyncDecodingEnabled:(BOOL)_animatedImageAsyncDecodingEnabled
358 {
359     _preferences->setAnimatedImageAsyncDecodingEnabled(_animatedImageAsyncDecodingEnabled);
360 }
361
362 - (BOOL)_textAutosizingEnabled
363 {
364     return _preferences->textAutosizingEnabled();
365 }
366
367 - (void)_setTextAutosizingEnabled:(BOOL)enabled
368 {
369     _preferences->setTextAutosizingEnabled(enabled);
370 }
371
372 - (BOOL)_subpixelAntialiasedLayerTextEnabled
373 {
374     return _preferences->subpixelAntialiasedLayerTextEnabled();
375 }
376
377 - (void)_setSubpixelAntialiasedLayerTextEnabled:(BOOL)enabled
378 {
379     _preferences->setSubpixelAntialiasedLayerTextEnabled(enabled);
380 }
381
382 - (BOOL)_developerExtrasEnabled
383 {
384     return _preferences->developerExtrasEnabled();
385 }
386
387 - (void)_setDeveloperExtrasEnabled:(BOOL)developerExtrasEnabled
388 {
389     _preferences->setDeveloperExtrasEnabled(developerExtrasEnabled);
390 }
391
392 - (BOOL)_logsPageMessagesToSystemConsoleEnabled
393 {
394     return _preferences->logsPageMessagesToSystemConsoleEnabled();
395 }
396
397 - (void)_setLogsPageMessagesToSystemConsoleEnabled:(BOOL)logsPageMessagesToSystemConsoleEnabled
398 {
399     _preferences->setLogsPageMessagesToSystemConsoleEnabled(logsPageMessagesToSystemConsoleEnabled);
400 }
401
402 - (BOOL)_hiddenPageDOMTimerThrottlingEnabled
403 {
404     return _preferences->hiddenPageDOMTimerThrottlingEnabled();
405 }
406
407 - (void)_setHiddenPageDOMTimerThrottlingEnabled:(BOOL)hiddenPageDOMTimerThrottlingEnabled
408 {
409     _preferences->setHiddenPageDOMTimerThrottlingEnabled(hiddenPageDOMTimerThrottlingEnabled);
410 }
411
412 - (BOOL)_hiddenPageDOMTimerThrottlingAutoIncreases
413 {
414     return _preferences->hiddenPageDOMTimerThrottlingAutoIncreases();
415 }
416
417 - (void)_setHiddenPageDOMTimerThrottlingAutoIncreases:(BOOL)hiddenPageDOMTimerThrottlingAutoIncreases
418 {
419     _preferences->setHiddenPageDOMTimerThrottlingAutoIncreases(hiddenPageDOMTimerThrottlingAutoIncreases);
420 }
421
422 - (BOOL)_pageVisibilityBasedProcessSuppressionEnabled
423 {
424     return _preferences->pageVisibilityBasedProcessSuppressionEnabled();
425 }
426
427 - (void)_setPageVisibilityBasedProcessSuppressionEnabled:(BOOL)pageVisibilityBasedProcessSuppressionEnabled
428 {
429     _preferences->setPageVisibilityBasedProcessSuppressionEnabled(pageVisibilityBasedProcessSuppressionEnabled);
430 }
431
432 - (BOOL)_allowFileAccessFromFileURLs
433 {
434     return _preferences->allowFileAccessFromFileURLs();
435 }
436
437 - (void)_setAllowFileAccessFromFileURLs:(BOOL)allowFileAccessFromFileURLs
438 {
439     _preferences->setAllowFileAccessFromFileURLs(allowFileAccessFromFileURLs);
440 }
441
442 - (_WKJavaScriptRuntimeFlags)_javaScriptRuntimeFlags
443 {
444     return _preferences->javaScriptRuntimeFlags();
445 }
446
447 - (void)_setJavaScriptRuntimeFlags:(_WKJavaScriptRuntimeFlags)javaScriptRuntimeFlags
448 {
449     _preferences->setJavaScriptRuntimeFlags(javaScriptRuntimeFlags);
450 }
451
452 - (BOOL)_isStandalone
453 {
454     return _preferences->standalone();
455 }
456
457 - (void)_setStandalone:(BOOL)standalone
458 {
459     _preferences->setStandalone(standalone);
460 }
461
462 - (BOOL)_diagnosticLoggingEnabled
463 {
464     return _preferences->diagnosticLoggingEnabled();
465 }
466
467 - (void)_setDiagnosticLoggingEnabled:(BOOL)diagnosticLoggingEnabled
468 {
469     _preferences->setDiagnosticLoggingEnabled(diagnosticLoggingEnabled);
470 }
471
472 - (NSUInteger)_defaultFontSize
473 {
474     return _preferences->defaultFontSize();
475 }
476
477 - (void)_setDefaultFontSize:(NSUInteger)defaultFontSize
478 {
479     _preferences->setDefaultFontSize(defaultFontSize);
480 }
481
482 - (NSUInteger)_defaultFixedPitchFontSize
483 {
484     return _preferences->defaultFixedFontSize();
485 }
486
487 - (void)_setDefaultFixedPitchFontSize:(NSUInteger)defaultFixedPitchFontSize
488 {
489     _preferences->setDefaultFixedFontSize(defaultFixedPitchFontSize);
490 }
491
492 - (NSString *)_fixedPitchFontFamily
493 {
494     return _preferences->fixedFontFamily();
495 }
496
497 - (void)_setFixedPitchFontFamily:(NSString *)fixedPitchFontFamily
498 {
499     _preferences->setFixedFontFamily(fixedPitchFontFamily);
500 }
501
502 + (NSArray<_WKInternalDebugFeature *> *)_internalDebugFeatures
503 {
504     auto features = WebKit::WebPreferences::internalDebugFeatures();
505     return wrapper(API::Array::create(WTFMove(features)));
506 }
507
508 - (BOOL)_isEnabledForInternalDebugFeature:(_WKInternalDebugFeature *)feature
509 {
510     return _preferences->isFeatureEnabled(*feature->_internalDebugFeature);
511 }
512
513 - (void)_setEnabled:(BOOL)value forInternalDebugFeature:(_WKInternalDebugFeature *)feature
514 {
515     _preferences->setFeatureEnabled(*feature->_internalDebugFeature, value);
516 }
517
518 + (NSArray<_WKExperimentalFeature *> *)_experimentalFeatures
519 {
520     auto features = WebKit::WebPreferences::experimentalFeatures();
521     return wrapper(API::Array::create(WTFMove(features)));
522 }
523
524 // FIXME: Remove this once Safari has adopted the new API.
525 - (BOOL)_isEnabledForFeature:(_WKExperimentalFeature *)feature
526 {
527     return [self _isEnabledForExperimentalFeature:feature];
528 }
529
530 // FIXME: Remove this once Safari has adopted the new API.
531 - (void)_setEnabled:(BOOL)value forFeature:(_WKExperimentalFeature *)feature
532 {
533     [self _setEnabled:value forExperimentalFeature:feature];
534 }
535
536 - (BOOL)_isEnabledForExperimentalFeature:(_WKExperimentalFeature *)feature
537 {
538     return _preferences->isFeatureEnabled(*feature->_experimentalFeature);
539 }
540
541 - (void)_setEnabled:(BOOL)value forExperimentalFeature:(_WKExperimentalFeature *)feature
542 {
543     _preferences->setFeatureEnabled(*feature->_experimentalFeature, value);
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 - (void)_setShouldIgnoreMetaViewport:(BOOL)ignoreMetaViewport
785 {
786     return _preferences->setShouldIgnoreMetaViewport(ignoreMetaViewport);
787 }
788
789 - (BOOL)_shouldIgnoreMetaViewport
790 {
791     return _preferences->shouldIgnoreMetaViewport();
792 }
793
794 - (void)_setNeedsSiteSpecificQuirks:(BOOL)enabled
795 {
796     _preferences->setNeedsSiteSpecificQuirks(enabled);
797 }
798
799 - (BOOL)_needsSiteSpecificQuirks
800 {
801     return _preferences->needsSiteSpecificQuirks();
802 }
803
804 - (void)_setItpDebugModeEnabled:(BOOL)enabled
805 {
806     _preferences->setItpDebugModeEnabled(enabled);
807 }
808
809 - (BOOL)_itpDebugModeEnabled
810 {
811     return _preferences->itpDebugModeEnabled();
812 }
813
814 - (void)_setMediaSourceEnabled:(BOOL)enabled
815 {
816     _preferences->setMediaSourceEnabled(enabled);
817 }
818
819 - (BOOL)_mediaSourceEnabled
820 {
821     return _preferences->mediaSourceEnabled();
822 }
823
824 #if PLATFORM(MAC)
825 - (void)_setJavaEnabledForLocalFiles:(BOOL)enabled
826 {
827     _preferences->setJavaEnabledForLocalFiles(enabled);
828 }
829
830 - (BOOL)_javaEnabledForLocalFiles
831 {
832     return _preferences->javaEnabledForLocalFiles();
833 }
834
835 - (void)_setCanvasUsesAcceleratedDrawing:(BOOL)enabled
836 {
837     _preferences->setCanvasUsesAcceleratedDrawing(enabled);
838 }
839
840 - (BOOL)_canvasUsesAcceleratedDrawing
841 {
842     return _preferences->canvasUsesAcceleratedDrawing();
843 }
844
845 - (void)_setAcceleratedCompositingEnabled:(BOOL)enabled
846 {
847     _preferences->setAcceleratedCompositingEnabled(enabled);
848 }
849
850 - (BOOL)_acceleratedCompositingEnabled
851 {
852     return _preferences->acceleratedCompositingEnabled();
853 }
854
855 - (void)_setDefaultTextEncodingName:(NSString *)name
856 {
857     _preferences->setDefaultTextEncodingName(name);
858 }
859
860 - (NSString *)_defaultTextEncodingName
861 {
862     return _preferences->defaultTextEncodingName();
863 }
864
865 - (void)_setAuthorAndUserStylesEnabled:(BOOL)enabled
866 {
867     _preferences->setAuthorAndUserStylesEnabled(enabled);
868 }
869
870 - (BOOL)_authorAndUserStylesEnabled
871 {
872     return _preferences->authorAndUserStylesEnabled();
873 }
874
875 - (void)_setDOMTimersThrottlingEnabled:(BOOL)enabled
876 {
877     _preferences->setDOMTimersThrottlingEnabled(enabled);
878 }
879
880 - (BOOL)_domTimersThrottlingEnabled
881 {
882     return _preferences->domTimersThrottlingEnabled();
883 }
884
885 - (void)_setWebArchiveDebugModeEnabled:(BOOL)enabled
886 {
887     _preferences->setWebArchiveDebugModeEnabled(enabled);
888 }
889
890 - (BOOL)_webArchiveDebugModeEnabled
891 {
892     return _preferences->webArchiveDebugModeEnabled();
893 }
894
895 - (void)_setLocalFileContentSniffingEnabled:(BOOL)enabled
896 {
897     _preferences->setLocalFileContentSniffingEnabled(enabled);
898 }
899
900 - (BOOL)_localFileContentSniffingEnabled
901 {
902     return _preferences->localFileContentSniffingEnabled();
903 }
904
905 - (void)_setUsesPageCache:(BOOL)enabled
906 {
907     _preferences->setUsesPageCache(enabled);
908 }
909
910 - (BOOL)_usesPageCache
911 {
912     return _preferences->usesPageCache();
913 }
914
915 - (void)_setPageCacheSupportsPlugins:(BOOL)enabled
916 {
917     _preferences->setPageCacheSupportsPlugins(enabled);
918 }
919
920 - (BOOL)_pageCacheSupportsPlugins
921 {
922     return _preferences->pageCacheSupportsPlugins();
923 }
924
925 - (void)_setShouldPrintBackgrounds:(BOOL)enabled
926 {
927     _preferences->setShouldPrintBackgrounds(enabled);
928 }
929
930 - (BOOL)_shouldPrintBackgrounds
931 {
932     return _preferences->shouldPrintBackgrounds();
933 }
934
935 - (void)_setWebSecurityEnabled:(BOOL)enabled
936 {
937     _preferences->setWebSecurityEnabled(enabled);
938 }
939
940 - (BOOL)_webSecurityEnabled
941 {
942     return _preferences->webSecurityEnabled();
943 }
944
945 - (void)_setUniversalAccessFromFileURLsAllowed:(BOOL)enabled
946 {
947     _preferences->setAllowUniversalAccessFromFileURLs(enabled);
948 }
949
950 - (BOOL)_universalAccessFromFileURLsAllowed
951 {
952     return _preferences->allowUniversalAccessFromFileURLs();
953 }
954
955 - (void)_setSuppressesIncrementalRendering:(BOOL)enabled
956 {
957     _preferences->setSuppressesIncrementalRendering(enabled);
958 }
959
960 - (BOOL)_suppressesIncrementalRendering
961 {
962     return _preferences->suppressesIncrementalRendering();
963 }
964
965 - (void)_setAsynchronousPluginInitializationEnabled:(BOOL)enabled
966 {
967     _preferences->setAsynchronousPluginInitializationEnabled(enabled);
968 }
969
970 - (BOOL)_asynchronousPluginInitializationEnabled
971 {
972     return _preferences->asynchronousPluginInitializationEnabled();
973 }
974
975 - (void)_setArtificialPluginInitializationDelayEnabled:(BOOL)enabled
976 {
977     _preferences->setArtificialPluginInitializationDelayEnabled(enabled);
978 }
979
980 - (BOOL)_artificialPluginInitializationDelayEnabled
981 {
982     return _preferences->artificialPluginInitializationDelayEnabled();
983 }
984
985 - (void)_setExperimentalPlugInSandboxProfilesEnabled:(BOOL)enabled
986 {
987 #if ENABLE(NETSCAPE_PLUGIN_API)
988     WebKit::PluginProcessManager::singleton().setExperimentalPlugInSandboxProfilesEnabled(enabled);
989 #endif
990     _preferences->setExperimentalPlugInSandboxProfilesEnabled(enabled);
991 }
992
993 - (BOOL)_experimentalPlugInSandboxProfilesEnabled
994 {
995     return _preferences->experimentalPlugInSandboxProfilesEnabled();
996 }
997
998 - (void)_setCookieEnabled:(BOOL)enabled
999 {
1000     _preferences->setCookieEnabled(enabled);
1001 }
1002
1003 - (BOOL)_cookieEnabled
1004 {
1005     return _preferences->cookieEnabled();
1006 }
1007
1008 - (void)_setPlugInSnapshottingEnabled:(BOOL)enabled
1009 {
1010     _preferences->setPlugInSnapshottingEnabled(enabled);
1011 }
1012
1013 - (BOOL)_plugInSnapshottingEnabled
1014 {
1015     return _preferences->plugInSnapshottingEnabled();
1016 }
1017
1018 - (void)_setSubpixelCSSOMElementMetricsEnabled:(BOOL)enabled
1019 {
1020     _preferences->setSubpixelCSSOMElementMetricsEnabled(enabled);
1021 }
1022
1023 - (BOOL)_subpixelCSSOMElementMetricsEnabled
1024 {
1025     return _preferences->subpixelCSSOMElementMetricsEnabled();
1026 }
1027
1028 - (void)_setViewGestureDebuggingEnabled:(BOOL)enabled
1029 {
1030     _preferences->setViewGestureDebuggingEnabled(enabled);
1031 }
1032
1033 - (BOOL)_viewGestureDebuggingEnabled
1034 {
1035     return _preferences->viewGestureDebuggingEnabled();
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 - (BOOL)_isSafeBrowsingEnabled
1302 {
1303     return _preferences->safeBrowsingEnabled();
1304 }
1305
1306 - (void)_setSafeBrowsingEnabled:(BOOL)enabled
1307 {
1308     _preferences->setSafeBrowsingEnabled(enabled);
1309 }
1310
1311 - (void)_setVideoQualityIncludesDisplayCompositingEnabled:(BOOL)videoQualityIncludesDisplayCompositingEnabled
1312 {
1313     _preferences->setVideoQualityIncludesDisplayCompositingEnabled(videoQualityIncludesDisplayCompositingEnabled);
1314 }
1315
1316 - (BOOL)_videoQualityIncludesDisplayCompositingEnabled
1317 {
1318     return _preferences->videoQualityIncludesDisplayCompositingEnabled();
1319 }
1320
1321 - (void)_setWebAnimationsCSSIntegrationEnabled:(BOOL)enabled
1322 {
1323     _preferences->setWebAnimationsCSSIntegrationEnabled(enabled);
1324 }
1325
1326 - (BOOL)_webAnimationsCSSIntegrationEnabled
1327 {
1328     return _preferences->webAnimationsCSSIntegrationEnabled();
1329 }
1330
1331 - (void)_setDeviceOrientationEventEnabled:(BOOL)enabled
1332 {
1333 #if ENABLE(DEVICE_ORIENTATION)
1334     _preferences->setDeviceOrientationEventEnabled(enabled);
1335 #endif
1336 }
1337
1338 - (BOOL)_deviceOrientationEventEnabled
1339 {
1340 #if ENABLE(DEVICE_ORIENTATION)
1341     return _preferences->deviceOrientationEventEnabled();
1342 #else
1343     return false;
1344 #endif
1345 }
1346
1347 @end
1348
1349 #if !TARGET_OS_IPHONE
1350
1351 @implementation WKPreferences (WKDeprecated)
1352
1353 - (BOOL)javaEnabled
1354 {
1355     return _preferences->javaEnabled();
1356 }
1357
1358 - (void)setJavaEnabled:(BOOL)javaEnabled
1359 {
1360     _preferences->setJavaEnabled(javaEnabled);
1361 }
1362
1363 - (BOOL)plugInsEnabled
1364 {
1365     return _preferences->pluginsEnabled();
1366 }
1367
1368 - (void)setPlugInsEnabled:(BOOL)plugInsEnabled
1369 {
1370     _preferences->setPluginsEnabled(plugInsEnabled);
1371 }
1372
1373 @end
1374
1375 #endif