2 * Copyright (C) 2005, 2006, 2007, 2011, 2012, 2014 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 "WebKitSystemBits.h"
38 #import "WebKitSystemInterface.h"
39 #import "WebKitVersionChecks.h"
40 #import "WebNSDictionaryExtras.h"
41 #import "WebNSURLExtras.h"
42 #import "WebSystemInterface.h"
43 #import <WebCore/ApplicationCacheStorage.h>
44 #import <WebCore/AudioSession.h>
45 #import <WebCore/NetworkStorageSession.h>
46 #import <WebCore/ResourceHandle.h>
47 #import <runtime/InitializeThreading.h>
48 #import <wtf/MainThread.h>
49 #import <wtf/RetainPtr.h>
50 #import <wtf/RunLoop.h>
53 NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain = 3
56 using namespace WebCore;
59 #import <AudioToolbox/AudioSession.h>
60 #import <WebCore/GraphicsContext.h>
61 #import <WebCore/ImageSource.h>
62 #import <WebCore/WebCoreThreadMessage.h>
65 NSString *WebPreferencesChangedNotification = @"WebPreferencesChangedNotification";
66 NSString *WebPreferencesRemovedNotification = @"WebPreferencesRemovedNotification";
67 NSString *WebPreferencesChangedInternalNotification = @"WebPreferencesChangedInternalNotification";
68 NSString *WebPreferencesCacheModelChangedInternalNotification = @"WebPreferencesCacheModelChangedInternalNotification";
70 #define KEY(x) (_private->identifier ? [_private->identifier.get() stringByAppendingString:(x)] : (x))
72 enum { WebPreferencesVersion = 1 };
74 static WebPreferences *_standardPreferences;
75 static NSMutableDictionary *webPreferencesInstances;
77 static unsigned webPreferencesInstanceCountWithPrivateBrowsingEnabled;
79 static bool contains(const char* const array[], int count, const char* item)
84 for (int i = 0; i < count; i++)
85 if (!strcasecmp(array[i], item))
90 static WebCacheModel cacheModelForMainBundle(void)
93 // Apps that probably need the small setting
94 static const char* const documentViewerIDs[] = {
95 "Microsoft/com.microsoft.Messenger",
97 "com.alientechnology.Proteus",
100 "com.barebones.bbedit",
101 "com.barebones.textwrangler",
102 "com.barebones.yojimbo",
103 "com.equinux.iSale4",
104 "com.growl.growlframework",
105 "com.intrarts.PandoraMan",
106 "com.karelia.Sandvox",
107 "com.macromates.textmate",
108 "com.realmacsoftware.rapidweaverpro",
109 "com.red-sweater.marsedit",
110 "com.yahoo.messenger3",
111 "de.codingmonkeys.SubEthaEdit",
117 // Apps that probably need the medium setting
118 static const char* const documentBrowserIDs[] = {
119 "com.apple.Dictionary",
121 "com.apple.dashboard.client",
122 "com.apple.helpviewer",
123 "com.culturedcode.xyle",
124 "com.macrabbit.CSSEdit",
126 "com.ranchero.NetNewsWire",
127 "com.thinkmac.NewsLife",
128 "org.xlife.NewsFire",
129 "uk.co.opencommunity.vienna2",
132 // Apps that probably need the large setting
133 static const char* const primaryWebBrowserIDs[] = {
134 "com.app4mac.KidsBrowser"
135 "com.app4mac.wKiosk",
136 "com.freeverse.bumpercar",
137 "com.omnigroup.OmniWeb5",
138 "com.sunrisebrowser.Sunrise",
139 "net.hmdt-web.Shiira",
142 const char* bundleID = [[[NSBundle mainBundle] bundleIdentifier] UTF8String];
143 if (contains(documentViewerIDs, sizeof(documentViewerIDs) / sizeof(documentViewerIDs[0]), bundleID))
144 return WebCacheModelDocumentViewer;
145 if (contains(documentBrowserIDs, sizeof(documentBrowserIDs) / sizeof(documentBrowserIDs[0]), bundleID))
146 return WebCacheModelDocumentBrowser;
147 if (contains(primaryWebBrowserIDs, sizeof(primaryWebBrowserIDs) / sizeof(primaryWebBrowserIDs[0]), bundleID))
148 return WebCacheModelPrimaryWebBrowser;
150 bool isLinkedAgainstWebKit = WebKitLinkedOnOrAfter(0);
151 if (!isLinkedAgainstWebKit)
152 return WebCacheModelDocumentViewer; // Apps that don't link against WebKit probably aren't meant to be browsers.
155 bool isLegacyApp = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_CACHE_MODEL_API);
157 bool isLegacyApp = false;
160 return WebCacheModelDocumentBrowser; // To avoid regressions in apps that depended on old WebKit's large cache.
162 return WebCacheModelDocumentViewer; // To save memory.
166 @interface WebPreferences ()
167 - (void)_postCacheModelChangedNotification;
170 @interface WebPreferences (WebInternal)
171 + (NSString *)_concatenateKeyWithIBCreatorID:(NSString *)key;
172 + (NSString *)_IBCreatorID;
175 struct WebPreferencesPrivate
178 WebPreferencesPrivate()
179 : inPrivateBrowsing(NO)
181 , automaticallyDetectsCacheModel(NO)
184 , readWriteQueue(dispatch_queue_create("com.apple.WebPreferences.ReadWriteQueue", DISPATCH_QUEUE_CONCURRENT))
190 ~WebPreferencesPrivate()
192 dispatch_release(readWriteQueue);
196 RetainPtr<NSMutableDictionary> values;
197 BOOL inPrivateBrowsing;
198 RetainPtr<NSString> identifier;
200 BOOL automaticallyDetectsCacheModel;
201 unsigned numWebViews;
203 dispatch_queue_t readWriteQueue;
207 @interface WebPreferences (WebForwardDeclarations)
208 // This pseudo-category is needed so these methods can be used from within other category implementations
209 // without being in the public header file.
210 - (BOOL)_boolValueForKey:(NSString *)key;
211 - (void)_setBoolValue:(BOOL)value forKey:(NSString *)key;
212 - (int)_integerValueForKey:(NSString *)key;
213 - (void)_setIntegerValue:(int)value forKey:(NSString *)key;
214 - (float)_floatValueForKey:(NSString *)key;
215 - (void)_setFloatValue:(float)value forKey:(NSString *)key;
216 - (void)_setLongLongValue:(long long)value forKey:(NSString *)key;
217 - (long long)_longLongValueForKey:(NSString *)key;
218 - (void)_setUnsignedLongLongValue:(unsigned long long)value forKey:(NSString *)key;
219 - (unsigned long long)_unsignedLongLongValueForKey:(NSString *)key;
223 @interface WebPreferences ()
224 - (id)initWithIdentifier:(NSString *)anIdentifier sendChangeNotification:(BOOL)sendChangeNotification;
228 @implementation WebPreferences
232 // Create fake identifier
233 static int instanceCount = 1;
234 NSString *fakeIdentifier;
236 // At least ensure that identifier hasn't been already used.
237 fakeIdentifier = [NSString stringWithFormat:@"WebPreferences%d", instanceCount++];
238 while ([[self class] _getInstanceForIdentifier:fakeIdentifier]){
239 fakeIdentifier = [NSString stringWithFormat:@"WebPreferences%d", instanceCount++];
242 return [self initWithIdentifier:fakeIdentifier];
246 - (id)initWithIdentifier:(NSString *)anIdentifier
248 return [self initWithIdentifier:anIdentifier sendChangeNotification:YES];
253 - (instancetype)initWithIdentifier:(NSString *)anIdentifier sendChangeNotification:(BOOL)sendChangeNotification
255 - (instancetype)initWithIdentifier:(NSString *)anIdentifier
258 WebPreferences *instance = [[self class] _getInstanceForIdentifier:anIdentifier];
261 return [instance retain];
268 _private = new WebPreferencesPrivate;
269 _private->values = adoptNS([[NSMutableDictionary alloc] init]);
270 _private->identifier = adoptNS([anIdentifier copy]);
271 _private->automaticallyDetectsCacheModel = YES;
273 [[self class] _setInstance:self forIdentifier:_private->identifier.get()];
275 [self _updatePrivateBrowsingStateTo:[self privateBrowsingEnabled]];
278 if (sendChangeNotification) {
279 [self _postPreferencesChangedNotification];
280 [self _postCacheModelChangedNotification];
283 [self _postPreferencesChangedNotification];
284 [self _postCacheModelChangedNotification];
290 - (instancetype)initWithCoder:(NSCoder *)decoder
296 _private = new WebPreferencesPrivate;
297 _private->automaticallyDetectsCacheModel = YES;
302 if ([decoder allowsKeyedCoding]) {
303 identifier = [decoder decodeObjectForKey:@"Identifier"];
304 values = [decoder decodeObjectForKey:@"Values"];
307 [decoder decodeValueOfObjCType:@encode(int) at:&version];
309 identifier = [decoder decodeObject];
310 values = [decoder decodeObject];
314 if ([identifier isKindOfClass:[NSString class]])
315 _private->identifier = adoptNS([identifier copy]);
316 if ([values isKindOfClass:[NSDictionary class]])
317 _private->values = adoptNS([values mutableCopy]); // ensure dictionary is mutable
319 LOG(Encoding, "Identifier = %@, Values = %@\n", _private->identifier.get(), _private->values.get());
325 // If we load a nib multiple times, or have instances in multiple
326 // nibs with the same name, the first guy up wins.
327 WebPreferences *instance = [[self class] _getInstanceForIdentifier:_private->identifier.get()];
330 self = [instance retain];
332 [[self class] _setInstance:self forIdentifier:_private->identifier.get()];
333 [self _updatePrivateBrowsingStateTo:[self privateBrowsingEnabled]];
339 - (void)encodeWithCoder:(NSCoder *)encoder
341 if ([encoder allowsKeyedCoding]){
342 [encoder encodeObject:_private->identifier.get() forKey:@"Identifier"];
344 dispatch_sync(_private->readWriteQueue, ^{
346 [encoder encodeObject:_private->values.get() forKey:@"Values"];
347 LOG (Encoding, "Identifier = %@, Values = %@\n", _private->identifier.get(), _private->values.get());
353 int version = WebPreferencesVersion;
354 [encoder encodeValueOfObjCType:@encode(int) at:&version];
355 [encoder encodeObject:_private->identifier.get()];
357 dispatch_sync(_private->readWriteQueue, ^{
359 [encoder encodeObject:_private->values.get()];
366 + (WebPreferences *)standardPreferences
369 if (_standardPreferences == nil) {
370 _standardPreferences = [[WebPreferences alloc] initWithIdentifier:nil];
371 [_standardPreferences setAutosaves:YES];
374 // FIXME: This check is necessary to avoid recursion (see <rdar://problem/9564337>), but it also makes _standardPreferences construction not thread safe.
375 if (_standardPreferences)
376 return _standardPreferences;
378 static dispatch_once_t pred;
379 dispatch_once(&pred, ^{
380 _standardPreferences = [[WebPreferences alloc] initWithIdentifier:nil sendChangeNotification:NO];
381 [_standardPreferences _postPreferencesChangedNotification];
382 [_standardPreferences setAutosaves:YES];
386 return _standardPreferences;
389 // if we ever have more than one WebPreferences object, this would move to init
393 JSC::initializeThreading();
394 WTF::initializeMainThreadToProcessMainThread();
395 RunLoop::initializeMainRunLoop();
397 InitWebCoreSystemInterface();
399 NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
400 @"Times", WebKitStandardFontPreferenceKey,
401 @"Courier", WebKitFixedFontPreferenceKey,
402 @"Times", WebKitSerifFontPreferenceKey,
403 @"Helvetica", WebKitSansSerifFontPreferenceKey,
405 @"Apple Chancery", WebKitCursiveFontPreferenceKey,
407 @"Snell Roundhand", WebKitCursiveFontPreferenceKey,
409 @"Papyrus", WebKitFantasyFontPreferenceKey,
411 @"AppleColorEmoji", WebKitPictographFontPreferenceKey,
413 @"Apple Color Emoji", WebKitPictographFontPreferenceKey,
415 @"0", WebKitMinimumFontSizePreferenceKey,
416 @"9", WebKitMinimumLogicalFontSizePreferenceKey,
417 @"16", WebKitDefaultFontSizePreferenceKey,
418 @"13", WebKitDefaultFixedFontSizePreferenceKey,
419 @"ISO-8859-1", WebKitDefaultTextEncodingNamePreferenceKey,
420 [NSNumber numberWithBool:NO], WebKitUsesEncodingDetectorPreferenceKey,
421 [NSNumber numberWithBool:NO], WebKitUserStyleSheetEnabledPreferenceKey,
422 @"", WebKitUserStyleSheetLocationPreferenceKey,
424 [NSNumber numberWithBool:NO], WebKitShouldPrintBackgroundsPreferenceKey,
425 [NSNumber numberWithBool:NO], WebKitTextAreasAreResizablePreferenceKey,
427 [NSNumber numberWithBool:NO], WebKitShrinksStandaloneImagesToFitPreferenceKey,
429 [NSNumber numberWithBool:YES], WebKitJavaEnabledPreferenceKey,
431 [NSNumber numberWithBool:YES], WebKitJavaScriptEnabledPreferenceKey,
432 [NSNumber numberWithBool:YES], WebKitWebSecurityEnabledPreferenceKey,
433 [NSNumber numberWithBool:YES], WebKitAllowUniversalAccessFromFileURLsPreferenceKey,
434 [NSNumber numberWithBool:YES], WebKitAllowFileAccessFromFileURLsPreferenceKey,
436 [NSNumber numberWithBool:NO], WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey,
438 [NSNumber numberWithBool:YES], WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey,
440 [NSNumber numberWithBool:YES], WebKitPluginsEnabledPreferenceKey,
441 [NSNumber numberWithBool:YES], WebKitDatabasesEnabledPreferenceKey,
443 [NSNumber numberWithBool:NO], WebKitStorageTrackerEnabledPreferenceKey,
445 [NSNumber numberWithBool:YES], WebKitLocalStorageEnabledPreferenceKey,
446 [NSNumber numberWithBool:NO], WebKitExperimentalNotificationsEnabledPreferenceKey,
447 [NSNumber numberWithBool:YES], WebKitAllowAnimatedImagesPreferenceKey,
448 [NSNumber numberWithBool:YES], WebKitAllowAnimatedImageLoopingPreferenceKey,
449 [NSNumber numberWithBool:YES], WebKitDisplayImagesKey,
450 [NSNumber numberWithBool:NO], WebKitLoadSiteIconsKey,
451 @"1800", WebKitBackForwardCacheExpirationIntervalKey,
453 [NSNumber numberWithBool:NO], WebKitTabToLinksPreferenceKey,
455 [NSNumber numberWithBool:NO], WebKitPrivateBrowsingEnabledPreferenceKey,
457 [NSNumber numberWithBool:NO], WebKitRespectStandardStyleKeyEquivalentsPreferenceKey,
458 [NSNumber numberWithBool:NO], WebKitShowsURLsInToolTipsPreferenceKey,
459 [NSNumber numberWithBool:NO], WebKitShowsToolTipOverTruncatedTextPreferenceKey,
460 @"1", WebKitPDFDisplayModePreferenceKey,
461 @"0", WebKitPDFScaleFactorPreferenceKey,
463 @"0", WebKitUseSiteSpecificSpoofingPreferenceKey,
464 [NSNumber numberWithInt:WebKitEditableLinkDefaultBehavior], WebKitEditableLinkBehaviorPreferenceKey,
466 [NSNumber numberWithInt:WebTextDirectionSubmenuAutomaticallyIncluded],
467 WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey,
468 [NSNumber numberWithBool:NO], WebKitDOMPasteAllowedPreferenceKey,
470 [NSNumber numberWithBool:YES], WebKitUsesPageCachePreferenceKey,
471 [NSNumber numberWithInt:cacheModelForMainBundle()], WebKitCacheModelPreferenceKey,
472 [NSNumber numberWithBool:YES], WebKitPageCacheSupportsPluginsPreferenceKey,
473 [NSNumber numberWithBool:NO], WebKitDeveloperExtrasEnabledPreferenceKey,
474 [NSNumber numberWithBool:NO], WebKitJavaScriptExperimentsEnabledPreferenceKey,
475 [NSNumber numberWithBool:YES], WebKitAuthorAndUserStylesEnabledPreferenceKey,
476 [NSNumber numberWithBool:NO], WebKitApplicationChromeModeEnabledPreferenceKey,
477 [NSNumber numberWithBool:NO], WebKitWebArchiveDebugModeEnabledPreferenceKey,
478 [NSNumber numberWithBool:NO], WebKitLocalFileContentSniffingEnabledPreferenceKey,
479 [NSNumber numberWithBool:NO], WebKitOfflineWebApplicationCacheEnabledPreferenceKey,
480 [NSNumber numberWithBool:YES], WebKitZoomsTextOnlyPreferenceKey,
481 [NSNumber numberWithBool:NO], WebKitJavaScriptCanAccessClipboardPreferenceKey,
482 [NSNumber numberWithBool:YES], WebKitXSSAuditorEnabledPreferenceKey,
483 [NSNumber numberWithBool:YES], WebKitAcceleratedCompositingEnabledPreferenceKey,
484 [NSNumber numberWithBool:YES], WebKitCSSRegionsEnabledPreferenceKey,
485 [NSNumber numberWithBool:YES], WebKitCSSCompositingEnabledPreferenceKey,
486 #if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR)
487 [NSNumber numberWithBool:YES], WebKitAcceleratedDrawingEnabledPreferenceKey,
488 [NSNumber numberWithBool:YES], WebKitCanvasUsesAcceleratedDrawingPreferenceKey,
490 [NSNumber numberWithBool:NO], WebKitAcceleratedDrawingEnabledPreferenceKey,
491 [NSNumber numberWithBool:NO], WebKitCanvasUsesAcceleratedDrawingPreferenceKey,
493 [NSNumber numberWithBool:NO], WebKitShowDebugBordersPreferenceKey,
494 [NSNumber numberWithBool:NO], WebKitShowRepaintCounterPreferenceKey,
495 [NSNumber numberWithBool:YES], WebKitWebGLEnabledPreferenceKey,
496 [NSNumber numberWithBool:NO], WebKitMultithreadedWebGLEnabledPreferenceKey,
497 [NSNumber numberWithBool:NO], WebKitForceSoftwareWebGLRenderingPreferenceKey,
498 [NSNumber numberWithBool:NO], WebKitAccelerated2dCanvasEnabledPreferenceKey,
499 [NSNumber numberWithBool:YES], WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey,
501 [NSNumber numberWithBool:YES], WebKitFrameFlatteningEnabledPreferenceKey,
503 [NSNumber numberWithBool:NO], WebKitFrameFlatteningEnabledPreferenceKey,
505 [NSNumber numberWithBool:NO], WebKitSpatialNavigationEnabledPreferenceKey,
506 [NSNumber numberWithBool:NO], WebKitDNSPrefetchingEnabledPreferenceKey,
507 [NSNumber numberWithBool:NO], WebKitFullScreenEnabledPreferenceKey,
508 [NSNumber numberWithBool:NO], WebKitAsynchronousSpellCheckingEnabledPreferenceKey,
509 [NSNumber numberWithBool:YES], WebKitHyperlinkAuditingEnabledPreferenceKey,
510 [NSNumber numberWithBool:NO], WebKitUsePreHTML5ParserQuirksKey,
511 [NSNumber numberWithBool:YES], WebKitAVFoundationEnabledKey,
512 [NSNumber numberWithBool:NO], WebKitSuppressesIncrementalRenderingKey,
514 [NSNumber numberWithBool:NO], WebKitMediaPlaybackRequiresUserGesturePreferenceKey,
515 [NSNumber numberWithBool:YES], WebKitMediaPlaybackAllowsInlinePreferenceKey,
516 [NSNumber numberWithBool:NO], WebKitWebAudioEnabledPreferenceKey,
517 [NSNumber numberWithBool:YES], WebKitBackspaceKeyNavigationEnabledKey,
518 [NSNumber numberWithBool:NO], WebKitShouldDisplaySubtitlesPreferenceKey,
519 [NSNumber numberWithBool:NO], WebKitShouldDisplayCaptionsPreferenceKey,
520 [NSNumber numberWithBool:NO], WebKitShouldDisplayTextDescriptionsPreferenceKey,
521 [NSNumber numberWithBool:YES], WebKitNotificationsEnabledKey,
522 [NSNumber numberWithBool:NO], WebKitShouldRespectImageOrientationKey,
524 [NSNumber numberWithBool:YES], WebKitMediaPlaybackRequiresUserGesturePreferenceKey,
525 [NSNumber numberWithBool:NO], WebKitMediaPlaybackAllowsInlinePreferenceKey,
526 [NSNumber numberWithBool:YES], WebKitMediaPlaybackAllowsAirPlayPreferenceKey,
527 [NSNumber numberWithUnsignedInt:AudioSession::None], WebKitAudioSessionCategoryOverride,
528 [NSNumber numberWithBool:YES], WebKitAVKitEnabled,
529 [NSNumber numberWithLongLong:WebCore::ApplicationCacheStorage::noQuota()], WebKitApplicationCacheTotalQuota,
531 // Per-Origin Quota on iOS is 25MB. When the quota is reached for a particular origin
532 // the quota for that origin can be increased. See also webView:exceededApplicationCacheOriginQuotaForSecurityOrigin:totalSpaceNeeded in WebUI/WebUIDelegate.m.
533 [NSNumber numberWithLongLong:(25 * 1024 * 1024)], WebKitApplicationCacheDefaultOriginQuota,
535 // Enable WebAudio by default in all iOS UIWebViews
536 [NSNumber numberWithBool:YES], WebKitWebAudioEnabledPreferenceKey,
538 [NSNumber numberWithBool:YES], WebKitShouldRespectImageOrientationKey,
539 #endif // PLATFORM(IOS)
540 [NSNumber numberWithBool:YES], WebKitRequestAnimationFrameEnabledPreferenceKey,
541 [NSNumber numberWithBool:NO], WebKitWantsBalancedSetDefersLoadingBehaviorKey,
542 [NSNumber numberWithBool:NO], WebKitDiagnosticLoggingEnabledKey,
543 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
544 [NSNumber numberWithBool:NO],
546 [NSNumber numberWithBool:YES],
548 WebKitScreenFontSubstitutionEnabledKey,
549 [NSNumber numberWithInt:WebAllowAllStorage], WebKitStorageBlockingPolicyKey,
550 [NSNumber numberWithBool:NO], WebKitPlugInSnapshottingEnabledPreferenceKey,
553 [NSNumber numberWithBool:NO], WebKitTelephoneParsingEnabledPreferenceKey,
554 [NSNumber numberWithInt:-1], WebKitLayoutIntervalPreferenceKey,
555 [NSNumber numberWithFloat:-1.0f], WebKitMaxParseDurationPreferenceKey,
556 [NSNumber numberWithBool:NO], WebKitAllowMultiElementImplicitFormSubmissionPreferenceKey,
557 [NSNumber numberWithInt:-1], WebKitPageCacheSizePreferenceKey,
558 [NSNumber numberWithInt:-1], WebKitObjectCacheSizePreferenceKey,
559 [NSNumber numberWithInt:-1], WebKitNSURLMemoryCacheSizePreferenceKey,
560 [NSNumber numberWithInt:-1], WebKitNSURLDiskCacheSizePreferenceKey,
561 [NSNumber numberWithBool:NO], WebKitAlwaysRequestGeolocationPermissionPreferenceKey,
562 [NSNumber numberWithInt:InterpolationLow], WebKitInterpolationQualityPreferenceKey,
563 [NSNumber numberWithBool:YES], WebKitPasswordEchoEnabledPreferenceKey,
564 [NSNumber numberWithFloat:2.0f], WebKitPasswordEchoDurationPreferenceKey,
565 [NSNumber numberWithBool:NO], WebKitNetworkDataUsageTrackingEnabledPreferenceKey,
566 @"", WebKitNetworkInterfaceNamePreferenceKey,
568 #if ENABLE(IOS_TEXT_AUTOSIZING)
569 [NSNumber numberWithFloat:WKGetMinimumZoomFontSize()], WebKitMinimumZoomFontSizePreferenceKey,
571 #if ENABLE(DISK_IMAGE_CACHE) && PLATFORM(IOS)
572 [NSNumber numberWithBool:YES], WebKitDiskImageCacheEnabledPreferenceKey,
573 [NSNumber numberWithUnsignedInt:(100 * 1024)], WebKitDiskImageCacheMinimumImageSizePreferenceKey,
574 [NSNumber numberWithUnsignedInt:(100 * 1024 * 1024)], WebKitDiskImageCacheMaximumCacheSizePreferenceKey,
576 [NSNumber numberWithLongLong:ApplicationCacheStorage::noQuota()], WebKitApplicationCacheTotalQuota,
577 [NSNumber numberWithLongLong:ApplicationCacheStorage::noQuota()], WebKitApplicationCacheDefaultOriginQuota,
578 [NSNumber numberWithBool:YES], WebKitQTKitEnabledPreferenceKey,
579 [NSNumber numberWithBool:NO], WebKitHiddenPageDOMTimerThrottlingEnabledPreferenceKey,
580 [NSNumber numberWithBool:NO], WebKitHiddenPageCSSAnimationSuspensionEnabledPreferenceKey,
581 [NSNumber numberWithBool:NO], WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey,
583 [NSNumber numberWithBool:NO], WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey,
584 #if ENABLE(MEDIA_SOURCE)
585 [NSNumber numberWithBool:YES], WebKitMediaSourceEnabledPreferenceKey,
587 #if ENABLE(SERVICE_CONTROLS)
588 [NSNumber numberWithBool:NO], WebKitImageControlsEnabledPreferenceKey,
590 [NSNumber numberWithBool:NO], WebKitEnableInheritURIQueryComponentPreferenceKey,
594 // This value shouldn't ever change, which is assumed in the initialization of WebKitPDFDisplayModePreferenceKey above
595 ASSERT(kPDFDisplaySinglePageContinuous == 1);
597 [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
602 [self _updatePrivateBrowsingStateTo:NO];
608 - (NSString *)identifier
610 return _private->identifier.get();
613 - (id)_valueForKey:(NSString *)key
615 NSString *_key = KEY(key);
618 dispatch_sync(_private->readWriteQueue, ^{
619 o = [_private->values.get() objectForKey:_key];
622 id o = [_private->values.get() objectForKey:_key];
626 o = [[NSUserDefaults standardUserDefaults] objectForKey:_key];
627 if (!o && key != _key)
628 o = [[NSUserDefaults standardUserDefaults] objectForKey:key];
632 - (NSString *)_stringValueForKey:(NSString *)key
634 id s = [self _valueForKey:key];
635 return [s isKindOfClass:[NSString class]] ? (NSString *)s : nil;
638 - (void)_setStringValue:(NSString *)value forKey:(NSString *)key
640 if ([[self _stringValueForKey:key] isEqualToString:value])
642 NSString *_key = KEY(key);
644 dispatch_barrier_sync(_private->readWriteQueue, ^{
646 [_private->values.get() setObject:value forKey:_key];
650 if (_private->autosaves)
651 [[NSUserDefaults standardUserDefaults] setObject:value forKey:_key];
652 [self _postPreferencesChangedNotification];
655 - (int)_integerValueForKey:(NSString *)key
657 id o = [self _valueForKey:key];
658 return [o respondsToSelector:@selector(intValue)] ? [o intValue] : 0;
661 - (void)_setIntegerValue:(int)value forKey:(NSString *)key
663 if ([self _integerValueForKey:key] == value)
665 NSString *_key = KEY(key);
667 dispatch_barrier_sync(_private->readWriteQueue, ^{
669 [_private->values.get() _webkit_setInt:value forKey:_key];
673 if (_private->autosaves)
674 [[NSUserDefaults standardUserDefaults] setInteger:value forKey:_key];
675 [self _postPreferencesChangedNotification];
679 - (unsigned int)_unsignedIntValueForKey:(NSString *)key
681 id o = [self _valueForKey:key];
682 return [o respondsToSelector:@selector(unsignedIntValue)] ? [o unsignedIntValue] : 0;
685 - (void)_setUnsignedIntValue:(unsigned int)value forKey:(NSString *)key
686 { if ([self _unsignedIntValueForKey:key] == value)
688 NSString *_key = KEY(key);
689 dispatch_barrier_sync(_private->readWriteQueue, ^{
690 [_private->values.get() _webkit_setUnsignedInt:value forKey:_key];
692 if (_private->autosaves)
693 [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInt:value] forKey:_key];
694 [self _postPreferencesChangedNotification];
698 - (float)_floatValueForKey:(NSString *)key
700 id o = [self _valueForKey:key];
701 return [o respondsToSelector:@selector(floatValue)] ? [o floatValue] : 0.0f;
704 - (void)_setFloatValue:(float)value forKey:(NSString *)key
706 if ([self _floatValueForKey:key] == value)
708 NSString *_key = KEY(key);
710 dispatch_barrier_sync(_private->readWriteQueue, ^{
712 [_private->values.get() _webkit_setFloat:value forKey:_key];
716 if (_private->autosaves)
717 [[NSUserDefaults standardUserDefaults] setFloat:value forKey:_key];
718 [self _postPreferencesChangedNotification];
721 - (BOOL)_boolValueForKey:(NSString *)key
723 return [self _integerValueForKey:key] != 0;
726 - (void)_setBoolValue:(BOOL)value forKey:(NSString *)key
728 if ([self _boolValueForKey:key] == value)
730 NSString *_key = KEY(key);
732 dispatch_barrier_sync(_private->readWriteQueue, ^{
734 [_private->values.get() _webkit_setBool:value forKey:_key];
738 if (_private->autosaves)
739 [[NSUserDefaults standardUserDefaults] setBool:value forKey:_key];
740 [self _postPreferencesChangedNotification];
743 - (long long)_longLongValueForKey:(NSString *)key
745 id o = [self _valueForKey:key];
746 return [o respondsToSelector:@selector(longLongValue)] ? [o longLongValue] : 0;
749 - (void)_setLongLongValue:(long long)value forKey:(NSString *)key
751 if ([self _longLongValueForKey:key] == value)
753 NSString *_key = KEY(key);
755 dispatch_barrier_sync(_private->readWriteQueue, ^{
757 [_private->values.get() _webkit_setLongLong:value forKey:_key];
761 if (_private->autosaves)
762 [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithLongLong:value] forKey:_key];
763 [self _postPreferencesChangedNotification];
766 - (unsigned long long)_unsignedLongLongValueForKey:(NSString *)key
768 id o = [self _valueForKey:key];
769 return [o respondsToSelector:@selector(unsignedLongLongValue)] ? [o unsignedLongLongValue] : 0;
772 - (void)_setUnsignedLongLongValue:(unsigned long long)value forKey:(NSString *)key
774 if ([self _unsignedLongLongValueForKey:key] == value)
776 NSString *_key = KEY(key);
778 dispatch_barrier_sync(_private->readWriteQueue, ^{
780 [_private->values.get() _webkit_setUnsignedLongLong:value forKey:_key];
784 if (_private->autosaves)
785 [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedLongLong:value] forKey:_key];
786 [self _postPreferencesChangedNotification];
789 - (NSString *)standardFontFamily
791 return [self _stringValueForKey: WebKitStandardFontPreferenceKey];
794 - (void)setStandardFontFamily:(NSString *)family
796 [self _setStringValue: family forKey: WebKitStandardFontPreferenceKey];
799 - (NSString *)fixedFontFamily
801 return [self _stringValueForKey: WebKitFixedFontPreferenceKey];
804 - (void)setFixedFontFamily:(NSString *)family
806 [self _setStringValue: family forKey: WebKitFixedFontPreferenceKey];
809 - (NSString *)serifFontFamily
811 return [self _stringValueForKey: WebKitSerifFontPreferenceKey];
814 - (void)setSerifFontFamily:(NSString *)family
816 [self _setStringValue: family forKey: WebKitSerifFontPreferenceKey];
819 - (NSString *)sansSerifFontFamily
821 return [self _stringValueForKey: WebKitSansSerifFontPreferenceKey];
824 - (void)setSansSerifFontFamily:(NSString *)family
826 [self _setStringValue: family forKey: WebKitSansSerifFontPreferenceKey];
829 - (NSString *)cursiveFontFamily
831 return [self _stringValueForKey: WebKitCursiveFontPreferenceKey];
834 - (void)setCursiveFontFamily:(NSString *)family
836 [self _setStringValue: family forKey: WebKitCursiveFontPreferenceKey];
839 - (NSString *)fantasyFontFamily
841 return [self _stringValueForKey: WebKitFantasyFontPreferenceKey];
844 - (void)setFantasyFontFamily:(NSString *)family
846 [self _setStringValue: family forKey: WebKitFantasyFontPreferenceKey];
849 - (int)defaultFontSize
851 return [self _integerValueForKey: WebKitDefaultFontSizePreferenceKey];
854 - (void)setDefaultFontSize:(int)size
856 [self _setIntegerValue: size forKey: WebKitDefaultFontSizePreferenceKey];
859 - (int)defaultFixedFontSize
861 return [self _integerValueForKey: WebKitDefaultFixedFontSizePreferenceKey];
864 - (void)setDefaultFixedFontSize:(int)size
866 [self _setIntegerValue: size forKey: WebKitDefaultFixedFontSizePreferenceKey];
869 - (int)minimumFontSize
871 return [self _integerValueForKey: WebKitMinimumFontSizePreferenceKey];
874 - (void)setMinimumFontSize:(int)size
876 [self _setIntegerValue: size forKey: WebKitMinimumFontSizePreferenceKey];
879 - (int)minimumLogicalFontSize
881 return [self _integerValueForKey: WebKitMinimumLogicalFontSizePreferenceKey];
884 - (void)setMinimumLogicalFontSize:(int)size
886 [self _setIntegerValue: size forKey: WebKitMinimumLogicalFontSizePreferenceKey];
889 - (NSString *)defaultTextEncodingName
891 return [self _stringValueForKey: WebKitDefaultTextEncodingNamePreferenceKey];
894 - (void)setDefaultTextEncodingName:(NSString *)encoding
896 [self _setStringValue: encoding forKey: WebKitDefaultTextEncodingNamePreferenceKey];
900 - (BOOL)userStyleSheetEnabled
902 return [self _boolValueForKey: WebKitUserStyleSheetEnabledPreferenceKey];
905 - (void)setUserStyleSheetEnabled:(BOOL)flag
907 [self _setBoolValue: flag forKey: WebKitUserStyleSheetEnabledPreferenceKey];
910 - (NSURL *)userStyleSheetLocation
912 NSString *locationString = [self _stringValueForKey: WebKitUserStyleSheetLocationPreferenceKey];
914 if ([locationString _webkit_looksLikeAbsoluteURL]) {
915 return [NSURL _web_URLWithDataAsString:locationString];
917 locationString = [locationString stringByExpandingTildeInPath];
918 return [NSURL fileURLWithPath:locationString];
922 - (void)setUserStyleSheetLocation:(NSURL *)URL
924 NSString *locationString;
926 if ([URL isFileURL]) {
927 locationString = [[URL path] _web_stringByAbbreviatingWithTildeInPath];
929 locationString = [URL _web_originalDataAsString];
933 locationString = @"";
935 [self _setStringValue:locationString forKey: WebKitUserStyleSheetLocationPreferenceKey];
939 // These methods have had their implementations removed on iOS since it
940 // is wrong to have such a setting stored in preferences that, when read,
941 // is applied to all WebViews in a iOS process. Such a design might work
942 // OK for an application like Safari on Mac OS X, where the only WebViews
943 // in use display web content in a straightforward manner. However, it is
944 // wrong for iOS, where WebViews are used for various purposes, like
945 // text editing, text rendering, and displaying web content.
947 // I have changed the user style sheet mechanism to be a per-WebView
948 // setting, rather than a per-process preference. This seems to give the
949 // behavior we want for iOS.
951 - (BOOL)userStyleSheetEnabled
956 - (void)setUserStyleSheetEnabled:(BOOL)flag
961 - (NSURL *)userStyleSheetLocation
966 - (void)setUserStyleSheetLocation:(NSURL *)URL
970 #endif // PLATFORM(IOS)
973 - (BOOL)shouldPrintBackgrounds
975 return [self _boolValueForKey: WebKitShouldPrintBackgroundsPreferenceKey];
978 - (void)setShouldPrintBackgrounds:(BOOL)flag
980 [self _setBoolValue: flag forKey: WebKitShouldPrintBackgroundsPreferenceKey];
984 - (BOOL)isJavaEnabled
986 return [self _boolValueForKey: WebKitJavaEnabledPreferenceKey];
989 - (void)setJavaEnabled:(BOOL)flag
991 [self _setBoolValue: flag forKey: WebKitJavaEnabledPreferenceKey];
994 - (BOOL)isJavaScriptEnabled
996 return [self _boolValueForKey: WebKitJavaScriptEnabledPreferenceKey];
999 - (void)setJavaScriptEnabled:(BOOL)flag
1001 [self _setBoolValue: flag forKey: WebKitJavaScriptEnabledPreferenceKey];
1004 - (BOOL)javaScriptCanOpenWindowsAutomatically
1006 return [self _boolValueForKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
1009 - (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag
1011 [self _setBoolValue: flag forKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
1014 - (BOOL)arePlugInsEnabled
1016 return [self _boolValueForKey: WebKitPluginsEnabledPreferenceKey];
1019 - (void)setPlugInsEnabled:(BOOL)flag
1021 [self _setBoolValue: flag forKey: WebKitPluginsEnabledPreferenceKey];
1024 - (BOOL)allowsAnimatedImages
1026 return [self _boolValueForKey: WebKitAllowAnimatedImagesPreferenceKey];
1029 - (void)setAllowsAnimatedImages:(BOOL)flag
1031 [self _setBoolValue: flag forKey: WebKitAllowAnimatedImagesPreferenceKey];
1034 - (BOOL)allowsAnimatedImageLooping
1036 return [self _boolValueForKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
1039 - (void)setAllowsAnimatedImageLooping: (BOOL)flag
1041 [self _setBoolValue: flag forKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
1044 - (void)setLoadsImagesAutomatically: (BOOL)flag
1046 [self _setBoolValue: flag forKey: WebKitDisplayImagesKey];
1049 - (BOOL)loadsImagesAutomatically
1051 return [self _boolValueForKey: WebKitDisplayImagesKey];
1054 - (void)setAutosaves:(BOOL)flag
1056 _private->autosaves = flag;
1061 return _private->autosaves;
1065 - (void)setTabsToLinks:(BOOL)flag
1067 [self _setBoolValue: flag forKey: WebKitTabToLinksPreferenceKey];
1072 return [self _boolValueForKey:WebKitTabToLinksPreferenceKey];
1076 - (void)setPrivateBrowsingEnabled:(BOOL)enabled
1078 [self _updatePrivateBrowsingStateTo:enabled];
1079 [self _setBoolValue:enabled forKey:WebKitPrivateBrowsingEnabledPreferenceKey];
1082 - (BOOL)privateBrowsingEnabled
1084 // Changes to private browsing defaults do not have effect on existing WebPreferences, and must be done through -setPrivateBrowsingEnabled.
1085 // This is needed to accurately track private browsing sessions in the process.
1086 return _private->inPrivateBrowsing;
1089 - (void)_updatePrivateBrowsingStateTo:(BOOL)enabled
1096 if (enabled == _private->inPrivateBrowsing)
1098 if (enabled > _private->inPrivateBrowsing) {
1099 WebFrameNetworkingContext::ensurePrivateBrowsingSession();
1100 ++webPreferencesInstanceCountWithPrivateBrowsingEnabled;
1102 ASSERT(webPreferencesInstanceCountWithPrivateBrowsingEnabled);
1103 --webPreferencesInstanceCountWithPrivateBrowsingEnabled;
1104 if (!webPreferencesInstanceCountWithPrivateBrowsingEnabled)
1105 WebFrameNetworkingContext::destroyPrivateBrowsingSession();
1107 _private->inPrivateBrowsing = enabled;
1110 - (void)setUsesPageCache:(BOOL)usesPageCache
1112 [self _setBoolValue:usesPageCache forKey:WebKitUsesPageCachePreferenceKey];
1115 - (BOOL)usesPageCache
1117 return [self _boolValueForKey:WebKitUsesPageCachePreferenceKey];
1120 - (void)_postCacheModelChangedNotification
1123 if (!pthread_main_np()) {
1124 [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO];
1129 [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesCacheModelChangedInternalNotification object:self userInfo:nil];
1132 - (void)setCacheModel:(WebCacheModel)cacheModel
1134 [self _setIntegerValue:cacheModel forKey:WebKitCacheModelPreferenceKey];
1135 [self setAutomaticallyDetectsCacheModel:NO];
1136 [self _postCacheModelChangedNotification];
1139 - (WebCacheModel)cacheModel
1141 return (WebCacheModel)[self _integerValueForKey:WebKitCacheModelPreferenceKey];
1145 - (void)setSuppressesIncrementalRendering:(BOOL)suppressesIncrementalRendering
1147 [self _setBoolValue:suppressesIncrementalRendering forKey:WebKitSuppressesIncrementalRenderingKey];
1150 - (BOOL)suppressesIncrementalRendering
1152 return [self _boolValueForKey:WebKitSuppressesIncrementalRenderingKey];
1157 @implementation WebPreferences (WebPrivate)
1159 #if PLATFORM(IOS) && !(__IPHONE_OS_VERSION_MIN_REQUIRED >= 60000)
1160 - (void) setWebInspectorServerEnabled:(BOOL)flag
1165 #if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 80000
1166 - (void)_setAllowCompositingLayerVisualDegradation:(BOOL)flag
1171 - (BOOL)isDNSPrefetchingEnabled
1173 return [self _boolValueForKey:WebKitDNSPrefetchingEnabledPreferenceKey];
1176 - (void)setDNSPrefetchingEnabled:(BOOL)flag
1178 [self _setBoolValue:flag forKey:WebKitDNSPrefetchingEnabledPreferenceKey];
1181 - (BOOL)developerExtrasEnabled
1183 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
1184 if ([defaults boolForKey:@"DisableWebKitDeveloperExtras"])
1187 if ([defaults boolForKey:@"WebKitDeveloperExtras"] || [defaults boolForKey:@"IncludeDebugMenu"])
1189 return [self _boolValueForKey:WebKitDeveloperExtrasEnabledPreferenceKey];
1191 return YES; // always enable in debug builds
1195 - (void)setJavaScriptExperimentsEnabled:(BOOL)flag
1197 [self _setBoolValue:flag forKey:WebKitJavaScriptExperimentsEnabledPreferenceKey];
1200 - (BOOL)javaScriptExperimentsEnabled
1202 return [self _boolValueForKey:WebKitJavaScriptExperimentsEnabledPreferenceKey];
1205 - (void)setDeveloperExtrasEnabled:(BOOL)flag
1207 [self _setBoolValue:flag forKey:WebKitDeveloperExtrasEnabledPreferenceKey];
1210 - (BOOL)authorAndUserStylesEnabled
1212 return [self _boolValueForKey:WebKitAuthorAndUserStylesEnabledPreferenceKey];
1215 - (void)setAuthorAndUserStylesEnabled:(BOOL)flag
1217 [self _setBoolValue:flag forKey:WebKitAuthorAndUserStylesEnabledPreferenceKey];
1220 - (BOOL)applicationChromeModeEnabled
1222 return [self _boolValueForKey:WebKitApplicationChromeModeEnabledPreferenceKey];
1225 - (void)setApplicationChromeModeEnabled:(BOOL)flag
1227 [self _setBoolValue:flag forKey:WebKitApplicationChromeModeEnabledPreferenceKey];
1230 - (BOOL)webArchiveDebugModeEnabled
1232 return [self _boolValueForKey:WebKitWebArchiveDebugModeEnabledPreferenceKey];
1235 - (void)setWebArchiveDebugModeEnabled:(BOOL)flag
1237 [self _setBoolValue:flag forKey:WebKitWebArchiveDebugModeEnabledPreferenceKey];
1240 - (BOOL)localFileContentSniffingEnabled
1242 return [self _boolValueForKey:WebKitLocalFileContentSniffingEnabledPreferenceKey];
1245 - (void)setLocalFileContentSniffingEnabled:(BOOL)flag
1247 [self _setBoolValue:flag forKey:WebKitLocalFileContentSniffingEnabledPreferenceKey];
1250 - (BOOL)offlineWebApplicationCacheEnabled
1252 return [self _boolValueForKey:WebKitOfflineWebApplicationCacheEnabledPreferenceKey];
1255 - (void)setOfflineWebApplicationCacheEnabled:(BOOL)flag
1257 [self _setBoolValue:flag forKey:WebKitOfflineWebApplicationCacheEnabledPreferenceKey];
1260 - (BOOL)zoomsTextOnly
1262 return [self _boolValueForKey:WebKitZoomsTextOnlyPreferenceKey];
1265 - (void)setZoomsTextOnly:(BOOL)flag
1267 [self _setBoolValue:flag forKey:WebKitZoomsTextOnlyPreferenceKey];
1270 - (BOOL)javaScriptCanAccessClipboard
1272 return [self _boolValueForKey:WebKitJavaScriptCanAccessClipboardPreferenceKey];
1275 - (void)setJavaScriptCanAccessClipboard:(BOOL)flag
1277 [self _setBoolValue:flag forKey:WebKitJavaScriptCanAccessClipboardPreferenceKey];
1280 - (BOOL)isXSSAuditorEnabled
1282 return [self _boolValueForKey:WebKitXSSAuditorEnabledPreferenceKey];
1285 - (void)setXSSAuditorEnabled:(BOOL)flag
1287 [self _setBoolValue:flag forKey:WebKitXSSAuditorEnabledPreferenceKey];
1291 - (BOOL)respectStandardStyleKeyEquivalents
1293 return [self _boolValueForKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
1296 - (void)setRespectStandardStyleKeyEquivalents:(BOOL)flag
1298 [self _setBoolValue:flag forKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
1301 - (BOOL)showsURLsInToolTips
1303 return [self _boolValueForKey:WebKitShowsURLsInToolTipsPreferenceKey];
1306 - (void)setShowsURLsInToolTips:(BOOL)flag
1308 [self _setBoolValue:flag forKey:WebKitShowsURLsInToolTipsPreferenceKey];
1311 - (BOOL)showsToolTipOverTruncatedText
1313 return [self _boolValueForKey:WebKitShowsToolTipOverTruncatedTextPreferenceKey];
1316 - (void)setShowsToolTipOverTruncatedText:(BOOL)flag
1318 [self _setBoolValue:flag forKey:WebKitShowsToolTipOverTruncatedTextPreferenceKey];
1321 - (BOOL)textAreasAreResizable
1323 return [self _boolValueForKey: WebKitTextAreasAreResizablePreferenceKey];
1326 - (void)setTextAreasAreResizable:(BOOL)flag
1328 [self _setBoolValue: flag forKey: WebKitTextAreasAreResizablePreferenceKey];
1330 #endif // !PLATFORM(IOS)
1332 - (BOOL)shrinksStandaloneImagesToFit
1334 return [self _boolValueForKey:WebKitShrinksStandaloneImagesToFitPreferenceKey];
1337 - (void)setShrinksStandaloneImagesToFit:(BOOL)flag
1339 [self _setBoolValue:flag forKey:WebKitShrinksStandaloneImagesToFitPreferenceKey];
1342 - (BOOL)automaticallyDetectsCacheModel
1344 return _private->automaticallyDetectsCacheModel;
1347 - (void)setAutomaticallyDetectsCacheModel:(BOOL)automaticallyDetectsCacheModel
1349 _private->automaticallyDetectsCacheModel = automaticallyDetectsCacheModel;
1352 - (BOOL)usesEncodingDetector
1354 return [self _boolValueForKey: WebKitUsesEncodingDetectorPreferenceKey];
1357 - (void)setUsesEncodingDetector:(BOOL)flag
1359 [self _setBoolValue: flag forKey: WebKitUsesEncodingDetectorPreferenceKey];
1362 - (BOOL)isWebSecurityEnabled
1364 return [self _boolValueForKey: WebKitWebSecurityEnabledPreferenceKey];
1367 - (void)setWebSecurityEnabled:(BOOL)flag
1369 [self _setBoolValue: flag forKey: WebKitWebSecurityEnabledPreferenceKey];
1372 - (BOOL)allowUniversalAccessFromFileURLs
1374 return [self _boolValueForKey: WebKitAllowUniversalAccessFromFileURLsPreferenceKey];
1377 - (void)setAllowUniversalAccessFromFileURLs:(BOOL)flag
1379 [self _setBoolValue: flag forKey: WebKitAllowUniversalAccessFromFileURLsPreferenceKey];
1382 - (BOOL)allowFileAccessFromFileURLs
1384 return [self _boolValueForKey: WebKitAllowFileAccessFromFileURLsPreferenceKey];
1387 - (void)setAllowFileAccessFromFileURLs:(BOOL)flag
1389 [self _setBoolValue: flag forKey: WebKitAllowFileAccessFromFileURLsPreferenceKey];
1392 - (NSTimeInterval)_backForwardCacheExpirationInterval
1394 return (NSTimeInterval)[self _floatValueForKey:WebKitBackForwardCacheExpirationIntervalKey];
1400 return [self _boolValueForKey:WebKitStandalonePreferenceKey];
1403 - (void)_setStandalone:(BOOL)flag
1405 [self _setBoolValue:flag forKey:WebKitStandalonePreferenceKey];
1408 - (void)_setTelephoneNumberParsingEnabled:(BOOL)flag
1410 [self _setBoolValue:flag forKey:WebKitTelephoneParsingEnabledPreferenceKey];
1413 - (BOOL)_telephoneNumberParsingEnabled
1415 return [self _boolValueForKey:WebKitTelephoneParsingEnabledPreferenceKey];
1419 #if ENABLE(IOS_TEXT_AUTOSIZING)
1420 - (void)_setMinimumZoomFontSize:(float)size
1422 [self _setFloatValue:size forKey:WebKitMinimumZoomFontSizePreferenceKey];
1425 - (float)_minimumZoomFontSize
1427 return [self _floatValueForKey:WebKitMinimumZoomFontSizePreferenceKey];
1432 - (void)_setLayoutInterval:(int)l
1434 [self _setIntegerValue:l forKey:WebKitLayoutIntervalPreferenceKey];
1437 - (int)_layoutInterval
1439 return [self _integerValueForKey:WebKitLayoutIntervalPreferenceKey];
1442 - (void)_setMaxParseDuration:(float)d
1444 [self _setFloatValue:d forKey:WebKitMaxParseDurationPreferenceKey];
1447 - (float)_maxParseDuration
1449 return [self _floatValueForKey:WebKitMaxParseDurationPreferenceKey];
1452 - (void)_setPageCacheSize:(int)size
1454 [self _setIntegerValue:size forKey:WebKitPageCacheSizePreferenceKey];
1457 - (int)_pageCacheSize
1459 return [self _integerValueForKey:WebKitPageCacheSizePreferenceKey];
1462 - (void)_setObjectCacheSize:(int)size
1464 [self _setIntegerValue:size forKey:WebKitObjectCacheSizePreferenceKey];
1467 - (int)_objectCacheSize
1469 return [self _integerValueForKey:WebKitObjectCacheSizePreferenceKey];
1472 - (void)_setNSURLMemoryCacheSize:(int)size
1474 [self _setIntegerValue:size forKey:WebKitNSURLMemoryCacheSizePreferenceKey];
1477 - (int)_NSURLMemoryCacheSize
1479 return [self _integerValueForKey:WebKitNSURLMemoryCacheSizePreferenceKey];
1482 - (void)_setNSURLDiskCacheSize:(int)size
1484 [self _setIntegerValue:size forKey:WebKitNSURLDiskCacheSizePreferenceKey];
1487 - (int)_NSURLDiskCacheSize
1489 return [self _integerValueForKey:WebKitNSURLDiskCacheSizePreferenceKey];
1492 - (void)_setAlwaysUseBaselineOfPrimaryFont:(BOOL)flag
1494 [self _setBoolValue:flag forKey:WebKitAlwaysUseBaselineOfPrimaryFontPreferenceKey];
1497 - (BOOL)_alwaysUseBaselineOfPrimaryFont
1499 return [self _boolValueForKey:WebKitAlwaysUseBaselineOfPrimaryFontPreferenceKey];
1502 - (void)_setAllowMultiElementImplicitFormSubmission:(BOOL)flag
1504 [self _setBoolValue:flag forKey:WebKitAllowMultiElementImplicitFormSubmissionPreferenceKey];
1507 - (BOOL)_allowMultiElementImplicitFormSubmission
1509 return [self _boolValueForKey:WebKitAllowMultiElementImplicitFormSubmissionPreferenceKey];
1512 - (void)_setAlwaysRequestGeolocationPermission:(BOOL)flag
1514 [self _setBoolValue:flag forKey:WebKitAlwaysRequestGeolocationPermissionPreferenceKey];
1517 - (BOOL)_alwaysRequestGeolocationPermission
1519 return [self _boolValueForKey:WebKitAlwaysRequestGeolocationPermissionPreferenceKey];
1522 - (void)_setAlwaysUseAcceleratedOverflowScroll:(BOOL)flag
1524 [self _setBoolValue:flag forKey:WebKitAlwaysUseAcceleratedOverflowScrollPreferenceKey];
1527 - (BOOL)_alwaysUseAcceleratedOverflowScroll
1529 return [self _boolValueForKey:WebKitAlwaysUseAcceleratedOverflowScrollPreferenceKey];
1532 - (void)_setInterpolationQuality:(int)quality
1534 [self _setIntegerValue:quality forKey:WebKitInterpolationQualityPreferenceKey];
1537 - (int)_interpolationQuality
1539 return [self _integerValueForKey:WebKitInterpolationQualityPreferenceKey];
1542 - (BOOL)_allowPasswordEcho
1544 return [self _boolValueForKey:WebKitPasswordEchoEnabledPreferenceKey];
1547 - (float)_passwordEchoDuration
1549 return [self _floatValueForKey:WebKitPasswordEchoDurationPreferenceKey];
1552 #endif // PLATFORM(IOS)
1555 - (float)PDFScaleFactor
1557 return [self _floatValueForKey:WebKitPDFScaleFactorPreferenceKey];
1560 - (void)setPDFScaleFactor:(float)factor
1562 [self _setFloatValue:factor forKey:WebKitPDFScaleFactorPreferenceKey];
1566 - (int64_t)applicationCacheTotalQuota
1568 return [self _longLongValueForKey:WebKitApplicationCacheTotalQuota];
1571 - (void)setApplicationCacheTotalQuota:(int64_t)quota
1573 [self _setLongLongValue:quota forKey:WebKitApplicationCacheTotalQuota];
1575 // Application Cache Preferences are stored on the global cache storage manager, not in Settings.
1576 [WebApplicationCache setMaximumSize:quota];
1579 - (int64_t)applicationCacheDefaultOriginQuota
1581 return [self _longLongValueForKey:WebKitApplicationCacheDefaultOriginQuota];
1584 - (void)setApplicationCacheDefaultOriginQuota:(int64_t)quota
1586 [self _setLongLongValue:quota forKey:WebKitApplicationCacheDefaultOriginQuota];
1590 - (PDFDisplayMode)PDFDisplayMode
1592 PDFDisplayMode value = [self _integerValueForKey:WebKitPDFDisplayModePreferenceKey];
1593 if (value != kPDFDisplaySinglePage && value != kPDFDisplaySinglePageContinuous && value != kPDFDisplayTwoUp && value != kPDFDisplayTwoUpContinuous) {
1594 // protect against new modes from future versions of OS X stored in defaults
1595 value = kPDFDisplaySinglePageContinuous;
1600 - (void)setPDFDisplayMode:(PDFDisplayMode)mode
1602 [self _setIntegerValue:mode forKey:WebKitPDFDisplayModePreferenceKey];
1606 - (WebKitEditableLinkBehavior)editableLinkBehavior
1608 WebKitEditableLinkBehavior value = static_cast<WebKitEditableLinkBehavior> ([self _integerValueForKey:WebKitEditableLinkBehaviorPreferenceKey]);
1609 if (value != WebKitEditableLinkDefaultBehavior &&
1610 value != WebKitEditableLinkAlwaysLive &&
1611 value != WebKitEditableLinkNeverLive &&
1612 value != WebKitEditableLinkOnlyLiveWithShiftKey &&
1613 value != WebKitEditableLinkLiveWhenNotFocused) {
1614 // ensure that a valid result is returned
1615 value = WebKitEditableLinkDefaultBehavior;
1621 - (void)setEditableLinkBehavior:(WebKitEditableLinkBehavior)behavior
1623 [self _setIntegerValue:behavior forKey:WebKitEditableLinkBehaviorPreferenceKey];
1626 - (WebTextDirectionSubmenuInclusionBehavior)textDirectionSubmenuInclusionBehavior
1628 WebTextDirectionSubmenuInclusionBehavior value = static_cast<WebTextDirectionSubmenuInclusionBehavior>([self _integerValueForKey:WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey]);
1629 if (value != WebTextDirectionSubmenuNeverIncluded &&
1630 value != WebTextDirectionSubmenuAutomaticallyIncluded &&
1631 value != WebTextDirectionSubmenuAlwaysIncluded) {
1632 // Ensure that a valid result is returned.
1633 value = WebTextDirectionSubmenuNeverIncluded;
1638 - (void)setTextDirectionSubmenuInclusionBehavior:(WebTextDirectionSubmenuInclusionBehavior)behavior
1640 [self _setIntegerValue:behavior forKey:WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey];
1643 - (BOOL)_useSiteSpecificSpoofing
1645 return [self _boolValueForKey:WebKitUseSiteSpecificSpoofingPreferenceKey];
1648 - (void)_setUseSiteSpecificSpoofing:(BOOL)newValue
1650 [self _setBoolValue:newValue forKey:WebKitUseSiteSpecificSpoofingPreferenceKey];
1653 - (BOOL)databasesEnabled
1655 return [self _boolValueForKey:WebKitDatabasesEnabledPreferenceKey];
1658 - (void)setDatabasesEnabled:(BOOL)databasesEnabled
1660 [self _setBoolValue:databasesEnabled forKey:WebKitDatabasesEnabledPreferenceKey];
1664 - (BOOL)storageTrackerEnabled
1666 return [self _boolValueForKey:WebKitStorageTrackerEnabledPreferenceKey];
1669 - (void)setStorageTrackerEnabled:(BOOL)storageTrackerEnabled
1671 [self _setBoolValue:storageTrackerEnabled forKey:WebKitStorageTrackerEnabledPreferenceKey];
1675 - (BOOL)localStorageEnabled
1677 return [self _boolValueForKey:WebKitLocalStorageEnabledPreferenceKey];
1680 - (void)setLocalStorageEnabled:(BOOL)localStorageEnabled
1682 [self _setBoolValue:localStorageEnabled forKey:WebKitLocalStorageEnabledPreferenceKey];
1685 - (BOOL)experimentalNotificationsEnabled
1687 return [self _boolValueForKey:WebKitExperimentalNotificationsEnabledPreferenceKey];
1690 - (void)setExperimentalNotificationsEnabled:(BOOL)experimentalNotificationsEnabled
1692 [self _setBoolValue:experimentalNotificationsEnabled forKey:WebKitExperimentalNotificationsEnabledPreferenceKey];
1695 + (WebPreferences *)_getInstanceForIdentifier:(NSString *)ident
1697 LOG(Encoding, "requesting for %@\n", ident);
1700 return _standardPreferences;
1702 WebPreferences *instance = [webPreferencesInstances objectForKey:[self _concatenateKeyWithIBCreatorID:ident]];
1707 + (void)_setInstance:(WebPreferences *)instance forIdentifier:(NSString *)ident
1709 if (!webPreferencesInstances)
1710 webPreferencesInstances = [[NSMutableDictionary alloc] init];
1712 [webPreferencesInstances setObject:instance forKey:[self _concatenateKeyWithIBCreatorID:ident]];
1713 LOG(Encoding, "recording %p for %@\n", instance, [self _concatenateKeyWithIBCreatorID:ident]);
1717 + (void)_checkLastReferenceForIdentifier:(id)identifier
1719 // FIXME: This won't work at all under garbage collection because retainCount returns a constant.
1720 // We may need to change WebPreferences API so there's an explicit way to end the lifetime of one.
1721 WebPreferences *instance = [webPreferencesInstances objectForKey:identifier];
1722 if ([instance retainCount] == 1)
1723 [webPreferencesInstances removeObjectForKey:identifier];
1726 + (void)_removeReferenceForIdentifier:(NSString *)ident
1729 [self performSelector:@selector(_checkLastReferenceForIdentifier:) withObject:[self _concatenateKeyWithIBCreatorID:ident] afterDelay:0.1];
1732 - (void)_postPreferencesChangedNotification
1735 if (!pthread_main_np()) {
1736 [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO];
1741 [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedInternalNotification object:self userInfo:nil];
1742 [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedNotification object:self userInfo:nil];
1745 - (void)_postPreferencesChangedAPINotification
1747 if (!pthread_main_np()) {
1748 [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO];
1752 [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedNotification object:self userInfo:nil];
1755 + (CFStringEncoding)_systemCFStringEncoding
1757 return WKGetWebDefaultCFStringEncoding();
1760 + (void)_setInitialDefaultTextEncodingToSystemEncoding
1762 NSString *systemEncodingName = (NSString *)CFStringConvertEncodingToIANACharSetName([self _systemCFStringEncoding]);
1764 // CFStringConvertEncodingToIANACharSetName() returns cp949 for kTextEncodingDOSKorean AKA "extended EUC-KR" AKA windows-949.
1765 // ICU uses this name for a different encoding, so we need to change the name to a value that actually gives us windows-949.
1766 // In addition, this value must match what is used in Safari, see <rdar://problem/5579292>.
1767 // On some OS versions, the result is CP949 (uppercase).
1768 if ([systemEncodingName _webkit_isCaseInsensitiveEqualToString:@"cp949"])
1769 systemEncodingName = @"ks_c_5601-1987";
1770 [[NSUserDefaults standardUserDefaults] registerDefaults:
1771 [NSDictionary dictionaryWithObject:systemEncodingName forKey:WebKitDefaultTextEncodingNamePreferenceKey]];
1774 static NSString *classIBCreatorID = nil;
1776 + (void)_setIBCreatorID:(NSString *)string
1778 NSString *old = classIBCreatorID;
1779 classIBCreatorID = [string copy];
1783 + (void)_switchNetworkLoaderToNewTestingSession
1785 NetworkStorageSession::switchToNewTestingSession();
1788 + (void)_setCurrentNetworkLoaderSessionCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)policy
1790 WKSetHTTPCookieAcceptPolicy(NetworkStorageSession::defaultStorageSession().cookieStorage().get(), policy);
1793 - (BOOL)isDOMPasteAllowed
1795 return [self _boolValueForKey:WebKitDOMPasteAllowedPreferenceKey];
1798 - (void)setDOMPasteAllowed:(BOOL)DOMPasteAllowed
1800 [self _setBoolValue:DOMPasteAllowed forKey:WebKitDOMPasteAllowedPreferenceKey];
1803 - (NSString *)_localStorageDatabasePath
1805 return [[self _stringValueForKey:WebKitLocalStorageDatabasePathPreferenceKey] stringByStandardizingPath];
1808 - (void)_setLocalStorageDatabasePath:(NSString *)path
1810 [self _setStringValue:[path stringByStandardizingPath] forKey:WebKitLocalStorageDatabasePathPreferenceKey];
1813 - (NSString *)_ftpDirectoryTemplatePath
1815 return [[self _stringValueForKey:WebKitFTPDirectoryTemplatePath] stringByStandardizingPath];
1818 - (void)_setFTPDirectoryTemplatePath:(NSString *)path
1820 [self _setStringValue:[path stringByStandardizingPath] forKey:WebKitFTPDirectoryTemplatePath];
1823 - (BOOL)_forceFTPDirectoryListings
1825 return [self _boolValueForKey:WebKitForceFTPDirectoryListings];
1828 - (void)_setForceFTPDirectoryListings:(BOOL)force
1830 [self _setBoolValue:force forKey:WebKitForceFTPDirectoryListings];
1833 - (BOOL)acceleratedDrawingEnabled
1835 return [self _boolValueForKey:WebKitAcceleratedDrawingEnabledPreferenceKey];
1838 - (void)setAcceleratedDrawingEnabled:(BOOL)enabled
1840 [self _setBoolValue:enabled forKey:WebKitAcceleratedDrawingEnabledPreferenceKey];
1843 - (BOOL)canvasUsesAcceleratedDrawing
1845 return [self _boolValueForKey:WebKitCanvasUsesAcceleratedDrawingPreferenceKey];
1848 - (void)setCanvasUsesAcceleratedDrawing:(BOOL)enabled
1850 [self _setBoolValue:enabled forKey:WebKitCanvasUsesAcceleratedDrawingPreferenceKey];
1853 - (BOOL)acceleratedCompositingEnabled
1855 return [self _boolValueForKey:WebKitAcceleratedCompositingEnabledPreferenceKey];
1858 - (void)setAcceleratedCompositingEnabled:(BOOL)enabled
1860 [self _setBoolValue:enabled forKey:WebKitAcceleratedCompositingEnabledPreferenceKey];
1863 - (BOOL)cssRegionsEnabled
1865 return [self _boolValueForKey:WebKitCSSRegionsEnabledPreferenceKey];
1868 - (void)setCSSRegionsEnabled:(BOOL)enabled
1870 [self _setBoolValue:enabled forKey:WebKitCSSRegionsEnabledPreferenceKey];
1873 - (BOOL)cssCompositingEnabled
1875 return [self _boolValueForKey:WebKitCSSCompositingEnabledPreferenceKey];
1878 - (void)setCSSCompositingEnabled:(BOOL)enabled
1880 [self _setBoolValue:enabled forKey:WebKitCSSCompositingEnabledPreferenceKey];
1883 - (BOOL)showDebugBorders
1885 return [self _boolValueForKey:WebKitShowDebugBordersPreferenceKey];
1888 - (void)setShowDebugBorders:(BOOL)enabled
1890 [self _setBoolValue:enabled forKey:WebKitShowDebugBordersPreferenceKey];
1893 - (BOOL)showRepaintCounter
1895 return [self _boolValueForKey:WebKitShowRepaintCounterPreferenceKey];
1898 - (void)setShowRepaintCounter:(BOOL)enabled
1900 [self _setBoolValue:enabled forKey:WebKitShowRepaintCounterPreferenceKey];
1903 - (BOOL)webAudioEnabled
1905 return [self _boolValueForKey:WebKitWebAudioEnabledPreferenceKey];
1908 - (void)setWebAudioEnabled:(BOOL)enabled
1910 [self _setBoolValue:enabled forKey:WebKitWebAudioEnabledPreferenceKey];
1913 - (BOOL)subpixelCSSOMElementMetricsEnabled
1915 return [self _boolValueForKey:WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey];
1918 - (void) setSubpixelCSSOMElementMetricsEnabled:(BOOL)enabled
1920 [self _setBoolValue:enabled forKey:WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey];
1923 - (BOOL)webGLEnabled
1925 return [self _boolValueForKey:WebKitWebGLEnabledPreferenceKey];
1928 - (void)setWebGLEnabled:(BOOL)enabled
1930 [self _setBoolValue:enabled forKey:WebKitWebGLEnabledPreferenceKey];
1933 - (BOOL)multithreadedWebGLEnabled
1935 return [self _boolValueForKey:WebKitMultithreadedWebGLEnabledPreferenceKey];
1938 - (void)setMultithreadedWebGLEnabled:(BOOL)enabled
1940 [self _setBoolValue:enabled forKey:WebKitMultithreadedWebGLEnabledPreferenceKey];
1943 - (BOOL)forceSoftwareWebGLRendering
1945 return [self _boolValueForKey:WebKitForceSoftwareWebGLRenderingPreferenceKey];
1948 - (void)setForceSoftwareWebGLRendering:(BOOL)forced
1950 [self _setBoolValue:forced forKey:WebKitForceSoftwareWebGLRenderingPreferenceKey];
1953 - (BOOL)accelerated2dCanvasEnabled
1955 return [self _boolValueForKey:WebKitAccelerated2dCanvasEnabledPreferenceKey];
1958 - (void)setAccelerated2dCanvasEnabled:(BOOL)enabled
1960 [self _setBoolValue:enabled forKey:WebKitAccelerated2dCanvasEnabledPreferenceKey];
1963 #if ENABLE(DISK_IMAGE_CACHE) && PLATFORM(IOS)
1964 - (BOOL)diskImageCacheEnabled
1966 return [self _boolValueForKey:WebKitDiskImageCacheEnabledPreferenceKey];
1969 - (void)setDiskImageCacheEnabled:(BOOL)enabled
1971 [self _setBoolValue:enabled forKey:WebKitDiskImageCacheEnabledPreferenceKey];
1974 - (unsigned)diskImageCacheMinimumImageSize
1976 return [self _integerValueForKey:WebKitDiskImageCacheMinimumImageSizePreferenceKey];
1979 - (void)setDiskImageCacheMinimumImageSize:(unsigned)minimumSize
1981 [self _setIntegerValue:minimumSize forKey:WebKitDiskImageCacheMinimumImageSizePreferenceKey];
1984 - (unsigned)diskImageCacheMaximumCacheSize
1986 return [self _integerValueForKey:WebKitDiskImageCacheMaximumCacheSizePreferenceKey];
1989 - (void)setDiskImageCacheMaximumCacheSize:(unsigned)maximumSize
1991 [self _setIntegerValue:maximumSize forKey:WebKitDiskImageCacheMaximumCacheSizePreferenceKey];
1994 - (NSString *)_diskImageCacheSavedCacheDirectory
1996 return [[self _stringValueForKey:WebKitDiskImageCacheSavedCacheDirectoryKey] stringByStandardizingPath];
1999 - (void)_setDiskImageCacheSavedCacheDirectory:(NSString *)path
2001 [self _setStringValue:[path stringByStandardizingPath] forKey:WebKitDiskImageCacheSavedCacheDirectoryKey];
2003 #endif // ENABLE(DISK_IMAGE_CACHE) && PLATFORM(IOS)
2005 - (BOOL)isFrameFlatteningEnabled
2007 return [self _boolValueForKey:WebKitFrameFlatteningEnabledPreferenceKey];
2010 - (void)setFrameFlatteningEnabled:(BOOL)flag
2012 [self _setBoolValue:flag forKey:WebKitFrameFlatteningEnabledPreferenceKey];
2015 - (BOOL)isSpatialNavigationEnabled
2017 return [self _boolValueForKey:WebKitSpatialNavigationEnabledPreferenceKey];
2020 - (void)setSpatialNavigationEnabled:(BOOL)flag
2022 [self _setBoolValue:flag forKey:WebKitSpatialNavigationEnabledPreferenceKey];
2025 - (BOOL)paginateDuringLayoutEnabled
2027 return [self _boolValueForKey:WebKitPaginateDuringLayoutEnabledPreferenceKey];
2030 - (void)setPaginateDuringLayoutEnabled:(BOOL)flag
2032 [self _setBoolValue:flag forKey:WebKitPaginateDuringLayoutEnabledPreferenceKey];
2035 - (BOOL)hyperlinkAuditingEnabled
2037 return [self _boolValueForKey:WebKitHyperlinkAuditingEnabledPreferenceKey];
2040 - (void)setHyperlinkAuditingEnabled:(BOOL)flag
2042 [self _setBoolValue:flag forKey:WebKitHyperlinkAuditingEnabledPreferenceKey];
2045 - (BOOL)usePreHTML5ParserQuirks
2047 return [self _boolValueForKey:WebKitUsePreHTML5ParserQuirksKey];
2050 - (void)setUsePreHTML5ParserQuirks:(BOOL)flag
2052 [self _setBoolValue:flag forKey:WebKitUsePreHTML5ParserQuirksKey];
2055 - (void)didRemoveFromWebView
2057 ASSERT(_private->numWebViews);
2058 if (--_private->numWebViews == 0)
2059 [[NSNotificationCenter defaultCenter]
2060 postNotificationName:WebPreferencesRemovedNotification
2065 - (void)willAddToWebView
2067 ++_private->numWebViews;
2070 - (void)_setPreferenceForTestWithValue:(NSString *)value forKey:(NSString *)key
2072 [self _setStringValue:value forKey:key];
2075 - (void)setFullScreenEnabled:(BOOL)flag
2077 [self _setBoolValue:flag forKey:WebKitFullScreenEnabledPreferenceKey];
2080 - (BOOL)fullScreenEnabled
2082 return [self _boolValueForKey:WebKitFullScreenEnabledPreferenceKey];
2085 - (void)setAsynchronousSpellCheckingEnabled:(BOOL)flag
2087 [self _setBoolValue:flag forKey:WebKitAsynchronousSpellCheckingEnabledPreferenceKey];
2090 - (BOOL)asynchronousSpellCheckingEnabled
2092 return [self _boolValueForKey:WebKitAsynchronousSpellCheckingEnabledPreferenceKey];
2095 + (void)setWebKitLinkTimeVersion:(int)version
2097 setWebKitLinkTimeVersion(version);
2100 - (void)setLoadsSiteIconsIgnoringImageLoadingPreference: (BOOL)flag
2102 [self _setBoolValue: flag forKey: WebKitLoadSiteIconsKey];
2105 - (BOOL)loadsSiteIconsIgnoringImageLoadingPreference
2107 return [self _boolValueForKey: WebKitLoadSiteIconsKey];
2110 - (void)setAVFoundationEnabled:(BOOL)flag
2112 [self _setBoolValue:flag forKey:WebKitAVFoundationEnabledKey];
2115 - (BOOL)isAVFoundationEnabled
2117 return [self _boolValueForKey:WebKitAVFoundationEnabledKey];
2120 - (void)setQTKitEnabled:(BOOL)flag
2122 [self _setBoolValue:flag forKey:WebKitQTKitEnabledPreferenceKey];
2125 - (BOOL)isQTKitEnabled
2127 return [self _boolValueForKey:WebKitQTKitEnabledPreferenceKey];
2130 - (void)setVideoPluginProxyEnabled:(BOOL)flag
2132 // No-op, left for SPI compatibility.
2135 - (BOOL)isVideoPluginProxyEnabled
2140 - (void)setHixie76WebSocketProtocolEnabled:(BOOL)flag
2144 - (BOOL)isHixie76WebSocketProtocolEnabled
2149 - (BOOL)isInheritURIQueryComponentEnabled
2151 return [self _boolValueForKey: WebKitEnableInheritURIQueryComponentPreferenceKey];
2154 - (void)setEnableInheritURIQueryComponent:(BOOL)flag
2156 [self _setBoolValue:flag forKey: WebKitEnableInheritURIQueryComponentPreferenceKey];
2160 - (BOOL)mediaPlaybackAllowsAirPlay
2162 return [self _boolValueForKey:WebKitMediaPlaybackAllowsAirPlayPreferenceKey];
2165 - (void)setMediaPlaybackAllowsAirPlay:(BOOL)flag
2167 [self _setBoolValue:flag forKey:WebKitMediaPlaybackAllowsAirPlayPreferenceKey];
2170 - (unsigned)audioSessionCategoryOverride
2172 return [self _unsignedIntValueForKey:WebKitAudioSessionCategoryOverride];
2175 - (void)setAudioSessionCategoryOverride:(unsigned)override
2177 if (override > AudioSession::AudioProcessing) {
2178 // Clients are passing us OSTypes values from AudioToolbox/AudioSession.h,
2179 // which need to be translated into AudioSession::CategoryType:
2181 case kAudioSessionCategory_AmbientSound:
2182 override = AudioSession::AmbientSound;
2184 case kAudioSessionCategory_SoloAmbientSound:
2185 override = AudioSession::SoloAmbientSound;
2187 case kAudioSessionCategory_MediaPlayback:
2188 override = AudioSession::MediaPlayback;
2190 case kAudioSessionCategory_RecordAudio:
2191 override = AudioSession::RecordAudio;
2193 case kAudioSessionCategory_PlayAndRecord:
2194 override = AudioSession::PlayAndRecord;
2196 case kAudioSessionCategory_AudioProcessing:
2197 override = AudioSession::AudioProcessing;
2200 override = AudioSession::None;
2205 [self _setUnsignedIntValue:override forKey:WebKitAudioSessionCategoryOverride];
2208 - (BOOL)avKitEnabled
2210 return [self _boolValueForKey:WebKitAVKitEnabled];
2213 - (void)setAVKitEnabled:(bool)flag
2215 [self _setBoolValue:flag forKey:WebKitAVKitEnabled];
2218 - (BOOL)networkDataUsageTrackingEnabled
2220 return [self _boolValueForKey:WebKitNetworkDataUsageTrackingEnabledPreferenceKey];
2223 - (void)setNetworkDataUsageTrackingEnabled:(bool)trackingEnabled
2225 [self _setBoolValue:trackingEnabled forKey:WebKitNetworkDataUsageTrackingEnabledPreferenceKey];
2228 - (NSString *)networkInterfaceName
2230 return [self _stringValueForKey:WebKitNetworkInterfaceNamePreferenceKey];
2233 - (void)setNetworkInterfaceName:(NSString *)name
2235 [self _setStringValue:name forKey:WebKitNetworkInterfaceNamePreferenceKey];
2237 #endif // PLATFORM(IOS)
2239 - (BOOL)mediaPlaybackRequiresUserGesture
2241 return [self _boolValueForKey:WebKitMediaPlaybackRequiresUserGesturePreferenceKey];
2244 - (void)setMediaPlaybackRequiresUserGesture:(BOOL)flag
2246 [self _setBoolValue:flag forKey:WebKitMediaPlaybackRequiresUserGesturePreferenceKey];
2249 - (BOOL)mediaPlaybackAllowsInline
2251 return [self _boolValueForKey:WebKitMediaPlaybackAllowsInlinePreferenceKey];
2254 - (void)setMediaPlaybackAllowsInline:(BOOL)flag
2256 [self _setBoolValue:flag forKey:WebKitMediaPlaybackAllowsInlinePreferenceKey];
2259 - (BOOL)mockScrollbarsEnabled
2261 return [self _boolValueForKey:WebKitMockScrollbarsEnabledPreferenceKey];
2264 - (void)setMockScrollbarsEnabled:(BOOL)flag
2266 [self _setBoolValue:flag forKey:WebKitMockScrollbarsEnabledPreferenceKey];
2269 - (NSString *)pictographFontFamily
2271 return [self _stringValueForKey: WebKitPictographFontPreferenceKey];
2274 - (void)setPictographFontFamily:(NSString *)family
2276 [self _setStringValue: family forKey: WebKitPictographFontPreferenceKey];
2279 - (BOOL)pageCacheSupportsPlugins
2281 return [self _boolValueForKey:WebKitPageCacheSupportsPluginsPreferenceKey];
2284 - (void)setPageCacheSupportsPlugins:(BOOL)flag
2286 [self _setBoolValue:flag forKey:WebKitPageCacheSupportsPluginsPreferenceKey];
2291 - (void)_invalidateCachedPreferences
2293 dispatch_barrier_sync(_private->readWriteQueue, ^{
2294 if (_private->values)
2295 _private->values = adoptNS([[NSMutableDictionary alloc] init]);
2298 [self _updatePrivateBrowsingStateTo:[self privateBrowsingEnabled]];
2300 // Tell any live WebViews to refresh their preferences
2301 [self _postPreferencesChangedNotification];
2304 - (void)_synchronizeWebStoragePolicyWithCookiePolicy
2306 // FIXME: This should be done in clients, WebKit shouldn't be making such policy decisions.
2308 NSHTTPCookieAcceptPolicy cookieAcceptPolicy = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookieAcceptPolicy];
2309 WebStorageBlockingPolicy storageBlockingPolicy;
2310 switch (static_cast<unsigned>(cookieAcceptPolicy)) {
2311 case NSHTTPCookieAcceptPolicyAlways:
2312 storageBlockingPolicy = WebAllowAllStorage;
2314 case NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
2315 case NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
2316 storageBlockingPolicy = WebBlockThirdPartyStorage;
2318 case NSHTTPCookieAcceptPolicyNever:
2319 storageBlockingPolicy = WebBlockAllStorage;
2322 ASSERT_NOT_REACHED();
2323 storageBlockingPolicy = WebBlockAllStorage;
2327 [self setStorageBlockingPolicy:storageBlockingPolicy];
2331 - (void)setBackspaceKeyNavigationEnabled:(BOOL)flag
2333 [self _setBoolValue:flag forKey:WebKitBackspaceKeyNavigationEnabledKey];
2336 - (BOOL)backspaceKeyNavigationEnabled
2338 return [self _boolValueForKey:WebKitBackspaceKeyNavigationEnabledKey];
2341 - (void)setWantsBalancedSetDefersLoadingBehavior:(BOOL)flag
2343 [self _setBoolValue:flag forKey:WebKitWantsBalancedSetDefersLoadingBehaviorKey];
2346 - (BOOL)wantsBalancedSetDefersLoadingBehavior
2348 return [self _boolValueForKey:WebKitWantsBalancedSetDefersLoadingBehaviorKey];
2351 - (void)setShouldDisplaySubtitles:(BOOL)flag
2353 [self _setBoolValue:flag forKey:WebKitShouldDisplaySubtitlesPreferenceKey];
2356 - (BOOL)shouldDisplaySubtitles
2358 return [self _boolValueForKey:WebKitShouldDisplaySubtitlesPreferenceKey];
2361 - (void)setShouldDisplayCaptions:(BOOL)flag
2363 [self _setBoolValue:flag forKey:WebKitShouldDisplayCaptionsPreferenceKey];
2366 - (BOOL)shouldDisplayCaptions
2368 return [self _boolValueForKey:WebKitShouldDisplayCaptionsPreferenceKey];
2371 - (void)setShouldDisplayTextDescriptions:(BOOL)flag
2373 [self _setBoolValue:flag forKey:WebKitShouldDisplayTextDescriptionsPreferenceKey];
2376 - (BOOL)shouldDisplayTextDescriptions
2378 return [self _boolValueForKey:WebKitShouldDisplayTextDescriptionsPreferenceKey];
2381 - (void)setNotificationsEnabled:(BOOL)flag
2383 [self _setBoolValue:flag forKey:WebKitNotificationsEnabledKey];
2386 - (BOOL)notificationsEnabled
2388 return [self _boolValueForKey:WebKitNotificationsEnabledKey];
2391 - (void)setShouldRespectImageOrientation:(BOOL)flag
2393 [self _setBoolValue:flag forKey:WebKitShouldRespectImageOrientationKey];
2396 - (BOOL)shouldRespectImageOrientation
2398 return [self _boolValueForKey:WebKitShouldRespectImageOrientationKey];
2401 - (BOOL)requestAnimationFrameEnabled
2403 return [self _boolValueForKey:WebKitRequestAnimationFrameEnabledPreferenceKey];
2406 - (void)setRequestAnimationFrameEnabled:(BOOL)enabled
2408 [self _setBoolValue:enabled forKey:WebKitRequestAnimationFrameEnabledPreferenceKey];
2411 - (void)setIncrementalRenderingSuppressionTimeoutInSeconds:(NSTimeInterval)timeout
2413 [self _setFloatValue:timeout forKey:WebKitIncrementalRenderingSuppressionTimeoutInSecondsKey];
2416 - (NSTimeInterval)incrementalRenderingSuppressionTimeoutInSeconds
2418 return [self _floatValueForKey:WebKitIncrementalRenderingSuppressionTimeoutInSecondsKey];
2421 - (BOOL)diagnosticLoggingEnabled
2423 return [self _boolValueForKey:WebKitDiagnosticLoggingEnabledKey];
2426 - (void)setDiagnosticLoggingEnabled:(BOOL)enabled
2428 [self _setBoolValue:enabled forKey:WebKitDiagnosticLoggingEnabledKey];
2431 static bool needsScreenFontsEnabledQuirk()
2433 #if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
2434 static bool is1PasswordNeedingScreenFontsQuirk = WKExecutableWasLinkedOnOrBeforeMountainLion()
2435 && [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"ws.agile.1Password"];
2436 return is1PasswordNeedingScreenFontsQuirk;
2442 - (BOOL)screenFontSubstitutionEnabled
2444 if (needsScreenFontsEnabledQuirk())
2446 return [self _boolValueForKey:WebKitScreenFontSubstitutionEnabledKey];
2449 - (void)setScreenFontSubstitutionEnabled:(BOOL)enabled
2451 [self _setBoolValue:enabled forKey:WebKitScreenFontSubstitutionEnabledKey];
2454 - (void)setStorageBlockingPolicy:(WebStorageBlockingPolicy)storageBlockingPolicy
2457 // We don't want to write the setting out, so we just reset the default instead of storing the new setting.
2458 // FIXME: This code removes any defaults previously registered by client process, which is not appropriate for this method to do.
2459 NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:storageBlockingPolicy] forKey:WebKitStorageBlockingPolicyKey];
2460 [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
2462 [self _setIntegerValue:storageBlockingPolicy forKey:WebKitStorageBlockingPolicyKey];
2466 - (WebStorageBlockingPolicy)storageBlockingPolicy
2468 return static_cast<WebStorageBlockingPolicy>([self _integerValueForKey:WebKitStorageBlockingPolicyKey]);
2471 - (BOOL)plugInSnapshottingEnabled
2473 return [self _boolValueForKey:WebKitPlugInSnapshottingEnabledPreferenceKey];
2476 - (void)setPlugInSnapshottingEnabled:(BOOL)enabled
2478 [self _setBoolValue:enabled forKey:WebKitPlugInSnapshottingEnabledPreferenceKey];
2481 - (BOOL)hiddenPageDOMTimerThrottlingEnabled
2483 return [self _boolValueForKey:WebKitHiddenPageDOMTimerThrottlingEnabledPreferenceKey];
2486 - (void)setHiddenPageDOMTimerThrottlingEnabled:(BOOL)enabled
2488 [self _setBoolValue:enabled forKey:WebKitHiddenPageDOMTimerThrottlingEnabledPreferenceKey];
2491 - (BOOL)hiddenPageCSSAnimationSuspensionEnabled
2493 return [self _boolValueForKey:WebKitHiddenPageCSSAnimationSuspensionEnabledPreferenceKey];
2496 - (void)setHiddenPageCSSAnimationSuspensionEnabled:(BOOL)enabled
2498 [self _setBoolValue:enabled forKey:WebKitHiddenPageCSSAnimationSuspensionEnabledPreferenceKey];
2501 - (BOOL)lowPowerVideoAudioBufferSizeEnabled
2503 return [self _boolValueForKey:WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey];
2506 - (void)setLowPowerVideoAudioBufferSizeEnabled:(BOOL)enabled
2508 [self _setBoolValue:enabled forKey:WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey];
2511 - (BOOL)useLegacyTextAlignPositionedElementBehavior
2513 return [self _boolValueForKey:WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey];
2516 - (void)setUseLegacyTextAlignPositionedElementBehavior:(BOOL)enabled
2518 [self _setBoolValue:enabled forKey:WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey];
2521 - (BOOL)mediaSourceEnabled
2523 return [self _boolValueForKey:WebKitMediaSourceEnabledPreferenceKey];
2526 - (void)setMediaSourceEnabled:(BOOL)enabled
2528 [self _setBoolValue:enabled forKey:WebKitMediaSourceEnabledPreferenceKey];
2531 - (BOOL)imageControlsEnabled
2533 return [self _boolValueForKey:WebKitImageControlsEnabledPreferenceKey];
2536 - (void)setImageControlsEnabled:(BOOL)enabled
2538 [self _setBoolValue:enabled forKey:WebKitImageControlsEnabledPreferenceKey];
2541 - (BOOL)gamepadsEnabled
2543 return [self _boolValueForKey:WebKitGamepadsEnabledPreferenceKey];
2546 - (void)setGamepadsEnabled:(BOOL)flag
2548 [self _setBoolValue:flag forKey:WebKitGamepadsEnabledPreferenceKey];
2551 - (BOOL)shouldConvertPositionStyleOnCopy
2553 return [self _boolValueForKey:WebKitShouldConvertPositionStyleOnCopyPreferenceKey];
2556 - (void)setShouldConvertPositionStyleOnCopy:(BOOL)enabled
2558 [self _setBoolValue:enabled forKey:WebKitShouldConvertPositionStyleOnCopyPreferenceKey];
2563 @implementation WebPreferences (WebInternal)
2565 + (NSString *)_IBCreatorID
2567 return classIBCreatorID;
2570 + (NSString *)_concatenateKeyWithIBCreatorID:(NSString *)key
2572 NSString *IBCreatorID = [WebPreferences _IBCreatorID];
2575 return [IBCreatorID stringByAppendingString:key];