2 * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
3 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #import "WebPreferencesPrivate.h"
31 #import "WebPreferenceKeysPrivate.h"
33 #import "WebApplicationCache.h"
34 #import "WebFrameNetworkingContext.h"
35 #import "WebKitLogging.h"
36 #import "WebKitNSStringExtras.h"
37 #import "WebKitSystemInterface.h"
38 #import "WebKitVersionChecks.h"
39 #import "WebNSDictionaryExtras.h"
40 #import "WebNSURLExtras.h"
41 #import "WebSystemInterface.h"
42 #import <WebCore/ApplicationCacheStorage.h>
43 #import <WebCore/AudioSession.h>
44 #import <WebCore/CFNetworkSPI.h>
45 #import <WebCore/NetworkStorageSession.h>
46 #import <WebCore/PlatformCookieJar.h>
47 #import <WebCore/ResourceHandle.h>
48 #import <WebCore/RuntimeApplicationChecks.h>
49 #import <WebCore/Settings.h>
50 #import <WebCore/TextEncodingRegistry.h>
51 #import <runtime/InitializeThreading.h>
52 #import <wtf/MainThread.h>
53 #import <wtf/RetainPtr.h>
54 #import <wtf/RunLoop.h>
56 using namespace WebCore;
59 #import <AudioToolbox/AudioSession.h>
60 #import <WebCore/Device.h>
61 #import <WebCore/GraphicsContext.h>
62 #import <WebCore/ImageSource.h>
63 #import <WebCore/WebCoreThreadMessage.h>
66 NSString *WebPreferencesChangedNotification = @"WebPreferencesChangedNotification";
67 NSString *WebPreferencesRemovedNotification = @"WebPreferencesRemovedNotification";
68 NSString *WebPreferencesChangedInternalNotification = @"WebPreferencesChangedInternalNotification";
69 NSString *WebPreferencesCacheModelChangedInternalNotification = @"WebPreferencesCacheModelChangedInternalNotification";
71 #define KEY(x) (_private->identifier ? [_private->identifier.get() stringByAppendingString:(x)] : (x))
73 enum { WebPreferencesVersion = 1 };
75 static WebPreferences *_standardPreferences;
76 static NSMutableDictionary *webPreferencesInstances;
78 static unsigned webPreferencesInstanceCountWithPrivateBrowsingEnabled;
80 static bool contains(const char* const array[], int count, const char* item)
85 for (int i = 0; i < count; i++)
86 if (!strcasecmp(array[i], item))
91 static WebCacheModel cacheModelForMainBundle(void)
94 // Apps that probably need the small setting
95 static const char* const documentViewerIDs[] = {
96 "Microsoft/com.microsoft.Messenger",
98 "com.alientechnology.Proteus",
101 "com.barebones.bbedit",
102 "com.barebones.textwrangler",
103 "com.barebones.yojimbo",
104 "com.equinux.iSale4",
105 "com.growl.growlframework",
106 "com.intrarts.PandoraMan",
107 "com.karelia.Sandvox",
108 "com.macromates.textmate",
109 "com.realmacsoftware.rapidweaverpro",
110 "com.red-sweater.marsedit",
111 "com.yahoo.messenger3",
112 "de.codingmonkeys.SubEthaEdit",
118 // Apps that probably need the medium setting
119 static const char* const documentBrowserIDs[] = {
120 "com.apple.Dictionary",
122 "com.apple.dashboard.client",
123 "com.apple.helpviewer",
124 "com.culturedcode.xyle",
125 "com.macrabbit.CSSEdit",
127 "com.ranchero.NetNewsWire",
128 "com.thinkmac.NewsLife",
129 "org.xlife.NewsFire",
130 "uk.co.opencommunity.vienna2",
133 // Apps that probably need the large setting
134 static const char* const primaryWebBrowserIDs[] = {
135 "com.app4mac.KidsBrowser"
136 "com.app4mac.wKiosk",
137 "com.freeverse.bumpercar",
138 "com.omnigroup.OmniWeb5",
139 "com.sunrisebrowser.Sunrise",
140 "net.hmdt-web.Shiira",
143 const char* bundleID = [[[NSBundle mainBundle] bundleIdentifier] UTF8String];
144 if (contains(documentViewerIDs, sizeof(documentViewerIDs) / sizeof(documentViewerIDs[0]), bundleID))
145 return WebCacheModelDocumentViewer;
146 if (contains(documentBrowserIDs, sizeof(documentBrowserIDs) / sizeof(documentBrowserIDs[0]), bundleID))
147 return WebCacheModelDocumentBrowser;
148 if (contains(primaryWebBrowserIDs, sizeof(primaryWebBrowserIDs) / sizeof(primaryWebBrowserIDs[0]), bundleID))
149 return WebCacheModelPrimaryWebBrowser;
151 bool isLinkedAgainstWebKit = WebKitLinkedOnOrAfter(0);
152 if (!isLinkedAgainstWebKit)
153 return WebCacheModelDocumentViewer; // Apps that don't link against WebKit probably aren't meant to be browsers.
156 bool isLegacyApp = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_CACHE_MODEL_API);
158 bool isLegacyApp = false;
161 return WebCacheModelDocumentBrowser; // To avoid regressions in apps that depended on old WebKit's large cache.
163 return WebCacheModelDocumentViewer; // To save memory.
167 @interface WebPreferences ()
168 - (void)_postCacheModelChangedNotification;
171 @interface WebPreferences (WebInternal)
172 + (NSString *)_concatenateKeyWithIBCreatorID:(NSString *)key;
173 + (NSString *)_IBCreatorID;
176 struct WebPreferencesPrivate
179 WebPreferencesPrivate()
180 : inPrivateBrowsing(NO)
182 , automaticallyDetectsCacheModel(NO)
185 , readWriteQueue(dispatch_queue_create("com.apple.WebPreferences.ReadWriteQueue", DISPATCH_QUEUE_CONCURRENT))
191 ~WebPreferencesPrivate()
193 dispatch_release(readWriteQueue);
197 RetainPtr<NSMutableDictionary> values;
198 BOOL inPrivateBrowsing;
199 RetainPtr<NSString> identifier;
201 BOOL automaticallyDetectsCacheModel;
202 unsigned numWebViews;
204 dispatch_queue_t readWriteQueue;
208 @interface WebPreferences (WebForwardDeclarations)
209 // This pseudo-category is needed so these methods can be used from within other category implementations
210 // without being in the public header file.
211 - (BOOL)_boolValueForKey:(NSString *)key;
212 - (void)_setBoolValue:(BOOL)value forKey:(NSString *)key;
213 - (int)_integerValueForKey:(NSString *)key;
214 - (void)_setIntegerValue:(int)value forKey:(NSString *)key;
215 - (float)_floatValueForKey:(NSString *)key;
216 - (void)_setFloatValue:(float)value forKey:(NSString *)key;
217 - (void)_setLongLongValue:(long long)value forKey:(NSString *)key;
218 - (long long)_longLongValueForKey:(NSString *)key;
219 - (void)_setUnsignedLongLongValue:(unsigned long long)value forKey:(NSString *)key;
220 - (unsigned long long)_unsignedLongLongValueForKey:(NSString *)key;
224 @interface WebPreferences ()
225 - (id)initWithIdentifier:(NSString *)anIdentifier sendChangeNotification:(BOOL)sendChangeNotification;
229 @implementation WebPreferences
233 // Create fake identifier
234 static int instanceCount = 1;
235 NSString *fakeIdentifier;
237 // At least ensure that identifier hasn't been already used.
238 fakeIdentifier = [NSString stringWithFormat:@"WebPreferences%d", instanceCount++];
239 while ([[self class] _getInstanceForIdentifier:fakeIdentifier]){
240 fakeIdentifier = [NSString stringWithFormat:@"WebPreferences%d", instanceCount++];
243 return [self initWithIdentifier:fakeIdentifier];
247 - (id)initWithIdentifier:(NSString *)anIdentifier
249 return [self initWithIdentifier:anIdentifier sendChangeNotification:YES];
254 - (instancetype)initWithIdentifier:(NSString *)anIdentifier sendChangeNotification:(BOOL)sendChangeNotification
256 - (instancetype)initWithIdentifier:(NSString *)anIdentifier
259 WebPreferences *instance = [[self class] _getInstanceForIdentifier:anIdentifier];
262 return [instance retain];
269 _private = new WebPreferencesPrivate;
270 _private->values = adoptNS([[NSMutableDictionary alloc] init]);
271 _private->identifier = adoptNS([anIdentifier copy]);
272 _private->automaticallyDetectsCacheModel = YES;
274 [[self class] _setInstance:self forIdentifier:_private->identifier.get()];
276 [self _updatePrivateBrowsingStateTo:[self privateBrowsingEnabled]];
279 if (sendChangeNotification) {
280 [self _postPreferencesChangedNotification];
281 [self _postCacheModelChangedNotification];
284 [self _postPreferencesChangedNotification];
285 [self _postCacheModelChangedNotification];
291 - (instancetype)initWithCoder:(NSCoder *)decoder
297 _private = new WebPreferencesPrivate;
298 _private->automaticallyDetectsCacheModel = YES;
303 if ([decoder allowsKeyedCoding]) {
304 identifier = [decoder decodeObjectForKey:@"Identifier"];
305 values = [decoder decodeObjectForKey:@"Values"];
308 [decoder decodeValueOfObjCType:@encode(int) at:&version];
310 identifier = [decoder decodeObject];
311 values = [decoder decodeObject];
315 if ([identifier isKindOfClass:[NSString class]])
316 _private->identifier = adoptNS([identifier copy]);
317 if ([values isKindOfClass:[NSDictionary class]])
318 _private->values = adoptNS([values mutableCopy]); // ensure dictionary is mutable
320 LOG(Encoding, "Identifier = %@, Values = %@\n", _private->identifier.get(), _private->values.get());
326 // If we load a nib multiple times, or have instances in multiple
327 // nibs with the same name, the first guy up wins.
328 WebPreferences *instance = [[self class] _getInstanceForIdentifier:_private->identifier.get()];
331 self = [instance retain];
333 [[self class] _setInstance:self forIdentifier:_private->identifier.get()];
334 [self _updatePrivateBrowsingStateTo:[self privateBrowsingEnabled]];
340 - (void)encodeWithCoder:(NSCoder *)encoder
342 if ([encoder allowsKeyedCoding]){
343 [encoder encodeObject:_private->identifier.get() forKey:@"Identifier"];
345 dispatch_sync(_private->readWriteQueue, ^{
347 [encoder encodeObject:_private->values.get() forKey:@"Values"];
348 LOG (Encoding, "Identifier = %@, Values = %@\n", _private->identifier.get(), _private->values.get());
354 int version = WebPreferencesVersion;
355 [encoder encodeValueOfObjCType:@encode(int) at:&version];
356 [encoder encodeObject:_private->identifier.get()];
358 dispatch_sync(_private->readWriteQueue, ^{
360 [encoder encodeObject:_private->values.get()];
367 + (WebPreferences *)standardPreferences
370 if (_standardPreferences == nil) {
371 _standardPreferences = [[WebPreferences alloc] initWithIdentifier:nil];
372 [_standardPreferences setAutosaves:YES];
375 // FIXME: This check is necessary to avoid recursion (see <rdar://problem/9564337>), but it also makes _standardPreferences construction not thread safe.
376 if (_standardPreferences)
377 return _standardPreferences;
379 static dispatch_once_t pred;
380 dispatch_once(&pred, ^{
381 _standardPreferences = [[WebPreferences alloc] initWithIdentifier:nil sendChangeNotification:NO];
382 [_standardPreferences _postPreferencesChangedNotification];
383 [_standardPreferences setAutosaves:YES];
387 return _standardPreferences;
390 // if we ever have more than one WebPreferences object, this would move to init
394 JSC::initializeThreading();
395 WTF::initializeMainThreadToProcessMainThread();
396 RunLoop::initializeMainRunLoop();
397 bool attachmentElementEnabled = MacApplication::isAppleMail();
399 bool allowsInlineMediaPlayback = WebCore::deviceClass() == MGDeviceClassiPad;
400 bool allowsInlineMediaPlaybackAfterFullscreen = WebCore::deviceClass() != MGDeviceClassiPad;
401 bool requiresPlaysInlineAttribute = !allowsInlineMediaPlayback;
402 bool attachmentElementEnabled = IOSApplication::isMobileMail();
404 InitWebCoreSystemInterface();
406 NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
407 @"Times", WebKitStandardFontPreferenceKey,
408 @"Courier", WebKitFixedFontPreferenceKey,
409 @"Times", WebKitSerifFontPreferenceKey,
410 @"Helvetica", WebKitSansSerifFontPreferenceKey,
412 @"Apple Chancery", WebKitCursiveFontPreferenceKey,
414 @"Snell Roundhand", WebKitCursiveFontPreferenceKey,
416 @"Papyrus", WebKitFantasyFontPreferenceKey,
418 @"AppleColorEmoji", WebKitPictographFontPreferenceKey,
420 @"Apple Color Emoji", WebKitPictographFontPreferenceKey,
422 @"0", WebKitMinimumFontSizePreferenceKey,
423 @"9", WebKitMinimumLogicalFontSizePreferenceKey,
424 @"16", WebKitDefaultFontSizePreferenceKey,
425 @"13", WebKitDefaultFixedFontSizePreferenceKey,
426 @"ISO-8859-1", WebKitDefaultTextEncodingNamePreferenceKey,
427 [NSNumber numberWithBool:NO], WebKitUsesEncodingDetectorPreferenceKey,
428 [NSNumber numberWithBool:NO], WebKitUserStyleSheetEnabledPreferenceKey,
429 @"", WebKitUserStyleSheetLocationPreferenceKey,
431 [NSNumber numberWithBool:NO], WebKitShouldPrintBackgroundsPreferenceKey,
432 [NSNumber numberWithBool:NO], WebKitTextAreasAreResizablePreferenceKey,
434 [NSNumber numberWithBool:NO], WebKitShrinksStandaloneImagesToFitPreferenceKey,
436 [NSNumber numberWithBool:YES], WebKitJavaEnabledPreferenceKey,
438 [NSNumber numberWithBool:YES], WebKitJavaScriptEnabledPreferenceKey,
439 [NSNumber numberWithBool:YES], WebKitJavaScriptMarkupEnabledPreferenceKey,
440 [NSNumber numberWithBool:YES], WebKitWebSecurityEnabledPreferenceKey,
441 [NSNumber numberWithBool:YES], WebKitAllowUniversalAccessFromFileURLsPreferenceKey,
442 [NSNumber numberWithBool:YES], WebKitAllowFileAccessFromFileURLsPreferenceKey,
444 [NSNumber numberWithBool:NO], WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey,
446 [NSNumber numberWithBool:YES], WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey,
448 [NSNumber numberWithBool:YES], WebKitPluginsEnabledPreferenceKey,
449 [NSNumber numberWithBool:YES], WebKitDatabasesEnabledPreferenceKey,
450 [NSNumber numberWithBool:YES], WebKitHTTPEquivEnabledPreferenceKey,
453 [NSNumber numberWithBool:NO], WebKitStorageTrackerEnabledPreferenceKey,
455 [NSNumber numberWithBool:YES], WebKitLocalStorageEnabledPreferenceKey,
456 [NSNumber numberWithBool:NO], WebKitExperimentalNotificationsEnabledPreferenceKey,
457 [NSNumber numberWithBool:YES], WebKitAllowAnimatedImagesPreferenceKey,
458 [NSNumber numberWithBool:YES], WebKitAllowAnimatedImageLoopingPreferenceKey,
459 [NSNumber numberWithBool:YES], WebKitDisplayImagesKey,
460 [NSNumber numberWithBool:NO], WebKitLoadSiteIconsKey,
461 @"1800", WebKitBackForwardCacheExpirationIntervalKey,
463 [NSNumber numberWithBool:NO], WebKitTabToLinksPreferenceKey,
465 [NSNumber numberWithBool:NO], WebKitPrivateBrowsingEnabledPreferenceKey,
467 [NSNumber numberWithBool:NO], WebKitRespectStandardStyleKeyEquivalentsPreferenceKey,
468 [NSNumber numberWithBool:NO], WebKitShowsURLsInToolTipsPreferenceKey,
469 [NSNumber numberWithBool:NO], WebKitShowsToolTipOverTruncatedTextPreferenceKey,
470 @"1", WebKitPDFDisplayModePreferenceKey,
471 @"0", WebKitPDFScaleFactorPreferenceKey,
473 @"0", WebKitUseSiteSpecificSpoofingPreferenceKey,
474 [NSNumber numberWithInt:WebKitEditableLinkDefaultBehavior], WebKitEditableLinkBehaviorPreferenceKey,
476 [NSNumber numberWithInt:WebTextDirectionSubmenuAutomaticallyIncluded],
477 WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey,
478 [NSNumber numberWithBool:NO], WebKitDOMPasteAllowedPreferenceKey,
480 [NSNumber numberWithBool:YES], WebKitUsesPageCachePreferenceKey,
481 [NSNumber numberWithInt:cacheModelForMainBundle()], WebKitCacheModelPreferenceKey,
482 [NSNumber numberWithBool:YES], WebKitPageCacheSupportsPluginsPreferenceKey,
483 [NSNumber numberWithBool:NO], WebKitDeveloperExtrasEnabledPreferenceKey,
484 [NSNumber numberWithUnsignedInt:0], WebKitJavaScriptRuntimeFlagsPreferenceKey,
485 [NSNumber numberWithBool:YES], WebKitAuthorAndUserStylesEnabledPreferenceKey,
486 [NSNumber numberWithBool:YES], WebKitDOMTimersThrottlingEnabledPreferenceKey,
487 [NSNumber numberWithBool:NO], WebKitWebArchiveDebugModeEnabledPreferenceKey,
488 [NSNumber numberWithBool:NO], WebKitLocalFileContentSniffingEnabledPreferenceKey,
489 [NSNumber numberWithBool:NO], WebKitOfflineWebApplicationCacheEnabledPreferenceKey,
490 [NSNumber numberWithBool:YES], WebKitZoomsTextOnlyPreferenceKey,
491 [NSNumber numberWithBool:NO], WebKitJavaScriptCanAccessClipboardPreferenceKey,
492 [NSNumber numberWithBool:YES], WebKitXSSAuditorEnabledPreferenceKey,
493 [NSNumber numberWithBool:YES], WebKitAcceleratedCompositingEnabledPreferenceKey,
495 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
496 #define DEFAULT_SUBPIXEL_ANTIALIASED_LAYER_TEXT_ENABLED YES
498 #define DEFAULT_SUBPIXEL_ANTIALIASED_LAYER_TEXT_ENABLED NO
500 [NSNumber numberWithBool:DEFAULT_SUBPIXEL_ANTIALIASED_LAYER_TEXT_ENABLED], WebKitSubpixelAntialiasedLayerTextEnabledPreferenceKey,
502 [NSNumber numberWithBool:NO], WebKitDisplayListDrawingEnabledPreferenceKey,
503 #if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR)
504 [NSNumber numberWithBool:YES], WebKitAcceleratedDrawingEnabledPreferenceKey,
505 [NSNumber numberWithBool:YES], WebKitCanvasUsesAcceleratedDrawingPreferenceKey,
507 [NSNumber numberWithBool:NO], WebKitAcceleratedDrawingEnabledPreferenceKey,
508 [NSNumber numberWithBool:NO], WebKitCanvasUsesAcceleratedDrawingPreferenceKey,
510 [NSNumber numberWithBool:NO], WebKitShowDebugBordersPreferenceKey,
511 [NSNumber numberWithBool:YES], WebKitSimpleLineLayoutEnabledPreferenceKey,
512 [NSNumber numberWithBool:NO], WebKitSimpleLineLayoutDebugBordersEnabledPreferenceKey,
513 [NSNumber numberWithBool:NO], WebKitShowRepaintCounterPreferenceKey,
514 [NSNumber numberWithBool:YES], WebKitWebGLEnabledPreferenceKey,
515 [NSNumber numberWithBool:NO], WebKitForceSoftwareWebGLRenderingPreferenceKey,
516 [NSNumber numberWithBool:YES], WebKitForceWebGLUsesLowPowerPreferenceKey,
517 [NSNumber numberWithBool:NO], WebKitAccelerated2dCanvasEnabledPreferenceKey,
518 [NSNumber numberWithBool:NO], WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey,
519 [NSNumber numberWithBool:NO], WebKitResourceLoadStatisticsEnabledPreferenceKey,
520 [NSNumber numberWithBool:YES], WebKitLargeImageAsyncDecodingEnabledPreferenceKey,
521 [NSNumber numberWithBool:YES], WebKitAnimatedImageAsyncDecodingEnabledPreferenceKey,
523 [NSNumber numberWithBool:YES], WebKitFrameFlatteningEnabledPreferenceKey,
525 [NSNumber numberWithBool:NO], WebKitFrameFlatteningEnabledPreferenceKey,
527 [NSNumber numberWithBool:NO], WebKitSpatialNavigationEnabledPreferenceKey,
528 [NSNumber numberWithBool:NO], WebKitDNSPrefetchingEnabledPreferenceKey,
529 [NSNumber numberWithBool:NO], WebKitFullScreenEnabledPreferenceKey,
530 [NSNumber numberWithBool:NO], WebKitAsynchronousSpellCheckingEnabledPreferenceKey,
531 [NSNumber numberWithBool:YES], WebKitHyperlinkAuditingEnabledPreferenceKey,
532 [NSNumber numberWithBool:NO], WebKitUsePreHTML5ParserQuirksKey,
533 [NSNumber numberWithBool:YES], WebKitAVFoundationEnabledKey,
534 [NSNumber numberWithBool:YES], WebKitAVFoundationNSURLSessionEnabledKey,
535 [NSNumber numberWithBool:NO], WebKitSuppressesIncrementalRenderingKey,
536 [NSNumber numberWithBool:attachmentElementEnabled], WebKitAttachmentElementEnabledPreferenceKey,
538 [NSNumber numberWithBool:YES], WebKitAllowsInlineMediaPlaybackPreferenceKey,
539 [NSNumber numberWithBool:NO], WebKitAllowsInlineMediaPlaybackAfterFullscreenPreferenceKey,
540 [NSNumber numberWithBool:NO], WebKitInlineMediaPlaybackRequiresPlaysInlineAttributeKey,
541 [NSNumber numberWithBool:YES], WebKitMediaControlsScaleWithPageZoomPreferenceKey,
542 [NSNumber numberWithBool:NO], WebKitWebAudioEnabledPreferenceKey,
543 [NSNumber numberWithBool:YES], WebKitBackspaceKeyNavigationEnabledKey,
544 [NSNumber numberWithBool:NO], WebKitShouldDisplaySubtitlesPreferenceKey,
545 [NSNumber numberWithBool:NO], WebKitShouldDisplayCaptionsPreferenceKey,
546 [NSNumber numberWithBool:NO], WebKitShouldDisplayTextDescriptionsPreferenceKey,
547 [NSNumber numberWithBool:YES], WebKitNotificationsEnabledKey,
548 [NSNumber numberWithBool:NO], WebKitShouldRespectImageOrientationKey,
549 [NSNumber numberWithBool:YES], WebKitMediaDataLoadsAutomaticallyPreferenceKey,
551 [NSNumber numberWithBool:allowsInlineMediaPlayback], WebKitAllowsInlineMediaPlaybackPreferenceKey,
552 [NSNumber numberWithBool:allowsInlineMediaPlaybackAfterFullscreen], WebKitAllowsInlineMediaPlaybackAfterFullscreenPreferenceKey,
553 [NSNumber numberWithBool:requiresPlaysInlineAttribute], WebKitInlineMediaPlaybackRequiresPlaysInlineAttributeKey,
554 [NSNumber numberWithBool:NO], WebKitMediaControlsScaleWithPageZoomPreferenceKey,
555 [NSNumber numberWithUnsignedInt:AudioSession::None], WebKitAudioSessionCategoryOverride,
556 [NSNumber numberWithBool:NO], WebKitMediaDataLoadsAutomaticallyPreferenceKey,
558 [NSNumber numberWithBool:YES], WebKitAVKitEnabled,
560 [NSNumber numberWithBool:YES], WebKitRequiresUserGestureForMediaPlaybackPreferenceKey,
561 [NSNumber numberWithBool:NO], WebKitRequiresUserGestureForVideoPlaybackPreferenceKey,
562 [NSNumber numberWithBool:NO], WebKitRequiresUserGestureForAudioPlaybackPreferenceKey,
563 [NSNumber numberWithLongLong:WebCore::ApplicationCacheStorage::noQuota()], WebKitApplicationCacheTotalQuota,
565 // Per-Origin Quota on iOS is 25MB. When the quota is reached for a particular origin
566 // the quota for that origin can be increased. See also webView:exceededApplicationCacheOriginQuotaForSecurityOrigin:totalSpaceNeeded in WebUI/WebUIDelegate.m.
567 [NSNumber numberWithLongLong:(25 * 1024 * 1024)], WebKitApplicationCacheDefaultOriginQuota,
569 // Enable WebAudio by default in all iOS UIWebViews
570 [NSNumber numberWithBool:YES], WebKitWebAudioEnabledPreferenceKey,
572 [NSNumber numberWithBool:YES], WebKitShouldRespectImageOrientationKey,
573 #endif // PLATFORM(IOS)
574 #if ENABLE(WIRELESS_TARGET_PLAYBACK)
575 [NSNumber numberWithBool:YES], WebKitAllowsAirPlayForMediaPlaybackPreferenceKey,
577 [NSNumber numberWithBool:YES], WebKitAllowsPictureInPictureMediaPlaybackPreferenceKey,
578 [NSNumber numberWithBool:YES], WebKitRequestAnimationFrameEnabledPreferenceKey,
579 [NSNumber numberWithBool:NO], WebKitWantsBalancedSetDefersLoadingBehaviorKey,
580 [NSNumber numberWithBool:NO], WebKitDiagnosticLoggingEnabledKey,
581 [NSNumber numberWithInt:WebAllowAllStorage], WebKitStorageBlockingPolicyKey,
582 [NSNumber numberWithBool:NO], WebKitPlugInSnapshottingEnabledPreferenceKey,
585 [NSNumber numberWithBool:NO], WebKitTelephoneParsingEnabledPreferenceKey,
586 [NSNumber numberWithInt:-1], WebKitLayoutIntervalPreferenceKey,
587 [NSNumber numberWithFloat:-1.0f], WebKitMaxParseDurationPreferenceKey,
588 [NSNumber numberWithBool:NO], WebKitAllowMultiElementImplicitFormSubmissionPreferenceKey,
589 [NSNumber numberWithBool:NO], WebKitAlwaysRequestGeolocationPermissionPreferenceKey,
590 [NSNumber numberWithInt:InterpolationLow], WebKitInterpolationQualityPreferenceKey,
591 [NSNumber numberWithBool:YES], WebKitPasswordEchoEnabledPreferenceKey,
592 [NSNumber numberWithFloat:2.0f], WebKitPasswordEchoDurationPreferenceKey,
593 [NSNumber numberWithBool:NO], WebKitNetworkDataUsageTrackingEnabledPreferenceKey,
594 @"", WebKitNetworkInterfaceNamePreferenceKey,
596 #if ENABLE(TEXT_AUTOSIZING)
597 [NSNumber numberWithFloat:Settings::defaultMinimumZoomFontSize()], WebKitMinimumZoomFontSizePreferenceKey,
598 [NSNumber numberWithBool:Settings::defaultTextAutosizingEnabled()], WebKitTextAutosizingEnabledPreferenceKey,
600 [NSNumber numberWithLongLong:ApplicationCacheStorage::noQuota()], WebKitApplicationCacheTotalQuota,
601 [NSNumber numberWithLongLong:ApplicationCacheStorage::noQuota()], WebKitApplicationCacheDefaultOriginQuota,
602 [NSNumber numberWithBool:Settings::isQTKitEnabled()], WebKitQTKitEnabledPreferenceKey,
603 [NSNumber numberWithBool:NO], WebKitHiddenPageDOMTimerThrottlingEnabledPreferenceKey,
604 [NSNumber numberWithBool:NO], WebKitHiddenPageCSSAnimationSuspensionEnabledPreferenceKey,
605 [NSNumber numberWithBool:NO], WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey,
607 [NSNumber numberWithBool:NO], WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey,
608 #if ENABLE(MEDIA_SOURCE)
609 [NSNumber numberWithBool:YES], WebKitMediaSourceEnabledPreferenceKey,
611 #if ENABLE(SERVICE_CONTROLS)
612 [NSNumber numberWithBool:NO], WebKitImageControlsEnabledPreferenceKey,
613 [NSNumber numberWithBool:NO], WebKitServiceControlsEnabledPreferenceKey,
615 [NSNumber numberWithBool:NO], WebKitEnableInheritURIQueryComponentPreferenceKey,
616 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
617 @"~/Library/WebKit/MediaKeys", WebKitMediaKeysStorageDirectoryKey,
619 #if ENABLE(MEDIA_STREAM)
620 [NSNumber numberWithBool:NO], WebKitMockCaptureDevicesEnabledPreferenceKey,
621 [NSNumber numberWithBool:YES], WebKitMediaCaptureRequiresSecureConnectionPreferenceKey,
622 [NSNumber numberWithBool:NO], WebKitUseAVFoundationAudioCapturePreferenceKey,
624 [NSNumber numberWithBool:YES], WebKitShadowDOMEnabledPreferenceKey,
625 [NSNumber numberWithBool:YES], WebKitCustomElementsEnabledPreferenceKey,
626 [NSNumber numberWithBool:YES], WebKitModernMediaControlsEnabledPreferenceKey,
628 [NSNumber numberWithBool:NO], WebKitWebGL2EnabledPreferenceKey,
631 [NSNumber numberWithBool:NO], WebKitWebGPUEnabledPreferenceKey,
633 #if ENABLE(FETCH_API)
634 [NSNumber numberWithBool:YES], WebKitFetchAPIEnabledPreferenceKey,
636 #if ENABLE(STREAMS_API)
637 [NSNumber numberWithBool:NO], WebKitReadableByteStreamAPIEnabledPreferenceKey,
638 [NSNumber numberWithBool:NO], WebKitWritableStreamAPIEnabledPreferenceKey,
640 #if ENABLE(DOWNLOAD_ATTRIBUTE)
641 [NSNumber numberWithBool:NO], WebKitDownloadAttributeEnabledPreferenceKey,
643 [NSNumber numberWithBool:YES], WebKitCSSGridLayoutEnabledPreferenceKey,
644 #if ENABLE(WEB_ANIMATIONS)
645 [NSNumber numberWithBool:NO], WebKitWebAnimationsEnabledPreferenceKey,
649 [NSNumber numberWithBool:NO], WebKitVisualViewportEnabledPreferenceKey,
651 [NSNumber numberWithBool:YES], WebKitVisualViewportEnabledPreferenceKey,
654 [NSNumber numberWithBool:YES], WebKitNeedsStorageAccessFromFileURLsQuirkKey,
655 #if ENABLE(SUBTLE_CRYPTO)
656 [NSNumber numberWithBool:YES], WebKitSubtleCryptoEnabledPreferenceKey,
658 #if ENABLE(MEDIA_STREAM)
659 [NSNumber numberWithBool:NO], WebKitMediaStreamEnabledPreferenceKey,
662 [NSNumber numberWithBool:NO], WebKitPeerConnectionEnabledPreferenceKey,
663 [NSNumber numberWithBool:NO], WebKitWebRTCLegacyAPIEnabledPreferenceKey,
665 #if ENABLE(INTERSECTION_OBSERVER)
666 @NO, WebKitIntersectionObserverEnabledPreferenceKey,
668 @NO, WebKitUserTimingEnabledPreferenceKey,
669 @NO, WebKitResourceTimingEnabledPreferenceKey,
670 @NO, WebKitCredentialManagementEnabledPreferenceKey,
674 // This value shouldn't ever change, which is assumed in the initialization of WebKitPDFDisplayModePreferenceKey above
675 ASSERT(kPDFDisplaySinglePageContinuous == 1);
677 [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
682 [self _updatePrivateBrowsingStateTo:NO];
688 - (NSString *)identifier
690 return _private->identifier.get();
693 - (id)_valueForKey:(NSString *)key
695 NSString *_key = KEY(key);
698 dispatch_sync(_private->readWriteQueue, ^{
699 o = [_private->values.get() objectForKey:_key];
702 id o = [_private->values.get() objectForKey:_key];
706 o = [[NSUserDefaults standardUserDefaults] objectForKey:_key];
707 if (!o && key != _key)
708 o = [[NSUserDefaults standardUserDefaults] objectForKey:key];
712 - (NSString *)_stringValueForKey:(NSString *)key
714 id s = [self _valueForKey:key];
715 return [s isKindOfClass:[NSString class]] ? (NSString *)s : nil;
718 - (void)_setStringValue:(NSString *)value forKey:(NSString *)key
720 if ([[self _stringValueForKey:key] isEqualToString:value])
722 NSString *_key = KEY(key);
724 dispatch_barrier_sync(_private->readWriteQueue, ^{
726 [_private->values.get() setObject:value forKey:_key];
730 if (_private->autosaves)
731 [[NSUserDefaults standardUserDefaults] setObject:value forKey:_key];
732 [self _postPreferencesChangedNotification];
735 - (int)_integerValueForKey:(NSString *)key
737 id o = [self _valueForKey:key];
738 return [o respondsToSelector:@selector(intValue)] ? [o intValue] : 0;
741 - (void)_setIntegerValue:(int)value forKey:(NSString *)key
743 if ([self _integerValueForKey:key] == value)
745 NSString *_key = KEY(key);
747 dispatch_barrier_sync(_private->readWriteQueue, ^{
749 [_private->values.get() _webkit_setInt:value forKey:_key];
753 if (_private->autosaves)
754 [[NSUserDefaults standardUserDefaults] setInteger:value forKey:_key];
755 [self _postPreferencesChangedNotification];
758 - (unsigned int)_unsignedIntValueForKey:(NSString *)key
760 id o = [self _valueForKey:key];
761 return [o respondsToSelector:@selector(unsignedIntValue)] ? [o unsignedIntValue] : 0;
764 - (void)_setUnsignedIntValue:(unsigned int)value forKey:(NSString *)key
766 if ([self _unsignedIntValueForKey:key] == value)
768 NSString *_key = KEY(key);
770 dispatch_barrier_sync(_private->readWriteQueue, ^{
772 [_private->values.get() _webkit_setUnsignedInt:value forKey:_key];
776 if (_private->autosaves)
777 [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInt:value] forKey:_key];
778 [self _postPreferencesChangedNotification];
781 - (float)_floatValueForKey:(NSString *)key
783 id o = [self _valueForKey:key];
784 return [o respondsToSelector:@selector(floatValue)] ? [o floatValue] : 0.0f;
787 - (void)_setFloatValue:(float)value forKey:(NSString *)key
789 if ([self _floatValueForKey:key] == value)
791 NSString *_key = KEY(key);
793 dispatch_barrier_sync(_private->readWriteQueue, ^{
795 [_private->values.get() _webkit_setFloat:value forKey:_key];
799 if (_private->autosaves)
800 [[NSUserDefaults standardUserDefaults] setFloat:value forKey:_key];
801 [self _postPreferencesChangedNotification];
804 - (BOOL)_boolValueForKey:(NSString *)key
806 return [self _integerValueForKey:key] != 0;
809 - (void)_setBoolValue:(BOOL)value forKey:(NSString *)key
811 if ([self _boolValueForKey:key] == value)
813 NSString *_key = KEY(key);
815 dispatch_barrier_sync(_private->readWriteQueue, ^{
817 [_private->values.get() _webkit_setBool:value forKey:_key];
821 if (_private->autosaves)
822 [[NSUserDefaults standardUserDefaults] setBool:value forKey:_key];
823 [self _postPreferencesChangedNotification];
826 - (long long)_longLongValueForKey:(NSString *)key
828 id o = [self _valueForKey:key];
829 return [o respondsToSelector:@selector(longLongValue)] ? [o longLongValue] : 0;
832 - (void)_setLongLongValue:(long long)value forKey:(NSString *)key
834 if ([self _longLongValueForKey:key] == value)
836 NSString *_key = KEY(key);
838 dispatch_barrier_sync(_private->readWriteQueue, ^{
840 [_private->values.get() _webkit_setLongLong:value forKey:_key];
844 if (_private->autosaves)
845 [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithLongLong:value] forKey:_key];
846 [self _postPreferencesChangedNotification];
849 - (unsigned long long)_unsignedLongLongValueForKey:(NSString *)key
851 id o = [self _valueForKey:key];
852 return [o respondsToSelector:@selector(unsignedLongLongValue)] ? [o unsignedLongLongValue] : 0;
855 - (void)_setUnsignedLongLongValue:(unsigned long long)value forKey:(NSString *)key
857 if ([self _unsignedLongLongValueForKey:key] == value)
859 NSString *_key = KEY(key);
861 dispatch_barrier_sync(_private->readWriteQueue, ^{
863 [_private->values.get() _webkit_setUnsignedLongLong:value forKey:_key];
867 if (_private->autosaves)
868 [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedLongLong:value] forKey:_key];
869 [self _postPreferencesChangedNotification];
872 - (NSString *)standardFontFamily
874 return [self _stringValueForKey: WebKitStandardFontPreferenceKey];
877 - (void)setStandardFontFamily:(NSString *)family
879 [self _setStringValue: family forKey: WebKitStandardFontPreferenceKey];
882 - (NSString *)fixedFontFamily
884 return [self _stringValueForKey: WebKitFixedFontPreferenceKey];
887 - (void)setFixedFontFamily:(NSString *)family
889 [self _setStringValue: family forKey: WebKitFixedFontPreferenceKey];
892 - (NSString *)serifFontFamily
894 return [self _stringValueForKey: WebKitSerifFontPreferenceKey];
897 - (void)setSerifFontFamily:(NSString *)family
899 [self _setStringValue: family forKey: WebKitSerifFontPreferenceKey];
902 - (NSString *)sansSerifFontFamily
904 return [self _stringValueForKey: WebKitSansSerifFontPreferenceKey];
907 - (void)setSansSerifFontFamily:(NSString *)family
909 [self _setStringValue: family forKey: WebKitSansSerifFontPreferenceKey];
912 - (NSString *)cursiveFontFamily
914 return [self _stringValueForKey: WebKitCursiveFontPreferenceKey];
917 - (void)setCursiveFontFamily:(NSString *)family
919 [self _setStringValue: family forKey: WebKitCursiveFontPreferenceKey];
922 - (NSString *)fantasyFontFamily
924 return [self _stringValueForKey: WebKitFantasyFontPreferenceKey];
927 - (void)setFantasyFontFamily:(NSString *)family
929 [self _setStringValue: family forKey: WebKitFantasyFontPreferenceKey];
932 - (int)defaultFontSize
934 return [self _integerValueForKey: WebKitDefaultFontSizePreferenceKey];
937 - (void)setDefaultFontSize:(int)size
939 [self _setIntegerValue: size forKey: WebKitDefaultFontSizePreferenceKey];
942 - (int)defaultFixedFontSize
944 return [self _integerValueForKey: WebKitDefaultFixedFontSizePreferenceKey];
947 - (void)setDefaultFixedFontSize:(int)size
949 [self _setIntegerValue: size forKey: WebKitDefaultFixedFontSizePreferenceKey];
952 - (int)minimumFontSize
954 return [self _integerValueForKey: WebKitMinimumFontSizePreferenceKey];
957 - (void)setMinimumFontSize:(int)size
959 [self _setIntegerValue: size forKey: WebKitMinimumFontSizePreferenceKey];
962 - (int)minimumLogicalFontSize
964 return [self _integerValueForKey: WebKitMinimumLogicalFontSizePreferenceKey];
967 - (void)setMinimumLogicalFontSize:(int)size
969 [self _setIntegerValue: size forKey: WebKitMinimumLogicalFontSizePreferenceKey];
972 - (NSString *)defaultTextEncodingName
974 return [self _stringValueForKey: WebKitDefaultTextEncodingNamePreferenceKey];
977 - (void)setDefaultTextEncodingName:(NSString *)encoding
979 [self _setStringValue: encoding forKey: WebKitDefaultTextEncodingNamePreferenceKey];
983 - (BOOL)userStyleSheetEnabled
985 return [self _boolValueForKey: WebKitUserStyleSheetEnabledPreferenceKey];
988 - (void)setUserStyleSheetEnabled:(BOOL)flag
990 [self _setBoolValue: flag forKey: WebKitUserStyleSheetEnabledPreferenceKey];
993 - (NSURL *)userStyleSheetLocation
995 NSString *locationString = [self _stringValueForKey: WebKitUserStyleSheetLocationPreferenceKey];
997 if ([locationString _webkit_looksLikeAbsoluteURL]) {
998 return [NSURL _web_URLWithDataAsString:locationString];
1000 locationString = [locationString stringByExpandingTildeInPath];
1001 return [NSURL fileURLWithPath:locationString];
1005 - (void)setUserStyleSheetLocation:(NSURL *)URL
1007 NSString *locationString;
1009 if ([URL isFileURL]) {
1010 locationString = [[URL path] _web_stringByAbbreviatingWithTildeInPath];
1012 locationString = [URL _web_originalDataAsString];
1015 if (!locationString)
1016 locationString = @"";
1018 [self _setStringValue:locationString forKey: WebKitUserStyleSheetLocationPreferenceKey];
1022 // These methods have had their implementations removed on iOS since it
1023 // is wrong to have such a setting stored in preferences that, when read,
1024 // is applied to all WebViews in a iOS process. Such a design might work
1025 // OK for an application like Safari on Mac OS X, where the only WebViews
1026 // in use display web content in a straightforward manner. However, it is
1027 // wrong for iOS, where WebViews are used for various purposes, like
1028 // text editing, text rendering, and displaying web content.
1030 // I have changed the user style sheet mechanism to be a per-WebView
1031 // setting, rather than a per-process preference. This seems to give the
1032 // behavior we want for iOS.
1034 - (BOOL)userStyleSheetEnabled
1039 - (void)setUserStyleSheetEnabled:(BOOL)flag
1044 - (NSURL *)userStyleSheetLocation
1049 - (void)setUserStyleSheetLocation:(NSURL *)URL
1053 #endif // PLATFORM(IOS)
1056 - (BOOL)shouldPrintBackgrounds
1058 return [self _boolValueForKey: WebKitShouldPrintBackgroundsPreferenceKey];
1061 - (void)setShouldPrintBackgrounds:(BOOL)flag
1063 [self _setBoolValue: flag forKey: WebKitShouldPrintBackgroundsPreferenceKey];
1067 - (BOOL)isJavaEnabled
1069 return [self _boolValueForKey: WebKitJavaEnabledPreferenceKey];
1072 - (void)setJavaEnabled:(BOOL)flag
1074 [self _setBoolValue: flag forKey: WebKitJavaEnabledPreferenceKey];
1077 - (BOOL)isJavaScriptEnabled
1079 return [self _boolValueForKey: WebKitJavaScriptEnabledPreferenceKey];
1082 - (void)setJavaScriptEnabled:(BOOL)flag
1084 [self _setBoolValue: flag forKey: WebKitJavaScriptEnabledPreferenceKey];
1087 - (BOOL)javaScriptCanOpenWindowsAutomatically
1089 return [self _boolValueForKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
1092 - (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag
1094 [self _setBoolValue: flag forKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
1097 - (BOOL)arePlugInsEnabled
1099 return [self _boolValueForKey: WebKitPluginsEnabledPreferenceKey];
1102 - (void)setPlugInsEnabled:(BOOL)flag
1104 [self _setBoolValue: flag forKey: WebKitPluginsEnabledPreferenceKey];
1107 - (BOOL)allowsAnimatedImages
1109 return [self _boolValueForKey: WebKitAllowAnimatedImagesPreferenceKey];
1112 - (void)setAllowsAnimatedImages:(BOOL)flag
1114 [self _setBoolValue: flag forKey: WebKitAllowAnimatedImagesPreferenceKey];
1117 - (BOOL)allowsAnimatedImageLooping
1119 return [self _boolValueForKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
1122 - (void)setAllowsAnimatedImageLooping: (BOOL)flag
1124 [self _setBoolValue: flag forKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
1127 - (void)setLoadsImagesAutomatically: (BOOL)flag
1129 [self _setBoolValue: flag forKey: WebKitDisplayImagesKey];
1132 - (BOOL)loadsImagesAutomatically
1134 return [self _boolValueForKey: WebKitDisplayImagesKey];
1137 - (void)setAutosaves:(BOOL)flag
1139 _private->autosaves = flag;
1144 return _private->autosaves;
1148 - (void)setTabsToLinks:(BOOL)flag
1150 [self _setBoolValue: flag forKey: WebKitTabToLinksPreferenceKey];
1155 return [self _boolValueForKey:WebKitTabToLinksPreferenceKey];
1159 - (void)setPrivateBrowsingEnabled:(BOOL)enabled
1161 [self _updatePrivateBrowsingStateTo:enabled];
1162 [self _setBoolValue:enabled forKey:WebKitPrivateBrowsingEnabledPreferenceKey];
1165 - (BOOL)privateBrowsingEnabled
1167 // Changes to private browsing defaults do not have effect on existing WebPreferences, and must be done through -setPrivateBrowsingEnabled.
1168 // This is needed to accurately track private browsing sessions in the process.
1169 return _private->inPrivateBrowsing;
1172 - (void)_updatePrivateBrowsingStateTo:(BOOL)enabled
1179 if (enabled == _private->inPrivateBrowsing)
1181 if (enabled > _private->inPrivateBrowsing) {
1182 WebFrameNetworkingContext::ensurePrivateBrowsingSession();
1183 ++webPreferencesInstanceCountWithPrivateBrowsingEnabled;
1185 ASSERT(webPreferencesInstanceCountWithPrivateBrowsingEnabled);
1186 --webPreferencesInstanceCountWithPrivateBrowsingEnabled;
1187 if (!webPreferencesInstanceCountWithPrivateBrowsingEnabled)
1188 WebFrameNetworkingContext::destroyPrivateBrowsingSession();
1190 _private->inPrivateBrowsing = enabled;
1193 - (void)setUsesPageCache:(BOOL)usesPageCache
1195 [self _setBoolValue:usesPageCache forKey:WebKitUsesPageCachePreferenceKey];
1198 - (BOOL)usesPageCache
1200 return [self _boolValueForKey:WebKitUsesPageCachePreferenceKey];
1203 - (void)_postCacheModelChangedNotification
1206 if (!pthread_main_np()) {
1207 [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO];
1212 [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesCacheModelChangedInternalNotification object:self userInfo:nil];
1215 - (void)setCacheModel:(WebCacheModel)cacheModel
1217 [self _setIntegerValue:cacheModel forKey:WebKitCacheModelPreferenceKey];
1218 [self setAutomaticallyDetectsCacheModel:NO];
1219 [self _postCacheModelChangedNotification];
1222 - (WebCacheModel)cacheModel
1224 return (WebCacheModel)[self _integerValueForKey:WebKitCacheModelPreferenceKey];
1228 - (void)setSuppressesIncrementalRendering:(BOOL)suppressesIncrementalRendering
1230 [self _setBoolValue:suppressesIncrementalRendering forKey:WebKitSuppressesIncrementalRenderingKey];
1233 - (BOOL)suppressesIncrementalRendering
1235 return [self _boolValueForKey:WebKitSuppressesIncrementalRenderingKey];
1238 - (BOOL)allowsAirPlayForMediaPlayback
1240 #if ENABLE(WIRELESS_TARGET_PLAYBACK)
1241 return [self _boolValueForKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
1247 - (void)setAllowsAirPlayForMediaPlayback:(BOOL)flag
1249 #if ENABLE(WIRELESS_TARGET_PLAYBACK)
1250 [self _setBoolValue:flag forKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
1256 @implementation WebPreferences (WebPrivate)
1258 - (BOOL)isDNSPrefetchingEnabled
1260 return [self _boolValueForKey:WebKitDNSPrefetchingEnabledPreferenceKey];
1263 - (void)setDNSPrefetchingEnabled:(BOOL)flag
1265 [self _setBoolValue:flag forKey:WebKitDNSPrefetchingEnabledPreferenceKey];
1268 - (BOOL)developerExtrasEnabled
1270 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
1271 if ([defaults boolForKey:@"DisableWebKitDeveloperExtras"])
1274 if ([defaults boolForKey:@"WebKitDeveloperExtras"] || [defaults boolForKey:@"IncludeDebugMenu"])
1276 return [self _boolValueForKey:WebKitDeveloperExtrasEnabledPreferenceKey];
1278 return YES; // always enable in debug builds
1282 - (WebKitJavaScriptRuntimeFlags)javaScriptRuntimeFlags
1284 return static_cast<WebKitJavaScriptRuntimeFlags>([self _unsignedIntValueForKey:WebKitJavaScriptRuntimeFlagsPreferenceKey]);
1287 - (void)setJavaScriptRuntimeFlags:(WebKitJavaScriptRuntimeFlags)flags
1289 [self _setUnsignedIntValue:flags forKey:WebKitJavaScriptRuntimeFlagsPreferenceKey];
1292 - (void)setDeveloperExtrasEnabled:(BOOL)flag
1294 [self _setBoolValue:flag forKey:WebKitDeveloperExtrasEnabledPreferenceKey];
1297 - (BOOL)authorAndUserStylesEnabled
1299 return [self _boolValueForKey:WebKitAuthorAndUserStylesEnabledPreferenceKey];
1302 - (void)setAuthorAndUserStylesEnabled:(BOOL)flag
1304 [self _setBoolValue:flag forKey:WebKitAuthorAndUserStylesEnabledPreferenceKey];
1307 // FIXME: applicationChromeMode is no longer needed by ToT, but is still used in Safari 8.
1308 - (BOOL)applicationChromeModeEnabled
1313 - (void)setApplicationChromeModeEnabled:(BOOL)flag
1317 - (BOOL)domTimersThrottlingEnabled
1319 return [self _boolValueForKey:WebKitDOMTimersThrottlingEnabledPreferenceKey];
1322 - (void)setDOMTimersThrottlingEnabled:(BOOL)flag
1324 [self _setBoolValue:flag forKey:WebKitDOMTimersThrottlingEnabledPreferenceKey];
1327 - (BOOL)webArchiveDebugModeEnabled
1329 return [self _boolValueForKey:WebKitWebArchiveDebugModeEnabledPreferenceKey];
1332 - (void)setWebArchiveDebugModeEnabled:(BOOL)flag
1334 [self _setBoolValue:flag forKey:WebKitWebArchiveDebugModeEnabledPreferenceKey];
1337 - (BOOL)localFileContentSniffingEnabled
1339 return [self _boolValueForKey:WebKitLocalFileContentSniffingEnabledPreferenceKey];
1342 - (void)setLocalFileContentSniffingEnabled:(BOOL)flag
1344 [self _setBoolValue:flag forKey:WebKitLocalFileContentSniffingEnabledPreferenceKey];
1347 - (BOOL)offlineWebApplicationCacheEnabled
1349 return [self _boolValueForKey:WebKitOfflineWebApplicationCacheEnabledPreferenceKey];
1352 - (void)setOfflineWebApplicationCacheEnabled:(BOOL)flag
1354 [self _setBoolValue:flag forKey:WebKitOfflineWebApplicationCacheEnabledPreferenceKey];
1357 - (BOOL)zoomsTextOnly
1359 return [self _boolValueForKey:WebKitZoomsTextOnlyPreferenceKey];
1362 - (void)setZoomsTextOnly:(BOOL)flag
1364 [self _setBoolValue:flag forKey:WebKitZoomsTextOnlyPreferenceKey];
1367 - (BOOL)javaScriptCanAccessClipboard
1369 return [self _boolValueForKey:WebKitJavaScriptCanAccessClipboardPreferenceKey];
1372 - (void)setJavaScriptCanAccessClipboard:(BOOL)flag
1374 [self _setBoolValue:flag forKey:WebKitJavaScriptCanAccessClipboardPreferenceKey];
1377 - (BOOL)isXSSAuditorEnabled
1379 return [self _boolValueForKey:WebKitXSSAuditorEnabledPreferenceKey];
1382 - (void)setXSSAuditorEnabled:(BOOL)flag
1384 [self _setBoolValue:flag forKey:WebKitXSSAuditorEnabledPreferenceKey];
1388 - (BOOL)respectStandardStyleKeyEquivalents
1390 return [self _boolValueForKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
1393 - (void)setRespectStandardStyleKeyEquivalents:(BOOL)flag
1395 [self _setBoolValue:flag forKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
1398 - (BOOL)showsURLsInToolTips
1400 return [self _boolValueForKey:WebKitShowsURLsInToolTipsPreferenceKey];
1403 - (void)setShowsURLsInToolTips:(BOOL)flag
1405 [self _setBoolValue:flag forKey:WebKitShowsURLsInToolTipsPreferenceKey];
1408 - (BOOL)showsToolTipOverTruncatedText
1410 return [self _boolValueForKey:WebKitShowsToolTipOverTruncatedTextPreferenceKey];
1413 - (void)setShowsToolTipOverTruncatedText:(BOOL)flag
1415 [self _setBoolValue:flag forKey:WebKitShowsToolTipOverTruncatedTextPreferenceKey];
1418 - (BOOL)textAreasAreResizable
1420 return [self _boolValueForKey: WebKitTextAreasAreResizablePreferenceKey];
1423 - (void)setTextAreasAreResizable:(BOOL)flag
1425 [self _setBoolValue: flag forKey: WebKitTextAreasAreResizablePreferenceKey];
1427 #endif // !PLATFORM(IOS)
1429 - (BOOL)shrinksStandaloneImagesToFit
1431 return [self _boolValueForKey:WebKitShrinksStandaloneImagesToFitPreferenceKey];
1434 - (void)setShrinksStandaloneImagesToFit:(BOOL)flag
1436 [self _setBoolValue:flag forKey:WebKitShrinksStandaloneImagesToFitPreferenceKey];
1439 - (BOOL)automaticallyDetectsCacheModel
1441 return _private->automaticallyDetectsCacheModel;
1444 - (void)setAutomaticallyDetectsCacheModel:(BOOL)automaticallyDetectsCacheModel
1446 _private->automaticallyDetectsCacheModel = automaticallyDetectsCacheModel;
1449 - (BOOL)usesEncodingDetector
1451 return [self _boolValueForKey: WebKitUsesEncodingDetectorPreferenceKey];
1454 - (void)setUsesEncodingDetector:(BOOL)flag
1456 [self _setBoolValue: flag forKey: WebKitUsesEncodingDetectorPreferenceKey];
1459 - (BOOL)isWebSecurityEnabled
1461 return [self _boolValueForKey: WebKitWebSecurityEnabledPreferenceKey];
1464 - (void)setWebSecurityEnabled:(BOOL)flag
1466 [self _setBoolValue: flag forKey: WebKitWebSecurityEnabledPreferenceKey];
1469 - (BOOL)allowUniversalAccessFromFileURLs
1471 return [self _boolValueForKey: WebKitAllowUniversalAccessFromFileURLsPreferenceKey];
1474 - (void)setAllowUniversalAccessFromFileURLs:(BOOL)flag
1476 [self _setBoolValue: flag forKey: WebKitAllowUniversalAccessFromFileURLsPreferenceKey];
1479 - (BOOL)allowFileAccessFromFileURLs
1481 return [self _boolValueForKey: WebKitAllowFileAccessFromFileURLsPreferenceKey];
1484 - (void)setAllowFileAccessFromFileURLs:(BOOL)flag
1486 [self _setBoolValue: flag forKey: WebKitAllowFileAccessFromFileURLsPreferenceKey];
1489 - (BOOL)needsStorageAccessFromFileURLsQuirk
1491 return [self _boolValueForKey: WebKitNeedsStorageAccessFromFileURLsQuirkKey];
1494 -(void)setNeedsStorageAccessFromFileURLsQuirk:(BOOL)flag
1496 [self _setBoolValue: flag forKey: WebKitNeedsStorageAccessFromFileURLsQuirkKey];
1499 - (NSTimeInterval)_backForwardCacheExpirationInterval
1501 return (NSTimeInterval)[self _floatValueForKey:WebKitBackForwardCacheExpirationIntervalKey];
1507 return [self _boolValueForKey:WebKitStandalonePreferenceKey];
1510 - (void)_setStandalone:(BOOL)flag
1512 [self _setBoolValue:flag forKey:WebKitStandalonePreferenceKey];
1515 - (void)_setTelephoneNumberParsingEnabled:(BOOL)flag
1517 [self _setBoolValue:flag forKey:WebKitTelephoneParsingEnabledPreferenceKey];
1520 - (BOOL)_telephoneNumberParsingEnabled
1522 return [self _boolValueForKey:WebKitTelephoneParsingEnabledPreferenceKey];
1526 #if ENABLE(TEXT_AUTOSIZING)
1527 - (void)_setMinimumZoomFontSize:(float)size
1529 [self _setFloatValue:size forKey:WebKitMinimumZoomFontSizePreferenceKey];
1532 - (float)_minimumZoomFontSize
1534 return [self _floatValueForKey:WebKitMinimumZoomFontSizePreferenceKey];
1537 - (void)_setTextAutosizingEnabled:(BOOL)enabled
1539 [self _setBoolValue:enabled forKey:WebKitTextAutosizingEnabledPreferenceKey];
1542 - (BOOL)_textAutosizingEnabled
1544 return [self _boolValueForKey:WebKitTextAutosizingEnabledPreferenceKey];
1549 - (void)_setLayoutInterval:(int)l
1551 [self _setIntegerValue:l forKey:WebKitLayoutIntervalPreferenceKey];
1554 - (int)_layoutInterval
1556 return [self _integerValueForKey:WebKitLayoutIntervalPreferenceKey];
1559 - (void)_setMaxParseDuration:(float)d
1561 [self _setFloatValue:d forKey:WebKitMaxParseDurationPreferenceKey];
1564 - (float)_maxParseDuration
1566 return [self _floatValueForKey:WebKitMaxParseDurationPreferenceKey];
1569 - (void)_setAllowMultiElementImplicitFormSubmission:(BOOL)flag
1571 [self _setBoolValue:flag forKey:WebKitAllowMultiElementImplicitFormSubmissionPreferenceKey];
1574 - (BOOL)_allowMultiElementImplicitFormSubmission
1576 return [self _boolValueForKey:WebKitAllowMultiElementImplicitFormSubmissionPreferenceKey];
1579 - (void)_setAlwaysRequestGeolocationPermission:(BOOL)flag
1581 [self _setBoolValue:flag forKey:WebKitAlwaysRequestGeolocationPermissionPreferenceKey];
1584 - (BOOL)_alwaysRequestGeolocationPermission
1586 return [self _boolValueForKey:WebKitAlwaysRequestGeolocationPermissionPreferenceKey];
1589 - (void)_setAlwaysUseAcceleratedOverflowScroll:(BOOL)flag
1591 [self _setBoolValue:flag forKey:WebKitAlwaysUseAcceleratedOverflowScrollPreferenceKey];
1594 - (BOOL)_alwaysUseAcceleratedOverflowScroll
1596 return [self _boolValueForKey:WebKitAlwaysUseAcceleratedOverflowScrollPreferenceKey];
1599 - (void)_setInterpolationQuality:(int)quality
1601 [self _setIntegerValue:quality forKey:WebKitInterpolationQualityPreferenceKey];
1604 - (int)_interpolationQuality
1606 return [self _integerValueForKey:WebKitInterpolationQualityPreferenceKey];
1609 - (BOOL)_allowPasswordEcho
1611 return [self _boolValueForKey:WebKitPasswordEchoEnabledPreferenceKey];
1614 - (float)_passwordEchoDuration
1616 return [self _floatValueForKey:WebKitPasswordEchoDurationPreferenceKey];
1619 #endif // PLATFORM(IOS)
1622 - (float)PDFScaleFactor
1624 return [self _floatValueForKey:WebKitPDFScaleFactorPreferenceKey];
1627 - (void)setPDFScaleFactor:(float)factor
1629 [self _setFloatValue:factor forKey:WebKitPDFScaleFactorPreferenceKey];
1633 - (int64_t)applicationCacheTotalQuota
1635 return [self _longLongValueForKey:WebKitApplicationCacheTotalQuota];
1638 - (void)setApplicationCacheTotalQuota:(int64_t)quota
1640 [self _setLongLongValue:quota forKey:WebKitApplicationCacheTotalQuota];
1642 // Application Cache Preferences are stored on the global cache storage manager, not in Settings.
1643 [WebApplicationCache setMaximumSize:quota];
1646 - (int64_t)applicationCacheDefaultOriginQuota
1648 return [self _longLongValueForKey:WebKitApplicationCacheDefaultOriginQuota];
1651 - (void)setApplicationCacheDefaultOriginQuota:(int64_t)quota
1653 [self _setLongLongValue:quota forKey:WebKitApplicationCacheDefaultOriginQuota];
1657 - (PDFDisplayMode)PDFDisplayMode
1659 PDFDisplayMode value = static_cast<PDFDisplayMode>([self _integerValueForKey:WebKitPDFDisplayModePreferenceKey]);
1660 if (value != kPDFDisplaySinglePage && value != kPDFDisplaySinglePageContinuous && value != kPDFDisplayTwoUp && value != kPDFDisplayTwoUpContinuous) {
1661 // protect against new modes from future versions of OS X stored in defaults
1662 value = kPDFDisplaySinglePageContinuous;
1667 - (void)setPDFDisplayMode:(PDFDisplayMode)mode
1669 [self _setIntegerValue:mode forKey:WebKitPDFDisplayModePreferenceKey];
1673 - (WebKitEditableLinkBehavior)editableLinkBehavior
1675 WebKitEditableLinkBehavior value = static_cast<WebKitEditableLinkBehavior> ([self _integerValueForKey:WebKitEditableLinkBehaviorPreferenceKey]);
1676 if (value != WebKitEditableLinkDefaultBehavior &&
1677 value != WebKitEditableLinkAlwaysLive &&
1678 value != WebKitEditableLinkNeverLive &&
1679 value != WebKitEditableLinkOnlyLiveWithShiftKey &&
1680 value != WebKitEditableLinkLiveWhenNotFocused) {
1681 // ensure that a valid result is returned
1682 value = WebKitEditableLinkDefaultBehavior;
1688 - (void)setEditableLinkBehavior:(WebKitEditableLinkBehavior)behavior
1690 [self _setIntegerValue:behavior forKey:WebKitEditableLinkBehaviorPreferenceKey];
1693 - (WebTextDirectionSubmenuInclusionBehavior)textDirectionSubmenuInclusionBehavior
1695 WebTextDirectionSubmenuInclusionBehavior value = static_cast<WebTextDirectionSubmenuInclusionBehavior>([self _integerValueForKey:WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey]);
1696 if (value != WebTextDirectionSubmenuNeverIncluded &&
1697 value != WebTextDirectionSubmenuAutomaticallyIncluded &&
1698 value != WebTextDirectionSubmenuAlwaysIncluded) {
1699 // Ensure that a valid result is returned.
1700 value = WebTextDirectionSubmenuNeverIncluded;
1705 - (void)setTextDirectionSubmenuInclusionBehavior:(WebTextDirectionSubmenuInclusionBehavior)behavior
1707 [self _setIntegerValue:behavior forKey:WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey];
1710 - (BOOL)_useSiteSpecificSpoofing
1712 return [self _boolValueForKey:WebKitUseSiteSpecificSpoofingPreferenceKey];
1715 - (void)_setUseSiteSpecificSpoofing:(BOOL)newValue
1717 [self _setBoolValue:newValue forKey:WebKitUseSiteSpecificSpoofingPreferenceKey];
1720 - (BOOL)databasesEnabled
1722 return [self _boolValueForKey:WebKitDatabasesEnabledPreferenceKey];
1725 - (void)setDatabasesEnabled:(BOOL)databasesEnabled
1727 [self _setBoolValue:databasesEnabled forKey:WebKitDatabasesEnabledPreferenceKey];
1731 - (BOOL)storageTrackerEnabled
1733 return [self _boolValueForKey:WebKitStorageTrackerEnabledPreferenceKey];
1736 - (void)setStorageTrackerEnabled:(BOOL)storageTrackerEnabled
1738 [self _setBoolValue:storageTrackerEnabled forKey:WebKitStorageTrackerEnabledPreferenceKey];
1742 - (BOOL)localStorageEnabled
1744 return [self _boolValueForKey:WebKitLocalStorageEnabledPreferenceKey];
1747 - (void)setLocalStorageEnabled:(BOOL)localStorageEnabled
1749 [self _setBoolValue:localStorageEnabled forKey:WebKitLocalStorageEnabledPreferenceKey];
1752 - (BOOL)experimentalNotificationsEnabled
1754 return [self _boolValueForKey:WebKitExperimentalNotificationsEnabledPreferenceKey];
1757 - (void)setExperimentalNotificationsEnabled:(BOOL)experimentalNotificationsEnabled
1759 [self _setBoolValue:experimentalNotificationsEnabled forKey:WebKitExperimentalNotificationsEnabledPreferenceKey];
1762 + (WebPreferences *)_getInstanceForIdentifier:(NSString *)ident
1764 LOG(Encoding, "requesting for %@\n", ident);
1767 return _standardPreferences;
1769 WebPreferences *instance = [webPreferencesInstances objectForKey:[self _concatenateKeyWithIBCreatorID:ident]];
1774 + (void)_setInstance:(WebPreferences *)instance forIdentifier:(NSString *)ident
1776 if (!webPreferencesInstances)
1777 webPreferencesInstances = [[NSMutableDictionary alloc] init];
1779 [webPreferencesInstances setObject:instance forKey:[self _concatenateKeyWithIBCreatorID:ident]];
1780 LOG(Encoding, "recording %p for %@\n", instance, [self _concatenateKeyWithIBCreatorID:ident]);
1784 + (void)_checkLastReferenceForIdentifier:(id)identifier
1786 // FIXME: This won't work at all under garbage collection because retainCount returns a constant.
1787 // We may need to change WebPreferences API so there's an explicit way to end the lifetime of one.
1788 WebPreferences *instance = [webPreferencesInstances objectForKey:identifier];
1789 if ([instance retainCount] == 1)
1790 [webPreferencesInstances removeObjectForKey:identifier];
1793 + (void)_removeReferenceForIdentifier:(NSString *)ident
1796 [self performSelector:@selector(_checkLastReferenceForIdentifier:) withObject:[self _concatenateKeyWithIBCreatorID:ident] afterDelay:0.1];
1799 - (void)_postPreferencesChangedNotification
1802 if (!pthread_main_np()) {
1803 [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO];
1808 [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedInternalNotification object:self userInfo:nil];
1809 [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedNotification object:self userInfo:nil];
1812 - (void)_postPreferencesChangedAPINotification
1814 if (!pthread_main_np()) {
1815 [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO];
1819 [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedNotification object:self userInfo:nil];
1822 + (CFStringEncoding)_systemCFStringEncoding
1824 return WKGetWebDefaultCFStringEncoding();
1827 + (void)_setInitialDefaultTextEncodingToSystemEncoding
1829 [[NSUserDefaults standardUserDefaults] registerDefaults:
1830 [NSDictionary dictionaryWithObject:defaultTextEncodingNameForSystemLanguage() forKey:WebKitDefaultTextEncodingNamePreferenceKey]];
1833 static NSString *classIBCreatorID = nil;
1835 + (void)_setIBCreatorID:(NSString *)string
1837 NSString *old = classIBCreatorID;
1838 classIBCreatorID = [string copy];
1842 + (void)_switchNetworkLoaderToNewTestingSession
1847 NetworkStorageSession::switchToNewTestingSession();
1850 + (void)_clearNetworkLoaderSession
1852 WebCore::deleteAllCookies(NetworkStorageSession::defaultStorageSession());
1855 + (void)_setCurrentNetworkLoaderSessionCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)policy
1857 RetainPtr<CFHTTPCookieStorageRef> cookieStorage = NetworkStorageSession::defaultStorageSession().cookieStorage();
1858 ASSERT(cookieStorage); // Will fail when building without USE(CFURLCONNECTION) and NetworkStorageSession::switchToNewTestingSession() was not called beforehand.
1859 CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage.get(), policy);
1862 - (BOOL)isDOMPasteAllowed
1864 return [self _boolValueForKey:WebKitDOMPasteAllowedPreferenceKey];
1867 - (void)setDOMPasteAllowed:(BOOL)DOMPasteAllowed
1869 [self _setBoolValue:DOMPasteAllowed forKey:WebKitDOMPasteAllowedPreferenceKey];
1872 - (NSString *)_localStorageDatabasePath
1874 return [[self _stringValueForKey:WebKitLocalStorageDatabasePathPreferenceKey] stringByStandardizingPath];
1877 - (void)_setLocalStorageDatabasePath:(NSString *)path
1879 [self _setStringValue:[path stringByStandardizingPath] forKey:WebKitLocalStorageDatabasePathPreferenceKey];
1882 - (NSString *)_ftpDirectoryTemplatePath
1884 return [[self _stringValueForKey:WebKitFTPDirectoryTemplatePath] stringByStandardizingPath];
1887 - (void)_setFTPDirectoryTemplatePath:(NSString *)path
1889 [self _setStringValue:[path stringByStandardizingPath] forKey:WebKitFTPDirectoryTemplatePath];
1892 - (BOOL)_forceFTPDirectoryListings
1894 return [self _boolValueForKey:WebKitForceFTPDirectoryListings];
1897 - (void)_setForceFTPDirectoryListings:(BOOL)force
1899 [self _setBoolValue:force forKey:WebKitForceFTPDirectoryListings];
1902 - (BOOL)acceleratedDrawingEnabled
1904 return [self _boolValueForKey:WebKitAcceleratedDrawingEnabledPreferenceKey];
1907 - (void)setAcceleratedDrawingEnabled:(BOOL)enabled
1909 [self _setBoolValue:enabled forKey:WebKitAcceleratedDrawingEnabledPreferenceKey];
1912 - (BOOL)displayListDrawingEnabled
1914 return [self _boolValueForKey:WebKitDisplayListDrawingEnabledPreferenceKey];
1917 - (void)setDisplayListDrawingEnabled:(BOOL)enabled
1919 [self _setBoolValue:enabled forKey:WebKitDisplayListDrawingEnabledPreferenceKey];
1922 - (BOOL)resourceLoadStatisticsEnabled
1924 return [self _boolValueForKey:WebKitResourceLoadStatisticsEnabledPreferenceKey];
1927 - (void)setResourceLoadStatisticsEnabled:(BOOL)enabled
1929 [self _setBoolValue:enabled forKey:WebKitResourceLoadStatisticsEnabledPreferenceKey];
1932 - (BOOL)largeImageAsyncDecodingEnabled
1934 return [self _boolValueForKey:WebKitLargeImageAsyncDecodingEnabledPreferenceKey];
1937 - (void)setLargeImageAsyncDecodingEnabled:(BOOL)enabled
1939 [self _setBoolValue:enabled forKey:WebKitLargeImageAsyncDecodingEnabledPreferenceKey];
1942 - (BOOL)animatedImageAsyncDecodingEnabled
1944 return [self _boolValueForKey:WebKitAnimatedImageAsyncDecodingEnabledPreferenceKey];
1947 - (void)setAnimatedImageAsyncDecodingEnabled:(BOOL)enabled
1949 [self _setBoolValue:enabled forKey:WebKitAnimatedImageAsyncDecodingEnabledPreferenceKey];
1952 - (BOOL)canvasUsesAcceleratedDrawing
1954 return [self _boolValueForKey:WebKitCanvasUsesAcceleratedDrawingPreferenceKey];
1957 - (void)setCanvasUsesAcceleratedDrawing:(BOOL)enabled
1959 [self _setBoolValue:enabled forKey:WebKitCanvasUsesAcceleratedDrawingPreferenceKey];
1962 - (BOOL)acceleratedCompositingEnabled
1964 return [self _boolValueForKey:WebKitAcceleratedCompositingEnabledPreferenceKey];
1967 - (void)setAcceleratedCompositingEnabled:(BOOL)enabled
1969 [self _setBoolValue:enabled forKey:WebKitAcceleratedCompositingEnabledPreferenceKey];
1972 - (BOOL)showDebugBorders
1974 return [self _boolValueForKey:WebKitShowDebugBordersPreferenceKey];
1977 - (void)setShowDebugBorders:(BOOL)enabled
1979 [self _setBoolValue:enabled forKey:WebKitShowDebugBordersPreferenceKey];
1982 - (BOOL)subpixelAntialiasedLayerTextEnabled
1984 return [self _boolValueForKey:WebKitSubpixelAntialiasedLayerTextEnabledPreferenceKey];
1987 - (void)setSubpixelAntialiasedLayerTextEnabled:(BOOL)enabled
1989 [self _setBoolValue:enabled forKey:WebKitSubpixelAntialiasedLayerTextEnabledPreferenceKey];
1992 - (BOOL)simpleLineLayoutEnabled
1994 return [self _boolValueForKey:WebKitSimpleLineLayoutEnabledPreferenceKey];
1997 - (void)setSimpleLineLayoutEnabled:(BOOL)enabled
1999 [self _setBoolValue:enabled forKey:WebKitSimpleLineLayoutEnabledPreferenceKey];
2002 - (BOOL)simpleLineLayoutDebugBordersEnabled
2004 return [self _boolValueForKey:WebKitSimpleLineLayoutDebugBordersEnabledPreferenceKey];
2007 - (void)setSimpleLineLayoutDebugBordersEnabled:(BOOL)enabled
2009 [self _setBoolValue:enabled forKey:WebKitSimpleLineLayoutDebugBordersEnabledPreferenceKey];
2012 - (BOOL)showRepaintCounter
2014 return [self _boolValueForKey:WebKitShowRepaintCounterPreferenceKey];
2017 - (void)setShowRepaintCounter:(BOOL)enabled
2019 [self _setBoolValue:enabled forKey:WebKitShowRepaintCounterPreferenceKey];
2022 - (BOOL)webAudioEnabled
2024 return [self _boolValueForKey:WebKitWebAudioEnabledPreferenceKey];
2027 - (void)setWebAudioEnabled:(BOOL)enabled
2029 [self _setBoolValue:enabled forKey:WebKitWebAudioEnabledPreferenceKey];
2032 - (BOOL)subpixelCSSOMElementMetricsEnabled
2034 return [self _boolValueForKey:WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey];
2037 - (void)setSubpixelCSSOMElementMetricsEnabled:(BOOL)enabled
2039 [self _setBoolValue:enabled forKey:WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey];
2042 - (BOOL)webGLEnabled
2044 return [self _boolValueForKey:WebKitWebGLEnabledPreferenceKey];
2047 - (void)setWebGLEnabled:(BOOL)enabled
2049 [self _setBoolValue:enabled forKey:WebKitWebGLEnabledPreferenceKey];
2052 - (BOOL)webGL2Enabled
2054 return [self _boolValueForKey:WebKitWebGL2EnabledPreferenceKey];
2057 - (void)setWebGL2Enabled:(BOOL)enabled
2059 [self _setBoolValue:enabled forKey:WebKitWebGL2EnabledPreferenceKey];
2062 - (BOOL)forceSoftwareWebGLRendering
2064 return [self _boolValueForKey:WebKitForceSoftwareWebGLRenderingPreferenceKey];
2067 - (void)setForceSoftwareWebGLRendering:(BOOL)forced
2069 [self _setBoolValue:forced forKey:WebKitForceSoftwareWebGLRenderingPreferenceKey];
2072 - (BOOL)forceLowPowerGPUForWebGL
2074 return [self _boolValueForKey:WebKitForceWebGLUsesLowPowerPreferenceKey];
2077 - (void)setForceWebGLUsesLowPower:(BOOL)forceLowPower
2079 [self _setBoolValue:forceLowPower forKey:WebKitForceWebGLUsesLowPowerPreferenceKey];
2082 - (BOOL)webGPUEnabled
2084 return [self _boolValueForKey:WebKitWebGPUEnabledPreferenceKey];
2087 - (void)setWebGPUEnabled:(BOOL)enabled
2089 [self _setBoolValue:enabled forKey:WebKitWebGPUEnabledPreferenceKey];
2092 - (BOOL)accelerated2dCanvasEnabled
2094 return [self _boolValueForKey:WebKitAccelerated2dCanvasEnabledPreferenceKey];
2097 - (void)setAccelerated2dCanvasEnabled:(BOOL)enabled
2099 [self _setBoolValue:enabled forKey:WebKitAccelerated2dCanvasEnabledPreferenceKey];
2102 - (void)setDiskImageCacheEnabled:(BOOL)enabled
2104 // Staging. Can be removed once there are no more callers.
2107 - (BOOL)isFrameFlatteningEnabled
2109 return [self _boolValueForKey:WebKitFrameFlatteningEnabledPreferenceKey];
2112 - (void)setFrameFlatteningEnabled:(BOOL)flag
2114 [self _setBoolValue:flag forKey:WebKitFrameFlatteningEnabledPreferenceKey];
2117 - (BOOL)isSpatialNavigationEnabled
2119 return [self _boolValueForKey:WebKitSpatialNavigationEnabledPreferenceKey];
2122 - (void)setSpatialNavigationEnabled:(BOOL)flag
2124 [self _setBoolValue:flag forKey:WebKitSpatialNavigationEnabledPreferenceKey];
2127 - (BOOL)paginateDuringLayoutEnabled
2129 return [self _boolValueForKey:WebKitPaginateDuringLayoutEnabledPreferenceKey];
2132 - (void)setPaginateDuringLayoutEnabled:(BOOL)flag
2134 [self _setBoolValue:flag forKey:WebKitPaginateDuringLayoutEnabledPreferenceKey];
2137 - (BOOL)hyperlinkAuditingEnabled
2139 return [self _boolValueForKey:WebKitHyperlinkAuditingEnabledPreferenceKey];
2142 - (void)setHyperlinkAuditingEnabled:(BOOL)flag
2144 [self _setBoolValue:flag forKey:WebKitHyperlinkAuditingEnabledPreferenceKey];
2147 - (BOOL)usePreHTML5ParserQuirks
2149 return [self _boolValueForKey:WebKitUsePreHTML5ParserQuirksKey];
2152 - (void)setUsePreHTML5ParserQuirks:(BOOL)flag
2154 [self _setBoolValue:flag forKey:WebKitUsePreHTML5ParserQuirksKey];
2157 - (void)didRemoveFromWebView
2159 ASSERT(_private->numWebViews);
2160 if (--_private->numWebViews == 0)
2161 [[NSNotificationCenter defaultCenter]
2162 postNotificationName:WebPreferencesRemovedNotification
2167 - (void)willAddToWebView
2169 ++_private->numWebViews;
2172 - (void)_setPreferenceForTestWithValue:(NSString *)value forKey:(NSString *)key
2174 [self _setStringValue:value forKey:key];
2177 - (void)setFullScreenEnabled:(BOOL)flag
2179 [self _setBoolValue:flag forKey:WebKitFullScreenEnabledPreferenceKey];
2182 - (BOOL)fullScreenEnabled
2184 return [self _boolValueForKey:WebKitFullScreenEnabledPreferenceKey];
2187 - (void)setAsynchronousSpellCheckingEnabled:(BOOL)flag
2189 [self _setBoolValue:flag forKey:WebKitAsynchronousSpellCheckingEnabledPreferenceKey];
2192 - (BOOL)asynchronousSpellCheckingEnabled
2194 return [self _boolValueForKey:WebKitAsynchronousSpellCheckingEnabledPreferenceKey];
2197 + (void)setWebKitLinkTimeVersion:(int)version
2199 setWebKitLinkTimeVersion(version);
2202 - (void)setLoadsSiteIconsIgnoringImageLoadingPreference: (BOOL)flag
2204 [self _setBoolValue: flag forKey: WebKitLoadSiteIconsKey];
2207 - (BOOL)loadsSiteIconsIgnoringImageLoadingPreference
2209 return [self _boolValueForKey: WebKitLoadSiteIconsKey];
2212 - (void)setAVFoundationEnabled:(BOOL)flag
2214 [self _setBoolValue:flag forKey:WebKitAVFoundationEnabledKey];
2217 - (BOOL)isAVFoundationEnabled
2219 return [self _boolValueForKey:WebKitAVFoundationEnabledKey];
2222 - (void)setAVFoundationNSURLSessionEnabled:(BOOL)flag
2224 [self _setBoolValue:flag forKey:WebKitAVFoundationNSURLSessionEnabledKey];
2227 - (BOOL)isAVFoundationNSURLSessionEnabled
2229 return [self _boolValueForKey:WebKitAVFoundationNSURLSessionEnabledKey];
2232 - (void)setQTKitEnabled:(BOOL)flag
2234 [self _setBoolValue:flag forKey:WebKitQTKitEnabledPreferenceKey];
2237 - (BOOL)isQTKitEnabled
2239 return [self _boolValueForKey:WebKitQTKitEnabledPreferenceKey];
2242 - (void)setVideoPluginProxyEnabled:(BOOL)flag
2244 // No-op, left for SPI compatibility.
2247 - (BOOL)isVideoPluginProxyEnabled
2252 - (void)setHixie76WebSocketProtocolEnabled:(BOOL)flag
2256 - (BOOL)isHixie76WebSocketProtocolEnabled
2261 - (BOOL)isInheritURIQueryComponentEnabled
2263 return [self _boolValueForKey: WebKitEnableInheritURIQueryComponentPreferenceKey];
2266 - (void)setEnableInheritURIQueryComponent:(BOOL)flag
2268 [self _setBoolValue:flag forKey: WebKitEnableInheritURIQueryComponentPreferenceKey];
2272 - (BOOL)mediaPlaybackAllowsAirPlay
2274 return [self _boolValueForKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
2277 - (void)setMediaPlaybackAllowsAirPlay:(BOOL)flag
2279 [self _setBoolValue:flag forKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
2282 - (unsigned)audioSessionCategoryOverride
2284 return [self _unsignedIntValueForKey:WebKitAudioSessionCategoryOverride];
2287 - (void)setAudioSessionCategoryOverride:(unsigned)override
2289 if (override > AudioSession::AudioProcessing) {
2290 // Clients are passing us OSTypes values from AudioToolbox/AudioSession.h,
2291 // which need to be translated into AudioSession::CategoryType:
2293 case kAudioSessionCategory_AmbientSound:
2294 override = AudioSession::AmbientSound;
2296 case kAudioSessionCategory_SoloAmbientSound:
2297 override = AudioSession::SoloAmbientSound;
2299 case kAudioSessionCategory_MediaPlayback:
2300 override = AudioSession::MediaPlayback;
2302 case kAudioSessionCategory_RecordAudio:
2303 override = AudioSession::RecordAudio;
2305 case kAudioSessionCategory_PlayAndRecord:
2306 override = AudioSession::PlayAndRecord;
2308 case kAudioSessionCategory_AudioProcessing:
2309 override = AudioSession::AudioProcessing;
2312 override = AudioSession::None;
2317 [self _setUnsignedIntValue:override forKey:WebKitAudioSessionCategoryOverride];
2320 - (BOOL)avKitEnabled
2322 return [self _boolValueForKey:WebKitAVKitEnabled];
2325 - (void)setAVKitEnabled:(bool)flag
2328 [self _setBoolValue:flag forKey:WebKitAVKitEnabled];
2332 - (BOOL)networkDataUsageTrackingEnabled
2334 return [self _boolValueForKey:WebKitNetworkDataUsageTrackingEnabledPreferenceKey];
2337 - (void)setNetworkDataUsageTrackingEnabled:(bool)trackingEnabled
2339 [self _setBoolValue:trackingEnabled forKey:WebKitNetworkDataUsageTrackingEnabledPreferenceKey];
2342 - (NSString *)networkInterfaceName
2344 return [self _stringValueForKey:WebKitNetworkInterfaceNamePreferenceKey];
2347 - (void)setNetworkInterfaceName:(NSString *)name
2349 [self _setStringValue:name forKey:WebKitNetworkInterfaceNamePreferenceKey];
2351 #endif // PLATFORM(IOS)
2353 // Deprecated. Use -videoPlaybackRequiresUserGesture and -audioPlaybackRequiresUserGesture instead.
2354 - (BOOL)mediaPlaybackRequiresUserGesture
2356 return [self _boolValueForKey:WebKitRequiresUserGestureForMediaPlaybackPreferenceKey];
2359 // Deprecated. Use -setVideoPlaybackRequiresUserGesture and -setAudioPlaybackRequiresUserGesture instead.
2360 - (void)setMediaPlaybackRequiresUserGesture:(BOOL)flag
2362 [self _setBoolValue:flag forKey:WebKitRequiresUserGestureForMediaPlaybackPreferenceKey];
2365 - (BOOL)videoPlaybackRequiresUserGesture
2367 return [self _boolValueForKey:WebKitRequiresUserGestureForVideoPlaybackPreferenceKey];
2370 - (void)setVideoPlaybackRequiresUserGesture:(BOOL)flag
2372 [self _setBoolValue:flag forKey:WebKitRequiresUserGestureForVideoPlaybackPreferenceKey];
2375 - (BOOL)audioPlaybackRequiresUserGesture
2377 return [self _boolValueForKey:WebKitRequiresUserGestureForAudioPlaybackPreferenceKey];
2380 - (void)setAudioPlaybackRequiresUserGesture:(BOOL)flag
2382 [self _setBoolValue:flag forKey:WebKitRequiresUserGestureForAudioPlaybackPreferenceKey];
2385 - (BOOL)overrideUserGestureRequirementForMainContent
2387 return [self _boolValueForKey:WebKitMainContentUserGestureOverrideEnabledPreferenceKey];
2390 - (void)setOverrideUserGestureRequirementForMainContent:(BOOL)flag
2392 [self _setBoolValue:flag forKey:WebKitMainContentUserGestureOverrideEnabledPreferenceKey];
2395 - (BOOL)mediaPlaybackAllowsInline
2397 return [self _boolValueForKey:WebKitAllowsInlineMediaPlaybackPreferenceKey];
2400 - (void)setMediaPlaybackAllowsInline:(BOOL)flag
2402 [self _setBoolValue:flag forKey:WebKitAllowsInlineMediaPlaybackPreferenceKey];
2405 - (BOOL)inlineMediaPlaybackRequiresPlaysInlineAttribute
2407 return [self _boolValueForKey:WebKitInlineMediaPlaybackRequiresPlaysInlineAttributeKey];
2410 - (void)setInlineMediaPlaybackRequiresPlaysInlineAttribute:(BOOL)flag
2412 [self _setBoolValue:flag forKey:WebKitInlineMediaPlaybackRequiresPlaysInlineAttributeKey];
2415 - (BOOL)invisibleAutoplayNotPermitted
2417 return [self _boolValueForKey:WebKitInvisibleAutoplayNotPermittedKey];
2420 - (void)setInvisibleAutoplayNotPermitted:(BOOL)flag
2422 [self _setBoolValue:flag forKey:WebKitInvisibleAutoplayNotPermittedKey];
2425 - (BOOL)mediaControlsScaleWithPageZoom
2427 return [self _boolValueForKey:WebKitMediaControlsScaleWithPageZoomPreferenceKey];
2430 - (void)setMediaControlsScaleWithPageZoom:(BOOL)flag
2432 [self _setBoolValue:flag forKey:WebKitMediaControlsScaleWithPageZoomPreferenceKey];
2435 - (BOOL)allowsAlternateFullscreen
2437 return [self allowsPictureInPictureMediaPlayback];
2440 - (void)setAllowsAlternateFullscreen:(BOOL)flag
2442 [self setAllowsPictureInPictureMediaPlayback:flag];
2445 - (BOOL)allowsPictureInPictureMediaPlayback
2447 return [self _boolValueForKey:WebKitAllowsPictureInPictureMediaPlaybackPreferenceKey];
2450 - (void)setAllowsPictureInPictureMediaPlayback:(BOOL)flag
2452 [self _setBoolValue:flag forKey:WebKitAllowsPictureInPictureMediaPlaybackPreferenceKey];
2455 - (BOOL)mockScrollbarsEnabled
2457 return [self _boolValueForKey:WebKitMockScrollbarsEnabledPreferenceKey];
2460 - (void)setMockScrollbarsEnabled:(BOOL)flag
2462 [self _setBoolValue:flag forKey:WebKitMockScrollbarsEnabledPreferenceKey];
2465 - (NSString *)pictographFontFamily
2467 return [self _stringValueForKey: WebKitPictographFontPreferenceKey];
2470 - (void)setPictographFontFamily:(NSString *)family
2472 [self _setStringValue: family forKey: WebKitPictographFontPreferenceKey];
2475 - (BOOL)pageCacheSupportsPlugins
2477 return [self _boolValueForKey:WebKitPageCacheSupportsPluginsPreferenceKey];
2480 - (void)setPageCacheSupportsPlugins:(BOOL)flag
2482 [self _setBoolValue:flag forKey:WebKitPageCacheSupportsPluginsPreferenceKey];
2487 - (void)_invalidateCachedPreferences
2489 dispatch_barrier_sync(_private->readWriteQueue, ^{
2490 if (_private->values)
2491 _private->values = adoptNS([[NSMutableDictionary alloc] init]);
2494 [self _updatePrivateBrowsingStateTo:[self privateBrowsingEnabled]];
2496 // Tell any live WebViews to refresh their preferences
2497 [self _postPreferencesChangedNotification];
2500 - (void)_synchronizeWebStoragePolicyWithCookiePolicy
2502 // FIXME: This should be done in clients, WebKit shouldn't be making such policy decisions.
2504 NSHTTPCookieAcceptPolicy cookieAcceptPolicy = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookieAcceptPolicy];
2505 WebStorageBlockingPolicy storageBlockingPolicy;
2506 switch (static_cast<unsigned>(cookieAcceptPolicy)) {
2507 case NSHTTPCookieAcceptPolicyAlways:
2508 storageBlockingPolicy = WebAllowAllStorage;
2510 case NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
2511 case NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
2512 storageBlockingPolicy = WebBlockThirdPartyStorage;
2514 case NSHTTPCookieAcceptPolicyNever:
2515 storageBlockingPolicy = WebBlockAllStorage;
2518 ASSERT_NOT_REACHED();
2519 storageBlockingPolicy = WebBlockAllStorage;
2523 [self setStorageBlockingPolicy:storageBlockingPolicy];
2527 - (void)setBackspaceKeyNavigationEnabled:(BOOL)flag
2529 [self _setBoolValue:flag forKey:WebKitBackspaceKeyNavigationEnabledKey];
2532 - (BOOL)backspaceKeyNavigationEnabled
2534 return [self _boolValueForKey:WebKitBackspaceKeyNavigationEnabledKey];
2537 - (void)setWantsBalancedSetDefersLoadingBehavior:(BOOL)flag
2539 [self _setBoolValue:flag forKey:WebKitWantsBalancedSetDefersLoadingBehaviorKey];
2542 - (BOOL)wantsBalancedSetDefersLoadingBehavior
2544 return [self _boolValueForKey:WebKitWantsBalancedSetDefersLoadingBehaviorKey];
2547 - (void)setShouldDisplaySubtitles:(BOOL)flag
2549 [self _setBoolValue:flag forKey:WebKitShouldDisplaySubtitlesPreferenceKey];
2552 - (BOOL)shouldDisplaySubtitles
2554 return [self _boolValueForKey:WebKitShouldDisplaySubtitlesPreferenceKey];
2557 - (void)setShouldDisplayCaptions:(BOOL)flag
2559 [self _setBoolValue:flag forKey:WebKitShouldDisplayCaptionsPreferenceKey];
2562 - (BOOL)shouldDisplayCaptions
2564 return [self _boolValueForKey:WebKitShouldDisplayCaptionsPreferenceKey];
2567 - (void)setShouldDisplayTextDescriptions:(BOOL)flag
2569 [self _setBoolValue:flag forKey:WebKitShouldDisplayTextDescriptionsPreferenceKey];
2572 - (BOOL)shouldDisplayTextDescriptions
2574 return [self _boolValueForKey:WebKitShouldDisplayTextDescriptionsPreferenceKey];
2577 - (void)setNotificationsEnabled:(BOOL)flag
2579 [self _setBoolValue:flag forKey:WebKitNotificationsEnabledKey];
2582 - (BOOL)notificationsEnabled
2584 return [self _boolValueForKey:WebKitNotificationsEnabledKey];
2587 - (void)setShouldRespectImageOrientation:(BOOL)flag
2589 [self _setBoolValue:flag forKey:WebKitShouldRespectImageOrientationKey];
2592 - (BOOL)shouldRespectImageOrientation
2594 return [self _boolValueForKey:WebKitShouldRespectImageOrientationKey];
2597 - (BOOL)requestAnimationFrameEnabled
2599 return [self _boolValueForKey:WebKitRequestAnimationFrameEnabledPreferenceKey];
2602 - (void)setRequestAnimationFrameEnabled:(BOOL)enabled
2604 [self _setBoolValue:enabled forKey:WebKitRequestAnimationFrameEnabledPreferenceKey];
2607 - (void)setIncrementalRenderingSuppressionTimeoutInSeconds:(NSTimeInterval)timeout
2609 [self _setFloatValue:timeout forKey:WebKitIncrementalRenderingSuppressionTimeoutInSecondsKey];
2612 - (NSTimeInterval)incrementalRenderingSuppressionTimeoutInSeconds
2614 return [self _floatValueForKey:WebKitIncrementalRenderingSuppressionTimeoutInSecondsKey];
2617 - (BOOL)diagnosticLoggingEnabled
2619 return [self _boolValueForKey:WebKitDiagnosticLoggingEnabledKey];
2622 - (void)setDiagnosticLoggingEnabled:(BOOL)enabled
2624 [self _setBoolValue:enabled forKey:WebKitDiagnosticLoggingEnabledKey];
2627 - (void)setStorageBlockingPolicy:(WebStorageBlockingPolicy)storageBlockingPolicy
2630 // We don't want to write the setting out, so we just reset the default instead of storing the new setting.
2631 // FIXME: This code removes any defaults previously registered by client process, which is not appropriate for this method to do.
2632 NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:storageBlockingPolicy] forKey:WebKitStorageBlockingPolicyKey];
2633 [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
2635 [self _setIntegerValue:storageBlockingPolicy forKey:WebKitStorageBlockingPolicyKey];
2639 - (WebStorageBlockingPolicy)storageBlockingPolicy
2641 return static_cast<WebStorageBlockingPolicy>([self _integerValueForKey:WebKitStorageBlockingPolicyKey]);
2644 - (BOOL)plugInSnapshottingEnabled
2646 return [self _boolValueForKey:WebKitPlugInSnapshottingEnabledPreferenceKey];
2649 - (void)setPlugInSnapshottingEnabled:(BOOL)enabled
2651 [self _setBoolValue:enabled forKey:WebKitPlugInSnapshottingEnabledPreferenceKey];
2654 - (BOOL)hiddenPageDOMTimerThrottlingEnabled
2656 return [self _boolValueForKey:WebKitHiddenPageDOMTimerThrottlingEnabledPreferenceKey];
2659 - (void)setHiddenPageDOMTimerThrottlingEnabled:(BOOL)enabled
2661 [self _setBoolValue:enabled forKey:WebKitHiddenPageDOMTimerThrottlingEnabledPreferenceKey];
2664 - (BOOL)hiddenPageCSSAnimationSuspensionEnabled
2666 return [self _boolValueForKey:WebKitHiddenPageCSSAnimationSuspensionEnabledPreferenceKey];
2669 - (void)setHiddenPageCSSAnimationSuspensionEnabled:(BOOL)enabled
2671 [self _setBoolValue:enabled forKey:WebKitHiddenPageCSSAnimationSuspensionEnabledPreferenceKey];
2674 - (BOOL)lowPowerVideoAudioBufferSizeEnabled
2676 return [self _boolValueForKey:WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey];
2679 - (void)setLowPowerVideoAudioBufferSizeEnabled:(BOOL)enabled
2681 [self _setBoolValue:enabled forKey:WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey];
2684 - (BOOL)useLegacyTextAlignPositionedElementBehavior
2686 return [self _boolValueForKey:WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey];
2689 - (void)setUseLegacyTextAlignPositionedElementBehavior:(BOOL)enabled
2691 [self _setBoolValue:enabled forKey:WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey];
2694 - (BOOL)mediaSourceEnabled
2696 return [self _boolValueForKey:WebKitMediaSourceEnabledPreferenceKey];
2699 - (void)setMediaSourceEnabled:(BOOL)enabled
2701 [self _setBoolValue:enabled forKey:WebKitMediaSourceEnabledPreferenceKey];
2704 - (BOOL)imageControlsEnabled
2706 return [self _boolValueForKey:WebKitImageControlsEnabledPreferenceKey];
2709 - (void)setImageControlsEnabled:(BOOL)enabled
2711 [self _setBoolValue:enabled forKey:WebKitImageControlsEnabledPreferenceKey];
2714 - (BOOL)serviceControlsEnabled
2716 return [self _boolValueForKey:WebKitServiceControlsEnabledPreferenceKey];
2719 - (void)setServiceControlsEnabled:(BOOL)enabled
2721 [self _setBoolValue:enabled forKey:WebKitServiceControlsEnabledPreferenceKey];
2724 - (BOOL)gamepadsEnabled
2726 return [self _boolValueForKey:WebKitGamepadsEnabledPreferenceKey];
2729 - (void)setGamepadsEnabled:(BOOL)flag
2731 [self _setBoolValue:flag forKey:WebKitGamepadsEnabledPreferenceKey];
2734 - (BOOL)shouldConvertPositionStyleOnCopy
2736 return [self _boolValueForKey:WebKitShouldConvertPositionStyleOnCopyPreferenceKey];
2739 - (void)setShouldConvertPositionStyleOnCopy:(BOOL)enabled
2741 [self _setBoolValue:enabled forKey:WebKitShouldConvertPositionStyleOnCopyPreferenceKey];
2744 - (NSString *)mediaKeysStorageDirectory
2746 return [[self _stringValueForKey:WebKitMediaKeysStorageDirectoryKey] stringByStandardizingPath];
2749 - (void)setMediaKeysStorageDirectory:(NSString *)directory
2751 [self _setStringValue:directory forKey:WebKitMediaKeysStorageDirectoryKey];
2754 - (BOOL)subtleCryptoEnabled
2756 return [self _boolValueForKey:WebKitSubtleCryptoEnabledPreferenceKey];
2759 - (void)setSubtleCryptoEnabled:(BOOL)flag
2761 [self _setBoolValue:flag forKey:WebKitSubtleCryptoEnabledPreferenceKey];
2764 - (BOOL)mediaStreamEnabled
2766 return [self _boolValueForKey:WebKitMediaStreamEnabledPreferenceKey];
2769 - (void)setMediaStreamEnabled:(BOOL)flag
2771 [self _setBoolValue:flag forKey:WebKitMediaStreamEnabledPreferenceKey];
2774 - (BOOL)peerConnectionEnabled
2776 return [self _boolValueForKey:WebKitPeerConnectionEnabledPreferenceKey];
2779 - (void)setPeerConnectionEnabled:(BOOL)flag
2781 [self _setBoolValue:flag forKey:WebKitPeerConnectionEnabledPreferenceKey];
2784 - (BOOL)webRTCLegacyAPIEnabled
2786 return [self _boolValueForKey:WebKitWebRTCLegacyAPIEnabledPreferenceKey];
2789 - (void)setWebRTCLegacyAPIEnabled:(BOOL)flag
2791 [self _setBoolValue:flag forKey:WebKitWebRTCLegacyAPIEnabledPreferenceKey];
2794 - (BOOL)linkPreloadEnabled
2796 return [self _boolValueForKey:WebKitLinkPreloadEnabledPreferenceKey];
2799 - (void)setLinkPreloadEnabled:(BOOL)flag
2801 [self _setBoolValue:flag forKey:WebKitLinkPreloadEnabledPreferenceKey];
2804 - (void)setMetaRefreshEnabled:(BOOL)enabled
2806 [self setHTTPEquivEnabled:enabled];
2809 - (BOOL)metaRefreshEnabled
2811 return [self httpEquivEnabled];
2814 - (void)setHTTPEquivEnabled:(BOOL)enabled
2816 [self _setBoolValue:enabled forKey:WebKitHTTPEquivEnabledPreferenceKey];
2819 - (BOOL)httpEquivEnabled
2821 return [self _boolValueForKey:WebKitHTTPEquivEnabledPreferenceKey];
2824 - (BOOL)javaScriptMarkupEnabled
2826 return [self _boolValueForKey:WebKitJavaScriptMarkupEnabledPreferenceKey];
2829 - (void)setJavaScriptMarkupEnabled:(BOOL)flag
2831 [self _setBoolValue:flag forKey:WebKitJavaScriptMarkupEnabledPreferenceKey];
2834 - (BOOL)mediaDataLoadsAutomatically
2836 return [self _boolValueForKey:WebKitMediaDataLoadsAutomaticallyPreferenceKey];
2839 - (void)setMediaDataLoadsAutomatically:(BOOL)flag
2841 [self _setBoolValue:flag forKey:WebKitMediaDataLoadsAutomaticallyPreferenceKey];
2844 - (BOOL)attachmentElementEnabled
2846 return [self _boolValueForKey:WebKitAttachmentElementEnabledPreferenceKey];
2849 - (void)setAttachmentElementEnabled:(BOOL)flag
2851 [self _setBoolValue:flag forKey:WebKitAttachmentElementEnabledPreferenceKey];
2854 - (BOOL)allowsInlineMediaPlaybackAfterFullscreen
2856 return [self _boolValueForKey:WebKitAllowsInlineMediaPlaybackAfterFullscreenPreferenceKey];
2859 - (void)setAllowsInlineMediaPlaybackAfterFullscreen:(BOOL)flag
2861 [self _setBoolValue:flag forKey:WebKitAllowsInlineMediaPlaybackAfterFullscreenPreferenceKey];
2864 - (BOOL)mockCaptureDevicesEnabled
2866 return [self _boolValueForKey:WebKitMockCaptureDevicesEnabledPreferenceKey];
2869 - (void)setMockCaptureDevicesEnabled:(BOOL)flag
2871 [self _setBoolValue:flag forKey:WebKitMockCaptureDevicesEnabledPreferenceKey];
2874 - (BOOL)useAVFoundationAudioCapture
2876 return [self _boolValueForKey:WebKitUseAVFoundationAudioCapturePreferenceKey];
2879 - (void)setUseAVFoundationAudioCapture:(BOOL)flag
2881 [self _setBoolValue:flag forKey:WebKitUseAVFoundationAudioCapturePreferenceKey];
2884 - (BOOL)enumeratingAllNetworkInterfacesEnabled
2886 return [self _boolValueForKey:WebKitEnumeratingAllNetworkInterfacesEnabledPreferenceKey];
2889 - (void)setEnumeratingAllNetworkInterfacesEnabled:(BOOL)flag
2891 [self _setBoolValue:flag forKey:WebKitEnumeratingAllNetworkInterfacesEnabledPreferenceKey];
2894 - (BOOL)iceCandidateFilteringEnabled
2896 return [self _boolValueForKey:WebKitICECandidateFilteringEnabledPreferenceKey];
2899 - (void)setIceCandidateFilteringEnabled:(BOOL)flag
2901 [self _setBoolValue:flag forKey:WebKitICECandidateFilteringEnabledPreferenceKey];
2904 - (BOOL)mediaCaptureRequiresSecureConnection
2906 return [self _boolValueForKey:WebKitMediaCaptureRequiresSecureConnectionPreferenceKey];
2909 - (void)setMediaCaptureRequiresSecureConnection:(BOOL)flag
2911 [self _setBoolValue:flag forKey:WebKitMediaCaptureRequiresSecureConnectionPreferenceKey];
2914 - (BOOL)shadowDOMEnabled
2916 return [self _boolValueForKey:WebKitShadowDOMEnabledPreferenceKey];
2919 - (void)setShadowDOMEnabled:(BOOL)flag
2921 [self _setBoolValue:flag forKey:WebKitShadowDOMEnabledPreferenceKey];
2924 - (BOOL)customElementsEnabled
2926 return [self _boolValueForKey:WebKitCustomElementsEnabledPreferenceKey];
2929 - (void)setCustomElementsEnabled:(BOOL)flag
2931 [self _setBoolValue:flag forKey:WebKitCustomElementsEnabledPreferenceKey];
2934 - (BOOL)fetchAPIEnabled
2936 return [self _boolValueForKey:WebKitFetchAPIEnabledPreferenceKey];
2939 - (void)setFetchAPIEnabled:(BOOL)flag
2941 [self _setBoolValue:flag forKey:WebKitFetchAPIEnabledPreferenceKey];
2944 - (BOOL)readableByteStreamAPIEnabled
2946 return [self _boolValueForKey:WebKitReadableByteStreamAPIEnabledPreferenceKey];
2949 - (void)setReadableByteStreamAPIEnabled:(BOOL)flag
2951 [self _setBoolValue:flag forKey:WebKitReadableByteStreamAPIEnabledPreferenceKey];
2954 - (BOOL)writableStreamAPIEnabled
2956 return [self _boolValueForKey:WebKitWritableStreamAPIEnabledPreferenceKey];
2959 - (void)setWritableStreamAPIEnabled:(BOOL)flag
2961 [self _setBoolValue:flag forKey:WebKitWritableStreamAPIEnabledPreferenceKey];
2964 - (BOOL)downloadAttributeEnabled
2966 return [self _boolValueForKey:WebKitDownloadAttributeEnabledPreferenceKey];
2969 - (void)setDownloadAttributeEnabled:(BOOL)flag
2971 [self _setBoolValue:flag forKey:WebKitDownloadAttributeEnabledPreferenceKey];
2974 - (BOOL)isCSSGridLayoutEnabled
2976 return [self _boolValueForKey:WebKitCSSGridLayoutEnabledPreferenceKey];
2979 - (void)setCSSGridLayoutEnabled:(BOOL)flag
2981 [self _setBoolValue:flag forKey:WebKitCSSGridLayoutEnabledPreferenceKey];
2984 - (BOOL)visualViewportEnabled
2986 return [self _boolValueForKey:WebKitVisualViewportEnabledPreferenceKey];
2989 - (void)setVisualViewportEnabled:(BOOL)flag
2991 [self _setBoolValue:flag forKey:WebKitVisualViewportEnabledPreferenceKey];
2994 - (BOOL)webAnimationsEnabled
2996 return [self _boolValueForKey:WebKitWebAnimationsEnabledPreferenceKey];
2999 - (void)setWebAnimationsEnabled:(BOOL)flag
3001 [self _setBoolValue:flag forKey:WebKitWebAnimationsEnabledPreferenceKey];
3004 - (BOOL)modernMediaControlsEnabled
3006 return [self _boolValueForKey:WebKitModernMediaControlsEnabledPreferenceKey];
3009 - (void)setModernMediaControlsEnabled:(BOOL)flag
3011 [self _setBoolValue:flag forKey:WebKitModernMediaControlsEnabledPreferenceKey];
3014 - (BOOL)intersectionObserverEnabled
3016 return [self _boolValueForKey:WebKitIntersectionObserverEnabledPreferenceKey];
3019 - (void)setIntersectionObserverEnabled:(BOOL)flag
3021 [self _setBoolValue:flag forKey:WebKitIntersectionObserverEnabledPreferenceKey];
3024 - (BOOL)userTimingEnabled
3026 return [self _boolValueForKey:WebKitUserTimingEnabledPreferenceKey];
3029 - (void)setUserTimingEnabled:(BOOL)flag
3031 [self _setBoolValue:flag forKey:WebKitUserTimingEnabledPreferenceKey];
3034 - (BOOL)resourceTimingEnabled
3036 return [self _boolValueForKey:WebKitResourceTimingEnabledPreferenceKey];
3039 - (void)setResourceTimingEnabled:(BOOL)flag
3041 [self _setBoolValue:flag forKey:WebKitResourceTimingEnabledPreferenceKey];
3044 - (BOOL)credentialManagementEnabled
3046 return [self _boolValueForKey:WebKitCredentialManagementEnabledPreferenceKey];
3049 - (void)setCredentialManagementEnabled:(BOOL)flag
3051 [self _setBoolValue:flag forKey:WebKitCredentialManagementEnabledPreferenceKey];
3055 - (BOOL)quickLookDocumentSavingEnabled
3057 return [self _boolValueForKey:WebKitQuickLookDocumentSavingPreferenceKey];
3060 - (void)setQuickLookDocumentSavingEnabled:(BOOL)flag
3062 [self _setBoolValue:flag forKey:WebKitQuickLookDocumentSavingPreferenceKey];
3068 @implementation WebPreferences (WebInternal)
3070 + (NSString *)_IBCreatorID
3072 return classIBCreatorID;
3075 + (NSString *)_concatenateKeyWithIBCreatorID:(NSString *)key
3077 NSString *IBCreatorID = [WebPreferences _IBCreatorID];
3080 return [IBCreatorID stringByAppendingString:key];