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