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