1f65df0266dade9a6738249487846ab8fe9fb27c
[WebKit.git] / Source / WebKitLegacy / mac / WebView / WebPreferences.mm
1 /*
2  * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
3  *           (C) 2006 Graham Dennis (graham.dennis@gmail.com)
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
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. 
17  *
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.
28  */
29
30 #import "WebPreferencesPrivate.h"
31 #import "WebPreferenceKeysPrivate.h"
32
33 #import "WebApplicationCache.h"
34 #import "WebFrameNetworkingContext.h"
35 #import "WebKitLogging.h"
36 #import "WebKitNSStringExtras.h"
37 #import "WebKitVersionChecks.h"
38 #import "WebNSDictionaryExtras.h"
39 #import "WebNSURLExtras.h"
40 #import <JavaScriptCore/InitializeThreading.h>
41 #import <WebCore/ApplicationCacheStorage.h>
42 #import <WebCore/AudioSession.h>
43 #import <WebCore/DeprecatedGlobalSettings.h>
44 #import <WebCore/NetworkStorageSession.h>
45 #import <WebCore/RuntimeApplicationChecks.h>
46 #import <WebCore/Settings.h>
47 #import <WebCore/TextEncodingRegistry.h>
48 #import <pal/spi/cf/CFNetworkSPI.h>
49 #import <wtf/MainThread.h>
50 #import <wtf/RetainPtr.h>
51 #import <wtf/RunLoop.h>
52
53 using namespace WebCore;
54
55 #if HAVE(AUDIO_TOOLBOX_AUDIO_SESSION)
56 #import <AudioToolbox/AudioSession.h>
57 #endif
58
59 #if PLATFORM(IOS)
60 #import <WebCore/Device.h>
61 #import <WebCore/GraphicsContext.h>
62 #import <WebCore/WebCoreThreadMessage.h>
63 #endif
64
65 NSString *WebPreferencesChangedNotification = @"WebPreferencesChangedNotification";
66 NSString *WebPreferencesRemovedNotification = @"WebPreferencesRemovedNotification";
67 NSString *WebPreferencesChangedInternalNotification = @"WebPreferencesChangedInternalNotification";
68 NSString *WebPreferencesCacheModelChangedInternalNotification = @"WebPreferencesCacheModelChangedInternalNotification";
69
70 #define KEY(x) (_private->identifier ? [_private->identifier.get() stringByAppendingString:(x)] : (x))
71
72 enum { WebPreferencesVersion = 1 };
73
74 static WebPreferences *_standardPreferences;
75 static NSMutableDictionary *webPreferencesInstances;
76
77 static unsigned webPreferencesInstanceCountWithPrivateBrowsingEnabled;
78
79 template<unsigned size> static bool contains(const char* const (&array)[size], const char* item)
80 {
81     if (!item)
82         return false;
83     for (auto* string : array) {
84         if (equalIgnoringASCIICase(string, item))
85             return true;
86     }
87     return false;
88 }
89
90 static WebCacheModel cacheModelForMainBundle(void)
91 {
92     @autoreleasepool {
93         // Apps that probably need the small setting
94         static const char* const documentViewerIDs[] = {
95             "Microsoft/com.microsoft.Messenger",
96             "com.adiumX.adiumX", 
97             "com.alientechnology.Proteus",
98             "com.apple.Dashcode",
99             "com.apple.iChat", 
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",
112             "fi.karppinen.Pyro",
113             "info.colloquy", 
114             "kungfoo.tv.ecto",
115         };
116
117         // Apps that probably need the medium setting
118         static const char* const documentBrowserIDs[] = {
119             "com.apple.Dictionary",
120             "com.apple.Xcode",
121             "com.apple.dashboard.client", 
122             "com.apple.helpviewer",
123             "com.culturedcode.xyle",
124             "com.macrabbit.CSSEdit",
125             "com.panic.Coda",
126             "com.ranchero.NetNewsWire",
127             "com.thinkmac.NewsLife",
128             "org.xlife.NewsFire",
129             "uk.co.opencommunity.vienna2",
130         };
131
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",
140         };
141
142         const char* bundleID = [[[NSBundle mainBundle] bundleIdentifier] UTF8String];
143         if (contains(documentViewerIDs, bundleID))
144             return WebCacheModelDocumentViewer;
145         if (contains(documentBrowserIDs, bundleID))
146             return WebCacheModelDocumentBrowser;
147         if (contains(primaryWebBrowserIDs, bundleID))
148             return WebCacheModelPrimaryWebBrowser;
149
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.
153
154 #if !PLATFORM(IOS)
155         bool isLegacyApp = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_CACHE_MODEL_API);
156 #else
157         bool isLegacyApp = false;
158 #endif
159         if (isLegacyApp)
160             return WebCacheModelDocumentBrowser; // To avoid regressions in apps that depended on old WebKit's large cache.
161
162         return WebCacheModelDocumentViewer; // To save memory.
163     }
164 }
165
166 @interface WebPreferences ()
167 - (void)_postCacheModelChangedNotification;
168 @end
169
170 @interface WebPreferences (WebInternal)
171 + (NSString *)_concatenateKeyWithIBCreatorID:(NSString *)key;
172 + (NSString *)_IBCreatorID;
173 @end
174
175 struct WebPreferencesPrivate
176 {
177 public:
178     WebPreferencesPrivate()
179     : inPrivateBrowsing(NO)
180     , autosaves(NO)
181     , automaticallyDetectsCacheModel(NO)
182     , numWebViews(0)
183 #if PLATFORM(IOS)
184     , readWriteQueue(dispatch_queue_create("com.apple.WebPreferences.ReadWriteQueue", DISPATCH_QUEUE_CONCURRENT))
185 #endif
186     {
187     }
188
189 #if PLATFORM(IOS)
190     ~WebPreferencesPrivate()
191     {
192         dispatch_release(readWriteQueue);
193     }
194 #endif
195
196     RetainPtr<NSMutableDictionary> values;
197     BOOL inPrivateBrowsing;
198     RetainPtr<NSString> identifier;
199     BOOL autosaves;
200     BOOL automaticallyDetectsCacheModel;
201     unsigned numWebViews;
202 #if PLATFORM(IOS)
203     dispatch_queue_t readWriteQueue;
204 #endif
205 };
206
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;
220 @end
221
222 #if PLATFORM(IOS)
223 @interface WebPreferences ()
224 - (id)initWithIdentifier:(NSString *)anIdentifier sendChangeNotification:(BOOL)sendChangeNotification;
225 @end
226 #endif
227
228 @implementation WebPreferences
229
230 - (instancetype)init
231 {
232     // Create fake identifier
233     static int instanceCount = 1;
234     NSString *fakeIdentifier;
235     
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++];
240     }
241     
242     return [self initWithIdentifier:fakeIdentifier];
243 }
244
245 #if PLATFORM(IOS)
246 - (id)initWithIdentifier:(NSString *)anIdentifier
247 {
248     return [self initWithIdentifier:anIdentifier sendChangeNotification:YES];
249 }
250 #endif
251
252 #if PLATFORM(IOS)
253 - (instancetype)initWithIdentifier:(NSString *)anIdentifier sendChangeNotification:(BOOL)sendChangeNotification
254 #else
255 - (instancetype)initWithIdentifier:(NSString *)anIdentifier
256 #endif
257 {
258     WebPreferences *instance = [[self class] _getInstanceForIdentifier:anIdentifier];
259     if (instance) {
260         [self release];
261         return [instance retain];
262     }
263
264     self = [super init];
265     if (!self)
266         return nil;
267
268     _private = new WebPreferencesPrivate;
269     _private->values = adoptNS([[NSMutableDictionary alloc] init]);
270     _private->identifier = adoptNS([anIdentifier copy]);
271     _private->automaticallyDetectsCacheModel = YES;
272
273     [[self class] _setInstance:self forIdentifier:_private->identifier.get()];
274
275     [self _updatePrivateBrowsingStateTo:[self privateBrowsingEnabled]];
276
277 #if PLATFORM(IOS)
278     if (sendChangeNotification) {
279         [self _postPreferencesChangedNotification];
280         [self _postCacheModelChangedNotification];
281     }
282 #else
283     [self _postPreferencesChangedNotification];
284     [self _postCacheModelChangedNotification];
285 #endif
286
287     return self;
288 }
289
290 - (instancetype)initWithCoder:(NSCoder *)decoder
291 {
292     self = [super init];
293     if (!self)
294         return nil;
295
296     _private = new WebPreferencesPrivate;
297     _private->automaticallyDetectsCacheModel = YES;
298
299     @try {
300         id identifier = nil;
301         id values = nil;
302         if ([decoder allowsKeyedCoding]) {
303             identifier = [decoder decodeObjectForKey:@"Identifier"];
304             values = [decoder decodeObjectForKey:@"Values"];
305         } else {
306             int version;
307             [decoder decodeValueOfObjCType:@encode(int) at:&version];
308             if (version == 1) {
309                 identifier = [decoder decodeObject];
310                 values = [decoder decodeObject];
311             }
312         }
313
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
318
319         LOG(Encoding, "Identifier = %@, Values = %@\n", _private->identifier.get(), _private->values.get());
320     } @catch(id) {
321         [self release];
322         return nil;
323     }
324
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()];
328     if (instance) {
329         [self release];
330         self = [instance retain];
331     } else {
332         [[self class] _setInstance:self forIdentifier:_private->identifier.get()];
333         [self _updatePrivateBrowsingStateTo:[self privateBrowsingEnabled]];
334     }
335
336     return self;
337 }
338
339 - (void)encodeWithCoder:(NSCoder *)encoder
340 {
341     if ([encoder allowsKeyedCoding]){
342         [encoder encodeObject:_private->identifier.get() forKey:@"Identifier"];
343 #if PLATFORM(IOS)
344         dispatch_sync(_private->readWriteQueue, ^{
345 #endif
346         [encoder encodeObject:_private->values.get() forKey:@"Values"];
347         LOG (Encoding, "Identifier = %@, Values = %@\n", _private->identifier.get(), _private->values.get());
348 #if PLATFORM(IOS)
349         });
350 #endif
351     }
352     else {
353         int version = WebPreferencesVersion;
354         [encoder encodeValueOfObjCType:@encode(int) at:&version];
355         [encoder encodeObject:_private->identifier.get()];
356 #if PLATFORM(IOS)
357         dispatch_sync(_private->readWriteQueue, ^{
358 #endif
359         [encoder encodeObject:_private->values.get()];
360 #if PLATFORM(IOS)
361         });
362 #endif
363     }
364 }
365
366 + (WebPreferences *)standardPreferences
367 {
368 #if !PLATFORM(IOS)
369     if (_standardPreferences == nil) {
370         _standardPreferences = [[WebPreferences alloc] initWithIdentifier:nil];
371         [_standardPreferences setAutosaves:YES];
372     }
373 #else
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;
377
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];
383     });
384 #endif
385
386     return _standardPreferences;
387 }
388
389 // if we ever have more than one WebPreferences object, this would move to init
390 + (void)initialize
391 {
392 #if !PLATFORM(IOS)
393     JSC::initializeThreading();
394     WTF::initializeMainThreadToProcessMainThread();
395     RunLoop::initializeMainRunLoop();
396     bool attachmentElementEnabled = MacApplication::isAppleMail();
397 #else
398     bool allowsInlineMediaPlayback = WebCore::deviceClass() == MGDeviceClassiPad;
399     bool allowsInlineMediaPlaybackAfterFullscreen = WebCore::deviceClass() != MGDeviceClassiPad;
400     bool requiresPlaysInlineAttribute = !allowsInlineMediaPlayback;
401     bool attachmentElementEnabled = IOSApplication::isMobileMail();
402 #endif
403
404     NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
405         @"Times",                       WebKitStandardFontPreferenceKey,
406         @"Courier",                     WebKitFixedFontPreferenceKey,
407         @"Times",                       WebKitSerifFontPreferenceKey,
408         @"Helvetica",                   WebKitSansSerifFontPreferenceKey,
409 #if !PLATFORM(IOS)
410         @"Apple Chancery",              WebKitCursiveFontPreferenceKey,
411 #else
412         @"Snell Roundhand",             WebKitCursiveFontPreferenceKey,
413 #endif
414         @"Papyrus",                     WebKitFantasyFontPreferenceKey,
415 #if PLATFORM(IOS)
416         @"AppleColorEmoji",             WebKitPictographFontPreferenceKey,
417 #else
418         @"Apple Color Emoji",           WebKitPictographFontPreferenceKey,
419 #endif
420         @"0",                           WebKitMinimumFontSizePreferenceKey,
421         @"9",                           WebKitMinimumLogicalFontSizePreferenceKey, 
422         @"16",                          WebKitDefaultFontSizePreferenceKey,
423         @"13",                          WebKitDefaultFixedFontSizePreferenceKey,
424         @"ISO-8859-1",                  WebKitDefaultTextEncodingNamePreferenceKey,
425         [NSNumber numberWithBool:NO],   WebKitUsesEncodingDetectorPreferenceKey,
426         [NSNumber numberWithBool:NO],   WebKitUserStyleSheetEnabledPreferenceKey,
427         @"",                            WebKitUserStyleSheetLocationPreferenceKey,
428 #if !PLATFORM(IOS)
429         [NSNumber numberWithBool:NO],   WebKitShouldPrintBackgroundsPreferenceKey,
430         [NSNumber numberWithBool:NO],   WebKitTextAreasAreResizablePreferenceKey,
431 #endif
432         [NSNumber numberWithBool:NO],   WebKitShrinksStandaloneImagesToFitPreferenceKey,
433 #if !PLATFORM(IOS)
434         [NSNumber numberWithBool:YES],  WebKitJavaEnabledPreferenceKey,
435 #endif
436         [NSNumber numberWithBool:YES],  WebKitJavaScriptEnabledPreferenceKey,
437         [NSNumber numberWithBool:YES],  WebKitJavaScriptMarkupEnabledPreferenceKey,
438         [NSNumber numberWithBool:YES],  WebKitWebSecurityEnabledPreferenceKey,
439         [NSNumber numberWithBool:YES],  WebKitAllowUniversalAccessFromFileURLsPreferenceKey,
440         [NSNumber numberWithBool:YES],  WebKitAllowFileAccessFromFileURLsPreferenceKey,
441 #if PLATFORM(IOS)
442         [NSNumber numberWithBool:NO],   WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey,
443 #else
444         [NSNumber numberWithBool:YES],  WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey,
445 #endif
446         [NSNumber numberWithBool:YES],  WebKitPluginsEnabledPreferenceKey,
447         [NSNumber numberWithBool:YES],  WebKitDatabasesEnabledPreferenceKey,
448         [NSNumber numberWithBool:YES],  WebKitHTTPEquivEnabledPreferenceKey,
449
450 #if PLATFORM(IOS)
451         [NSNumber numberWithBool:NO],   WebKitStorageTrackerEnabledPreferenceKey,
452 #endif
453         [NSNumber numberWithBool:YES],  WebKitLocalStorageEnabledPreferenceKey,
454         [NSNumber numberWithBool:NO],   WebKitExperimentalNotificationsEnabledPreferenceKey,
455         [NSNumber numberWithBool:YES],  WebKitAllowAnimatedImagesPreferenceKey,
456         [NSNumber numberWithBool:YES],  WebKitAllowAnimatedImageLoopingPreferenceKey,
457         [NSNumber numberWithBool:YES],  WebKitDisplayImagesKey,
458         [NSNumber numberWithBool:NO],   WebKitLoadSiteIconsKey,
459         @"1800",                        WebKitBackForwardCacheExpirationIntervalKey,
460 #if !PLATFORM(IOS)
461         [NSNumber numberWithBool:NO],   WebKitTabToLinksPreferenceKey,
462 #endif
463         [NSNumber numberWithBool:NO],   WebKitPrivateBrowsingEnabledPreferenceKey,
464 #if !PLATFORM(IOS)
465         [NSNumber numberWithBool:NO],   WebKitRespectStandardStyleKeyEquivalentsPreferenceKey,
466         [NSNumber numberWithBool:NO],   WebKitShowsURLsInToolTipsPreferenceKey,
467         [NSNumber numberWithBool:NO],   WebKitShowsToolTipOverTruncatedTextPreferenceKey,
468         @"1",                           WebKitPDFDisplayModePreferenceKey,
469         @"0",                           WebKitPDFScaleFactorPreferenceKey,
470 #endif
471         @"0",                           WebKitUseSiteSpecificSpoofingPreferenceKey,
472         [NSNumber numberWithInt:WebKitEditableLinkDefaultBehavior], WebKitEditableLinkBehaviorPreferenceKey,
473 #if !PLATFORM(IOS)
474         [NSNumber numberWithInt:WebTextDirectionSubmenuAutomaticallyIncluded],
475                                         WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey,
476         [NSNumber numberWithBool:NO],   WebKitDOMPasteAllowedPreferenceKey,
477 #endif
478         [NSNumber numberWithBool:YES],  WebKitUsesPageCachePreferenceKey,
479         [NSNumber numberWithInt:cacheModelForMainBundle()], WebKitCacheModelPreferenceKey,
480         [NSNumber numberWithBool:YES],  WebKitPageCacheSupportsPluginsPreferenceKey,
481         [NSNumber numberWithBool:NO],   WebKitDeveloperExtrasEnabledPreferenceKey,
482         [NSNumber numberWithUnsignedInt:0], WebKitJavaScriptRuntimeFlagsPreferenceKey,
483         [NSNumber numberWithBool:YES],  WebKitAuthorAndUserStylesEnabledPreferenceKey,
484         [NSNumber numberWithBool:YES],  WebKitDOMTimersThrottlingEnabledPreferenceKey,
485         [NSNumber numberWithBool:NO],   WebKitWebArchiveDebugModeEnabledPreferenceKey,
486         [NSNumber numberWithBool:NO],   WebKitLocalFileContentSniffingEnabledPreferenceKey,
487         [NSNumber numberWithBool:NO],   WebKitOfflineWebApplicationCacheEnabledPreferenceKey,
488         [NSNumber numberWithBool:YES],  WebKitZoomsTextOnlyPreferenceKey,
489         [NSNumber numberWithBool:NO],   WebKitJavaScriptCanAccessClipboardPreferenceKey,
490         [NSNumber numberWithBool:YES],  WebKitXSSAuditorEnabledPreferenceKey,
491         [NSNumber numberWithBool:YES],  WebKitAcceleratedCompositingEnabledPreferenceKey,
492
493 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
494 #define DEFAULT_SUBPIXEL_ANTIALIASED_LAYER_TEXT_ENABLED YES
495 #else
496 #define DEFAULT_SUBPIXEL_ANTIALIASED_LAYER_TEXT_ENABLED NO
497 #endif
498         [NSNumber numberWithBool:DEFAULT_SUBPIXEL_ANTIALIASED_LAYER_TEXT_ENABLED], WebKitSubpixelAntialiasedLayerTextEnabledPreferenceKey,
499
500         [NSNumber numberWithBool:NO],   WebKitDisplayListDrawingEnabledPreferenceKey,
501 #if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR)
502         [NSNumber numberWithBool:YES],  WebKitAcceleratedDrawingEnabledPreferenceKey,
503         [NSNumber numberWithBool:YES],  WebKitCanvasUsesAcceleratedDrawingPreferenceKey,
504 #else
505         [NSNumber numberWithBool:NO],  WebKitAcceleratedDrawingEnabledPreferenceKey,
506         [NSNumber numberWithBool:NO],  WebKitCanvasUsesAcceleratedDrawingPreferenceKey,
507 #endif
508         [NSNumber numberWithBool:NO],   WebKitShowDebugBordersPreferenceKey,
509         [NSNumber numberWithBool:YES],  WebKitSimpleLineLayoutEnabledPreferenceKey,
510         [NSNumber numberWithBool:NO],   WebKitSimpleLineLayoutDebugBordersEnabledPreferenceKey,
511         [NSNumber numberWithBool:NO],   WebKitShowRepaintCounterPreferenceKey,
512         [NSNumber numberWithBool:YES],  WebKitWebGLEnabledPreferenceKey,
513         [NSNumber numberWithBool:NO],  WebKitForceSoftwareWebGLRenderingPreferenceKey,
514         [NSNumber numberWithBool:YES],   WebKitForceWebGLUsesLowPowerPreferenceKey,
515         [NSNumber numberWithBool:NO],   WebKitAccelerated2dCanvasEnabledPreferenceKey,
516         [NSNumber numberWithBool:NO],  WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey,
517         [NSNumber numberWithBool:NO],  WebKitResourceLoadStatisticsEnabledPreferenceKey,
518         [NSNumber numberWithBool:YES],  WebKitLargeImageAsyncDecodingEnabledPreferenceKey,
519         [NSNumber numberWithBool:YES],  WebKitAnimatedImageAsyncDecodingEnabledPreferenceKey,
520 #if PLATFORM(IOS)
521         [NSNumber numberWithUnsignedInt:static_cast<uint32_t>(FrameFlattening::FullyEnabled)], WebKitFrameFlatteningPreferenceKey,
522 #else
523         [NSNumber numberWithUnsignedInt:static_cast<uint32_t>(FrameFlattening::Disabled)], WebKitFrameFlatteningPreferenceKey,
524 #endif
525         [NSNumber numberWithBool:NO], WebKitAsyncFrameScrollingEnabledPreferenceKey,
526         [NSNumber numberWithBool:NO],   WebKitSpatialNavigationEnabledPreferenceKey,
527         [NSNumber numberWithBool:NO],  WebKitDNSPrefetchingEnabledPreferenceKey,
528         [NSNumber numberWithBool:NO],   WebKitFullScreenEnabledPreferenceKey,
529         [NSNumber numberWithBool:NO],   WebKitAsynchronousSpellCheckingEnabledPreferenceKey,
530         [NSNumber numberWithBool:YES],  WebKitHyperlinkAuditingEnabledPreferenceKey,
531         [NSNumber numberWithBool:NO],   WebKitUsePreHTML5ParserQuirksKey,
532         [NSNumber numberWithBool:YES],  WebKitAVFoundationEnabledKey,
533         [NSNumber numberWithBool:YES],  WebKitAVFoundationNSURLSessionEnabledKey,
534         [NSNumber numberWithBool:NO],   WebKitSuppressesIncrementalRenderingKey,
535         [NSNumber numberWithBool:attachmentElementEnabled], WebKitAttachmentElementEnabledPreferenceKey,
536 #if !PLATFORM(IOS)
537         [NSNumber numberWithBool:YES],  WebKitAllowsInlineMediaPlaybackPreferenceKey,
538         [NSNumber numberWithBool:NO],   WebKitAllowsInlineMediaPlaybackAfterFullscreenPreferenceKey,
539         [NSNumber numberWithBool:NO],   WebKitInlineMediaPlaybackRequiresPlaysInlineAttributeKey,
540         [NSNumber numberWithBool:YES],  WebKitMediaControlsScaleWithPageZoomPreferenceKey,
541         [NSNumber numberWithBool:NO],   WebKitWebAudioEnabledPreferenceKey,
542         [NSNumber numberWithBool:YES],  WebKitBackspaceKeyNavigationEnabledKey,
543         [NSNumber numberWithBool:NO],   WebKitShouldDisplaySubtitlesPreferenceKey,
544         [NSNumber numberWithBool:NO],   WebKitShouldDisplayCaptionsPreferenceKey,
545         [NSNumber numberWithBool:NO],   WebKitShouldDisplayTextDescriptionsPreferenceKey,
546         [NSNumber numberWithBool:YES],  WebKitNotificationsEnabledKey,
547         [NSNumber numberWithBool:NO],   WebKitShouldRespectImageOrientationKey,
548         [NSNumber numberWithBool:YES],  WebKitMediaDataLoadsAutomaticallyPreferenceKey,
549 #else
550         [NSNumber numberWithBool:allowsInlineMediaPlayback],   WebKitAllowsInlineMediaPlaybackPreferenceKey,
551         [NSNumber numberWithBool:allowsInlineMediaPlaybackAfterFullscreen],   WebKitAllowsInlineMediaPlaybackAfterFullscreenPreferenceKey,
552         [NSNumber numberWithBool:requiresPlaysInlineAttribute], WebKitInlineMediaPlaybackRequiresPlaysInlineAttributeKey,
553         [NSNumber numberWithBool:NO],   WebKitMediaControlsScaleWithPageZoomPreferenceKey,
554         [NSNumber numberWithUnsignedInt:AudioSession::None],  WebKitAudioSessionCategoryOverride,
555         [NSNumber numberWithBool:NO],   WebKitMediaDataLoadsAutomaticallyPreferenceKey,
556 #if HAVE(AVKIT)
557         [NSNumber numberWithBool:YES],  WebKitAVKitEnabled,
558 #endif
559         [NSNumber numberWithBool:YES],  WebKitRequiresUserGestureForMediaPlaybackPreferenceKey,
560         [NSNumber numberWithBool:NO],   WebKitRequiresUserGestureForVideoPlaybackPreferenceKey,
561         [NSNumber numberWithBool:NO],   WebKitRequiresUserGestureForAudioPlaybackPreferenceKey,
562         [NSNumber numberWithLongLong:WebCore::ApplicationCacheStorage::noQuota()], WebKitApplicationCacheTotalQuota,
563
564         // Per-Origin Quota on iOS is 25MB. When the quota is reached for a particular origin
565         // the quota for that origin can be increased. See also webView:exceededApplicationCacheOriginQuotaForSecurityOrigin:totalSpaceNeeded in WebUI/WebUIDelegate.m.
566         [NSNumber numberWithLongLong:(25 * 1024 * 1024)], WebKitApplicationCacheDefaultOriginQuota,
567
568         // Enable WebAudio by default in all iOS UIWebViews
569         [NSNumber numberWithBool:YES],   WebKitWebAudioEnabledPreferenceKey,
570
571         [NSNumber numberWithBool:YES],   WebKitShouldRespectImageOrientationKey,
572 #endif // PLATFORM(IOS)
573 #if ENABLE(WIRELESS_TARGET_PLAYBACK)
574         [NSNumber numberWithBool:YES],  WebKitAllowsAirPlayForMediaPlaybackPreferenceKey,
575 #endif
576         [NSNumber numberWithBool:YES],  WebKitAllowsPictureInPictureMediaPlaybackPreferenceKey,
577         [NSNumber numberWithBool:YES],  WebKitRequestAnimationFrameEnabledPreferenceKey,
578         [NSNumber numberWithBool:NO],   WebKitWantsBalancedSetDefersLoadingBehaviorKey,
579         [NSNumber numberWithBool:NO],   WebKitDiagnosticLoggingEnabledKey,
580         [NSNumber numberWithInt:WebAllowAllStorage], WebKitStorageBlockingPolicyKey,
581         [NSNumber numberWithBool:NO],   WebKitPlugInSnapshottingEnabledPreferenceKey,
582
583 #if PLATFORM(IOS)
584         [NSNumber numberWithBool:NO],   WebKitTelephoneParsingEnabledPreferenceKey,
585         [NSNumber numberWithInt:-1],      WebKitLayoutIntervalPreferenceKey,
586         [NSNumber numberWithFloat:-1.0f], WebKitMaxParseDurationPreferenceKey,
587         [NSNumber numberWithBool:NO],     WebKitAllowMultiElementImplicitFormSubmissionPreferenceKey,
588         [NSNumber numberWithBool:NO],     WebKitAlwaysRequestGeolocationPermissionPreferenceKey,
589         [NSNumber numberWithInt:InterpolationLow], WebKitInterpolationQualityPreferenceKey,
590         [NSNumber numberWithBool:YES],    WebKitPasswordEchoEnabledPreferenceKey,
591         [NSNumber numberWithFloat:2.0f],  WebKitPasswordEchoDurationPreferenceKey,
592         [NSNumber numberWithBool:NO],     WebKitNetworkDataUsageTrackingEnabledPreferenceKey,
593         @"",                              WebKitNetworkInterfaceNamePreferenceKey,
594 #endif
595 #if ENABLE(TEXT_AUTOSIZING)
596         [NSNumber numberWithFloat:Settings::defaultMinimumZoomFontSize()], WebKitMinimumZoomFontSizePreferenceKey,
597         [NSNumber numberWithBool:Settings::defaultTextAutosizingEnabled()], WebKitTextAutosizingEnabledPreferenceKey,
598 #endif
599         [NSNumber numberWithLongLong:ApplicationCacheStorage::noQuota()], WebKitApplicationCacheTotalQuota,
600         [NSNumber numberWithLongLong:ApplicationCacheStorage::noQuota()], WebKitApplicationCacheDefaultOriginQuota,
601         [NSNumber numberWithBool:NO], WebKitHiddenPageDOMTimerThrottlingEnabledPreferenceKey,
602         [NSNumber numberWithBool:NO], WebKitHiddenPageCSSAnimationSuspensionEnabledPreferenceKey,
603         [NSNumber numberWithBool:NO], WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey,
604         
605         [NSNumber numberWithBool:NO], WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey,
606 #if ENABLE(MEDIA_SOURCE)
607         [NSNumber numberWithBool:YES], WebKitMediaSourceEnabledPreferenceKey,
608 #endif
609 #if ENABLE(SERVICE_CONTROLS)
610         [NSNumber numberWithBool:NO], WebKitImageControlsEnabledPreferenceKey,
611         [NSNumber numberWithBool:NO], WebKitServiceControlsEnabledPreferenceKey,
612 #endif
613         [NSNumber numberWithBool:NO], WebKitEnableInheritURIQueryComponentPreferenceKey,
614 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
615         @"~/Library/WebKit/MediaKeys", WebKitMediaKeysStorageDirectoryKey,
616 #endif
617 #if ENABLE(MEDIA_STREAM)
618         [NSNumber numberWithBool:NO], WebKitMockCaptureDevicesEnabledPreferenceKey,
619         [NSNumber numberWithBool:YES], WebKitMockCaptureDevicesPromptEnabledPreferenceKey,
620         [NSNumber numberWithBool:YES], WebKitMediaCaptureRequiresSecureConnectionPreferenceKey,
621 #endif
622         [NSNumber numberWithBool:YES], WebKitShadowDOMEnabledPreferenceKey,
623         [NSNumber numberWithBool:YES], WebKitCustomElementsEnabledPreferenceKey,
624         [NSNumber numberWithBool:YES], WebKitDataTransferItemsEnabledPreferenceKey,
625         [NSNumber numberWithBool:NO], WebKitCustomPasteboardDataEnabledPreferenceKey,
626         [NSNumber numberWithBool:YES], WebKitModernMediaControlsEnabledPreferenceKey,
627         [NSNumber numberWithBool:NO], WebKitWebAnimationsCSSIntegrationEnabledPreferenceKey,
628
629 #if ENABLE(WEBGL2)
630         [NSNumber numberWithBool:NO], WebKitWebGL2EnabledPreferenceKey,
631 #endif
632 #if ENABLE(WEBGPU)
633         [NSNumber numberWithBool:NO], WebKitWebGPUEnabledPreferenceKey,
634 #endif
635         [NSNumber numberWithBool:NO], WebKitCacheAPIEnabledPreferenceKey,
636         [NSNumber numberWithBool:NO], WebKitCrossOriginWindowPolicySupportEnabledPreferenceKey,
637         [NSNumber numberWithBool:YES], WebKitFetchAPIEnabledPreferenceKey,
638
639 #if ENABLE(STREAMS_API)
640         [NSNumber numberWithBool:NO], WebKitReadableByteStreamAPIEnabledPreferenceKey,
641         [NSNumber numberWithBool:NO], WebKitWritableStreamAPIEnabledPreferenceKey,
642 #endif
643 #if ENABLE(DOWNLOAD_ATTRIBUTE)
644         [NSNumber numberWithBool:NO], WebKitDownloadAttributeEnabledPreferenceKey,
645 #endif
646         [NSNumber numberWithBool:NO], WebKitDirectoryUploadEnabledPreferenceKey,
647         [NSNumber numberWithBool:NO], WebKitWebAnimationsEnabledPreferenceKey,
648
649 #if PLATFORM(IOS)
650         [NSNumber numberWithBool:NO], WebKitVisualViewportEnabledPreferenceKey,
651 #else
652         [NSNumber numberWithBool:YES], WebKitVisualViewportEnabledPreferenceKey,
653 #endif
654         [NSNumber numberWithBool:NO], WebKitVisualViewportAPIEnabledPreferenceKey,
655
656         [NSNumber numberWithBool:YES], WebKitNeedsStorageAccessFromFileURLsQuirkKey,
657         [NSNumber numberWithBool:NO], WebKitAllowCrossOriginSubresourcesToAskForCredentialsKey,
658 #if ENABLE(MEDIA_STREAM)
659         [NSNumber numberWithBool:NO], WebKitMediaDevicesEnabledPreferenceKey,
660         [NSNumber numberWithBool:YES], WebKitMediaStreamEnabledPreferenceKey,
661 #endif
662 #if ENABLE(WEB_RTC)
663         [NSNumber numberWithBool:YES], WebKitPeerConnectionEnabledPreferenceKey,
664         [NSNumber numberWithBool:NO], WebKitWebRTCLegacyAPIEnabledPreferenceKey,
665 #endif
666 #if ENABLE(INTERSECTION_OBSERVER)
667         @NO, WebKitIntersectionObserverEnabledPreferenceKey,
668 #endif
669         @YES, WebKitDisplayContentsEnabledPreferenceKey,
670         @NO, WebKitUserTimingEnabledPreferenceKey,
671         @NO, WebKitResourceTimingEnabledPreferenceKey,
672         @NO, WebKitWebAuthenticationEnabledPreferenceKey,
673         @NO, WebKitMediaUserGestureInheritsFromDocument,
674         @NO, WebKitIsSecureContextAttributeEnabledPreferenceKey,
675         @YES, WebKitLegacyEncryptedMediaAPIEnabledKey,
676         @NO, WebKitEncryptedMediaAPIEnabledKey,
677         @YES, WebKitViewportFitEnabledPreferenceKey,
678         @YES, WebKitConstantPropertiesEnabledPreferenceKey,
679         @NO, WebKitColorFilterEnabledPreferenceKey,
680         @NO, WebKitPunchOutWhiteBackgroundsInDarkModePreferenceKey,
681         @YES, WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallbackKey,
682         @NO, WebKitInspectorAdditionsEnabledPreferenceKey,
683         (NSString *)Settings::defaultMediaContentTypesRequiringHardwareSupport(), WebKitMediaContentTypesRequiringHardwareSupportPreferenceKey,
684         @NO, WebKitAccessibilityObjectModelEnabledPreferenceKey,
685         @YES, WebKitAriaReflectionEnabledPreferenceKey,
686         @NO, WebKitMediaCapabilitiesEnabledPreferenceKey,
687         @NO, WebKitFetchAPIKeepAliveEnabledPreferenceKey,
688         @NO, WebKitServerTimingEnabledPreferenceKey,
689         nil];
690
691 #if !PLATFORM(IOS)
692     // This value shouldn't ever change, which is assumed in the initialization of WebKitPDFDisplayModePreferenceKey above
693     ASSERT(kPDFDisplaySinglePageContinuous == 1);
694 #endif
695     [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
696 }
697
698 - (void)dealloc
699 {
700     [self _updatePrivateBrowsingStateTo:NO];
701
702     delete _private;
703     [super dealloc];
704 }
705
706 - (NSString *)identifier
707 {
708     return _private->identifier.get();
709 }
710
711 - (id)_valueForKey:(NSString *)key
712 {
713     NSString *_key = KEY(key);
714 #if PLATFORM(IOS)
715     __block id o = nil;
716     dispatch_sync(_private->readWriteQueue, ^{
717         o = [_private->values.get() objectForKey:_key];
718     });
719 #else
720     id o = [_private->values.get() objectForKey:_key];
721 #endif
722     if (o)
723         return o;
724     o = [[NSUserDefaults standardUserDefaults] objectForKey:_key];
725     if (!o && key != _key)
726         o = [[NSUserDefaults standardUserDefaults] objectForKey:key];
727     return o;
728 }
729
730 - (NSString *)_stringValueForKey:(NSString *)key
731 {
732     id s = [self _valueForKey:key];
733     return [s isKindOfClass:[NSString class]] ? (NSString *)s : nil;
734 }
735
736 - (void)_setStringValue:(NSString *)value forKey:(NSString *)key
737 {
738     if ([[self _stringValueForKey:key] isEqualToString:value])
739         return;
740     NSString *_key = KEY(key);
741 #if PLATFORM(IOS)
742     dispatch_barrier_sync(_private->readWriteQueue, ^{
743 #endif
744     [_private->values.get() setObject:value forKey:_key];
745 #if PLATFORM(IOS)
746     });
747 #endif
748     if (_private->autosaves)
749         [[NSUserDefaults standardUserDefaults] setObject:value forKey:_key];
750     [self _postPreferencesChangedNotification];
751 }
752
753 - (int)_integerValueForKey:(NSString *)key
754 {
755     id o = [self _valueForKey:key];
756     return [o respondsToSelector:@selector(intValue)] ? [o intValue] : 0;
757 }
758
759 - (void)_setIntegerValue:(int)value forKey:(NSString *)key
760 {
761     if ([self _integerValueForKey:key] == value)
762         return;
763     NSString *_key = KEY(key);
764 #if PLATFORM(IOS)
765     dispatch_barrier_sync(_private->readWriteQueue, ^{
766 #endif
767     [_private->values.get() _webkit_setInt:value forKey:_key];
768 #if PLATFORM(IOS)
769     });
770 #endif
771     if (_private->autosaves)
772         [[NSUserDefaults standardUserDefaults] setInteger:value forKey:_key];
773     [self _postPreferencesChangedNotification];
774 }
775
776 - (unsigned int)_unsignedIntValueForKey:(NSString *)key
777 {
778     id o = [self _valueForKey:key];
779     return [o respondsToSelector:@selector(unsignedIntValue)] ? [o unsignedIntValue] : 0;
780 }
781
782 - (void)_setUnsignedIntValue:(unsigned int)value forKey:(NSString *)key
783 {
784     if ([self _unsignedIntValueForKey:key] == value)
785         return;
786     NSString *_key = KEY(key);
787 #if PLATFORM(IOS)
788     dispatch_barrier_sync(_private->readWriteQueue, ^{
789 #endif
790     [_private->values.get() _webkit_setUnsignedInt:value forKey:_key];
791 #if PLATFORM(IOS)
792     });
793 #endif
794     if (_private->autosaves)
795         [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInt:value] forKey:_key];
796     [self _postPreferencesChangedNotification];
797 }
798
799 - (float)_floatValueForKey:(NSString *)key
800 {
801     id o = [self _valueForKey:key];
802     return [o respondsToSelector:@selector(floatValue)] ? [o floatValue] : 0.0f;
803 }
804
805 - (void)_setFloatValue:(float)value forKey:(NSString *)key
806 {
807     if ([self _floatValueForKey:key] == value)
808         return;
809     NSString *_key = KEY(key);
810 #if PLATFORM(IOS)
811     dispatch_barrier_sync(_private->readWriteQueue, ^{
812 #endif
813     [_private->values.get() _webkit_setFloat:value forKey:_key];
814 #if PLATFORM(IOS)
815     });
816 #endif
817     if (_private->autosaves)
818         [[NSUserDefaults standardUserDefaults] setFloat:value forKey:_key];
819     [self _postPreferencesChangedNotification];
820 }
821
822 - (BOOL)_boolValueForKey:(NSString *)key
823 {
824     return [self _integerValueForKey:key] != 0;
825 }
826
827 - (void)_setBoolValue:(BOOL)value forKey:(NSString *)key
828 {
829     if ([self _boolValueForKey:key] == value)
830         return;
831     NSString *_key = KEY(key);
832 #if PLATFORM(IOS)
833     dispatch_barrier_sync(_private->readWriteQueue, ^{
834 #endif
835     [_private->values.get() _webkit_setBool:value forKey:_key];
836 #if PLATFORM(IOS)
837     });
838 #endif
839     if (_private->autosaves)
840         [[NSUserDefaults standardUserDefaults] setBool:value forKey:_key];
841     [self _postPreferencesChangedNotification];
842 }
843
844 - (long long)_longLongValueForKey:(NSString *)key
845 {
846     id o = [self _valueForKey:key];
847     return [o respondsToSelector:@selector(longLongValue)] ? [o longLongValue] : 0;
848 }
849
850 - (void)_setLongLongValue:(long long)value forKey:(NSString *)key
851 {
852     if ([self _longLongValueForKey:key] == value)
853         return;
854     NSString *_key = KEY(key);
855 #if PLATFORM(IOS)
856     dispatch_barrier_sync(_private->readWriteQueue, ^{
857 #endif
858     [_private->values.get() _webkit_setLongLong:value forKey:_key];
859 #if PLATFORM(IOS)
860     });
861 #endif
862     if (_private->autosaves)
863         [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithLongLong:value] forKey:_key];
864     [self _postPreferencesChangedNotification];
865 }
866
867 - (unsigned long long)_unsignedLongLongValueForKey:(NSString *)key
868 {
869     id o = [self _valueForKey:key];
870     return [o respondsToSelector:@selector(unsignedLongLongValue)] ? [o unsignedLongLongValue] : 0;
871 }
872
873 - (void)_setUnsignedLongLongValue:(unsigned long long)value forKey:(NSString *)key
874 {
875     if ([self _unsignedLongLongValueForKey:key] == value)
876         return;
877     NSString *_key = KEY(key);
878 #if PLATFORM(IOS)
879     dispatch_barrier_sync(_private->readWriteQueue, ^{
880 #endif
881     [_private->values.get() _webkit_setUnsignedLongLong:value forKey:_key];
882 #if PLATFORM(IOS)
883     });
884 #endif
885     if (_private->autosaves)
886         [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedLongLong:value] forKey:_key];
887     [self _postPreferencesChangedNotification];
888 }
889
890 - (NSString *)standardFontFamily
891 {
892     return [self _stringValueForKey: WebKitStandardFontPreferenceKey];
893 }
894
895 - (void)setStandardFontFamily:(NSString *)family
896 {
897     [self _setStringValue: family forKey: WebKitStandardFontPreferenceKey];
898 }
899
900 - (NSString *)fixedFontFamily
901 {
902     return [self _stringValueForKey: WebKitFixedFontPreferenceKey];
903 }
904
905 - (void)setFixedFontFamily:(NSString *)family
906 {
907     [self _setStringValue: family forKey: WebKitFixedFontPreferenceKey];
908 }
909
910 - (NSString *)serifFontFamily
911 {
912     return [self _stringValueForKey: WebKitSerifFontPreferenceKey];
913 }
914
915 - (void)setSerifFontFamily:(NSString *)family 
916 {
917     [self _setStringValue: family forKey: WebKitSerifFontPreferenceKey];
918 }
919
920 - (NSString *)sansSerifFontFamily
921 {
922     return [self _stringValueForKey: WebKitSansSerifFontPreferenceKey];
923 }
924
925 - (void)setSansSerifFontFamily:(NSString *)family
926 {
927     [self _setStringValue: family forKey: WebKitSansSerifFontPreferenceKey];
928 }
929
930 - (NSString *)cursiveFontFamily
931 {
932     return [self _stringValueForKey: WebKitCursiveFontPreferenceKey];
933 }
934
935 - (void)setCursiveFontFamily:(NSString *)family
936 {
937     [self _setStringValue: family forKey: WebKitCursiveFontPreferenceKey];
938 }
939
940 - (NSString *)fantasyFontFamily
941 {
942     return [self _stringValueForKey: WebKitFantasyFontPreferenceKey];
943 }
944
945 - (void)setFantasyFontFamily:(NSString *)family
946 {
947     [self _setStringValue: family forKey: WebKitFantasyFontPreferenceKey];
948 }
949
950 - (int)defaultFontSize
951 {
952     return [self _integerValueForKey: WebKitDefaultFontSizePreferenceKey];
953 }
954
955 - (void)setDefaultFontSize:(int)size
956 {
957     [self _setIntegerValue: size forKey: WebKitDefaultFontSizePreferenceKey];
958 }
959
960 - (int)defaultFixedFontSize
961 {
962     return [self _integerValueForKey: WebKitDefaultFixedFontSizePreferenceKey];
963 }
964
965 - (void)setDefaultFixedFontSize:(int)size
966 {
967     [self _setIntegerValue: size forKey: WebKitDefaultFixedFontSizePreferenceKey];
968 }
969
970 - (int)minimumFontSize
971 {
972     return [self _integerValueForKey: WebKitMinimumFontSizePreferenceKey];
973 }
974
975 - (void)setMinimumFontSize:(int)size
976 {
977     [self _setIntegerValue: size forKey: WebKitMinimumFontSizePreferenceKey];
978 }
979
980 - (int)minimumLogicalFontSize
981 {
982   return [self _integerValueForKey: WebKitMinimumLogicalFontSizePreferenceKey];
983 }
984
985 - (void)setMinimumLogicalFontSize:(int)size
986 {
987   [self _setIntegerValue: size forKey: WebKitMinimumLogicalFontSizePreferenceKey];
988 }
989
990 - (NSString *)defaultTextEncodingName
991 {
992     return [self _stringValueForKey: WebKitDefaultTextEncodingNamePreferenceKey];
993 }
994
995 - (void)setDefaultTextEncodingName:(NSString *)encoding
996 {
997     [self _setStringValue: encoding forKey: WebKitDefaultTextEncodingNamePreferenceKey];
998 }
999
1000 #if !PLATFORM(IOS)
1001 - (BOOL)userStyleSheetEnabled
1002 {
1003     return [self _boolValueForKey: WebKitUserStyleSheetEnabledPreferenceKey];
1004 }
1005
1006 - (void)setUserStyleSheetEnabled:(BOOL)flag
1007 {
1008     [self _setBoolValue: flag forKey: WebKitUserStyleSheetEnabledPreferenceKey];
1009 }
1010
1011 - (NSURL *)userStyleSheetLocation
1012 {
1013     NSString *locationString = [self _stringValueForKey: WebKitUserStyleSheetLocationPreferenceKey];
1014     
1015     if ([locationString _webkit_looksLikeAbsoluteURL]) {
1016         return [NSURL _web_URLWithDataAsString:locationString];
1017     } else {
1018         locationString = [locationString stringByExpandingTildeInPath];
1019         return [NSURL fileURLWithPath:locationString isDirectory:NO];
1020     }
1021 }
1022
1023 - (void)setUserStyleSheetLocation:(NSURL *)URL
1024 {
1025     NSString *locationString;
1026     
1027     if ([URL isFileURL]) {
1028         locationString = [[URL path] _web_stringByAbbreviatingWithTildeInPath];
1029     } else {
1030         locationString = [URL _web_originalDataAsString];
1031     }
1032
1033     if (!locationString)
1034         locationString = @"";
1035
1036     [self _setStringValue:locationString forKey: WebKitUserStyleSheetLocationPreferenceKey];
1037 }
1038 #else
1039
1040 // These methods have had their implementations removed on iOS since it
1041 // is wrong to have such a setting stored in preferences that, when read,
1042 // is applied to all WebViews in a iOS process. Such a design might work
1043 // OK for an application like Safari on Mac OS X, where the only WebViews
1044 // in use display web content in a straightforward manner. However, it is
1045 // wrong for iOS, where WebViews are used for various purposes, like
1046 // text editing, text rendering, and displaying web content.
1047 // 
1048 // I have changed the user style sheet mechanism to be a per-WebView
1049 // setting, rather than a per-process preference. This seems to give the
1050 // behavior we want for iOS.
1051
1052 - (BOOL)userStyleSheetEnabled
1053 {
1054     return NO;
1055 }
1056
1057 - (void)setUserStyleSheetEnabled:(BOOL)flag
1058 {
1059     // no-op
1060 }
1061
1062 - (NSURL *)userStyleSheetLocation
1063 {
1064     return nil;
1065 }
1066
1067 - (void)setUserStyleSheetLocation:(NSURL *)URL
1068 {
1069     // no-op
1070 }
1071 #endif // PLATFORM(IOS)
1072
1073 #if !PLATFORM(IOS)
1074 - (BOOL)shouldPrintBackgrounds
1075 {
1076     return [self _boolValueForKey: WebKitShouldPrintBackgroundsPreferenceKey];
1077 }
1078
1079 - (void)setShouldPrintBackgrounds:(BOOL)flag
1080 {
1081     [self _setBoolValue: flag forKey: WebKitShouldPrintBackgroundsPreferenceKey];
1082 }
1083 #endif
1084
1085 - (BOOL)isJavaEnabled
1086 {
1087     return [self _boolValueForKey: WebKitJavaEnabledPreferenceKey];
1088 }
1089
1090 - (void)setJavaEnabled:(BOOL)flag
1091 {
1092     [self _setBoolValue: flag forKey: WebKitJavaEnabledPreferenceKey];
1093 }
1094
1095 - (BOOL)isJavaScriptEnabled
1096 {
1097     return [self _boolValueForKey: WebKitJavaScriptEnabledPreferenceKey];
1098 }
1099
1100 - (void)setJavaScriptEnabled:(BOOL)flag
1101 {
1102     [self _setBoolValue: flag forKey: WebKitJavaScriptEnabledPreferenceKey];
1103 }
1104
1105 - (BOOL)javaScriptCanOpenWindowsAutomatically
1106 {
1107     return [self _boolValueForKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
1108 }
1109
1110 - (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag
1111 {
1112     [self _setBoolValue: flag forKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
1113 }
1114
1115 - (BOOL)arePlugInsEnabled
1116 {
1117     return [self _boolValueForKey: WebKitPluginsEnabledPreferenceKey];
1118 }
1119
1120 - (void)setPlugInsEnabled:(BOOL)flag
1121 {
1122     [self _setBoolValue: flag forKey: WebKitPluginsEnabledPreferenceKey];
1123 }
1124
1125 - (BOOL)allowsAnimatedImages
1126 {
1127     return [self _boolValueForKey: WebKitAllowAnimatedImagesPreferenceKey];
1128 }
1129
1130 - (void)setAllowsAnimatedImages:(BOOL)flag
1131 {
1132     [self _setBoolValue: flag forKey: WebKitAllowAnimatedImagesPreferenceKey];
1133 }
1134
1135 - (BOOL)allowsAnimatedImageLooping
1136 {
1137     return [self _boolValueForKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
1138 }
1139
1140 - (void)setAllowsAnimatedImageLooping: (BOOL)flag
1141 {
1142     [self _setBoolValue: flag forKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
1143 }
1144
1145 - (void)setLoadsImagesAutomatically: (BOOL)flag
1146 {
1147     [self _setBoolValue: flag forKey: WebKitDisplayImagesKey];
1148 }
1149
1150 - (BOOL)loadsImagesAutomatically
1151 {
1152     return [self _boolValueForKey: WebKitDisplayImagesKey];
1153 }
1154
1155 - (void)setAutosaves:(BOOL)flag
1156 {
1157     _private->autosaves = flag;
1158 }
1159
1160 - (BOOL)autosaves
1161 {
1162     return _private->autosaves;
1163 }
1164
1165 #if !PLATFORM(IOS)
1166 - (void)setTabsToLinks:(BOOL)flag
1167 {
1168     [self _setBoolValue: flag forKey: WebKitTabToLinksPreferenceKey];
1169 }
1170
1171 - (BOOL)tabsToLinks
1172 {
1173     return [self _boolValueForKey:WebKitTabToLinksPreferenceKey];
1174 }
1175 #endif
1176
1177 - (void)setPrivateBrowsingEnabled:(BOOL)enabled
1178 {
1179     [self _updatePrivateBrowsingStateTo:enabled];
1180     [self _setBoolValue:enabled forKey:WebKitPrivateBrowsingEnabledPreferenceKey];
1181 }
1182
1183 - (BOOL)privateBrowsingEnabled
1184 {
1185     // Changes to private browsing defaults do not have effect on existing WebPreferences, and must be done through -setPrivateBrowsingEnabled.
1186     // This is needed to accurately track private browsing sessions in the process.
1187     return _private->inPrivateBrowsing;
1188 }
1189
1190 - (void)_updatePrivateBrowsingStateTo:(BOOL)enabled
1191 {
1192     if (!_private) {
1193         ASSERT(!enabled);
1194         return;
1195     }
1196
1197     if (enabled == _private->inPrivateBrowsing)
1198         return;
1199     if (enabled > _private->inPrivateBrowsing) {
1200         WebFrameNetworkingContext::ensurePrivateBrowsingSession();
1201         ++webPreferencesInstanceCountWithPrivateBrowsingEnabled;
1202     } else {
1203         ASSERT(webPreferencesInstanceCountWithPrivateBrowsingEnabled);
1204         --webPreferencesInstanceCountWithPrivateBrowsingEnabled;
1205         if (!webPreferencesInstanceCountWithPrivateBrowsingEnabled)
1206             WebFrameNetworkingContext::destroyPrivateBrowsingSession();
1207     }
1208     _private->inPrivateBrowsing = enabled;
1209 }
1210
1211 - (void)setUsesPageCache:(BOOL)usesPageCache
1212 {
1213     [self _setBoolValue:usesPageCache forKey:WebKitUsesPageCachePreferenceKey];
1214 }
1215
1216 - (BOOL)usesPageCache
1217 {
1218     return [self _boolValueForKey:WebKitUsesPageCachePreferenceKey];
1219 }
1220
1221 - (void)_postCacheModelChangedNotification
1222 {
1223 #if !PLATFORM(IOS)
1224     if (!pthread_main_np()) {
1225         [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO];
1226         return;
1227     }
1228 #endif
1229
1230     [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesCacheModelChangedInternalNotification object:self userInfo:nil];
1231 }
1232
1233 - (void)setCacheModel:(WebCacheModel)cacheModel
1234 {
1235     [self _setIntegerValue:cacheModel forKey:WebKitCacheModelPreferenceKey];
1236     [self setAutomaticallyDetectsCacheModel:NO];
1237     [self _postCacheModelChangedNotification];
1238 }
1239
1240 - (WebCacheModel)cacheModel
1241 {
1242     return (WebCacheModel)[self _integerValueForKey:WebKitCacheModelPreferenceKey];
1243 }
1244
1245
1246 - (void)setSuppressesIncrementalRendering:(BOOL)suppressesIncrementalRendering
1247 {
1248     [self _setBoolValue:suppressesIncrementalRendering forKey:WebKitSuppressesIncrementalRenderingKey];
1249 }
1250
1251 - (BOOL)suppressesIncrementalRendering
1252 {
1253     return [self _boolValueForKey:WebKitSuppressesIncrementalRenderingKey];
1254 }
1255
1256 - (BOOL)allowsAirPlayForMediaPlayback
1257 {
1258 #if ENABLE(WIRELESS_TARGET_PLAYBACK)
1259     return [self _boolValueForKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
1260 #else
1261     return false;
1262 #endif
1263 }
1264
1265 - (void)setAllowsAirPlayForMediaPlayback:(BOOL)flag
1266 {
1267 #if ENABLE(WIRELESS_TARGET_PLAYBACK)
1268     [self _setBoolValue:flag forKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
1269 #endif
1270 }
1271
1272 @end
1273
1274 @implementation WebPreferences (WebPrivate)
1275
1276 - (BOOL)isDNSPrefetchingEnabled
1277 {
1278     return [self _boolValueForKey:WebKitDNSPrefetchingEnabledPreferenceKey];
1279 }
1280
1281 - (void)setDNSPrefetchingEnabled:(BOOL)flag
1282 {
1283     [self _setBoolValue:flag forKey:WebKitDNSPrefetchingEnabledPreferenceKey];
1284 }
1285
1286 - (BOOL)developerExtrasEnabled
1287 {
1288     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
1289     if ([defaults boolForKey:@"DisableWebKitDeveloperExtras"])
1290         return NO;
1291 #ifdef NDEBUG
1292     if ([defaults boolForKey:@"WebKitDeveloperExtras"] || [defaults boolForKey:@"IncludeDebugMenu"])
1293         return YES;
1294     return [self _boolValueForKey:WebKitDeveloperExtrasEnabledPreferenceKey];
1295 #else
1296     return YES; // always enable in debug builds
1297 #endif
1298 }
1299
1300 - (WebKitJavaScriptRuntimeFlags)javaScriptRuntimeFlags
1301 {
1302     return static_cast<WebKitJavaScriptRuntimeFlags>([self _unsignedIntValueForKey:WebKitJavaScriptRuntimeFlagsPreferenceKey]);
1303 }
1304
1305 - (void)setJavaScriptRuntimeFlags:(WebKitJavaScriptRuntimeFlags)flags
1306 {
1307     [self _setUnsignedIntValue:flags forKey:WebKitJavaScriptRuntimeFlagsPreferenceKey];
1308 }
1309
1310 - (void)setDeveloperExtrasEnabled:(BOOL)flag
1311 {
1312     [self _setBoolValue:flag forKey:WebKitDeveloperExtrasEnabledPreferenceKey];
1313 }
1314
1315 - (BOOL)authorAndUserStylesEnabled
1316 {
1317     return [self _boolValueForKey:WebKitAuthorAndUserStylesEnabledPreferenceKey];
1318 }
1319
1320 - (void)setAuthorAndUserStylesEnabled:(BOOL)flag
1321 {
1322     [self _setBoolValue:flag forKey:WebKitAuthorAndUserStylesEnabledPreferenceKey];
1323 }
1324
1325 // FIXME: applicationChromeMode is no longer needed by ToT, but is still used in Safari 8.
1326 - (BOOL)applicationChromeModeEnabled
1327 {
1328     return NO;
1329 }
1330
1331 - (void)setApplicationChromeModeEnabled:(BOOL)flag
1332 {
1333 }
1334
1335 - (BOOL)domTimersThrottlingEnabled
1336 {
1337     return [self _boolValueForKey:WebKitDOMTimersThrottlingEnabledPreferenceKey];
1338 }
1339
1340 - (void)setDOMTimersThrottlingEnabled:(BOOL)flag
1341 {
1342     [self _setBoolValue:flag forKey:WebKitDOMTimersThrottlingEnabledPreferenceKey];
1343 }
1344
1345 - (BOOL)webArchiveDebugModeEnabled
1346 {
1347     return [self _boolValueForKey:WebKitWebArchiveDebugModeEnabledPreferenceKey];
1348 }
1349
1350 - (void)setWebArchiveDebugModeEnabled:(BOOL)flag
1351 {
1352     [self _setBoolValue:flag forKey:WebKitWebArchiveDebugModeEnabledPreferenceKey];
1353 }
1354
1355 - (BOOL)localFileContentSniffingEnabled
1356 {
1357     return [self _boolValueForKey:WebKitLocalFileContentSniffingEnabledPreferenceKey];
1358 }
1359
1360 - (void)setLocalFileContentSniffingEnabled:(BOOL)flag
1361 {
1362     [self _setBoolValue:flag forKey:WebKitLocalFileContentSniffingEnabledPreferenceKey];
1363 }
1364
1365 - (BOOL)offlineWebApplicationCacheEnabled
1366 {
1367     return [self _boolValueForKey:WebKitOfflineWebApplicationCacheEnabledPreferenceKey];
1368 }
1369
1370 - (void)setOfflineWebApplicationCacheEnabled:(BOOL)flag
1371 {
1372     [self _setBoolValue:flag forKey:WebKitOfflineWebApplicationCacheEnabledPreferenceKey];
1373 }
1374
1375 - (BOOL)zoomsTextOnly
1376 {
1377     return [self _boolValueForKey:WebKitZoomsTextOnlyPreferenceKey];
1378 }
1379
1380 - (void)setZoomsTextOnly:(BOOL)flag
1381 {
1382     [self _setBoolValue:flag forKey:WebKitZoomsTextOnlyPreferenceKey];
1383 }
1384
1385 - (BOOL)javaScriptCanAccessClipboard
1386 {
1387     return [self _boolValueForKey:WebKitJavaScriptCanAccessClipboardPreferenceKey];
1388 }
1389
1390 - (void)setJavaScriptCanAccessClipboard:(BOOL)flag
1391 {
1392     [self _setBoolValue:flag forKey:WebKitJavaScriptCanAccessClipboardPreferenceKey];
1393 }
1394
1395 - (BOOL)isXSSAuditorEnabled
1396 {
1397     return [self _boolValueForKey:WebKitXSSAuditorEnabledPreferenceKey];
1398 }
1399
1400 - (void)setXSSAuditorEnabled:(BOOL)flag
1401 {
1402     [self _setBoolValue:flag forKey:WebKitXSSAuditorEnabledPreferenceKey];
1403 }
1404
1405 #if !PLATFORM(IOS)
1406 - (BOOL)respectStandardStyleKeyEquivalents
1407 {
1408     return [self _boolValueForKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
1409 }
1410
1411 - (void)setRespectStandardStyleKeyEquivalents:(BOOL)flag
1412 {
1413     [self _setBoolValue:flag forKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
1414 }
1415
1416 - (BOOL)showsURLsInToolTips
1417 {
1418     return [self _boolValueForKey:WebKitShowsURLsInToolTipsPreferenceKey];
1419 }
1420
1421 - (void)setShowsURLsInToolTips:(BOOL)flag
1422 {
1423     [self _setBoolValue:flag forKey:WebKitShowsURLsInToolTipsPreferenceKey];
1424 }
1425
1426 - (BOOL)showsToolTipOverTruncatedText
1427 {
1428     return [self _boolValueForKey:WebKitShowsToolTipOverTruncatedTextPreferenceKey];
1429 }
1430
1431 - (void)setShowsToolTipOverTruncatedText:(BOOL)flag
1432 {
1433     [self _setBoolValue:flag forKey:WebKitShowsToolTipOverTruncatedTextPreferenceKey];
1434 }
1435
1436 - (BOOL)textAreasAreResizable
1437 {
1438     return [self _boolValueForKey: WebKitTextAreasAreResizablePreferenceKey];
1439 }
1440
1441 - (void)setTextAreasAreResizable:(BOOL)flag
1442 {
1443     [self _setBoolValue: flag forKey: WebKitTextAreasAreResizablePreferenceKey];
1444 }
1445 #endif // !PLATFORM(IOS)
1446
1447 - (BOOL)shrinksStandaloneImagesToFit
1448 {
1449     return [self _boolValueForKey:WebKitShrinksStandaloneImagesToFitPreferenceKey];
1450 }
1451
1452 - (void)setShrinksStandaloneImagesToFit:(BOOL)flag
1453 {
1454     [self _setBoolValue:flag forKey:WebKitShrinksStandaloneImagesToFitPreferenceKey];
1455 }
1456
1457 - (BOOL)automaticallyDetectsCacheModel
1458 {
1459     return _private->automaticallyDetectsCacheModel;
1460 }
1461
1462 - (void)setAutomaticallyDetectsCacheModel:(BOOL)automaticallyDetectsCacheModel
1463 {
1464     _private->automaticallyDetectsCacheModel = automaticallyDetectsCacheModel;
1465 }
1466
1467 - (BOOL)usesEncodingDetector
1468 {
1469     return [self _boolValueForKey: WebKitUsesEncodingDetectorPreferenceKey];
1470 }
1471
1472 - (void)setUsesEncodingDetector:(BOOL)flag
1473 {
1474     [self _setBoolValue: flag forKey: WebKitUsesEncodingDetectorPreferenceKey];
1475 }
1476
1477 - (BOOL)isWebSecurityEnabled
1478 {
1479     return [self _boolValueForKey: WebKitWebSecurityEnabledPreferenceKey];
1480 }
1481
1482 - (void)setWebSecurityEnabled:(BOOL)flag
1483 {
1484     [self _setBoolValue: flag forKey: WebKitWebSecurityEnabledPreferenceKey];
1485 }
1486
1487 - (BOOL)allowUniversalAccessFromFileURLs
1488 {
1489     return [self _boolValueForKey: WebKitAllowUniversalAccessFromFileURLsPreferenceKey];
1490 }
1491
1492 - (void)setAllowUniversalAccessFromFileURLs:(BOOL)flag
1493 {
1494     [self _setBoolValue: flag forKey: WebKitAllowUniversalAccessFromFileURLsPreferenceKey];
1495 }
1496
1497 - (BOOL)allowFileAccessFromFileURLs
1498 {
1499     return [self _boolValueForKey: WebKitAllowFileAccessFromFileURLsPreferenceKey];
1500 }
1501
1502 - (void)setAllowFileAccessFromFileURLs:(BOOL)flag
1503 {
1504     [self _setBoolValue: flag forKey: WebKitAllowFileAccessFromFileURLsPreferenceKey];
1505 }
1506
1507 - (BOOL)allowCrossOriginSubresourcesToAskForCredentials
1508 {
1509     return [self _boolValueForKey:WebKitAllowCrossOriginSubresourcesToAskForCredentialsKey];
1510 }
1511
1512 - (void)setAllowCrossOriginSubresourcesToAskForCredentials:(BOOL)flag
1513 {
1514     [self _setBoolValue:flag forKey:WebKitAllowCrossOriginSubresourcesToAskForCredentialsKey];
1515 }
1516
1517 - (BOOL)needsStorageAccessFromFileURLsQuirk
1518 {
1519     return [self _boolValueForKey: WebKitNeedsStorageAccessFromFileURLsQuirkKey];
1520 }
1521
1522 -(void)setNeedsStorageAccessFromFileURLsQuirk:(BOOL)flag
1523 {
1524     [self _setBoolValue: flag forKey: WebKitNeedsStorageAccessFromFileURLsQuirkKey];
1525 }
1526
1527 - (NSTimeInterval)_backForwardCacheExpirationInterval
1528 {
1529     return (NSTimeInterval)[self _floatValueForKey:WebKitBackForwardCacheExpirationIntervalKey];
1530 }
1531
1532 #if PLATFORM(IOS)
1533 - (BOOL)_standalone
1534 {
1535     return [self _boolValueForKey:WebKitStandalonePreferenceKey];
1536 }
1537
1538 - (void)_setStandalone:(BOOL)flag
1539 {
1540     [self _setBoolValue:flag forKey:WebKitStandalonePreferenceKey];
1541 }
1542
1543 - (void)_setTelephoneNumberParsingEnabled:(BOOL)flag
1544 {
1545     [self _setBoolValue:flag forKey:WebKitTelephoneParsingEnabledPreferenceKey];
1546 }
1547
1548 - (BOOL)_telephoneNumberParsingEnabled
1549 {
1550     return [self _boolValueForKey:WebKitTelephoneParsingEnabledPreferenceKey];
1551 }
1552 #endif
1553
1554 #if ENABLE(TEXT_AUTOSIZING)
1555 - (void)_setMinimumZoomFontSize:(float)size
1556 {
1557     [self _setFloatValue:size forKey:WebKitMinimumZoomFontSizePreferenceKey];
1558 }
1559
1560 - (float)_minimumZoomFontSize
1561 {
1562     return [self _floatValueForKey:WebKitMinimumZoomFontSizePreferenceKey];
1563 }
1564
1565 - (void)_setTextAutosizingEnabled:(BOOL)enabled
1566 {
1567     [self _setBoolValue:enabled forKey:WebKitTextAutosizingEnabledPreferenceKey];
1568 }
1569
1570 - (BOOL)_textAutosizingEnabled
1571 {
1572     return [self _boolValueForKey:WebKitTextAutosizingEnabledPreferenceKey];
1573 }
1574 #endif
1575
1576 #if PLATFORM(IOS)
1577 - (void)_setLayoutInterval:(int)l
1578 {
1579     [self _setIntegerValue:l forKey:WebKitLayoutIntervalPreferenceKey];
1580 }
1581
1582 - (int)_layoutInterval
1583 {
1584     return [self _integerValueForKey:WebKitLayoutIntervalPreferenceKey];
1585 }
1586
1587 - (void)_setMaxParseDuration:(float)d
1588 {
1589     [self _setFloatValue:d forKey:WebKitMaxParseDurationPreferenceKey];
1590 }
1591
1592 - (float)_maxParseDuration
1593 {
1594     return [self _floatValueForKey:WebKitMaxParseDurationPreferenceKey];
1595 }
1596
1597 - (void)_setAllowMultiElementImplicitFormSubmission:(BOOL)flag
1598 {
1599     [self _setBoolValue:flag forKey:WebKitAllowMultiElementImplicitFormSubmissionPreferenceKey];
1600 }
1601
1602 - (BOOL)_allowMultiElementImplicitFormSubmission
1603 {
1604     return [self _boolValueForKey:WebKitAllowMultiElementImplicitFormSubmissionPreferenceKey];
1605 }
1606
1607 - (void)_setAlwaysRequestGeolocationPermission:(BOOL)flag
1608 {
1609     [self _setBoolValue:flag forKey:WebKitAlwaysRequestGeolocationPermissionPreferenceKey];
1610 }
1611
1612 - (BOOL)_alwaysRequestGeolocationPermission
1613 {
1614     return [self _boolValueForKey:WebKitAlwaysRequestGeolocationPermissionPreferenceKey];
1615 }
1616
1617 - (void)_setAlwaysUseAcceleratedOverflowScroll:(BOOL)flag
1618 {
1619     [self _setBoolValue:flag forKey:WebKitAlwaysUseAcceleratedOverflowScrollPreferenceKey];
1620 }
1621
1622 - (BOOL)_alwaysUseAcceleratedOverflowScroll
1623 {
1624     return [self _boolValueForKey:WebKitAlwaysUseAcceleratedOverflowScrollPreferenceKey];
1625 }
1626
1627 - (void)_setInterpolationQuality:(int)quality
1628 {
1629     [self _setIntegerValue:quality forKey:WebKitInterpolationQualityPreferenceKey];
1630 }
1631
1632 - (int)_interpolationQuality
1633 {
1634     return [self _integerValueForKey:WebKitInterpolationQualityPreferenceKey];
1635 }
1636
1637 - (BOOL)_allowPasswordEcho
1638 {
1639     return [self _boolValueForKey:WebKitPasswordEchoEnabledPreferenceKey];
1640 }
1641
1642 - (float)_passwordEchoDuration
1643 {
1644     return [self _floatValueForKey:WebKitPasswordEchoDurationPreferenceKey];
1645 }
1646
1647 #endif // PLATFORM(IOS)
1648
1649 #if !PLATFORM(IOS)
1650 - (float)PDFScaleFactor
1651 {
1652     return [self _floatValueForKey:WebKitPDFScaleFactorPreferenceKey];
1653 }
1654
1655 - (void)setPDFScaleFactor:(float)factor
1656 {
1657     [self _setFloatValue:factor forKey:WebKitPDFScaleFactorPreferenceKey];
1658 }
1659 #endif
1660
1661 - (int64_t)applicationCacheTotalQuota
1662 {
1663     return [self _longLongValueForKey:WebKitApplicationCacheTotalQuota];
1664 }
1665
1666 - (void)setApplicationCacheTotalQuota:(int64_t)quota
1667 {
1668     [self _setLongLongValue:quota forKey:WebKitApplicationCacheTotalQuota];
1669
1670     // Application Cache Preferences are stored on the global cache storage manager, not in Settings.
1671     [WebApplicationCache setMaximumSize:quota];
1672 }
1673
1674 - (int64_t)applicationCacheDefaultOriginQuota
1675 {
1676     return [self _longLongValueForKey:WebKitApplicationCacheDefaultOriginQuota];
1677 }
1678
1679 - (void)setApplicationCacheDefaultOriginQuota:(int64_t)quota
1680 {
1681     [self _setLongLongValue:quota forKey:WebKitApplicationCacheDefaultOriginQuota];
1682 }
1683
1684 #if !PLATFORM(IOS)
1685 - (PDFDisplayMode)PDFDisplayMode
1686 {
1687     PDFDisplayMode value = static_cast<PDFDisplayMode>([self _integerValueForKey:WebKitPDFDisplayModePreferenceKey]);
1688     if (value != kPDFDisplaySinglePage && value != kPDFDisplaySinglePageContinuous && value != kPDFDisplayTwoUp && value != kPDFDisplayTwoUpContinuous) {
1689         // protect against new modes from future versions of OS X stored in defaults
1690         value = kPDFDisplaySinglePageContinuous;
1691     }
1692     return value;
1693 }
1694
1695 - (void)setPDFDisplayMode:(PDFDisplayMode)mode
1696 {
1697     [self _setIntegerValue:mode forKey:WebKitPDFDisplayModePreferenceKey];
1698 }
1699 #endif
1700
1701 - (WebKitEditableLinkBehavior)editableLinkBehavior
1702 {
1703     WebKitEditableLinkBehavior value = static_cast<WebKitEditableLinkBehavior> ([self _integerValueForKey:WebKitEditableLinkBehaviorPreferenceKey]);
1704     if (value != WebKitEditableLinkDefaultBehavior &&
1705         value != WebKitEditableLinkAlwaysLive &&
1706         value != WebKitEditableLinkNeverLive &&
1707         value != WebKitEditableLinkOnlyLiveWithShiftKey &&
1708         value != WebKitEditableLinkLiveWhenNotFocused) {
1709         // ensure that a valid result is returned
1710         value = WebKitEditableLinkDefaultBehavior;
1711     }
1712     
1713     return value;
1714 }
1715
1716 - (void)setEditableLinkBehavior:(WebKitEditableLinkBehavior)behavior
1717 {
1718     [self _setIntegerValue:behavior forKey:WebKitEditableLinkBehaviorPreferenceKey];
1719 }
1720
1721 - (WebTextDirectionSubmenuInclusionBehavior)textDirectionSubmenuInclusionBehavior
1722 {
1723     WebTextDirectionSubmenuInclusionBehavior value = static_cast<WebTextDirectionSubmenuInclusionBehavior>([self _integerValueForKey:WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey]);
1724     if (value != WebTextDirectionSubmenuNeverIncluded &&
1725         value != WebTextDirectionSubmenuAutomaticallyIncluded &&
1726         value != WebTextDirectionSubmenuAlwaysIncluded) {
1727         // Ensure that a valid result is returned.
1728         value = WebTextDirectionSubmenuNeverIncluded;
1729     }
1730     return value;
1731 }
1732
1733 - (void)setTextDirectionSubmenuInclusionBehavior:(WebTextDirectionSubmenuInclusionBehavior)behavior
1734 {
1735     [self _setIntegerValue:behavior forKey:WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey];
1736 }
1737
1738 - (BOOL)_useSiteSpecificSpoofing
1739 {
1740     return [self _boolValueForKey:WebKitUseSiteSpecificSpoofingPreferenceKey];
1741 }
1742
1743 - (void)_setUseSiteSpecificSpoofing:(BOOL)newValue
1744 {
1745     [self _setBoolValue:newValue forKey:WebKitUseSiteSpecificSpoofingPreferenceKey];
1746 }
1747
1748 - (BOOL)databasesEnabled
1749 {
1750     return [self _boolValueForKey:WebKitDatabasesEnabledPreferenceKey];
1751 }
1752
1753 - (void)setDatabasesEnabled:(BOOL)databasesEnabled
1754 {
1755     [self _setBoolValue:databasesEnabled forKey:WebKitDatabasesEnabledPreferenceKey];
1756 }
1757
1758 #if PLATFORM(IOS)
1759 - (BOOL)storageTrackerEnabled
1760 {
1761     return [self _boolValueForKey:WebKitStorageTrackerEnabledPreferenceKey];
1762 }
1763
1764 - (void)setStorageTrackerEnabled:(BOOL)storageTrackerEnabled
1765 {
1766     [self _setBoolValue:storageTrackerEnabled forKey:WebKitStorageTrackerEnabledPreferenceKey];
1767 }
1768 #endif
1769
1770 - (BOOL)localStorageEnabled
1771 {
1772     return [self _boolValueForKey:WebKitLocalStorageEnabledPreferenceKey];
1773 }
1774
1775 - (void)setLocalStorageEnabled:(BOOL)localStorageEnabled
1776 {
1777     [self _setBoolValue:localStorageEnabled forKey:WebKitLocalStorageEnabledPreferenceKey];
1778 }
1779
1780 - (BOOL)experimentalNotificationsEnabled
1781 {
1782     return [self _boolValueForKey:WebKitExperimentalNotificationsEnabledPreferenceKey];
1783 }
1784
1785 - (void)setExperimentalNotificationsEnabled:(BOOL)experimentalNotificationsEnabled
1786 {
1787     [self _setBoolValue:experimentalNotificationsEnabled forKey:WebKitExperimentalNotificationsEnabledPreferenceKey];
1788 }
1789
1790 + (WebPreferences *)_getInstanceForIdentifier:(NSString *)ident
1791 {
1792     LOG(Encoding, "requesting for %@\n", ident);
1793
1794     if (!ident)
1795         return _standardPreferences;
1796     
1797     WebPreferences *instance = [webPreferencesInstances objectForKey:[self _concatenateKeyWithIBCreatorID:ident]];
1798
1799     return instance;
1800 }
1801
1802 + (void)_setInstance:(WebPreferences *)instance forIdentifier:(NSString *)ident
1803 {
1804     if (!webPreferencesInstances)
1805         webPreferencesInstances = [[NSMutableDictionary alloc] init];
1806     if (ident) {
1807         [webPreferencesInstances setObject:instance forKey:[self _concatenateKeyWithIBCreatorID:ident]];
1808         LOG(Encoding, "recording %p for %@\n", instance, [self _concatenateKeyWithIBCreatorID:ident]);
1809     }
1810 }
1811
1812 + (void)_checkLastReferenceForIdentifier:(id)identifier
1813 {
1814     // FIXME: This won't work at all under garbage collection because retainCount returns a constant.
1815     // We may need to change WebPreferences API so there's an explicit way to end the lifetime of one.
1816     WebPreferences *instance = [webPreferencesInstances objectForKey:identifier];
1817     if ([instance retainCount] == 1)
1818         [webPreferencesInstances removeObjectForKey:identifier];
1819 }
1820
1821 + (void)_removeReferenceForIdentifier:(NSString *)ident
1822 {
1823     if (ident)
1824         [self performSelector:@selector(_checkLastReferenceForIdentifier:) withObject:[self _concatenateKeyWithIBCreatorID:ident] afterDelay:0.1];
1825 }
1826
1827 - (void)_postPreferencesChangedNotification
1828 {
1829 #if !PLATFORM(IOS)
1830     if (!pthread_main_np()) {
1831         [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO];
1832         return;
1833     }
1834 #endif
1835
1836     [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedInternalNotification object:self userInfo:nil];
1837     [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedNotification object:self userInfo:nil];
1838 }
1839
1840 - (void)_postPreferencesChangedAPINotification
1841 {
1842     if (!pthread_main_np()) {
1843         [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO];
1844         return;
1845     }
1846
1847     [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedNotification object:self userInfo:nil];
1848 }
1849
1850 + (CFStringEncoding)_systemCFStringEncoding
1851 {
1852     return webDefaultCFStringEncoding();
1853 }
1854
1855 + (void)_setInitialDefaultTextEncodingToSystemEncoding
1856 {
1857     [[NSUserDefaults standardUserDefaults] registerDefaults:
1858         [NSDictionary dictionaryWithObject:defaultTextEncodingNameForSystemLanguage() forKey:WebKitDefaultTextEncodingNamePreferenceKey]];
1859 }
1860
1861 static NSString *classIBCreatorID = nil;
1862
1863 + (void)_setIBCreatorID:(NSString *)string
1864 {
1865     NSString *old = classIBCreatorID;
1866     classIBCreatorID = [string copy];
1867     [old release];
1868 }
1869
1870 + (void)_switchNetworkLoaderToNewTestingSession
1871 {
1872 #if PLATFORM(IOS)
1873     WebThreadLock();
1874 #endif
1875     NetworkStorageSession::switchToNewTestingSession();
1876 }
1877
1878 + (void)_clearNetworkLoaderSession
1879 {
1880     NetworkStorageSession::defaultStorageSession().deleteAllCookies();
1881 }
1882
1883 + (void)_setCurrentNetworkLoaderSessionCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)policy
1884 {
1885     RetainPtr<CFHTTPCookieStorageRef> cookieStorage = NetworkStorageSession::defaultStorageSession().cookieStorage();
1886     ASSERT(cookieStorage); // Will fail when NetworkStorageSession::switchToNewTestingSession() was not called beforehand.
1887     CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage.get(), policy);
1888 }
1889
1890 - (BOOL)isDOMPasteAllowed
1891 {
1892     return [self _boolValueForKey:WebKitDOMPasteAllowedPreferenceKey];
1893 }
1894
1895 - (void)setDOMPasteAllowed:(BOOL)DOMPasteAllowed
1896 {
1897     [self _setBoolValue:DOMPasteAllowed forKey:WebKitDOMPasteAllowedPreferenceKey];
1898 }
1899
1900 - (NSString *)_localStorageDatabasePath
1901 {
1902     return [[self _stringValueForKey:WebKitLocalStorageDatabasePathPreferenceKey] stringByStandardizingPath];
1903 }
1904
1905 - (void)_setLocalStorageDatabasePath:(NSString *)path
1906 {
1907     [self _setStringValue:[path stringByStandardizingPath] forKey:WebKitLocalStorageDatabasePathPreferenceKey];
1908 }
1909
1910 - (NSString *)_ftpDirectoryTemplatePath
1911 {
1912     return [[self _stringValueForKey:WebKitFTPDirectoryTemplatePath] stringByStandardizingPath];
1913 }
1914
1915 - (void)_setFTPDirectoryTemplatePath:(NSString *)path
1916 {
1917     [self _setStringValue:[path stringByStandardizingPath] forKey:WebKitFTPDirectoryTemplatePath];
1918 }
1919
1920 - (BOOL)_forceFTPDirectoryListings
1921 {
1922     return [self _boolValueForKey:WebKitForceFTPDirectoryListings];
1923 }
1924
1925 - (void)_setForceFTPDirectoryListings:(BOOL)force
1926 {
1927     [self _setBoolValue:force forKey:WebKitForceFTPDirectoryListings];
1928 }
1929
1930 - (BOOL)acceleratedDrawingEnabled
1931 {
1932     return [self _boolValueForKey:WebKitAcceleratedDrawingEnabledPreferenceKey];
1933 }
1934
1935 - (void)setAcceleratedDrawingEnabled:(BOOL)enabled
1936 {
1937     [self _setBoolValue:enabled forKey:WebKitAcceleratedDrawingEnabledPreferenceKey];
1938 }
1939
1940 - (BOOL)displayListDrawingEnabled
1941 {
1942     return [self _boolValueForKey:WebKitDisplayListDrawingEnabledPreferenceKey];
1943 }
1944
1945 - (void)setDisplayListDrawingEnabled:(BOOL)enabled
1946 {
1947     [self _setBoolValue:enabled forKey:WebKitDisplayListDrawingEnabledPreferenceKey];
1948 }
1949
1950 - (BOOL)resourceLoadStatisticsEnabled
1951 {
1952     return [self _boolValueForKey:WebKitResourceLoadStatisticsEnabledPreferenceKey];
1953 }
1954
1955 - (void)setResourceLoadStatisticsEnabled:(BOOL)enabled
1956 {
1957     [self _setBoolValue:enabled forKey:WebKitResourceLoadStatisticsEnabledPreferenceKey];
1958 }
1959
1960 - (BOOL)largeImageAsyncDecodingEnabled
1961 {
1962     return [self _boolValueForKey:WebKitLargeImageAsyncDecodingEnabledPreferenceKey];
1963 }
1964
1965 - (void)setLargeImageAsyncDecodingEnabled:(BOOL)enabled
1966 {
1967     [self _setBoolValue:enabled forKey:WebKitLargeImageAsyncDecodingEnabledPreferenceKey];
1968 }
1969
1970 - (BOOL)animatedImageAsyncDecodingEnabled
1971 {
1972     return [self _boolValueForKey:WebKitAnimatedImageAsyncDecodingEnabledPreferenceKey];
1973 }
1974
1975 - (void)setAnimatedImageAsyncDecodingEnabled:(BOOL)enabled
1976 {
1977     [self _setBoolValue:enabled forKey:WebKitAnimatedImageAsyncDecodingEnabledPreferenceKey];
1978 }
1979
1980 - (BOOL)canvasUsesAcceleratedDrawing
1981 {
1982     return [self _boolValueForKey:WebKitCanvasUsesAcceleratedDrawingPreferenceKey];
1983 }
1984
1985 - (void)setCanvasUsesAcceleratedDrawing:(BOOL)enabled
1986 {
1987     [self _setBoolValue:enabled forKey:WebKitCanvasUsesAcceleratedDrawingPreferenceKey];
1988 }
1989
1990 - (BOOL)acceleratedCompositingEnabled
1991 {
1992     return [self _boolValueForKey:WebKitAcceleratedCompositingEnabledPreferenceKey];
1993 }
1994
1995 - (void)setAcceleratedCompositingEnabled:(BOOL)enabled
1996 {
1997     [self _setBoolValue:enabled forKey:WebKitAcceleratedCompositingEnabledPreferenceKey];
1998 }
1999
2000 - (BOOL)showDebugBorders
2001 {
2002     return [self _boolValueForKey:WebKitShowDebugBordersPreferenceKey];
2003 }
2004
2005 - (void)setShowDebugBorders:(BOOL)enabled
2006 {
2007     [self _setBoolValue:enabled forKey:WebKitShowDebugBordersPreferenceKey];
2008 }
2009
2010 - (BOOL)subpixelAntialiasedLayerTextEnabled
2011 {
2012     return [self _boolValueForKey:WebKitSubpixelAntialiasedLayerTextEnabledPreferenceKey];
2013 }
2014
2015 - (void)setSubpixelAntialiasedLayerTextEnabled:(BOOL)enabled
2016 {
2017     [self _setBoolValue:enabled forKey:WebKitSubpixelAntialiasedLayerTextEnabledPreferenceKey];
2018 }
2019
2020 - (BOOL)simpleLineLayoutEnabled
2021 {
2022     return [self _boolValueForKey:WebKitSimpleLineLayoutEnabledPreferenceKey];
2023 }
2024
2025 - (void)setSimpleLineLayoutEnabled:(BOOL)enabled
2026 {
2027     [self _setBoolValue:enabled forKey:WebKitSimpleLineLayoutEnabledPreferenceKey];
2028 }
2029
2030 - (BOOL)simpleLineLayoutDebugBordersEnabled
2031 {
2032     return [self _boolValueForKey:WebKitSimpleLineLayoutDebugBordersEnabledPreferenceKey];
2033 }
2034
2035 - (void)setSimpleLineLayoutDebugBordersEnabled:(BOOL)enabled
2036 {
2037     [self _setBoolValue:enabled forKey:WebKitSimpleLineLayoutDebugBordersEnabledPreferenceKey];
2038 }
2039
2040 - (BOOL)showRepaintCounter
2041 {
2042     return [self _boolValueForKey:WebKitShowRepaintCounterPreferenceKey];
2043 }
2044
2045 - (void)setShowRepaintCounter:(BOOL)enabled
2046 {
2047     [self _setBoolValue:enabled forKey:WebKitShowRepaintCounterPreferenceKey];
2048 }
2049
2050 - (BOOL)webAudioEnabled
2051 {
2052     return [self _boolValueForKey:WebKitWebAudioEnabledPreferenceKey];
2053 }
2054
2055 - (void)setWebAudioEnabled:(BOOL)enabled
2056 {
2057     [self _setBoolValue:enabled forKey:WebKitWebAudioEnabledPreferenceKey];
2058 }
2059
2060 - (BOOL)subpixelCSSOMElementMetricsEnabled
2061 {
2062     return [self _boolValueForKey:WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey];
2063 }
2064
2065 - (void)setSubpixelCSSOMElementMetricsEnabled:(BOOL)enabled
2066 {
2067     [self _setBoolValue:enabled forKey:WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey];
2068 }
2069
2070 - (BOOL)webGLEnabled
2071 {
2072     return [self _boolValueForKey:WebKitWebGLEnabledPreferenceKey];
2073 }
2074
2075 - (void)setWebGLEnabled:(BOOL)enabled
2076 {
2077     [self _setBoolValue:enabled forKey:WebKitWebGLEnabledPreferenceKey];
2078 }
2079
2080 - (BOOL)webGL2Enabled
2081 {
2082     return [self _boolValueForKey:WebKitWebGL2EnabledPreferenceKey];
2083 }
2084
2085 - (void)setWebGL2Enabled:(BOOL)enabled
2086 {
2087     [self _setBoolValue:enabled forKey:WebKitWebGL2EnabledPreferenceKey];
2088 }
2089
2090 - (BOOL)forceSoftwareWebGLRendering
2091 {
2092     return [self _boolValueForKey:WebKitForceSoftwareWebGLRenderingPreferenceKey];
2093 }
2094
2095 - (void)setForceSoftwareWebGLRendering:(BOOL)forced
2096 {
2097     [self _setBoolValue:forced forKey:WebKitForceSoftwareWebGLRenderingPreferenceKey];
2098 }
2099
2100 - (BOOL)forceLowPowerGPUForWebGL
2101 {
2102     return [self _boolValueForKey:WebKitForceWebGLUsesLowPowerPreferenceKey];
2103 }
2104
2105 - (void)setForceWebGLUsesLowPower:(BOOL)forceLowPower
2106 {
2107     [self _setBoolValue:forceLowPower forKey:WebKitForceWebGLUsesLowPowerPreferenceKey];
2108 }
2109
2110 - (BOOL)webGPUEnabled
2111 {
2112     return [self _boolValueForKey:WebKitWebGPUEnabledPreferenceKey];
2113 }
2114
2115 - (void)setWebGPUEnabled:(BOOL)enabled
2116 {
2117     [self _setBoolValue:enabled forKey:WebKitWebGPUEnabledPreferenceKey];
2118 }
2119
2120 - (BOOL)accelerated2dCanvasEnabled
2121 {
2122     return [self _boolValueForKey:WebKitAccelerated2dCanvasEnabledPreferenceKey];
2123 }
2124
2125 - (void)setAccelerated2dCanvasEnabled:(BOOL)enabled
2126 {
2127     [self _setBoolValue:enabled forKey:WebKitAccelerated2dCanvasEnabledPreferenceKey];
2128 }
2129
2130 - (void)setDiskImageCacheEnabled:(BOOL)enabled
2131 {
2132     // Staging. Can be removed once there are no more callers.
2133 }
2134
2135 - (BOOL)isFrameFlatteningEnabled
2136 {
2137     return [self _unsignedIntValueForKey:WebKitFrameFlatteningPreferenceKey] != WebKitFrameFlatteningDisabled;
2138 }
2139
2140 - (void)setFrameFlatteningEnabled:(BOOL)flattening
2141 {
2142     WebKitFrameFlattening value = flattening ? WebKitFrameFlatteningFullyEnabled : WebKitFrameFlatteningDisabled;
2143     [self _setUnsignedIntValue:value forKey:WebKitFrameFlatteningPreferenceKey];
2144 }
2145
2146 - (WebKitFrameFlattening)frameFlattening
2147 {
2148     return static_cast<WebKitFrameFlattening>([self _unsignedIntValueForKey:WebKitFrameFlatteningPreferenceKey]);
2149 }
2150
2151 - (void)setFrameFlattening:(WebKitFrameFlattening)flattening
2152 {
2153     [self _setUnsignedIntValue:flattening forKey:WebKitFrameFlatteningPreferenceKey];
2154 }
2155
2156 - (BOOL)asyncFrameScrollingEnabled
2157 {
2158     return [self _boolValueForKey:WebKitAsyncFrameScrollingEnabledPreferenceKey];
2159 }
2160
2161 - (void)setAsyncFrameScrollingEnabled:(BOOL)enabled
2162 {
2163     [self _setBoolValue:enabled forKey:WebKitAsyncFrameScrollingEnabledPreferenceKey];
2164 }
2165
2166 - (BOOL)isSpatialNavigationEnabled
2167 {
2168     return [self _boolValueForKey:WebKitSpatialNavigationEnabledPreferenceKey];
2169 }
2170
2171 - (void)setSpatialNavigationEnabled:(BOOL)flag
2172 {
2173     [self _setBoolValue:flag forKey:WebKitSpatialNavigationEnabledPreferenceKey];
2174 }
2175
2176 - (BOOL)paginateDuringLayoutEnabled
2177 {
2178     return [self _boolValueForKey:WebKitPaginateDuringLayoutEnabledPreferenceKey];
2179 }
2180
2181 - (void)setPaginateDuringLayoutEnabled:(BOOL)flag
2182 {
2183     [self _setBoolValue:flag forKey:WebKitPaginateDuringLayoutEnabledPreferenceKey];
2184 }
2185
2186 - (BOOL)hyperlinkAuditingEnabled
2187 {
2188     return [self _boolValueForKey:WebKitHyperlinkAuditingEnabledPreferenceKey];
2189 }
2190
2191 - (void)setHyperlinkAuditingEnabled:(BOOL)flag
2192 {
2193     [self _setBoolValue:flag forKey:WebKitHyperlinkAuditingEnabledPreferenceKey];
2194 }
2195
2196 - (BOOL)usePreHTML5ParserQuirks
2197 {
2198     return [self _boolValueForKey:WebKitUsePreHTML5ParserQuirksKey];
2199 }
2200
2201 - (void)setUsePreHTML5ParserQuirks:(BOOL)flag
2202 {
2203     [self _setBoolValue:flag forKey:WebKitUsePreHTML5ParserQuirksKey];
2204 }
2205
2206 - (void)didRemoveFromWebView
2207 {
2208     ASSERT(_private->numWebViews);
2209     if (--_private->numWebViews == 0)
2210         [[NSNotificationCenter defaultCenter]
2211             postNotificationName:WebPreferencesRemovedNotification
2212                           object:self
2213                         userInfo:nil];
2214 }
2215
2216 - (void)willAddToWebView
2217 {
2218     ++_private->numWebViews;
2219 }
2220
2221 - (void)_setPreferenceForTestWithValue:(NSString *)value forKey:(NSString *)key
2222 {
2223     [self _setStringValue:value forKey:key];
2224 }
2225
2226 - (void)setFullScreenEnabled:(BOOL)flag
2227 {
2228     [self _setBoolValue:flag forKey:WebKitFullScreenEnabledPreferenceKey];
2229 }
2230
2231 - (BOOL)fullScreenEnabled
2232 {
2233     return [self _boolValueForKey:WebKitFullScreenEnabledPreferenceKey];
2234 }
2235
2236 - (void)setAsynchronousSpellCheckingEnabled:(BOOL)flag
2237 {
2238     [self _setBoolValue:flag forKey:WebKitAsynchronousSpellCheckingEnabledPreferenceKey];
2239 }
2240
2241 - (BOOL)asynchronousSpellCheckingEnabled
2242 {
2243     return [self _boolValueForKey:WebKitAsynchronousSpellCheckingEnabledPreferenceKey];
2244 }
2245
2246 + (void)setWebKitLinkTimeVersion:(int)version
2247 {
2248     setWebKitLinkTimeVersion(version);
2249 }
2250
2251 - (void)setLoadsSiteIconsIgnoringImageLoadingPreference: (BOOL)flag
2252 {
2253     [self _setBoolValue: flag forKey: WebKitLoadSiteIconsKey];
2254 }
2255
2256 - (BOOL)loadsSiteIconsIgnoringImageLoadingPreference
2257 {
2258     return [self _boolValueForKey: WebKitLoadSiteIconsKey];
2259 }
2260
2261 - (void)setAVFoundationEnabled:(BOOL)flag
2262 {
2263     [self _setBoolValue:flag forKey:WebKitAVFoundationEnabledKey];
2264 }
2265
2266 - (BOOL)isAVFoundationEnabled
2267 {
2268     return [self _boolValueForKey:WebKitAVFoundationEnabledKey];
2269 }
2270
2271 - (void)setAVFoundationNSURLSessionEnabled:(BOOL)flag
2272 {
2273     [self _setBoolValue:flag forKey:WebKitAVFoundationNSURLSessionEnabledKey];
2274 }
2275
2276 - (BOOL)isAVFoundationNSURLSessionEnabled
2277 {
2278     return [self _boolValueForKey:WebKitAVFoundationNSURLSessionEnabledKey];
2279 }
2280
2281 - (void)setVideoPluginProxyEnabled:(BOOL)flag
2282 {
2283     // No-op, left for SPI compatibility.
2284 }
2285
2286 - (BOOL)isVideoPluginProxyEnabled
2287 {
2288     return NO;
2289 }
2290
2291 - (void)setHixie76WebSocketProtocolEnabled:(BOOL)flag
2292 {
2293 }
2294
2295 - (BOOL)isHixie76WebSocketProtocolEnabled
2296 {
2297     return false;
2298 }
2299
2300 - (BOOL)isInheritURIQueryComponentEnabled
2301 {
2302     return [self _boolValueForKey: WebKitEnableInheritURIQueryComponentPreferenceKey];
2303 }
2304
2305 - (void)setEnableInheritURIQueryComponent:(BOOL)flag
2306 {
2307     [self _setBoolValue:flag forKey: WebKitEnableInheritURIQueryComponentPreferenceKey];
2308 }
2309
2310 #if PLATFORM(IOS)
2311 - (BOOL)mediaPlaybackAllowsAirPlay
2312 {
2313     return [self _boolValueForKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
2314 }
2315
2316 - (void)setMediaPlaybackAllowsAirPlay:(BOOL)flag
2317 {
2318     [self _setBoolValue:flag forKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
2319 }
2320
2321 - (unsigned)audioSessionCategoryOverride
2322 {
2323     return [self _unsignedIntValueForKey:WebKitAudioSessionCategoryOverride];
2324 }
2325
2326 - (void)setAudioSessionCategoryOverride:(unsigned)override
2327 {
2328 #if HAVE(AUDIO_TOOLBOX_AUDIO_SESSION)
2329     if (override > AudioSession::AudioProcessing) {
2330         // Clients are passing us OSTypes values from AudioToolbox/AudioSession.h,
2331         // which need to be translated into AudioSession::CategoryType:
2332         switch (override) {
2333         case kAudioSessionCategory_AmbientSound:
2334             override = AudioSession::AmbientSound;
2335             break;
2336         case kAudioSessionCategory_SoloAmbientSound:
2337             override = AudioSession::SoloAmbientSound;
2338             break;
2339         case kAudioSessionCategory_MediaPlayback:
2340             override = AudioSession::MediaPlayback;
2341             break;
2342         case kAudioSessionCategory_RecordAudio:
2343             override = AudioSession::RecordAudio;
2344             break;
2345         case kAudioSessionCategory_PlayAndRecord:
2346             override = AudioSession::PlayAndRecord;
2347             break;
2348         case kAudioSessionCategory_AudioProcessing:
2349             override = AudioSession::AudioProcessing;
2350             break;
2351         default:
2352             override = AudioSession::None;
2353             break;
2354         }
2355     }
2356 #endif
2357
2358     [self _setUnsignedIntValue:override forKey:WebKitAudioSessionCategoryOverride];
2359 }
2360
2361 - (BOOL)avKitEnabled
2362 {
2363     return [self _boolValueForKey:WebKitAVKitEnabled];
2364 }
2365
2366 - (void)setAVKitEnabled:(bool)flag
2367 {
2368 #if HAVE(AVKIT)
2369     [self _setBoolValue:flag forKey:WebKitAVKitEnabled];
2370 #endif
2371 }
2372
2373 - (BOOL)networkDataUsageTrackingEnabled
2374 {
2375     return [self _boolValueForKey:WebKitNetworkDataUsageTrackingEnabledPreferenceKey];
2376 }
2377
2378 - (void)setNetworkDataUsageTrackingEnabled:(bool)trackingEnabled
2379 {
2380     [self _setBoolValue:trackingEnabled forKey:WebKitNetworkDataUsageTrackingEnabledPreferenceKey];
2381 }
2382
2383 - (NSString *)networkInterfaceName
2384 {
2385     return [self _stringValueForKey:WebKitNetworkInterfaceNamePreferenceKey];
2386 }
2387
2388 - (void)setNetworkInterfaceName:(NSString *)name
2389 {
2390     [self _setStringValue:name forKey:WebKitNetworkInterfaceNamePreferenceKey];
2391 }
2392 #endif // PLATFORM(IOS)
2393
2394 // Deprecated. Use -videoPlaybackRequiresUserGesture and -audioPlaybackRequiresUserGesture instead.
2395 - (BOOL)mediaPlaybackRequiresUserGesture
2396 {
2397     return [self _boolValueForKey:WebKitRequiresUserGestureForMediaPlaybackPreferenceKey];
2398 }
2399
2400 // Deprecated. Use -setVideoPlaybackRequiresUserGesture and -setAudioPlaybackRequiresUserGesture instead.
2401 - (void)setMediaPlaybackRequiresUserGesture:(BOOL)flag
2402 {
2403     [self _setBoolValue:flag forKey:WebKitRequiresUserGestureForMediaPlaybackPreferenceKey];
2404 }
2405
2406 - (BOOL)videoPlaybackRequiresUserGesture
2407 {
2408     return [self _boolValueForKey:WebKitRequiresUserGestureForVideoPlaybackPreferenceKey];
2409 }
2410
2411 - (void)setVideoPlaybackRequiresUserGesture:(BOOL)flag
2412 {
2413     [self _setBoolValue:flag forKey:WebKitRequiresUserGestureForVideoPlaybackPreferenceKey];
2414 }
2415
2416 - (BOOL)audioPlaybackRequiresUserGesture
2417 {
2418     return [self _boolValueForKey:WebKitRequiresUserGestureForAudioPlaybackPreferenceKey];
2419 }
2420
2421 - (void)setAudioPlaybackRequiresUserGesture:(BOOL)flag
2422 {
2423     [self _setBoolValue:flag forKey:WebKitRequiresUserGestureForAudioPlaybackPreferenceKey];
2424 }
2425
2426 - (BOOL)overrideUserGestureRequirementForMainContent
2427 {
2428     return [self _boolValueForKey:WebKitMainContentUserGestureOverrideEnabledPreferenceKey];
2429 }
2430
2431 - (void)setOverrideUserGestureRequirementForMainContent:(BOOL)flag
2432 {
2433     [self _setBoolValue:flag forKey:WebKitMainContentUserGestureOverrideEnabledPreferenceKey];
2434 }
2435
2436 - (BOOL)mediaPlaybackAllowsInline
2437 {
2438     return [self _boolValueForKey:WebKitAllowsInlineMediaPlaybackPreferenceKey];
2439 }
2440
2441 - (void)setMediaPlaybackAllowsInline:(BOOL)flag
2442 {
2443     [self _setBoolValue:flag forKey:WebKitAllowsInlineMediaPlaybackPreferenceKey];
2444 }
2445
2446 - (BOOL)inlineMediaPlaybackRequiresPlaysInlineAttribute
2447 {
2448     return [self _boolValueForKey:WebKitInlineMediaPlaybackRequiresPlaysInlineAttributeKey];
2449 }
2450
2451 - (void)setInlineMediaPlaybackRequiresPlaysInlineAttribute:(BOOL)flag
2452 {
2453     [self _setBoolValue:flag forKey:WebKitInlineMediaPlaybackRequiresPlaysInlineAttributeKey];
2454 }
2455
2456 - (BOOL)invisibleAutoplayNotPermitted
2457 {
2458     return [self _boolValueForKey:WebKitInvisibleAutoplayNotPermittedKey];
2459 }
2460
2461 - (void)setInvisibleAutoplayNotPermitted:(BOOL)flag
2462 {
2463     [self _setBoolValue:flag forKey:WebKitInvisibleAutoplayNotPermittedKey];
2464 }
2465
2466 - (BOOL)mediaControlsScaleWithPageZoom
2467 {
2468     return [self _boolValueForKey:WebKitMediaControlsScaleWithPageZoomPreferenceKey];
2469 }
2470
2471 - (void)setMediaControlsScaleWithPageZoom:(BOOL)flag
2472 {
2473     [self _setBoolValue:flag forKey:WebKitMediaControlsScaleWithPageZoomPreferenceKey];
2474 }
2475
2476 - (BOOL)allowsAlternateFullscreen
2477 {
2478     return [self allowsPictureInPictureMediaPlayback];
2479 }
2480
2481 - (void)setAllowsAlternateFullscreen:(BOOL)flag
2482 {
2483     [self setAllowsPictureInPictureMediaPlayback:flag];
2484 }
2485
2486 - (BOOL)allowsPictureInPictureMediaPlayback
2487 {
2488     return [self _boolValueForKey:WebKitAllowsPictureInPictureMediaPlaybackPreferenceKey];
2489 }
2490
2491 - (void)setAllowsPictureInPictureMediaPlayback:(BOOL)flag
2492 {
2493     [self _setBoolValue:flag forKey:WebKitAllowsPictureInPictureMediaPlaybackPreferenceKey];
2494 }
2495
2496 - (BOOL)mockScrollbarsEnabled
2497 {
2498     return [self _boolValueForKey:WebKitMockScrollbarsEnabledPreferenceKey];
2499 }
2500
2501 - (void)setMockScrollbarsEnabled:(BOOL)flag
2502 {
2503     [self _setBoolValue:flag forKey:WebKitMockScrollbarsEnabledPreferenceKey];
2504 }
2505
2506 - (NSString *)pictographFontFamily
2507 {
2508     return [self _stringValueForKey: WebKitPictographFontPreferenceKey];
2509 }
2510
2511 - (void)setPictographFontFamily:(NSString *)family
2512 {
2513     [self _setStringValue: family forKey: WebKitPictographFontPreferenceKey];
2514 }
2515
2516 - (BOOL)pageCacheSupportsPlugins
2517 {
2518     return [self _boolValueForKey:WebKitPageCacheSupportsPluginsPreferenceKey];
2519 }
2520
2521 - (void)setPageCacheSupportsPlugins:(BOOL)flag
2522 {
2523     [self _setBoolValue:flag forKey:WebKitPageCacheSupportsPluginsPreferenceKey];
2524
2525 }
2526
2527 #if PLATFORM(IOS)
2528 - (void)_invalidateCachedPreferences
2529 {
2530     dispatch_barrier_sync(_private->readWriteQueue, ^{
2531         if (_private->values)
2532             _private->values = adoptNS([[NSMutableDictionary alloc] init]);
2533     });
2534
2535     [self _updatePrivateBrowsingStateTo:[self privateBrowsingEnabled]];
2536
2537     // Tell any live WebViews to refresh their preferences
2538     [self _postPreferencesChangedNotification];
2539 }
2540
2541 - (void)_synchronizeWebStoragePolicyWithCookiePolicy
2542 {
2543     // FIXME: This should be done in clients, WebKit shouldn't be making such policy decisions.
2544
2545     NSHTTPCookieAcceptPolicy cookieAcceptPolicy = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookieAcceptPolicy];
2546     WebStorageBlockingPolicy storageBlockingPolicy;
2547     switch (static_cast<unsigned>(cookieAcceptPolicy)) {
2548     case NSHTTPCookieAcceptPolicyAlways:
2549         storageBlockingPolicy = WebAllowAllStorage;
2550         break;
2551     case NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
2552     case NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
2553         storageBlockingPolicy = WebBlockThirdPartyStorage;
2554         break;
2555     case NSHTTPCookieAcceptPolicyNever:
2556         storageBlockingPolicy = WebBlockAllStorage;
2557         break;
2558     default:
2559         ASSERT_NOT_REACHED();
2560         storageBlockingPolicy = WebBlockAllStorage;
2561         break;
2562     }    
2563
2564     [self setStorageBlockingPolicy:storageBlockingPolicy];
2565 }
2566 #endif
2567
2568 - (void)setBackspaceKeyNavigationEnabled:(BOOL)flag
2569 {
2570     [self _setBoolValue:flag forKey:WebKitBackspaceKeyNavigationEnabledKey];
2571 }
2572
2573 - (BOOL)backspaceKeyNavigationEnabled
2574 {
2575     return [self _boolValueForKey:WebKitBackspaceKeyNavigationEnabledKey];
2576 }
2577
2578 - (void)setWantsBalancedSetDefersLoadingBehavior:(BOOL)flag
2579 {
2580     [self _setBoolValue:flag forKey:WebKitWantsBalancedSetDefersLoadingBehaviorKey];
2581 }
2582
2583 - (BOOL)wantsBalancedSetDefersLoadingBehavior
2584 {
2585     return [self _boolValueForKey:WebKitWantsBalancedSetDefersLoadingBehaviorKey];
2586 }
2587
2588 - (void)setShouldDisplaySubtitles:(BOOL)flag
2589 {
2590     [self _setBoolValue:flag forKey:WebKitShouldDisplaySubtitlesPreferenceKey];
2591 }
2592
2593 - (BOOL)shouldDisplaySubtitles
2594 {
2595     return [self _boolValueForKey:WebKitShouldDisplaySubtitlesPreferenceKey];
2596 }
2597
2598 - (void)setShouldDisplayCaptions:(BOOL)flag
2599 {
2600     [self _setBoolValue:flag forKey:WebKitShouldDisplayCaptionsPreferenceKey];
2601 }
2602
2603 - (BOOL)shouldDisplayCaptions
2604 {
2605     return [self _boolValueForKey:WebKitShouldDisplayCaptionsPreferenceKey];
2606 }
2607
2608 - (void)setShouldDisplayTextDescriptions:(BOOL)flag
2609 {
2610     [self _setBoolValue:flag forKey:WebKitShouldDisplayTextDescriptionsPreferenceKey];
2611 }
2612
2613 - (BOOL)shouldDisplayTextDescriptions
2614 {
2615     return [self _boolValueForKey:WebKitShouldDisplayTextDescriptionsPreferenceKey];
2616 }
2617
2618 - (void)setNotificationsEnabled:(BOOL)flag
2619 {
2620     [self _setBoolValue:flag forKey:WebKitNotificationsEnabledKey];
2621 }
2622
2623 - (BOOL)notificationsEnabled
2624 {
2625     return [self _boolValueForKey:WebKitNotificationsEnabledKey];
2626 }
2627
2628 - (void)setShouldRespectImageOrientation:(BOOL)flag
2629 {
2630     [self _setBoolValue:flag forKey:WebKitShouldRespectImageOrientationKey];
2631 }
2632
2633 - (BOOL)shouldRespectImageOrientation
2634 {
2635     return [self _boolValueForKey:WebKitShouldRespectImageOrientationKey];
2636 }
2637
2638 - (BOOL)requestAnimationFrameEnabled
2639 {
2640     return [self _boolValueForKey:WebKitRequestAnimationFrameEnabledPreferenceKey];
2641 }
2642
2643 - (void)setRequestAnimationFrameEnabled:(BOOL)enabled
2644 {
2645     [self _setBoolValue:enabled forKey:WebKitRequestAnimationFrameEnabledPreferenceKey];
2646 }
2647
2648 - (void)setIncrementalRenderingSuppressionTimeoutInSeconds:(NSTimeInterval)timeout
2649 {
2650     [self _setFloatValue:timeout forKey:WebKitIncrementalRenderingSuppressionTimeoutInSecondsKey];
2651 }
2652
2653 - (NSTimeInterval)incrementalRenderingSuppressionTimeoutInSeconds
2654 {
2655     return [self _floatValueForKey:WebKitIncrementalRenderingSuppressionTimeoutInSecondsKey];
2656 }
2657
2658 - (BOOL)diagnosticLoggingEnabled
2659 {
2660     return [self _boolValueForKey:WebKitDiagnosticLoggingEnabledKey];
2661 }
2662
2663 - (void)setDiagnosticLoggingEnabled:(BOOL)enabled
2664 {
2665     [self _setBoolValue:enabled forKey:WebKitDiagnosticLoggingEnabledKey];
2666 }
2667
2668 - (void)setStorageBlockingPolicy:(WebStorageBlockingPolicy)storageBlockingPolicy
2669 {
2670 #if PLATFORM(IOS)
2671     // We don't want to write the setting out, so we just reset the default instead of storing the new setting.
2672     // FIXME: This code removes any defaults previously registered by client process, which is not appropriate for this method to do.
2673     NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:storageBlockingPolicy] forKey:WebKitStorageBlockingPolicyKey];
2674     [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
2675 #else
2676     [self _setIntegerValue:storageBlockingPolicy forKey:WebKitStorageBlockingPolicyKey];
2677 #endif
2678 }
2679
2680 - (WebStorageBlockingPolicy)storageBlockingPolicy
2681 {
2682     return static_cast<WebStorageBlockingPolicy>([self _integerValueForKey:WebKitStorageBlockingPolicyKey]);
2683 }
2684
2685 - (BOOL)plugInSnapshottingEnabled
2686 {
2687     return [self _boolValueForKey:WebKitPlugInSnapshottingEnabledPreferenceKey];
2688 }
2689
2690 - (void)setPlugInSnapshottingEnabled:(BOOL)enabled
2691 {
2692     [self _setBoolValue:enabled forKey:WebKitPlugInSnapshottingEnabledPreferenceKey];
2693 }
2694
2695 - (BOOL)hiddenPageDOMTimerThrottlingEnabled
2696 {
2697     return [self _boolValueForKey:WebKitHiddenPageDOMTimerThrottlingEnabledPreferenceKey];
2698 }
2699
2700 - (void)setHiddenPageDOMTimerThrottlingEnabled:(BOOL)enabled
2701 {
2702     [self _setBoolValue:enabled forKey:WebKitHiddenPageDOMTimerThrottlingEnabledPreferenceKey];
2703 }
2704
2705 - (BOOL)hiddenPageCSSAnimationSuspensionEnabled
2706 {
2707     return [self _boolValueForKey:WebKitHiddenPageCSSAnimationSuspensionEnabledPreferenceKey];
2708 }
2709
2710 - (void)setHiddenPageCSSAnimationSuspensionEnabled:(BOOL)enabled
2711 {
2712     [self _setBoolValue:enabled forKey:WebKitHiddenPageCSSAnimationSuspensionEnabledPreferenceKey];
2713 }
2714
2715 - (BOOL)lowPowerVideoAudioBufferSizeEnabled
2716 {
2717     return [self _boolValueForKey:WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey];
2718 }
2719
2720 - (void)setLowPowerVideoAudioBufferSizeEnabled:(BOOL)enabled
2721 {
2722     [self _setBoolValue:enabled forKey:WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey];
2723 }
2724
2725 - (BOOL)useLegacyTextAlignPositionedElementBehavior
2726 {
2727     return [self _boolValueForKey:WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey];
2728 }
2729
2730 - (void)setUseLegacyTextAlignPositionedElementBehavior:(BOOL)enabled
2731 {
2732     [self _setBoolValue:enabled forKey:WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey];
2733 }
2734
2735 - (BOOL)mediaSourceEnabled
2736 {
2737     return [self _boolValueForKey:WebKitMediaSourceEnabledPreferenceKey];
2738 }
2739
2740 - (void)setMediaSourceEnabled:(BOOL)enabled
2741 {
2742     [self _setBoolValue:enabled forKey:WebKitMediaSourceEnabledPreferenceKey];
2743 }
2744
2745 - (BOOL)imageControlsEnabled
2746 {
2747     return [self _boolValueForKey:WebKitImageControlsEnabledPreferenceKey];
2748 }
2749
2750 - (void)setImageControlsEnabled:(BOOL)enabled
2751 {
2752     [self _setBoolValue:enabled forKey:WebKitImageControlsEnabledPreferenceKey];
2753 }
2754
2755 - (BOOL)serviceControlsEnabled
2756 {
2757     return [self _boolValueForKey:WebKitServiceControlsEnabledPreferenceKey];
2758 }
2759
2760 - (void)setServiceControlsEnabled:(BOOL)enabled
2761 {
2762     [self _setBoolValue:enabled forKey:WebKitServiceControlsEnabledPreferenceKey];
2763 }
2764
2765 - (BOOL)gamepadsEnabled
2766 {
2767     return [self _boolValueForKey:WebKitGamepadsEnabledPreferenceKey];
2768 }
2769
2770 - (void)setGamepadsEnabled:(BOOL)flag
2771 {
2772     [self _setBoolValue:flag forKey:WebKitGamepadsEnabledPreferenceKey];
2773 }
2774
2775 - (BOOL)shouldConvertPositionStyleOnCopy
2776 {
2777     return [self _boolValueForKey:WebKitShouldConvertPositionStyleOnCopyPreferenceKey];
2778 }
2779
2780 - (void)setShouldConvertPositionStyleOnCopy:(BOOL)enabled
2781 {
2782     [self _setBoolValue:enabled forKey:WebKitShouldConvertPositionStyleOnCopyPreferenceKey];
2783 }
2784
2785 - (NSString *)mediaKeysStorageDirectory
2786 {
2787     return [[self _stringValueForKey:WebKitMediaKeysStorageDirectoryKey] stringByStandardizingPath];
2788 }
2789
2790 - (void)setMediaKeysStorageDirectory:(NSString *)directory
2791 {
2792     [self _setStringValue:directory forKey:WebKitMediaKeysStorageDirectoryKey];
2793 }
2794
2795 - (BOOL)mediaDevicesEnabled
2796 {
2797     return [self _boolValueForKey:WebKitMediaDevicesEnabledPreferenceKey];
2798 }
2799
2800 - (void)setMediaDevicesEnabled:(BOOL)flag
2801 {
2802     [self _setBoolValue:flag forKey:WebKitMediaDevicesEnabledPreferenceKey];
2803 }
2804
2805 - (BOOL)mediaStreamEnabled
2806 {
2807     return [self _boolValueForKey:WebKitMediaStreamEnabledPreferenceKey];
2808 }
2809
2810 - (void)setMediaStreamEnabled:(BOOL)flag
2811 {
2812     [self _setBoolValue:flag forKey:WebKitMediaStreamEnabledPreferenceKey];
2813 }
2814
2815 - (BOOL)peerConnectionEnabled
2816 {
2817     return [self _boolValueForKey:WebKitPeerConnectionEnabledPreferenceKey];
2818 }
2819
2820 - (void)setPeerConnectionEnabled:(BOOL)flag
2821 {
2822     [self _setBoolValue:flag forKey:WebKitPeerConnectionEnabledPreferenceKey];
2823 }
2824
2825 - (BOOL)webRTCLegacyAPIEnabled
2826 {
2827     return [self _boolValueForKey:WebKitWebRTCLegacyAPIEnabledPreferenceKey];
2828 }
2829
2830 - (void)setWebRTCLegacyAPIEnabled:(BOOL)flag
2831 {
2832     [self _setBoolValue:flag forKey:WebKitWebRTCLegacyAPIEnabledPreferenceKey];
2833 }
2834
2835 - (BOOL)linkPreloadEnabled
2836 {
2837     return [self _boolValueForKey:WebKitLinkPreloadEnabledPreferenceKey];
2838 }
2839
2840 - (void)setLinkPreloadEnabled:(BOOL)flag
2841 {
2842     [self _setBoolValue:flag forKey:WebKitLinkPreloadEnabledPreferenceKey];
2843 }
2844
2845 - (BOOL)mediaPreloadingEnabled
2846 {
2847     return [self _boolValueForKey:WebKitMediaPreloadingEnabledPreferenceKey];
2848 }
2849
2850 - (void)setMediaPreloadingEnabled:(BOOL)flag
2851 {
2852     [self _setBoolValue:flag forKey:WebKitMediaPreloadingEnabledPreferenceKey];
2853 }
2854
2855 - (void)setMetaRefreshEnabled:(BOOL)enabled
2856 {
2857     [self setHTTPEquivEnabled:enabled];
2858 }
2859
2860 - (BOOL)metaRefreshEnabled
2861 {
2862     return [self httpEquivEnabled];
2863 }
2864
2865 - (void)setHTTPEquivEnabled:(BOOL)enabled
2866 {
2867     [self _setBoolValue:enabled forKey:WebKitHTTPEquivEnabledPreferenceKey];
2868 }
2869
2870 - (BOOL)httpEquivEnabled
2871 {
2872     return [self _boolValueForKey:WebKitHTTPEquivEnabledPreferenceKey];
2873 }
2874
2875 - (BOOL)javaScriptMarkupEnabled
2876 {
2877     return [self _boolValueForKey:WebKitJavaScriptMarkupEnabledPreferenceKey];
2878 }
2879
2880 - (void)setJavaScriptMarkupEnabled:(BOOL)flag
2881 {
2882     [self _setBoolValue:flag forKey:WebKitJavaScriptMarkupEnabledPreferenceKey];
2883 }
2884
2885 - (BOOL)mediaDataLoadsAutomatically
2886 {
2887     return [self _boolValueForKey:WebKitMediaDataLoadsAutomaticallyPreferenceKey];
2888 }
2889
2890 - (void)setMediaDataLoadsAutomatically:(BOOL)flag
2891 {
2892     [self _setBoolValue:flag forKey:WebKitMediaDataLoadsAutomaticallyPreferenceKey];
2893 }
2894
2895 - (BOOL)attachmentElementEnabled
2896 {
2897     return [self _boolValueForKey:WebKitAttachmentElementEnabledPreferenceKey];
2898 }
2899
2900 - (void)setAttachmentElementEnabled:(BOOL)flag
2901 {
2902     [self _setBoolValue:flag forKey:WebKitAttachmentElementEnabledPreferenceKey];
2903 }
2904
2905 - (BOOL)allowsInlineMediaPlaybackAfterFullscreen
2906 {
2907     return [self _boolValueForKey:WebKitAllowsInlineMediaPlaybackAfterFullscreenPreferenceKey];
2908 }
2909
2910 - (void)setAllowsInlineMediaPlaybackAfterFullscreen:(BOOL)flag
2911 {
2912     [self _setBoolValue:flag forKey:WebKitAllowsInlineMediaPlaybackAfterFullscreenPreferenceKey];
2913 }
2914
2915 - (BOOL)mockCaptureDevicesEnabled
2916 {
2917     return [self _boolValueForKey:WebKitMockCaptureDevicesEnabledPreferenceKey];
2918 }
2919
2920 - (void)setMockCaptureDevicesEnabled:(BOOL)flag
2921 {
2922     [self _setBoolValue:flag forKey:WebKitMockCaptureDevicesEnabledPreferenceKey];
2923 }
2924
2925 - (BOOL)mockCaptureDevicesPromptEnabled
2926 {
2927     return [self _boolValueForKey:WebKitMockCaptureDevicesPromptEnabledPreferenceKey];
2928 }
2929
2930 - (void)setMockCaptureDevicesPromptEnabled:(BOOL)flag
2931 {
2932     [self _setBoolValue:flag forKey:WebKitMockCaptureDevicesPromptEnabledPreferenceKey];
2933 }
2934
2935 - (BOOL)enumeratingAllNetworkInterfacesEnabled
2936 {
2937     return [self _boolValueForKey:WebKitEnumeratingAllNetworkInterfacesEnabledPreferenceKey];
2938 }
2939
2940 - (void)setEnumeratingAllNetworkInterfacesEnabled:(BOOL)flag
2941 {
2942     [self _setBoolValue:flag forKey:WebKitEnumeratingAllNetworkInterfacesEnabledPreferenceKey];
2943 }
2944
2945 - (BOOL)iceCandidateFilteringEnabled
2946 {
2947     return [self _boolValueForKey:WebKitICECandidateFilteringEnabledPreferenceKey];
2948 }
2949
2950 - (void)setIceCandidateFilteringEnabled:(BOOL)flag
2951 {
2952     [self _setBoolValue:flag forKey:WebKitICECandidateFilteringEnabledPreferenceKey];
2953 }
2954
2955 - (BOOL)mediaCaptureRequiresSecureConnection
2956 {
2957     return [self _boolValueForKey:WebKitMediaCaptureRequiresSecureConnectionPreferenceKey];
2958 }
2959
2960 - (void)setMediaCaptureRequiresSecureConnection:(BOOL)flag
2961 {
2962     [self _setBoolValue:flag forKey:WebKitMediaCaptureRequiresSecureConnectionPreferenceKey];
2963 }
2964
2965 - (BOOL)shadowDOMEnabled
2966 {
2967     return [self _boolValueForKey:WebKitShadowDOMEnabledPreferenceKey];
2968 }
2969
2970 - (void)setShadowDOMEnabled:(BOOL)flag
2971 {
2972     [self _setBoolValue:flag forKey:WebKitShadowDOMEnabledPreferenceKey];
2973 }
2974
2975 - (BOOL)customElementsEnabled
2976 {
2977     return [self _boolValueForKey:WebKitCustomElementsEnabledPreferenceKey];
2978 }
2979
2980 - (void)setCustomElementsEnabled:(BOOL)flag
2981 {
2982     [self _setBoolValue:flag forKey:WebKitCustomElementsEnabledPreferenceKey];
2983 }
2984
2985 - (BOOL)dataTransferItemsEnabled
2986 {
2987     return [self _boolValueForKey:WebKitDataTransferItemsEnabledPreferenceKey];
2988 }
2989
2990 - (void)setDataTransferItemsEnabled:(BOOL)flag
2991 {
2992     [self _setBoolValue:flag forKey:WebKitDataTransferItemsEnabledPreferenceKey];
2993 }
2994
2995 - (BOOL)customPasteboardDataEnabled
2996 {
2997     return [self _boolValueForKey:WebKitCustomPasteboardDataEnabledPreferenceKey];
2998 }
2999
3000 - (void)setCustomPasteboardDataEnabled:(BOOL)flag
3001 {
3002     [self _setBoolValue:flag forKey:WebKitCustomPasteboardDataEnabledPreferenceKey];
3003 }
3004
3005 - (BOOL)cacheAPIEnabled
3006 {
3007     return [self _boolValueForKey:WebKitCacheAPIEnabledPreferenceKey];
3008 }
3009
3010 - (void)setCacheAPIEnabled:(BOOL)flag
3011 {
3012     [self _setBoolValue:flag forKey:WebKitCacheAPIEnabledPreferenceKey];
3013 }
3014
3015 - (BOOL)crossOriginWindowPolicySupportEnabled
3016 {
3017     return [self _boolValueForKey:WebKitCrossOriginWindowPolicySupportEnabledPreferenceKey];
3018 }
3019
3020 - (void)setCrossOriginWindowPolicySupportEnabled:(BOOL)flag
3021 {
3022     [self _setBoolValue:flag forKey:WebKitCrossOriginWindowPolicySupportEnabledPreferenceKey];
3023 }
3024
3025 - (BOOL)fetchAPIEnabled
3026 {
3027     return [self _boolValueForKey:WebKitFetchAPIEnabledPreferenceKey];
3028 }
3029
3030 - (void)setFetchAPIEnabled:(BOOL)flag
3031 {
3032     [self _setBoolValue:flag forKey:WebKitFetchAPIEnabledPreferenceKey];
3033 }
3034
3035 - (BOOL)readableByteStreamAPIEnabled
3036 {
3037     return [self _boolValueForKey:WebKitReadableByteStreamAPIEnabledPreferenceKey];
3038 }
3039
3040 - (void)setReadableByteStreamAPIEnabled:(BOOL)flag
3041 {
3042     [self _setBoolValue:flag forKey:WebKitReadableByteStreamAPIEnabledPreferenceKey];
3043 }
3044
3045 - (BOOL)writableStreamAPIEnabled
3046 {
3047     return [self _boolValueForKey:WebKitWritableStreamAPIEnabledPreferenceKey];
3048 }
3049
3050 - (void)setWritableStreamAPIEnabled:(BOOL)flag
3051 {
3052     [self _setBoolValue:flag forKey:WebKitWritableStreamAPIEnabledPreferenceKey];
3053 }
3054
3055 - (BOOL)downloadAttributeEnabled
3056 {
3057     return [self _boolValueForKey:WebKitDownloadAttributeEnabledPreferenceKey];
3058 }
3059
3060 - (void)setDownloadAttributeEnabled:(BOOL)flag
3061 {
3062     [self _setBoolValue:flag forKey:WebKitDownloadAttributeEnabledPreferenceKey];
3063 }
3064
3065 - (void)setDirectoryUploadEnabled:(BOOL)flag
3066 {
3067     [self _setBoolValue:flag forKey:WebKitDirectoryUploadEnabledPreferenceKey];
3068 }
3069
3070 - (BOOL)directoryUploadEnabled
3071 {
3072     return [self _boolValueForKey:WebKitDirectoryUploadEnabledPreferenceKey];
3073 }
3074
3075 - (BOOL)visualViewportEnabled
3076 {
3077     return [self _boolValueForKey:WebKitVisualViewportEnabledPreferenceKey];
3078 }
3079
3080 - (void)setVisualViewportEnabled:(BOOL)flag
3081 {
3082     [self _setBoolValue:flag forKey:WebKitVisualViewportEnabledPreferenceKey];
3083 }
3084
3085 - (BOOL)visualViewportAPIEnabled
3086 {
3087     return [self _boolValueForKey:WebKitVisualViewportAPIEnabledPreferenceKey];
3088 }
3089
3090 - (void)setVisualViewportAPIEnabled:(BOOL)flag
3091 {
3092     [self _setBoolValue:flag forKey:WebKitVisualViewportAPIEnabledPreferenceKey];
3093 }
3094
3095 - (BOOL)webAnimationsEnabled
3096 {
3097     return [self _boolValueForKey:WebKitWebAnimationsEnabledPreferenceKey];
3098 }
3099
3100 - (void)setWebAnimationsEnabled:(BOOL)flag
3101 {
3102     [self _setBoolValue:flag forKey:WebKitWebAnimationsEnabledPreferenceKey];
3103 }
3104
3105 - (BOOL)fetchAPIKeepAliveEnabled
3106 {
3107     return [self _boolValueForKey:WebKitFetchAPIEnabledPreferenceKey];
3108 }
3109
3110 - (void)setFetchAPIKeepAliveEnabled:(BOOL)flag
3111 {
3112     [self _setBoolValue:flag forKey:WebKitFetchAPIEnabledPreferenceKey];
3113 }
3114
3115 - (BOOL)modernMediaControlsEnabled
3116 {
3117     return [self _boolValueForKey:WebKitModernMediaControlsEnabledPreferenceKey];
3118 }
3119
3120 - (void)setModernMediaControlsEnabled:(BOOL)flag
3121 {
3122     [self _setBoolValue:flag forKey:WebKitModernMediaControlsEnabledPreferenceKey];
3123 }
3124
3125 - (BOOL)webAnimationsCSSIntegrationEnabled
3126 {
3127     return [self _boolValueForKey:WebKitWebAnimationsCSSIntegrationEnabledPreferenceKey];
3128 }
3129
3130 - (void)setWebAnimationsCSSIntegrationEnabled:(BOOL)flag
3131 {
3132     [self _setBoolValue:flag forKey:WebKitWebAnimationsCSSIntegrationEnabledPreferenceKey];
3133 }
3134
3135 - (BOOL)intersectionObserverEnabled
3136 {
3137     return [self _boolValueForKey:WebKitIntersectionObserverEnabledPreferenceKey];
3138 }
3139
3140 - (void)setIntersectionObserverEnabled:(BOOL)flag
3141 {
3142     [self _setBoolValue:flag forKey:WebKitIntersectionObserverEnabledPreferenceKey];
3143 }
3144
3145 - (BOOL)menuItemElementEnabled
3146 {
3147     return [self _boolValueForKey:WebKitMenuItemElementEnabledPreferenceKey];
3148 }
3149
3150 - (void)setMenuItemElementEnabled:(BOOL)flag
3151 {
3152     [self _setBoolValue:flag forKey:WebKitMenuItemElementEnabledPreferenceKey];
3153 }
3154
3155 - (BOOL)displayContentsEnabled
3156 {
3157     return [self _boolValueForKey:WebKitDisplayContentsEnabledPreferenceKey];
3158 }
3159
3160 - (void)setDisplayContentsEnabled:(BOOL)flag
3161 {
3162     [self _setBoolValue:flag forKey:WebKitDisplayContentsEnabledPreferenceKey];
3163 }
3164
3165 - (BOOL)userTimingEnabled
3166 {
3167     return [self _boolValueForKey:WebKitUserTimingEnabledPreferenceKey];
3168 }
3169
3170 - (void)setUserTimingEnabled:(BOOL)flag
3171 {
3172     [self _setBoolValue:flag forKey:WebKitUserTimingEnabledPreferenceKey];
3173 }
3174
3175 - (BOOL)resourceTimingEnabled
3176 {
3177     return [self _boolValueForKey:WebKitResourceTimingEnabledPreferenceKey];
3178 }
3179
3180 - (void)setResourceTimingEnabled:(BOOL)flag
3181 {
3182     [self _setBoolValue:flag forKey:WebKitResourceTimingEnabledPreferenceKey];
3183 }
3184
3185 - (BOOL)webAuthenticationEnabled
3186 {
3187     return [self _boolValueForKey:WebKitWebAuthenticationEnabledPreferenceKey];
3188 }
3189
3190 - (void)setWebAuthenticationEnabled:(BOOL)flag
3191 {
3192     [self _setBoolValue:flag forKey:WebKitWebAuthenticationEnabledPreferenceKey];
3193 }
3194
3195 - (BOOL)mediaUserGestureInheritsFromDocument
3196 {
3197     return [self _boolValueForKey:WebKitMediaUserGestureInheritsFromDocument];
3198 }
3199
3200 - (void)setMediaUserGestureInheritsFromDocument:(BOOL)flag
3201 {
3202     [self _setBoolValue:flag forKey:WebKitMediaUserGestureInheritsFromDocument];
3203 }
3204
3205 #if PLATFORM(IOS)
3206 - (BOOL)quickLookDocumentSavingEnabled
3207 {
3208     return [self _boolValueForKey:WebKitQuickLookDocumentSavingPreferenceKey];
3209 }
3210
3211 - (void)setQuickLookDocumentSavingEnabled:(BOOL)flag
3212 {
3213     [self _setBoolValue:flag forKey:WebKitQuickLookDocumentSavingPreferenceKey];
3214 }
3215 #endif
3216
3217 - (NSString *)mediaContentTypesRequiringHardwareSupport
3218 {
3219     return [self _stringValueForKey:WebKitMediaContentTypesRequiringHardwareSupportPreferenceKey];
3220 }
3221
3222 - (void)setMediaContentTypesRequiringHardwareSupport:(NSString *)value
3223 {
3224     [self _setStringValue:value forKey:WebKitMediaContentTypesRequiringHardwareSupportPreferenceKey];
3225 }
3226
3227 - (BOOL)isSecureContextAttributeEnabled
3228 {
3229     return [self _boolValueForKey:WebKitIsSecureContextAttributeEnabledPreferenceKey];
3230 }
3231
3232 - (void)setIsSecureContextAttributeEnabled:(BOOL)flag
3233 {
3234     [self _setBoolValue:flag forKey:WebKitIsSecureContextAttributeEnabledPreferenceKey];
3235 }
3236
3237 - (BOOL)legacyEncryptedMediaAPIEnabled
3238 {
3239     return [self _boolValueForKey:WebKitLegacyEncryptedMediaAPIEnabledKey];
3240 }
3241
3242 - (void)setLegacyEncryptedMediaAPIEnabled:(BOOL)flag
3243 {
3244     [self _setBoolValue:flag forKey:WebKitLegacyEncryptedMediaAPIEnabledKey];
3245 }
3246
3247 - (BOOL)encryptedMediaAPIEnabled
3248 {
3249     return [self _boolValueForKey:WebKitEncryptedMediaAPIEnabledKey];
3250 }
3251
3252 - (void)setEncryptedMediaAPIEnabled:(BOOL)flag
3253 {
3254     [self _setBoolValue:flag forKey:WebKitEncryptedMediaAPIEnabledKey];
3255 }
3256
3257 - (BOOL)viewportFitEnabled
3258 {
3259     return [self _boolValueForKey:WebKitViewportFitEnabledPreferenceKey];
3260 }
3261
3262 - (void)setViewportFitEnabled:(BOOL)flag
3263 {
3264     [self _setBoolValue:flag forKey:WebKitViewportFitEnabledPreferenceKey];
3265 }
3266
3267 - (BOOL)constantPropertiesEnabled
3268 {
3269     return [self _boolValueForKey:WebKitConstantPropertiesEnabledPreferenceKey];
3270 }
3271
3272 - (void)setConstantPropertiesEnabled:(BOOL)flag
3273 {
3274     [self _setBoolValue:flag forKey:WebKitConstantPropertiesEnabledPreferenceKey];
3275 }
3276
3277 - (BOOL)colorFilterEnabled
3278 {
3279     return [self _boolValueForKey:WebKitColorFilterEnabledPreferenceKey];
3280 }
3281
3282 - (void)setColorFilterEnabled:(BOOL)flag
3283 {
3284     [self _setBoolValue:flag forKey:WebKitColorFilterEnabledPreferenceKey];
3285 }
3286
3287 - (BOOL)punchOutWhiteBackgroundsInDarkMode
3288 {
3289     return [self _boolValueForKey:WebKitPunchOutWhiteBackgroundsInDarkModePreferenceKey];
3290 }
3291
3292 - (void)setPunchOutWhiteBackgroundsInDarkMode:(BOOL)flag
3293 {
3294     [self _setBoolValue:flag forKey:WebKitPunchOutWhiteBackgroundsInDarkModePreferenceKey];
3295 }
3296
3297 - (BOOL)allowMediaContentTypesRequiringHardwareSupportAsFallback
3298 {
3299     return [self _boolValueForKey:WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallbackKey];
3300 }
3301
3302 - (void)setAllowMediaContentTypesRequiringHardwareSupportAsFallback:(BOOL)flag
3303 {
3304     [self _setBoolValue:flag forKey:WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallbackKey];
3305 }
3306
3307 - (BOOL)inspectorAdditionsEnabled
3308 {
3309     return [self _boolValueForKey:WebKitInspectorAdditionsEnabledPreferenceKey];
3310 }
3311
3312 - (void)setInspectorAdditionsEnabled:(BOOL)flag
3313 {
3314     [self _setBoolValue:flag forKey:WebKitInspectorAdditionsEnabledPreferenceKey];
3315 }
3316
3317 - (BOOL)accessibilityObjectModelEnabled
3318 {
3319     return [self _boolValueForKey:WebKitAccessibilityObjectModelEnabledPreferenceKey];
3320 }
3321
3322 - (void)setAccessibilityObjectModelEnabled:(BOOL)flag
3323 {
3324     [self _setBoolValue:flag forKey:WebKitAccessibilityObjectModelEnabledPreferenceKey];
3325 }
3326
3327 - (BOOL)ariaReflectionEnabled
3328 {
3329     return [self _boolValueForKey:WebKitAriaReflectionEnabledPreferenceKey];
3330 }
3331
3332 - (void)setAriaReflectionEnabled:(BOOL)flag
3333 {
3334     [self _setBoolValue:flag forKey:WebKitAriaReflectionEnabledPreferenceKey];
3335 }
3336
3337 - (BOOL)mediaCapabilitiesEnabled
3338 {
3339     return [self _boolValueForKey:WebKitMediaCapabilitiesEnabledPreferenceKey];
3340 }
3341
3342 - (void)setMediaCapabilitiesEnabled:(BOOL)flag
3343 {
3344     [self _setBoolValue:flag forKey:WebKitMediaCapabilitiesEnabledPreferenceKey];
3345 }
3346
3347 - (BOOL)serverTimingEnabled
3348 {
3349     return [self _boolValueForKey:WebKitServerTimingEnabledPreferenceKey];
3350 }
3351
3352 - (void)setServerTimingEnabled:(BOOL)flag
3353 {
3354     [self _setBoolValue:flag forKey:WebKitServerTimingEnabledPreferenceKey];
3355 }
3356
3357 @end
3358
3359 @implementation WebPreferences (WebInternal)
3360
3361 + (NSString *)_IBCreatorID
3362 {
3363     return classIBCreatorID;
3364 }
3365
3366 + (NSString *)_concatenateKeyWithIBCreatorID:(NSString *)key
3367 {
3368     NSString *IBCreatorID = [WebPreferences _IBCreatorID];
3369     if (!IBCreatorID)
3370         return key;
3371     return [IBCreatorID stringByAppendingString:key];
3372 }
3373
3374 @end