Replace WebRTCLegacyAPIDisabled by WebRTCLegacyAPIEnabled and switch off WebRTC legac...
[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:DeprecatedGlobalSettings::defaultCustomPasteboardDataEnabled()], 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         nil];
686
687 #if !PLATFORM(IOS)
688     // This value shouldn't ever change, which is assumed in the initialization of WebKitPDFDisplayModePreferenceKey above
689     ASSERT(kPDFDisplaySinglePageContinuous == 1);
690 #endif
691     [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
692 }
693
694 - (void)dealloc
695 {
696     [self _updatePrivateBrowsingStateTo:NO];
697
698     delete _private;
699     [super dealloc];
700 }
701
702 - (NSString *)identifier
703 {
704     return _private->identifier.get();
705 }
706
707 - (id)_valueForKey:(NSString *)key
708 {
709     NSString *_key = KEY(key);
710 #if PLATFORM(IOS)
711     __block id o = nil;
712     dispatch_sync(_private->readWriteQueue, ^{
713         o = [_private->values.get() objectForKey:_key];
714     });
715 #else
716     id o = [_private->values.get() objectForKey:_key];
717 #endif
718     if (o)
719         return o;
720     o = [[NSUserDefaults standardUserDefaults] objectForKey:_key];
721     if (!o && key != _key)
722         o = [[NSUserDefaults standardUserDefaults] objectForKey:key];
723     return o;
724 }
725
726 - (NSString *)_stringValueForKey:(NSString *)key
727 {
728     id s = [self _valueForKey:key];
729     return [s isKindOfClass:[NSString class]] ? (NSString *)s : nil;
730 }
731
732 - (void)_setStringValue:(NSString *)value forKey:(NSString *)key
733 {
734     if ([[self _stringValueForKey:key] isEqualToString:value])
735         return;
736     NSString *_key = KEY(key);
737 #if PLATFORM(IOS)
738     dispatch_barrier_sync(_private->readWriteQueue, ^{
739 #endif
740     [_private->values.get() setObject:value forKey:_key];
741 #if PLATFORM(IOS)
742     });
743 #endif
744     if (_private->autosaves)
745         [[NSUserDefaults standardUserDefaults] setObject:value forKey:_key];
746     [self _postPreferencesChangedNotification];
747 }
748
749 - (int)_integerValueForKey:(NSString *)key
750 {
751     id o = [self _valueForKey:key];
752     return [o respondsToSelector:@selector(intValue)] ? [o intValue] : 0;
753 }
754
755 - (void)_setIntegerValue:(int)value forKey:(NSString *)key
756 {
757     if ([self _integerValueForKey:key] == value)
758         return;
759     NSString *_key = KEY(key);
760 #if PLATFORM(IOS)
761     dispatch_barrier_sync(_private->readWriteQueue, ^{
762 #endif
763     [_private->values.get() _webkit_setInt:value forKey:_key];
764 #if PLATFORM(IOS)
765     });
766 #endif
767     if (_private->autosaves)
768         [[NSUserDefaults standardUserDefaults] setInteger:value forKey:_key];
769     [self _postPreferencesChangedNotification];
770 }
771
772 - (unsigned int)_unsignedIntValueForKey:(NSString *)key
773 {
774     id o = [self _valueForKey:key];
775     return [o respondsToSelector:@selector(unsignedIntValue)] ? [o unsignedIntValue] : 0;
776 }
777
778 - (void)_setUnsignedIntValue:(unsigned int)value forKey:(NSString *)key
779 {
780     if ([self _unsignedIntValueForKey:key] == value)
781         return;
782     NSString *_key = KEY(key);
783 #if PLATFORM(IOS)
784     dispatch_barrier_sync(_private->readWriteQueue, ^{
785 #endif
786     [_private->values.get() _webkit_setUnsignedInt:value forKey:_key];
787 #if PLATFORM(IOS)
788     });
789 #endif
790     if (_private->autosaves)
791         [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInt:value] forKey:_key];
792     [self _postPreferencesChangedNotification];
793 }
794
795 - (float)_floatValueForKey:(NSString *)key
796 {
797     id o = [self _valueForKey:key];
798     return [o respondsToSelector:@selector(floatValue)] ? [o floatValue] : 0.0f;
799 }
800
801 - (void)_setFloatValue:(float)value forKey:(NSString *)key
802 {
803     if ([self _floatValueForKey:key] == value)
804         return;
805     NSString *_key = KEY(key);
806 #if PLATFORM(IOS)
807     dispatch_barrier_sync(_private->readWriteQueue, ^{
808 #endif
809     [_private->values.get() _webkit_setFloat:value forKey:_key];
810 #if PLATFORM(IOS)
811     });
812 #endif
813     if (_private->autosaves)
814         [[NSUserDefaults standardUserDefaults] setFloat:value forKey:_key];
815     [self _postPreferencesChangedNotification];
816 }
817
818 - (BOOL)_boolValueForKey:(NSString *)key
819 {
820     return [self _integerValueForKey:key] != 0;
821 }
822
823 - (void)_setBoolValue:(BOOL)value forKey:(NSString *)key
824 {
825     if ([self _boolValueForKey:key] == value)
826         return;
827     NSString *_key = KEY(key);
828 #if PLATFORM(IOS)
829     dispatch_barrier_sync(_private->readWriteQueue, ^{
830 #endif
831     [_private->values.get() _webkit_setBool:value forKey:_key];
832 #if PLATFORM(IOS)
833     });
834 #endif
835     if (_private->autosaves)
836         [[NSUserDefaults standardUserDefaults] setBool:value forKey:_key];
837     [self _postPreferencesChangedNotification];
838 }
839
840 - (long long)_longLongValueForKey:(NSString *)key
841 {
842     id o = [self _valueForKey:key];
843     return [o respondsToSelector:@selector(longLongValue)] ? [o longLongValue] : 0;
844 }
845
846 - (void)_setLongLongValue:(long long)value forKey:(NSString *)key
847 {
848     if ([self _longLongValueForKey:key] == value)
849         return;
850     NSString *_key = KEY(key);
851 #if PLATFORM(IOS)
852     dispatch_barrier_sync(_private->readWriteQueue, ^{
853 #endif
854     [_private->values.get() _webkit_setLongLong:value forKey:_key];
855 #if PLATFORM(IOS)
856     });
857 #endif
858     if (_private->autosaves)
859         [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithLongLong:value] forKey:_key];
860     [self _postPreferencesChangedNotification];
861 }
862
863 - (unsigned long long)_unsignedLongLongValueForKey:(NSString *)key
864 {
865     id o = [self _valueForKey:key];
866     return [o respondsToSelector:@selector(unsignedLongLongValue)] ? [o unsignedLongLongValue] : 0;
867 }
868
869 - (void)_setUnsignedLongLongValue:(unsigned long long)value forKey:(NSString *)key
870 {
871     if ([self _unsignedLongLongValueForKey:key] == value)
872         return;
873     NSString *_key = KEY(key);
874 #if PLATFORM(IOS)
875     dispatch_barrier_sync(_private->readWriteQueue, ^{
876 #endif
877     [_private->values.get() _webkit_setUnsignedLongLong:value forKey:_key];
878 #if PLATFORM(IOS)
879     });
880 #endif
881     if (_private->autosaves)
882         [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedLongLong:value] forKey:_key];
883     [self _postPreferencesChangedNotification];
884 }
885
886 - (NSString *)standardFontFamily
887 {
888     return [self _stringValueForKey: WebKitStandardFontPreferenceKey];
889 }
890
891 - (void)setStandardFontFamily:(NSString *)family
892 {
893     [self _setStringValue: family forKey: WebKitStandardFontPreferenceKey];
894 }
895
896 - (NSString *)fixedFontFamily
897 {
898     return [self _stringValueForKey: WebKitFixedFontPreferenceKey];
899 }
900
901 - (void)setFixedFontFamily:(NSString *)family
902 {
903     [self _setStringValue: family forKey: WebKitFixedFontPreferenceKey];
904 }
905
906 - (NSString *)serifFontFamily
907 {
908     return [self _stringValueForKey: WebKitSerifFontPreferenceKey];
909 }
910
911 - (void)setSerifFontFamily:(NSString *)family 
912 {
913     [self _setStringValue: family forKey: WebKitSerifFontPreferenceKey];
914 }
915
916 - (NSString *)sansSerifFontFamily
917 {
918     return [self _stringValueForKey: WebKitSansSerifFontPreferenceKey];
919 }
920
921 - (void)setSansSerifFontFamily:(NSString *)family
922 {
923     [self _setStringValue: family forKey: WebKitSansSerifFontPreferenceKey];
924 }
925
926 - (NSString *)cursiveFontFamily
927 {
928     return [self _stringValueForKey: WebKitCursiveFontPreferenceKey];
929 }
930
931 - (void)setCursiveFontFamily:(NSString *)family
932 {
933     [self _setStringValue: family forKey: WebKitCursiveFontPreferenceKey];
934 }
935
936 - (NSString *)fantasyFontFamily
937 {
938     return [self _stringValueForKey: WebKitFantasyFontPreferenceKey];
939 }
940
941 - (void)setFantasyFontFamily:(NSString *)family
942 {
943     [self _setStringValue: family forKey: WebKitFantasyFontPreferenceKey];
944 }
945
946 - (int)defaultFontSize
947 {
948     return [self _integerValueForKey: WebKitDefaultFontSizePreferenceKey];
949 }
950
951 - (void)setDefaultFontSize:(int)size
952 {
953     [self _setIntegerValue: size forKey: WebKitDefaultFontSizePreferenceKey];
954 }
955
956 - (int)defaultFixedFontSize
957 {
958     return [self _integerValueForKey: WebKitDefaultFixedFontSizePreferenceKey];
959 }
960
961 - (void)setDefaultFixedFontSize:(int)size
962 {
963     [self _setIntegerValue: size forKey: WebKitDefaultFixedFontSizePreferenceKey];
964 }
965
966 - (int)minimumFontSize
967 {
968     return [self _integerValueForKey: WebKitMinimumFontSizePreferenceKey];
969 }
970
971 - (void)setMinimumFontSize:(int)size
972 {
973     [self _setIntegerValue: size forKey: WebKitMinimumFontSizePreferenceKey];
974 }
975
976 - (int)minimumLogicalFontSize
977 {
978   return [self _integerValueForKey: WebKitMinimumLogicalFontSizePreferenceKey];
979 }
980
981 - (void)setMinimumLogicalFontSize:(int)size
982 {
983   [self _setIntegerValue: size forKey: WebKitMinimumLogicalFontSizePreferenceKey];
984 }
985
986 - (NSString *)defaultTextEncodingName
987 {
988     return [self _stringValueForKey: WebKitDefaultTextEncodingNamePreferenceKey];
989 }
990
991 - (void)setDefaultTextEncodingName:(NSString *)encoding
992 {
993     [self _setStringValue: encoding forKey: WebKitDefaultTextEncodingNamePreferenceKey];
994 }
995
996 #if !PLATFORM(IOS)
997 - (BOOL)userStyleSheetEnabled
998 {
999     return [self _boolValueForKey: WebKitUserStyleSheetEnabledPreferenceKey];
1000 }
1001
1002 - (void)setUserStyleSheetEnabled:(BOOL)flag
1003 {
1004     [self _setBoolValue: flag forKey: WebKitUserStyleSheetEnabledPreferenceKey];
1005 }
1006
1007 - (NSURL *)userStyleSheetLocation
1008 {
1009     NSString *locationString = [self _stringValueForKey: WebKitUserStyleSheetLocationPreferenceKey];
1010     
1011     if ([locationString _webkit_looksLikeAbsoluteURL]) {
1012         return [NSURL _web_URLWithDataAsString:locationString];
1013     } else {
1014         locationString = [locationString stringByExpandingTildeInPath];
1015         return [NSURL fileURLWithPath:locationString];
1016     }
1017 }
1018
1019 - (void)setUserStyleSheetLocation:(NSURL *)URL
1020 {
1021     NSString *locationString;
1022     
1023     if ([URL isFileURL]) {
1024         locationString = [[URL path] _web_stringByAbbreviatingWithTildeInPath];
1025     } else {
1026         locationString = [URL _web_originalDataAsString];
1027     }
1028
1029     if (!locationString)
1030         locationString = @"";
1031
1032     [self _setStringValue:locationString forKey: WebKitUserStyleSheetLocationPreferenceKey];
1033 }
1034 #else
1035
1036 // These methods have had their implementations removed on iOS since it
1037 // is wrong to have such a setting stored in preferences that, when read,
1038 // is applied to all WebViews in a iOS process. Such a design might work
1039 // OK for an application like Safari on Mac OS X, where the only WebViews
1040 // in use display web content in a straightforward manner. However, it is
1041 // wrong for iOS, where WebViews are used for various purposes, like
1042 // text editing, text rendering, and displaying web content.
1043 // 
1044 // I have changed the user style sheet mechanism to be a per-WebView
1045 // setting, rather than a per-process preference. This seems to give the
1046 // behavior we want for iOS.
1047
1048 - (BOOL)userStyleSheetEnabled
1049 {
1050     return NO;
1051 }
1052
1053 - (void)setUserStyleSheetEnabled:(BOOL)flag
1054 {
1055     // no-op
1056 }
1057
1058 - (NSURL *)userStyleSheetLocation
1059 {
1060     return nil;
1061 }
1062
1063 - (void)setUserStyleSheetLocation:(NSURL *)URL
1064 {
1065     // no-op
1066 }
1067 #endif // PLATFORM(IOS)
1068
1069 #if !PLATFORM(IOS)
1070 - (BOOL)shouldPrintBackgrounds
1071 {
1072     return [self _boolValueForKey: WebKitShouldPrintBackgroundsPreferenceKey];
1073 }
1074
1075 - (void)setShouldPrintBackgrounds:(BOOL)flag
1076 {
1077     [self _setBoolValue: flag forKey: WebKitShouldPrintBackgroundsPreferenceKey];
1078 }
1079 #endif
1080
1081 - (BOOL)isJavaEnabled
1082 {
1083     return [self _boolValueForKey: WebKitJavaEnabledPreferenceKey];
1084 }
1085
1086 - (void)setJavaEnabled:(BOOL)flag
1087 {
1088     [self _setBoolValue: flag forKey: WebKitJavaEnabledPreferenceKey];
1089 }
1090
1091 - (BOOL)isJavaScriptEnabled
1092 {
1093     return [self _boolValueForKey: WebKitJavaScriptEnabledPreferenceKey];
1094 }
1095
1096 - (void)setJavaScriptEnabled:(BOOL)flag
1097 {
1098     [self _setBoolValue: flag forKey: WebKitJavaScriptEnabledPreferenceKey];
1099 }
1100
1101 - (BOOL)javaScriptCanOpenWindowsAutomatically
1102 {
1103     return [self _boolValueForKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
1104 }
1105
1106 - (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag
1107 {
1108     [self _setBoolValue: flag forKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
1109 }
1110
1111 - (BOOL)arePlugInsEnabled
1112 {
1113     return [self _boolValueForKey: WebKitPluginsEnabledPreferenceKey];
1114 }
1115
1116 - (void)setPlugInsEnabled:(BOOL)flag
1117 {
1118     [self _setBoolValue: flag forKey: WebKitPluginsEnabledPreferenceKey];
1119 }
1120
1121 - (BOOL)allowsAnimatedImages
1122 {
1123     return [self _boolValueForKey: WebKitAllowAnimatedImagesPreferenceKey];
1124 }
1125
1126 - (void)setAllowsAnimatedImages:(BOOL)flag
1127 {
1128     [self _setBoolValue: flag forKey: WebKitAllowAnimatedImagesPreferenceKey];
1129 }
1130
1131 - (BOOL)allowsAnimatedImageLooping
1132 {
1133     return [self _boolValueForKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
1134 }
1135
1136 - (void)setAllowsAnimatedImageLooping: (BOOL)flag
1137 {
1138     [self _setBoolValue: flag forKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
1139 }
1140
1141 - (void)setLoadsImagesAutomatically: (BOOL)flag
1142 {
1143     [self _setBoolValue: flag forKey: WebKitDisplayImagesKey];
1144 }
1145
1146 - (BOOL)loadsImagesAutomatically
1147 {
1148     return [self _boolValueForKey: WebKitDisplayImagesKey];
1149 }
1150
1151 - (void)setAutosaves:(BOOL)flag
1152 {
1153     _private->autosaves = flag;
1154 }
1155
1156 - (BOOL)autosaves
1157 {
1158     return _private->autosaves;
1159 }
1160
1161 #if !PLATFORM(IOS)
1162 - (void)setTabsToLinks:(BOOL)flag
1163 {
1164     [self _setBoolValue: flag forKey: WebKitTabToLinksPreferenceKey];
1165 }
1166
1167 - (BOOL)tabsToLinks
1168 {
1169     return [self _boolValueForKey:WebKitTabToLinksPreferenceKey];
1170 }
1171 #endif
1172
1173 - (void)setPrivateBrowsingEnabled:(BOOL)enabled
1174 {
1175     [self _updatePrivateBrowsingStateTo:enabled];
1176     [self _setBoolValue:enabled forKey:WebKitPrivateBrowsingEnabledPreferenceKey];
1177 }
1178
1179 - (BOOL)privateBrowsingEnabled
1180 {
1181     // Changes to private browsing defaults do not have effect on existing WebPreferences, and must be done through -setPrivateBrowsingEnabled.
1182     // This is needed to accurately track private browsing sessions in the process.
1183     return _private->inPrivateBrowsing;
1184 }
1185
1186 - (void)_updatePrivateBrowsingStateTo:(BOOL)enabled
1187 {
1188     if (!_private) {
1189         ASSERT(!enabled);
1190         return;
1191     }
1192
1193     if (enabled == _private->inPrivateBrowsing)
1194         return;
1195     if (enabled > _private->inPrivateBrowsing) {
1196         WebFrameNetworkingContext::ensurePrivateBrowsingSession();
1197         ++webPreferencesInstanceCountWithPrivateBrowsingEnabled;
1198     } else {
1199         ASSERT(webPreferencesInstanceCountWithPrivateBrowsingEnabled);
1200         --webPreferencesInstanceCountWithPrivateBrowsingEnabled;
1201         if (!webPreferencesInstanceCountWithPrivateBrowsingEnabled)
1202             WebFrameNetworkingContext::destroyPrivateBrowsingSession();
1203     }
1204     _private->inPrivateBrowsing = enabled;
1205 }
1206
1207 - (void)setUsesPageCache:(BOOL)usesPageCache
1208 {
1209     [self _setBoolValue:usesPageCache forKey:WebKitUsesPageCachePreferenceKey];
1210 }
1211
1212 - (BOOL)usesPageCache
1213 {
1214     return [self _boolValueForKey:WebKitUsesPageCachePreferenceKey];
1215 }
1216
1217 - (void)_postCacheModelChangedNotification
1218 {
1219 #if !PLATFORM(IOS)
1220     if (!pthread_main_np()) {
1221         [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO];
1222         return;
1223     }
1224 #endif
1225
1226     [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesCacheModelChangedInternalNotification object:self userInfo:nil];
1227 }
1228
1229 - (void)setCacheModel:(WebCacheModel)cacheModel
1230 {
1231     [self _setIntegerValue:cacheModel forKey:WebKitCacheModelPreferenceKey];
1232     [self setAutomaticallyDetectsCacheModel:NO];
1233     [self _postCacheModelChangedNotification];
1234 }
1235
1236 - (WebCacheModel)cacheModel
1237 {
1238     return (WebCacheModel)[self _integerValueForKey:WebKitCacheModelPreferenceKey];
1239 }
1240
1241
1242 - (void)setSuppressesIncrementalRendering:(BOOL)suppressesIncrementalRendering
1243 {
1244     [self _setBoolValue:suppressesIncrementalRendering forKey:WebKitSuppressesIncrementalRenderingKey];
1245 }
1246
1247 - (BOOL)suppressesIncrementalRendering
1248 {
1249     return [self _boolValueForKey:WebKitSuppressesIncrementalRenderingKey];
1250 }
1251
1252 - (BOOL)allowsAirPlayForMediaPlayback
1253 {
1254 #if ENABLE(WIRELESS_TARGET_PLAYBACK)
1255     return [self _boolValueForKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
1256 #else
1257     return false;
1258 #endif
1259 }
1260
1261 - (void)setAllowsAirPlayForMediaPlayback:(BOOL)flag
1262 {
1263 #if ENABLE(WIRELESS_TARGET_PLAYBACK)
1264     [self _setBoolValue:flag forKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
1265 #endif
1266 }
1267
1268 @end
1269
1270 @implementation WebPreferences (WebPrivate)
1271
1272 - (BOOL)isDNSPrefetchingEnabled
1273 {
1274     return [self _boolValueForKey:WebKitDNSPrefetchingEnabledPreferenceKey];
1275 }
1276
1277 - (void)setDNSPrefetchingEnabled:(BOOL)flag
1278 {
1279     [self _setBoolValue:flag forKey:WebKitDNSPrefetchingEnabledPreferenceKey];
1280 }
1281
1282 - (BOOL)developerExtrasEnabled
1283 {
1284     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
1285     if ([defaults boolForKey:@"DisableWebKitDeveloperExtras"])
1286         return NO;
1287 #ifdef NDEBUG
1288     if ([defaults boolForKey:@"WebKitDeveloperExtras"] || [defaults boolForKey:@"IncludeDebugMenu"])
1289         return YES;
1290     return [self _boolValueForKey:WebKitDeveloperExtrasEnabledPreferenceKey];
1291 #else
1292     return YES; // always enable in debug builds
1293 #endif
1294 }
1295
1296 - (WebKitJavaScriptRuntimeFlags)javaScriptRuntimeFlags
1297 {
1298     return static_cast<WebKitJavaScriptRuntimeFlags>([self _unsignedIntValueForKey:WebKitJavaScriptRuntimeFlagsPreferenceKey]);
1299 }
1300
1301 - (void)setJavaScriptRuntimeFlags:(WebKitJavaScriptRuntimeFlags)flags
1302 {
1303     [self _setUnsignedIntValue:flags forKey:WebKitJavaScriptRuntimeFlagsPreferenceKey];
1304 }
1305
1306 - (void)setDeveloperExtrasEnabled:(BOOL)flag
1307 {
1308     [self _setBoolValue:flag forKey:WebKitDeveloperExtrasEnabledPreferenceKey];
1309 }
1310
1311 - (BOOL)authorAndUserStylesEnabled
1312 {
1313     return [self _boolValueForKey:WebKitAuthorAndUserStylesEnabledPreferenceKey];
1314 }
1315
1316 - (void)setAuthorAndUserStylesEnabled:(BOOL)flag
1317 {
1318     [self _setBoolValue:flag forKey:WebKitAuthorAndUserStylesEnabledPreferenceKey];
1319 }
1320
1321 // FIXME: applicationChromeMode is no longer needed by ToT, but is still used in Safari 8.
1322 - (BOOL)applicationChromeModeEnabled
1323 {
1324     return NO;
1325 }
1326
1327 - (void)setApplicationChromeModeEnabled:(BOOL)flag
1328 {
1329 }
1330
1331 - (BOOL)domTimersThrottlingEnabled
1332 {
1333     return [self _boolValueForKey:WebKitDOMTimersThrottlingEnabledPreferenceKey];
1334 }
1335
1336 - (void)setDOMTimersThrottlingEnabled:(BOOL)flag
1337 {
1338     [self _setBoolValue:flag forKey:WebKitDOMTimersThrottlingEnabledPreferenceKey];
1339 }
1340
1341 - (BOOL)webArchiveDebugModeEnabled
1342 {
1343     return [self _boolValueForKey:WebKitWebArchiveDebugModeEnabledPreferenceKey];
1344 }
1345
1346 - (void)setWebArchiveDebugModeEnabled:(BOOL)flag
1347 {
1348     [self _setBoolValue:flag forKey:WebKitWebArchiveDebugModeEnabledPreferenceKey];
1349 }
1350
1351 - (BOOL)localFileContentSniffingEnabled
1352 {
1353     return [self _boolValueForKey:WebKitLocalFileContentSniffingEnabledPreferenceKey];
1354 }
1355
1356 - (void)setLocalFileContentSniffingEnabled:(BOOL)flag
1357 {
1358     [self _setBoolValue:flag forKey:WebKitLocalFileContentSniffingEnabledPreferenceKey];
1359 }
1360
1361 - (BOOL)offlineWebApplicationCacheEnabled
1362 {
1363     return [self _boolValueForKey:WebKitOfflineWebApplicationCacheEnabledPreferenceKey];
1364 }
1365
1366 - (void)setOfflineWebApplicationCacheEnabled:(BOOL)flag
1367 {
1368     [self _setBoolValue:flag forKey:WebKitOfflineWebApplicationCacheEnabledPreferenceKey];
1369 }
1370
1371 - (BOOL)zoomsTextOnly
1372 {
1373     return [self _boolValueForKey:WebKitZoomsTextOnlyPreferenceKey];
1374 }
1375
1376 - (void)setZoomsTextOnly:(BOOL)flag
1377 {
1378     [self _setBoolValue:flag forKey:WebKitZoomsTextOnlyPreferenceKey];
1379 }
1380
1381 - (BOOL)javaScriptCanAccessClipboard
1382 {
1383     return [self _boolValueForKey:WebKitJavaScriptCanAccessClipboardPreferenceKey];
1384 }
1385
1386 - (void)setJavaScriptCanAccessClipboard:(BOOL)flag
1387 {
1388     [self _setBoolValue:flag forKey:WebKitJavaScriptCanAccessClipboardPreferenceKey];
1389 }
1390
1391 - (BOOL)isXSSAuditorEnabled
1392 {
1393     return [self _boolValueForKey:WebKitXSSAuditorEnabledPreferenceKey];
1394 }
1395
1396 - (void)setXSSAuditorEnabled:(BOOL)flag
1397 {
1398     [self _setBoolValue:flag forKey:WebKitXSSAuditorEnabledPreferenceKey];
1399 }
1400
1401 #if !PLATFORM(IOS)
1402 - (BOOL)respectStandardStyleKeyEquivalents
1403 {
1404     return [self _boolValueForKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
1405 }
1406
1407 - (void)setRespectStandardStyleKeyEquivalents:(BOOL)flag
1408 {
1409     [self _setBoolValue:flag forKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
1410 }
1411
1412 - (BOOL)showsURLsInToolTips
1413 {
1414     return [self _boolValueForKey:WebKitShowsURLsInToolTipsPreferenceKey];
1415 }
1416
1417 - (void)setShowsURLsInToolTips:(BOOL)flag
1418 {
1419     [self _setBoolValue:flag forKey:WebKitShowsURLsInToolTipsPreferenceKey];
1420 }
1421
1422 - (BOOL)showsToolTipOverTruncatedText
1423 {
1424     return [self _boolValueForKey:WebKitShowsToolTipOverTruncatedTextPreferenceKey];
1425 }
1426
1427 - (void)setShowsToolTipOverTruncatedText:(BOOL)flag
1428 {
1429     [self _setBoolValue:flag forKey:WebKitShowsToolTipOverTruncatedTextPreferenceKey];
1430 }
1431
1432 - (BOOL)textAreasAreResizable
1433 {
1434     return [self _boolValueForKey: WebKitTextAreasAreResizablePreferenceKey];
1435 }
1436
1437 - (void)setTextAreasAreResizable:(BOOL)flag
1438 {
1439     [self _setBoolValue: flag forKey: WebKitTextAreasAreResizablePreferenceKey];
1440 }
1441 #endif // !PLATFORM(IOS)
1442
1443 - (BOOL)shrinksStandaloneImagesToFit
1444 {
1445     return [self _boolValueForKey:WebKitShrinksStandaloneImagesToFitPreferenceKey];
1446 }
1447
1448 - (void)setShrinksStandaloneImagesToFit:(BOOL)flag
1449 {
1450     [self _setBoolValue:flag forKey:WebKitShrinksStandaloneImagesToFitPreferenceKey];
1451 }
1452
1453 - (BOOL)automaticallyDetectsCacheModel
1454 {
1455     return _private->automaticallyDetectsCacheModel;
1456 }
1457
1458 - (void)setAutomaticallyDetectsCacheModel:(BOOL)automaticallyDetectsCacheModel
1459 {
1460     _private->automaticallyDetectsCacheModel = automaticallyDetectsCacheModel;
1461 }
1462
1463 - (BOOL)usesEncodingDetector
1464 {
1465     return [self _boolValueForKey: WebKitUsesEncodingDetectorPreferenceKey];
1466 }
1467
1468 - (void)setUsesEncodingDetector:(BOOL)flag
1469 {
1470     [self _setBoolValue: flag forKey: WebKitUsesEncodingDetectorPreferenceKey];
1471 }
1472
1473 - (BOOL)isWebSecurityEnabled
1474 {
1475     return [self _boolValueForKey: WebKitWebSecurityEnabledPreferenceKey];
1476 }
1477
1478 - (void)setWebSecurityEnabled:(BOOL)flag
1479 {
1480     [self _setBoolValue: flag forKey: WebKitWebSecurityEnabledPreferenceKey];
1481 }
1482
1483 - (BOOL)allowUniversalAccessFromFileURLs
1484 {
1485     return [self _boolValueForKey: WebKitAllowUniversalAccessFromFileURLsPreferenceKey];
1486 }
1487
1488 - (void)setAllowUniversalAccessFromFileURLs:(BOOL)flag
1489 {
1490     [self _setBoolValue: flag forKey: WebKitAllowUniversalAccessFromFileURLsPreferenceKey];
1491 }
1492
1493 - (BOOL)allowFileAccessFromFileURLs
1494 {
1495     return [self _boolValueForKey: WebKitAllowFileAccessFromFileURLsPreferenceKey];
1496 }
1497
1498 - (void)setAllowFileAccessFromFileURLs:(BOOL)flag
1499 {
1500     [self _setBoolValue: flag forKey: WebKitAllowFileAccessFromFileURLsPreferenceKey];
1501 }
1502
1503 - (BOOL)needsStorageAccessFromFileURLsQuirk
1504 {
1505     return [self _boolValueForKey: WebKitNeedsStorageAccessFromFileURLsQuirkKey];
1506 }
1507
1508 -(void)setNeedsStorageAccessFromFileURLsQuirk:(BOOL)flag
1509 {
1510     [self _setBoolValue: flag forKey: WebKitNeedsStorageAccessFromFileURLsQuirkKey];
1511 }
1512
1513 - (NSTimeInterval)_backForwardCacheExpirationInterval
1514 {
1515     return (NSTimeInterval)[self _floatValueForKey:WebKitBackForwardCacheExpirationIntervalKey];
1516 }
1517
1518 #if PLATFORM(IOS)
1519 - (BOOL)_standalone
1520 {
1521     return [self _boolValueForKey:WebKitStandalonePreferenceKey];
1522 }
1523
1524 - (void)_setStandalone:(BOOL)flag
1525 {
1526     [self _setBoolValue:flag forKey:WebKitStandalonePreferenceKey];
1527 }
1528
1529 - (void)_setTelephoneNumberParsingEnabled:(BOOL)flag
1530 {
1531     [self _setBoolValue:flag forKey:WebKitTelephoneParsingEnabledPreferenceKey];
1532 }
1533
1534 - (BOOL)_telephoneNumberParsingEnabled
1535 {
1536     return [self _boolValueForKey:WebKitTelephoneParsingEnabledPreferenceKey];
1537 }
1538 #endif
1539
1540 #if ENABLE(TEXT_AUTOSIZING)
1541 - (void)_setMinimumZoomFontSize:(float)size
1542 {
1543     [self _setFloatValue:size forKey:WebKitMinimumZoomFontSizePreferenceKey];
1544 }
1545
1546 - (float)_minimumZoomFontSize
1547 {
1548     return [self _floatValueForKey:WebKitMinimumZoomFontSizePreferenceKey];
1549 }
1550
1551 - (void)_setTextAutosizingEnabled:(BOOL)enabled
1552 {
1553     [self _setBoolValue:enabled forKey:WebKitTextAutosizingEnabledPreferenceKey];
1554 }
1555
1556 - (BOOL)_textAutosizingEnabled
1557 {
1558     return [self _boolValueForKey:WebKitTextAutosizingEnabledPreferenceKey];
1559 }
1560 #endif
1561
1562 #if PLATFORM(IOS)
1563 - (void)_setLayoutInterval:(int)l
1564 {
1565     [self _setIntegerValue:l forKey:WebKitLayoutIntervalPreferenceKey];
1566 }
1567
1568 - (int)_layoutInterval
1569 {
1570     return [self _integerValueForKey:WebKitLayoutIntervalPreferenceKey];
1571 }
1572
1573 - (void)_setMaxParseDuration:(float)d
1574 {
1575     [self _setFloatValue:d forKey:WebKitMaxParseDurationPreferenceKey];
1576 }
1577
1578 - (float)_maxParseDuration
1579 {
1580     return [self _floatValueForKey:WebKitMaxParseDurationPreferenceKey];
1581 }
1582
1583 - (void)_setAllowMultiElementImplicitFormSubmission:(BOOL)flag
1584 {
1585     [self _setBoolValue:flag forKey:WebKitAllowMultiElementImplicitFormSubmissionPreferenceKey];
1586 }
1587
1588 - (BOOL)_allowMultiElementImplicitFormSubmission
1589 {
1590     return [self _boolValueForKey:WebKitAllowMultiElementImplicitFormSubmissionPreferenceKey];
1591 }
1592
1593 - (void)_setAlwaysRequestGeolocationPermission:(BOOL)flag
1594 {
1595     [self _setBoolValue:flag forKey:WebKitAlwaysRequestGeolocationPermissionPreferenceKey];
1596 }
1597
1598 - (BOOL)_alwaysRequestGeolocationPermission
1599 {
1600     return [self _boolValueForKey:WebKitAlwaysRequestGeolocationPermissionPreferenceKey];
1601 }
1602
1603 - (void)_setAlwaysUseAcceleratedOverflowScroll:(BOOL)flag
1604 {
1605     [self _setBoolValue:flag forKey:WebKitAlwaysUseAcceleratedOverflowScrollPreferenceKey];
1606 }
1607
1608 - (BOOL)_alwaysUseAcceleratedOverflowScroll
1609 {
1610     return [self _boolValueForKey:WebKitAlwaysUseAcceleratedOverflowScrollPreferenceKey];
1611 }
1612
1613 - (void)_setInterpolationQuality:(int)quality
1614 {
1615     [self _setIntegerValue:quality forKey:WebKitInterpolationQualityPreferenceKey];
1616 }
1617
1618 - (int)_interpolationQuality
1619 {
1620     return [self _integerValueForKey:WebKitInterpolationQualityPreferenceKey];
1621 }
1622
1623 - (BOOL)_allowPasswordEcho
1624 {
1625     return [self _boolValueForKey:WebKitPasswordEchoEnabledPreferenceKey];
1626 }
1627
1628 - (float)_passwordEchoDuration
1629 {
1630     return [self _floatValueForKey:WebKitPasswordEchoDurationPreferenceKey];
1631 }
1632
1633 #endif // PLATFORM(IOS)
1634
1635 #if !PLATFORM(IOS)
1636 - (float)PDFScaleFactor
1637 {
1638     return [self _floatValueForKey:WebKitPDFScaleFactorPreferenceKey];
1639 }
1640
1641 - (void)setPDFScaleFactor:(float)factor
1642 {
1643     [self _setFloatValue:factor forKey:WebKitPDFScaleFactorPreferenceKey];
1644 }
1645 #endif
1646
1647 - (int64_t)applicationCacheTotalQuota
1648 {
1649     return [self _longLongValueForKey:WebKitApplicationCacheTotalQuota];
1650 }
1651
1652 - (void)setApplicationCacheTotalQuota:(int64_t)quota
1653 {
1654     [self _setLongLongValue:quota forKey:WebKitApplicationCacheTotalQuota];
1655
1656     // Application Cache Preferences are stored on the global cache storage manager, not in Settings.
1657     [WebApplicationCache setMaximumSize:quota];
1658 }
1659
1660 - (int64_t)applicationCacheDefaultOriginQuota
1661 {
1662     return [self _longLongValueForKey:WebKitApplicationCacheDefaultOriginQuota];
1663 }
1664
1665 - (void)setApplicationCacheDefaultOriginQuota:(int64_t)quota
1666 {
1667     [self _setLongLongValue:quota forKey:WebKitApplicationCacheDefaultOriginQuota];
1668 }
1669
1670 #if !PLATFORM(IOS)
1671 - (PDFDisplayMode)PDFDisplayMode
1672 {
1673     PDFDisplayMode value = static_cast<PDFDisplayMode>([self _integerValueForKey:WebKitPDFDisplayModePreferenceKey]);
1674     if (value != kPDFDisplaySinglePage && value != kPDFDisplaySinglePageContinuous && value != kPDFDisplayTwoUp && value != kPDFDisplayTwoUpContinuous) {
1675         // protect against new modes from future versions of OS X stored in defaults
1676         value = kPDFDisplaySinglePageContinuous;
1677     }
1678     return value;
1679 }
1680
1681 - (void)setPDFDisplayMode:(PDFDisplayMode)mode
1682 {
1683     [self _setIntegerValue:mode forKey:WebKitPDFDisplayModePreferenceKey];
1684 }
1685 #endif
1686
1687 - (WebKitEditableLinkBehavior)editableLinkBehavior
1688 {
1689     WebKitEditableLinkBehavior value = static_cast<WebKitEditableLinkBehavior> ([self _integerValueForKey:WebKitEditableLinkBehaviorPreferenceKey]);
1690     if (value != WebKitEditableLinkDefaultBehavior &&
1691         value != WebKitEditableLinkAlwaysLive &&
1692         value != WebKitEditableLinkNeverLive &&
1693         value != WebKitEditableLinkOnlyLiveWithShiftKey &&
1694         value != WebKitEditableLinkLiveWhenNotFocused) {
1695         // ensure that a valid result is returned
1696         value = WebKitEditableLinkDefaultBehavior;
1697     }
1698     
1699     return value;
1700 }
1701
1702 - (void)setEditableLinkBehavior:(WebKitEditableLinkBehavior)behavior
1703 {
1704     [self _setIntegerValue:behavior forKey:WebKitEditableLinkBehaviorPreferenceKey];
1705 }
1706
1707 - (WebTextDirectionSubmenuInclusionBehavior)textDirectionSubmenuInclusionBehavior
1708 {
1709     WebTextDirectionSubmenuInclusionBehavior value = static_cast<WebTextDirectionSubmenuInclusionBehavior>([self _integerValueForKey:WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey]);
1710     if (value != WebTextDirectionSubmenuNeverIncluded &&
1711         value != WebTextDirectionSubmenuAutomaticallyIncluded &&
1712         value != WebTextDirectionSubmenuAlwaysIncluded) {
1713         // Ensure that a valid result is returned.
1714         value = WebTextDirectionSubmenuNeverIncluded;
1715     }
1716     return value;
1717 }
1718
1719 - (void)setTextDirectionSubmenuInclusionBehavior:(WebTextDirectionSubmenuInclusionBehavior)behavior
1720 {
1721     [self _setIntegerValue:behavior forKey:WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey];
1722 }
1723
1724 - (BOOL)_useSiteSpecificSpoofing
1725 {
1726     return [self _boolValueForKey:WebKitUseSiteSpecificSpoofingPreferenceKey];
1727 }
1728
1729 - (void)_setUseSiteSpecificSpoofing:(BOOL)newValue
1730 {
1731     [self _setBoolValue:newValue forKey:WebKitUseSiteSpecificSpoofingPreferenceKey];
1732 }
1733
1734 - (BOOL)databasesEnabled
1735 {
1736     return [self _boolValueForKey:WebKitDatabasesEnabledPreferenceKey];
1737 }
1738
1739 - (void)setDatabasesEnabled:(BOOL)databasesEnabled
1740 {
1741     [self _setBoolValue:databasesEnabled forKey:WebKitDatabasesEnabledPreferenceKey];
1742 }
1743
1744 #if PLATFORM(IOS)
1745 - (BOOL)storageTrackerEnabled
1746 {
1747     return [self _boolValueForKey:WebKitStorageTrackerEnabledPreferenceKey];
1748 }
1749
1750 - (void)setStorageTrackerEnabled:(BOOL)storageTrackerEnabled
1751 {
1752     [self _setBoolValue:storageTrackerEnabled forKey:WebKitStorageTrackerEnabledPreferenceKey];
1753 }
1754 #endif
1755
1756 - (BOOL)localStorageEnabled
1757 {
1758     return [self _boolValueForKey:WebKitLocalStorageEnabledPreferenceKey];
1759 }
1760
1761 - (void)setLocalStorageEnabled:(BOOL)localStorageEnabled
1762 {
1763     [self _setBoolValue:localStorageEnabled forKey:WebKitLocalStorageEnabledPreferenceKey];
1764 }
1765
1766 - (BOOL)experimentalNotificationsEnabled
1767 {
1768     return [self _boolValueForKey:WebKitExperimentalNotificationsEnabledPreferenceKey];
1769 }
1770
1771 - (void)setExperimentalNotificationsEnabled:(BOOL)experimentalNotificationsEnabled
1772 {
1773     [self _setBoolValue:experimentalNotificationsEnabled forKey:WebKitExperimentalNotificationsEnabledPreferenceKey];
1774 }
1775
1776 + (WebPreferences *)_getInstanceForIdentifier:(NSString *)ident
1777 {
1778     LOG(Encoding, "requesting for %@\n", ident);
1779
1780     if (!ident)
1781         return _standardPreferences;
1782     
1783     WebPreferences *instance = [webPreferencesInstances objectForKey:[self _concatenateKeyWithIBCreatorID:ident]];
1784
1785     return instance;
1786 }
1787
1788 + (void)_setInstance:(WebPreferences *)instance forIdentifier:(NSString *)ident
1789 {
1790     if (!webPreferencesInstances)
1791         webPreferencesInstances = [[NSMutableDictionary alloc] init];
1792     if (ident) {
1793         [webPreferencesInstances setObject:instance forKey:[self _concatenateKeyWithIBCreatorID:ident]];
1794         LOG(Encoding, "recording %p for %@\n", instance, [self _concatenateKeyWithIBCreatorID:ident]);
1795     }
1796 }
1797
1798 + (void)_checkLastReferenceForIdentifier:(id)identifier
1799 {
1800     // FIXME: This won't work at all under garbage collection because retainCount returns a constant.
1801     // We may need to change WebPreferences API so there's an explicit way to end the lifetime of one.
1802     WebPreferences *instance = [webPreferencesInstances objectForKey:identifier];
1803     if ([instance retainCount] == 1)
1804         [webPreferencesInstances removeObjectForKey:identifier];
1805 }
1806
1807 + (void)_removeReferenceForIdentifier:(NSString *)ident
1808 {
1809     if (ident)
1810         [self performSelector:@selector(_checkLastReferenceForIdentifier:) withObject:[self _concatenateKeyWithIBCreatorID:ident] afterDelay:0.1];
1811 }
1812
1813 - (void)_postPreferencesChangedNotification
1814 {
1815 #if !PLATFORM(IOS)
1816     if (!pthread_main_np()) {
1817         [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO];
1818         return;
1819     }
1820 #endif
1821
1822     [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedInternalNotification object:self userInfo:nil];
1823     [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedNotification object:self userInfo:nil];
1824 }
1825
1826 - (void)_postPreferencesChangedAPINotification
1827 {
1828     if (!pthread_main_np()) {
1829         [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO];
1830         return;
1831     }
1832
1833     [[NSNotificationCenter defaultCenter] postNotificationName:WebPreferencesChangedNotification object:self userInfo:nil];
1834 }
1835
1836 + (CFStringEncoding)_systemCFStringEncoding
1837 {
1838     return webDefaultCFStringEncoding();
1839 }
1840
1841 + (void)_setInitialDefaultTextEncodingToSystemEncoding
1842 {
1843     [[NSUserDefaults standardUserDefaults] registerDefaults:
1844         [NSDictionary dictionaryWithObject:defaultTextEncodingNameForSystemLanguage() forKey:WebKitDefaultTextEncodingNamePreferenceKey]];
1845 }
1846
1847 static NSString *classIBCreatorID = nil;
1848
1849 + (void)_setIBCreatorID:(NSString *)string
1850 {
1851     NSString *old = classIBCreatorID;
1852     classIBCreatorID = [string copy];
1853     [old release];
1854 }
1855
1856 + (void)_switchNetworkLoaderToNewTestingSession
1857 {
1858 #if PLATFORM(IOS)
1859     WebThreadLock();
1860 #endif
1861     NetworkStorageSession::switchToNewTestingSession();
1862 }
1863
1864 + (void)_clearNetworkLoaderSession
1865 {
1866     WebCore::deleteAllCookies(NetworkStorageSession::defaultStorageSession());
1867 }
1868
1869 + (void)_setCurrentNetworkLoaderSessionCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)policy
1870 {
1871     RetainPtr<CFHTTPCookieStorageRef> cookieStorage = NetworkStorageSession::defaultStorageSession().cookieStorage();
1872     ASSERT(cookieStorage); // Will fail when NetworkStorageSession::switchToNewTestingSession() was not called beforehand.
1873     CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage.get(), policy);
1874 }
1875
1876 - (BOOL)isDOMPasteAllowed
1877 {
1878     return [self _boolValueForKey:WebKitDOMPasteAllowedPreferenceKey];
1879 }
1880
1881 - (void)setDOMPasteAllowed:(BOOL)DOMPasteAllowed
1882 {
1883     [self _setBoolValue:DOMPasteAllowed forKey:WebKitDOMPasteAllowedPreferenceKey];
1884 }
1885
1886 - (NSString *)_localStorageDatabasePath
1887 {
1888     return [[self _stringValueForKey:WebKitLocalStorageDatabasePathPreferenceKey] stringByStandardizingPath];
1889 }
1890
1891 - (void)_setLocalStorageDatabasePath:(NSString *)path
1892 {
1893     [self _setStringValue:[path stringByStandardizingPath] forKey:WebKitLocalStorageDatabasePathPreferenceKey];
1894 }
1895
1896 - (NSString *)_ftpDirectoryTemplatePath
1897 {
1898     return [[self _stringValueForKey:WebKitFTPDirectoryTemplatePath] stringByStandardizingPath];
1899 }
1900
1901 - (void)_setFTPDirectoryTemplatePath:(NSString *)path
1902 {
1903     [self _setStringValue:[path stringByStandardizingPath] forKey:WebKitFTPDirectoryTemplatePath];
1904 }
1905
1906 - (BOOL)_forceFTPDirectoryListings
1907 {
1908     return [self _boolValueForKey:WebKitForceFTPDirectoryListings];
1909 }
1910
1911 - (void)_setForceFTPDirectoryListings:(BOOL)force
1912 {
1913     [self _setBoolValue:force forKey:WebKitForceFTPDirectoryListings];
1914 }
1915
1916 - (BOOL)acceleratedDrawingEnabled
1917 {
1918     return [self _boolValueForKey:WebKitAcceleratedDrawingEnabledPreferenceKey];
1919 }
1920
1921 - (void)setAcceleratedDrawingEnabled:(BOOL)enabled
1922 {
1923     [self _setBoolValue:enabled forKey:WebKitAcceleratedDrawingEnabledPreferenceKey];
1924 }
1925
1926 - (BOOL)displayListDrawingEnabled
1927 {
1928     return [self _boolValueForKey:WebKitDisplayListDrawingEnabledPreferenceKey];
1929 }
1930
1931 - (void)setDisplayListDrawingEnabled:(BOOL)enabled
1932 {
1933     [self _setBoolValue:enabled forKey:WebKitDisplayListDrawingEnabledPreferenceKey];
1934 }
1935
1936 - (BOOL)resourceLoadStatisticsEnabled
1937 {
1938     return [self _boolValueForKey:WebKitResourceLoadStatisticsEnabledPreferenceKey];
1939 }
1940
1941 - (void)setResourceLoadStatisticsEnabled:(BOOL)enabled
1942 {
1943     [self _setBoolValue:enabled forKey:WebKitResourceLoadStatisticsEnabledPreferenceKey];
1944 }
1945
1946 - (BOOL)largeImageAsyncDecodingEnabled
1947 {
1948     return [self _boolValueForKey:WebKitLargeImageAsyncDecodingEnabledPreferenceKey];
1949 }
1950
1951 - (void)setLargeImageAsyncDecodingEnabled:(BOOL)enabled
1952 {
1953     [self _setBoolValue:enabled forKey:WebKitLargeImageAsyncDecodingEnabledPreferenceKey];
1954 }
1955
1956 - (BOOL)animatedImageAsyncDecodingEnabled
1957 {
1958     return [self _boolValueForKey:WebKitAnimatedImageAsyncDecodingEnabledPreferenceKey];
1959 }
1960
1961 - (void)setAnimatedImageAsyncDecodingEnabled:(BOOL)enabled
1962 {
1963     [self _setBoolValue:enabled forKey:WebKitAnimatedImageAsyncDecodingEnabledPreferenceKey];
1964 }
1965
1966 - (BOOL)canvasUsesAcceleratedDrawing
1967 {
1968     return [self _boolValueForKey:WebKitCanvasUsesAcceleratedDrawingPreferenceKey];
1969 }
1970
1971 - (void)setCanvasUsesAcceleratedDrawing:(BOOL)enabled
1972 {
1973     [self _setBoolValue:enabled forKey:WebKitCanvasUsesAcceleratedDrawingPreferenceKey];
1974 }
1975
1976 - (BOOL)acceleratedCompositingEnabled
1977 {
1978     return [self _boolValueForKey:WebKitAcceleratedCompositingEnabledPreferenceKey];
1979 }
1980
1981 - (void)setAcceleratedCompositingEnabled:(BOOL)enabled
1982 {
1983     [self _setBoolValue:enabled forKey:WebKitAcceleratedCompositingEnabledPreferenceKey];
1984 }
1985
1986 - (BOOL)showDebugBorders
1987 {
1988     return [self _boolValueForKey:WebKitShowDebugBordersPreferenceKey];
1989 }
1990
1991 - (void)setShowDebugBorders:(BOOL)enabled
1992 {
1993     [self _setBoolValue:enabled forKey:WebKitShowDebugBordersPreferenceKey];
1994 }
1995
1996 - (BOOL)subpixelAntialiasedLayerTextEnabled
1997 {
1998     return [self _boolValueForKey:WebKitSubpixelAntialiasedLayerTextEnabledPreferenceKey];
1999 }
2000
2001 - (void)setSubpixelAntialiasedLayerTextEnabled:(BOOL)enabled
2002 {
2003     [self _setBoolValue:enabled forKey:WebKitSubpixelAntialiasedLayerTextEnabledPreferenceKey];
2004 }
2005
2006 - (BOOL)simpleLineLayoutEnabled
2007 {
2008     return [self _boolValueForKey:WebKitSimpleLineLayoutEnabledPreferenceKey];
2009 }
2010
2011 - (void)setSimpleLineLayoutEnabled:(BOOL)enabled
2012 {
2013     [self _setBoolValue:enabled forKey:WebKitSimpleLineLayoutEnabledPreferenceKey];
2014 }
2015
2016 - (BOOL)simpleLineLayoutDebugBordersEnabled
2017 {
2018     return [self _boolValueForKey:WebKitSimpleLineLayoutDebugBordersEnabledPreferenceKey];
2019 }
2020
2021 - (void)setSimpleLineLayoutDebugBordersEnabled:(BOOL)enabled
2022 {
2023     [self _setBoolValue:enabled forKey:WebKitSimpleLineLayoutDebugBordersEnabledPreferenceKey];
2024 }
2025
2026 - (BOOL)showRepaintCounter
2027 {
2028     return [self _boolValueForKey:WebKitShowRepaintCounterPreferenceKey];
2029 }
2030
2031 - (void)setShowRepaintCounter:(BOOL)enabled
2032 {
2033     [self _setBoolValue:enabled forKey:WebKitShowRepaintCounterPreferenceKey];
2034 }
2035
2036 - (BOOL)webAudioEnabled
2037 {
2038     return [self _boolValueForKey:WebKitWebAudioEnabledPreferenceKey];
2039 }
2040
2041 - (void)setWebAudioEnabled:(BOOL)enabled
2042 {
2043     [self _setBoolValue:enabled forKey:WebKitWebAudioEnabledPreferenceKey];
2044 }
2045
2046 - (BOOL)subpixelCSSOMElementMetricsEnabled
2047 {
2048     return [self _boolValueForKey:WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey];
2049 }
2050
2051 - (void)setSubpixelCSSOMElementMetricsEnabled:(BOOL)enabled
2052 {
2053     [self _setBoolValue:enabled forKey:WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey];
2054 }
2055
2056 - (BOOL)webGLEnabled
2057 {
2058     return [self _boolValueForKey:WebKitWebGLEnabledPreferenceKey];
2059 }
2060
2061 - (void)setWebGLEnabled:(BOOL)enabled
2062 {
2063     [self _setBoolValue:enabled forKey:WebKitWebGLEnabledPreferenceKey];
2064 }
2065
2066 - (BOOL)webGL2Enabled
2067 {
2068     return [self _boolValueForKey:WebKitWebGL2EnabledPreferenceKey];
2069 }
2070
2071 - (void)setWebGL2Enabled:(BOOL)enabled
2072 {
2073     [self _setBoolValue:enabled forKey:WebKitWebGL2EnabledPreferenceKey];
2074 }
2075
2076 - (BOOL)forceSoftwareWebGLRendering
2077 {
2078     return [self _boolValueForKey:WebKitForceSoftwareWebGLRenderingPreferenceKey];
2079 }
2080
2081 - (void)setForceSoftwareWebGLRendering:(BOOL)forced
2082 {
2083     [self _setBoolValue:forced forKey:WebKitForceSoftwareWebGLRenderingPreferenceKey];
2084 }
2085
2086 - (BOOL)forceLowPowerGPUForWebGL
2087 {
2088     return [self _boolValueForKey:WebKitForceWebGLUsesLowPowerPreferenceKey];
2089 }
2090
2091 - (void)setForceWebGLUsesLowPower:(BOOL)forceLowPower
2092 {
2093     [self _setBoolValue:forceLowPower forKey:WebKitForceWebGLUsesLowPowerPreferenceKey];
2094 }
2095
2096 - (BOOL)webGPUEnabled
2097 {
2098     return [self _boolValueForKey:WebKitWebGPUEnabledPreferenceKey];
2099 }
2100
2101 - (void)setWebGPUEnabled:(BOOL)enabled
2102 {
2103     [self _setBoolValue:enabled forKey:WebKitWebGPUEnabledPreferenceKey];
2104 }
2105
2106 - (BOOL)accelerated2dCanvasEnabled
2107 {
2108     return [self _boolValueForKey:WebKitAccelerated2dCanvasEnabledPreferenceKey];
2109 }
2110
2111 - (void)setAccelerated2dCanvasEnabled:(BOOL)enabled
2112 {
2113     [self _setBoolValue:enabled forKey:WebKitAccelerated2dCanvasEnabledPreferenceKey];
2114 }
2115
2116 - (void)setDiskImageCacheEnabled:(BOOL)enabled
2117 {
2118     // Staging. Can be removed once there are no more callers.
2119 }
2120
2121 - (BOOL)isFrameFlatteningEnabled
2122 {
2123     return [self _unsignedIntValueForKey:WebKitFrameFlatteningPreferenceKey] != WebKitFrameFlatteningDisabled;
2124 }
2125
2126 - (void)setFrameFlatteningEnabled:(BOOL)flattening
2127 {
2128     WebKitFrameFlattening value = flattening ? WebKitFrameFlatteningFullyEnabled : WebKitFrameFlatteningDisabled;
2129     [self _setUnsignedIntValue:value forKey:WebKitFrameFlatteningPreferenceKey];
2130 }
2131
2132 - (WebKitFrameFlattening)frameFlattening
2133 {
2134     return static_cast<WebKitFrameFlattening>([self _unsignedIntValueForKey:WebKitFrameFlatteningPreferenceKey]);
2135 }
2136
2137 - (void)setFrameFlattening:(WebKitFrameFlattening)flattening
2138 {
2139     [self _setUnsignedIntValue:flattening forKey:WebKitFrameFlatteningPreferenceKey];
2140 }
2141
2142 - (BOOL)asyncFrameScrollingEnabled
2143 {
2144     return [self _boolValueForKey:WebKitAsyncFrameScrollingEnabledPreferenceKey];
2145 }
2146
2147 - (void)setAsyncFrameScrollingEnabled:(BOOL)enabled
2148 {
2149     [self _setBoolValue:enabled forKey:WebKitAsyncFrameScrollingEnabledPreferenceKey];
2150 }
2151
2152 - (BOOL)isSpatialNavigationEnabled
2153 {
2154     return [self _boolValueForKey:WebKitSpatialNavigationEnabledPreferenceKey];
2155 }
2156
2157 - (void)setSpatialNavigationEnabled:(BOOL)flag
2158 {
2159     [self _setBoolValue:flag forKey:WebKitSpatialNavigationEnabledPreferenceKey];
2160 }
2161
2162 - (BOOL)paginateDuringLayoutEnabled
2163 {
2164     return [self _boolValueForKey:WebKitPaginateDuringLayoutEnabledPreferenceKey];
2165 }
2166
2167 - (void)setPaginateDuringLayoutEnabled:(BOOL)flag
2168 {
2169     [self _setBoolValue:flag forKey:WebKitPaginateDuringLayoutEnabledPreferenceKey];
2170 }
2171
2172 - (BOOL)hyperlinkAuditingEnabled
2173 {
2174     return [self _boolValueForKey:WebKitHyperlinkAuditingEnabledPreferenceKey];
2175 }
2176
2177 - (void)setHyperlinkAuditingEnabled:(BOOL)flag
2178 {
2179     [self _setBoolValue:flag forKey:WebKitHyperlinkAuditingEnabledPreferenceKey];
2180 }
2181
2182 - (BOOL)usePreHTML5ParserQuirks
2183 {
2184     return [self _boolValueForKey:WebKitUsePreHTML5ParserQuirksKey];
2185 }
2186
2187 - (void)setUsePreHTML5ParserQuirks:(BOOL)flag
2188 {
2189     [self _setBoolValue:flag forKey:WebKitUsePreHTML5ParserQuirksKey];
2190 }
2191
2192 - (void)didRemoveFromWebView
2193 {
2194     ASSERT(_private->numWebViews);
2195     if (--_private->numWebViews == 0)
2196         [[NSNotificationCenter defaultCenter]
2197             postNotificationName:WebPreferencesRemovedNotification
2198                           object:self
2199                         userInfo:nil];
2200 }
2201
2202 - (void)willAddToWebView
2203 {
2204     ++_private->numWebViews;
2205 }
2206
2207 - (void)_setPreferenceForTestWithValue:(NSString *)value forKey:(NSString *)key
2208 {
2209     [self _setStringValue:value forKey:key];
2210 }
2211
2212 - (void)setFullScreenEnabled:(BOOL)flag
2213 {
2214     [self _setBoolValue:flag forKey:WebKitFullScreenEnabledPreferenceKey];
2215 }
2216
2217 - (BOOL)fullScreenEnabled
2218 {
2219     return [self _boolValueForKey:WebKitFullScreenEnabledPreferenceKey];
2220 }
2221
2222 - (void)setAsynchronousSpellCheckingEnabled:(BOOL)flag
2223 {
2224     [self _setBoolValue:flag forKey:WebKitAsynchronousSpellCheckingEnabledPreferenceKey];
2225 }
2226
2227 - (BOOL)asynchronousSpellCheckingEnabled
2228 {
2229     return [self _boolValueForKey:WebKitAsynchronousSpellCheckingEnabledPreferenceKey];
2230 }
2231
2232 + (void)setWebKitLinkTimeVersion:(int)version
2233 {
2234     setWebKitLinkTimeVersion(version);
2235 }
2236
2237 - (void)setLoadsSiteIconsIgnoringImageLoadingPreference: (BOOL)flag
2238 {
2239     [self _setBoolValue: flag forKey: WebKitLoadSiteIconsKey];
2240 }
2241
2242 - (BOOL)loadsSiteIconsIgnoringImageLoadingPreference
2243 {
2244     return [self _boolValueForKey: WebKitLoadSiteIconsKey];
2245 }
2246
2247 - (void)setAVFoundationEnabled:(BOOL)flag
2248 {
2249     [self _setBoolValue:flag forKey:WebKitAVFoundationEnabledKey];
2250 }
2251
2252 - (BOOL)isAVFoundationEnabled
2253 {
2254     return [self _boolValueForKey:WebKitAVFoundationEnabledKey];
2255 }
2256
2257 - (void)setAVFoundationNSURLSessionEnabled:(BOOL)flag
2258 {
2259     [self _setBoolValue:flag forKey:WebKitAVFoundationNSURLSessionEnabledKey];
2260 }
2261
2262 - (BOOL)isAVFoundationNSURLSessionEnabled
2263 {
2264     return [self _boolValueForKey:WebKitAVFoundationNSURLSessionEnabledKey];
2265 }
2266
2267 - (void)setQTKitEnabled:(BOOL)flag
2268 {
2269     [self _setBoolValue:flag forKey:WebKitQTKitEnabledPreferenceKey];
2270 }
2271
2272 - (BOOL)isQTKitEnabled
2273 {
2274     return [self _boolValueForKey:WebKitQTKitEnabledPreferenceKey];
2275 }
2276
2277 - (void)setVideoPluginProxyEnabled:(BOOL)flag
2278 {
2279     // No-op, left for SPI compatibility.
2280 }
2281
2282 - (BOOL)isVideoPluginProxyEnabled
2283 {
2284     return NO;
2285 }
2286
2287 - (void)setHixie76WebSocketProtocolEnabled:(BOOL)flag
2288 {
2289 }
2290
2291 - (BOOL)isHixie76WebSocketProtocolEnabled
2292 {
2293     return false;
2294 }
2295
2296 - (BOOL)isInheritURIQueryComponentEnabled
2297 {
2298     return [self _boolValueForKey: WebKitEnableInheritURIQueryComponentPreferenceKey];
2299 }
2300
2301 - (void)setEnableInheritURIQueryComponent:(BOOL)flag
2302 {
2303     [self _setBoolValue:flag forKey: WebKitEnableInheritURIQueryComponentPreferenceKey];
2304 }
2305
2306 #if PLATFORM(IOS)
2307 - (BOOL)mediaPlaybackAllowsAirPlay
2308 {
2309     return [self _boolValueForKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
2310 }
2311
2312 - (void)setMediaPlaybackAllowsAirPlay:(BOOL)flag
2313 {
2314     [self _setBoolValue:flag forKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
2315 }
2316
2317 - (unsigned)audioSessionCategoryOverride
2318 {
2319     return [self _unsignedIntValueForKey:WebKitAudioSessionCategoryOverride];
2320 }
2321
2322 - (void)setAudioSessionCategoryOverride:(unsigned)override
2323 {
2324     if (override > AudioSession::AudioProcessing) {
2325         // Clients are passing us OSTypes values from AudioToolbox/AudioSession.h,
2326         // which need to be translated into AudioSession::CategoryType:
2327         switch (override) {
2328         case kAudioSessionCategory_AmbientSound:
2329             override = AudioSession::AmbientSound;
2330             break;
2331         case kAudioSessionCategory_SoloAmbientSound:
2332             override = AudioSession::SoloAmbientSound;
2333             break;
2334         case kAudioSessionCategory_MediaPlayback:
2335             override = AudioSession::MediaPlayback;
2336             break;
2337         case kAudioSessionCategory_RecordAudio:
2338             override = AudioSession::RecordAudio;
2339             break;
2340         case kAudioSessionCategory_PlayAndRecord:
2341             override = AudioSession::PlayAndRecord;
2342             break;
2343         case kAudioSessionCategory_AudioProcessing:
2344             override = AudioSession::AudioProcessing;
2345             break;
2346         default:
2347             override = AudioSession::None;
2348             break;
2349         }
2350     }
2351
2352     [self _setUnsignedIntValue:override forKey:WebKitAudioSessionCategoryOverride];
2353 }
2354
2355 - (BOOL)avKitEnabled
2356 {
2357     return [self _boolValueForKey:WebKitAVKitEnabled];
2358 }
2359
2360 - (void)setAVKitEnabled:(bool)flag
2361 {
2362 #if HAVE(AVKIT)
2363     [self _setBoolValue:flag forKey:WebKitAVKitEnabled];
2364 #endif
2365 }
2366
2367 - (BOOL)networkDataUsageTrackingEnabled
2368 {
2369     return [self _boolValueForKey:WebKitNetworkDataUsageTrackingEnabledPreferenceKey];
2370 }
2371
2372 - (void)setNetworkDataUsageTrackingEnabled:(bool)trackingEnabled
2373 {
2374     [self _setBoolValue:trackingEnabled forKey:WebKitNetworkDataUsageTrackingEnabledPreferenceKey];
2375 }
2376
2377 - (NSString *)networkInterfaceName
2378 {
2379     return [self _stringValueForKey:WebKitNetworkInterfaceNamePreferenceKey];
2380 }
2381
2382 - (void)setNetworkInterfaceName:(NSString *)name
2383 {
2384     [self _setStringValue:name forKey:WebKitNetworkInterfaceNamePreferenceKey];
2385 }
2386 #endif // PLATFORM(IOS)
2387
2388 // Deprecated. Use -videoPlaybackRequiresUserGesture and -audioPlaybackRequiresUserGesture instead.
2389 - (BOOL)mediaPlaybackRequiresUserGesture
2390 {
2391     return [self _boolValueForKey:WebKitRequiresUserGestureForMediaPlaybackPreferenceKey];
2392 }
2393
2394 // Deprecated. Use -setVideoPlaybackRequiresUserGesture and -setAudioPlaybackRequiresUserGesture instead.
2395 - (void)setMediaPlaybackRequiresUserGesture:(BOOL)flag
2396 {
2397     [self _setBoolValue:flag forKey:WebKitRequiresUserGestureForMediaPlaybackPreferenceKey];
2398 }
2399
2400 - (BOOL)videoPlaybackRequiresUserGesture
2401 {
2402     return [self _boolValueForKey:WebKitRequiresUserGestureForVideoPlaybackPreferenceKey];
2403 }
2404
2405 - (void)setVideoPlaybackRequiresUserGesture:(BOOL)flag
2406 {
2407     [self _setBoolValue:flag forKey:WebKitRequiresUserGestureForVideoPlaybackPreferenceKey];
2408 }
2409
2410 - (BOOL)audioPlaybackRequiresUserGesture
2411 {
2412     return [self _boolValueForKey:WebKitRequiresUserGestureForAudioPlaybackPreferenceKey];
2413 }
2414
2415 - (void)setAudioPlaybackRequiresUserGesture:(BOOL)flag
2416 {
2417     [self _setBoolValue:flag forKey:WebKitRequiresUserGestureForAudioPlaybackPreferenceKey];
2418 }
2419
2420 - (BOOL)overrideUserGestureRequirementForMainContent
2421 {
2422     return [self _boolValueForKey:WebKitMainContentUserGestureOverrideEnabledPreferenceKey];
2423 }
2424
2425 - (void)setOverrideUserGestureRequirementForMainContent:(BOOL)flag
2426 {
2427     [self _setBoolValue:flag forKey:WebKitMainContentUserGestureOverrideEnabledPreferenceKey];
2428 }
2429
2430 - (BOOL)mediaPlaybackAllowsInline
2431 {
2432     return [self _boolValueForKey:WebKitAllowsInlineMediaPlaybackPreferenceKey];
2433 }
2434
2435 - (void)setMediaPlaybackAllowsInline:(BOOL)flag
2436 {
2437     [self _setBoolValue:flag forKey:WebKitAllowsInlineMediaPlaybackPreferenceKey];
2438 }
2439
2440 - (BOOL)inlineMediaPlaybackRequiresPlaysInlineAttribute
2441 {
2442     return [self _boolValueForKey:WebKitInlineMediaPlaybackRequiresPlaysInlineAttributeKey];
2443 }
2444
2445 - (void)setInlineMediaPlaybackRequiresPlaysInlineAttribute:(BOOL)flag
2446 {
2447     [self _setBoolValue:flag forKey:WebKitInlineMediaPlaybackRequiresPlaysInlineAttributeKey];
2448 }
2449
2450 - (BOOL)invisibleAutoplayNotPermitted
2451 {
2452     return [self _boolValueForKey:WebKitInvisibleAutoplayNotPermittedKey];
2453 }
2454
2455 - (void)setInvisibleAutoplayNotPermitted:(BOOL)flag
2456 {
2457     [self _setBoolValue:flag forKey:WebKitInvisibleAutoplayNotPermittedKey];
2458 }
2459
2460 - (BOOL)mediaControlsScaleWithPageZoom
2461 {
2462     return [self _boolValueForKey:WebKitMediaControlsScaleWithPageZoomPreferenceKey];
2463 }
2464
2465 - (void)setMediaControlsScaleWithPageZoom:(BOOL)flag
2466 {
2467     [self _setBoolValue:flag forKey:WebKitMediaControlsScaleWithPageZoomPreferenceKey];
2468 }
2469
2470 - (BOOL)allowsAlternateFullscreen
2471 {
2472     return [self allowsPictureInPictureMediaPlayback];
2473 }
2474
2475 - (void)setAllowsAlternateFullscreen:(BOOL)flag
2476 {
2477     [self setAllowsPictureInPictureMediaPlayback:flag];
2478 }
2479
2480 - (BOOL)allowsPictureInPictureMediaPlayback
2481 {
2482     return [self _boolValueForKey:WebKitAllowsPictureInPictureMediaPlaybackPreferenceKey];
2483 }
2484
2485 - (void)setAllowsPictureInPictureMediaPlayback:(BOOL)flag
2486 {
2487     [self _setBoolValue:flag forKey:WebKitAllowsPictureInPictureMediaPlaybackPreferenceKey];
2488 }
2489
2490 - (BOOL)mockScrollbarsEnabled
2491 {
2492     return [self _boolValueForKey:WebKitMockScrollbarsEnabledPreferenceKey];
2493 }
2494
2495 - (void)setMockScrollbarsEnabled:(BOOL)flag
2496 {
2497     [self _setBoolValue:flag forKey:WebKitMockScrollbarsEnabledPreferenceKey];
2498 }
2499
2500 - (NSString *)pictographFontFamily
2501 {
2502     return [self _stringValueForKey: WebKitPictographFontPreferenceKey];
2503 }
2504
2505 - (void)setPictographFontFamily:(NSString *)family
2506 {
2507     [self _setStringValue: family forKey: WebKitPictographFontPreferenceKey];
2508 }
2509
2510 - (BOOL)pageCacheSupportsPlugins
2511 {
2512     return [self _boolValueForKey:WebKitPageCacheSupportsPluginsPreferenceKey];
2513 }
2514
2515 - (void)setPageCacheSupportsPlugins:(BOOL)flag
2516 {
2517     [self _setBoolValue:flag forKey:WebKitPageCacheSupportsPluginsPreferenceKey];
2518
2519 }
2520
2521 #if PLATFORM(IOS)
2522 - (void)_invalidateCachedPreferences
2523 {
2524     dispatch_barrier_sync(_private->readWriteQueue, ^{
2525         if (_private->values)
2526             _private->values = adoptNS([[NSMutableDictionary alloc] init]);
2527     });
2528
2529     [self _updatePrivateBrowsingStateTo:[self privateBrowsingEnabled]];
2530
2531     // Tell any live WebViews to refresh their preferences
2532     [self _postPreferencesChangedNotification];
2533 }
2534
2535 - (void)_synchronizeWebStoragePolicyWithCookiePolicy
2536 {
2537     // FIXME: This should be done in clients, WebKit shouldn't be making such policy decisions.
2538
2539     NSHTTPCookieAcceptPolicy cookieAcceptPolicy = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookieAcceptPolicy];
2540     WebStorageBlockingPolicy storageBlockingPolicy;
2541     switch (static_cast<unsigned>(cookieAcceptPolicy)) {
2542     case NSHTTPCookieAcceptPolicyAlways:
2543         storageBlockingPolicy = WebAllowAllStorage;
2544         break;
2545     case NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
2546     case NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
2547         storageBlockingPolicy = WebBlockThirdPartyStorage;
2548         break;
2549     case NSHTTPCookieAcceptPolicyNever:
2550         storageBlockingPolicy = WebBlockAllStorage;
2551         break;
2552     default:
2553         ASSERT_NOT_REACHED();
2554         storageBlockingPolicy = WebBlockAllStorage;
2555         break;
2556     }    
2557
2558     [self setStorageBlockingPolicy:storageBlockingPolicy];
2559 }
2560 #endif
2561
2562 - (void)setBackspaceKeyNavigationEnabled:(BOOL)flag
2563 {
2564     [self _setBoolValue:flag forKey:WebKitBackspaceKeyNavigationEnabledKey];
2565 }
2566
2567 - (BOOL)backspaceKeyNavigationEnabled
2568 {
2569     return [self _boolValueForKey:WebKitBackspaceKeyNavigationEnabledKey];
2570 }
2571
2572 - (void)setWantsBalancedSetDefersLoadingBehavior:(BOOL)flag
2573 {
2574     [self _setBoolValue:flag forKey:WebKitWantsBalancedSetDefersLoadingBehaviorKey];
2575 }
2576
2577 - (BOOL)wantsBalancedSetDefersLoadingBehavior
2578 {
2579     return [self _boolValueForKey:WebKitWantsBalancedSetDefersLoadingBehaviorKey];
2580 }
2581
2582 - (void)setShouldDisplaySubtitles:(BOOL)flag
2583 {
2584     [self _setBoolValue:flag forKey:WebKitShouldDisplaySubtitlesPreferenceKey];
2585 }
2586
2587 - (BOOL)shouldDisplaySubtitles
2588 {
2589     return [self _boolValueForKey:WebKitShouldDisplaySubtitlesPreferenceKey];
2590 }
2591
2592 - (void)setShouldDisplayCaptions:(BOOL)flag
2593 {
2594     [self _setBoolValue:flag forKey:WebKitShouldDisplayCaptionsPreferenceKey];
2595 }
2596
2597 - (BOOL)shouldDisplayCaptions
2598 {
2599     return [self _boolValueForKey:WebKitShouldDisplayCaptionsPreferenceKey];
2600 }
2601
2602 - (void)setShouldDisplayTextDescriptions:(BOOL)flag
2603 {
2604     [self _setBoolValue:flag forKey:WebKitShouldDisplayTextDescriptionsPreferenceKey];
2605 }
2606
2607 - (BOOL)shouldDisplayTextDescriptions
2608 {
2609     return [self _boolValueForKey:WebKitShouldDisplayTextDescriptionsPreferenceKey];
2610 }
2611
2612 - (void)setNotificationsEnabled:(BOOL)flag
2613 {
2614     [self _setBoolValue:flag forKey:WebKitNotificationsEnabledKey];
2615 }
2616
2617 - (BOOL)notificationsEnabled
2618 {
2619     return [self _boolValueForKey:WebKitNotificationsEnabledKey];
2620 }
2621
2622 - (void)setShouldRespectImageOrientation:(BOOL)flag
2623 {
2624     [self _setBoolValue:flag forKey:WebKitShouldRespectImageOrientationKey];
2625 }
2626
2627 - (BOOL)shouldRespectImageOrientation
2628 {
2629     return [self _boolValueForKey:WebKitShouldRespectImageOrientationKey];
2630 }
2631
2632 - (BOOL)requestAnimationFrameEnabled
2633 {
2634     return [self _boolValueForKey:WebKitRequestAnimationFrameEnabledPreferenceKey];
2635 }
2636
2637 - (void)setRequestAnimationFrameEnabled:(BOOL)enabled
2638 {
2639     [self _setBoolValue:enabled forKey:WebKitRequestAnimationFrameEnabledPreferenceKey];
2640 }
2641
2642 - (void)setIncrementalRenderingSuppressionTimeoutInSeconds:(NSTimeInterval)timeout
2643 {
2644     [self _setFloatValue:timeout forKey:WebKitIncrementalRenderingSuppressionTimeoutInSecondsKey];
2645 }
2646
2647 - (NSTimeInterval)incrementalRenderingSuppressionTimeoutInSeconds
2648 {
2649     return [self _floatValueForKey:WebKitIncrementalRenderingSuppressionTimeoutInSecondsKey];
2650 }
2651
2652 - (BOOL)diagnosticLoggingEnabled
2653 {
2654     return [self _boolValueForKey:WebKitDiagnosticLoggingEnabledKey];
2655 }
2656
2657 - (void)setDiagnosticLoggingEnabled:(BOOL)enabled
2658 {
2659     [self _setBoolValue:enabled forKey:WebKitDiagnosticLoggingEnabledKey];
2660 }
2661
2662 - (void)setStorageBlockingPolicy:(WebStorageBlockingPolicy)storageBlockingPolicy
2663 {
2664 #if PLATFORM(IOS)
2665     // We don't want to write the setting out, so we just reset the default instead of storing the new setting.
2666     // FIXME: This code removes any defaults previously registered by client process, which is not appropriate for this method to do.
2667     NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:storageBlockingPolicy] forKey:WebKitStorageBlockingPolicyKey];
2668     [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
2669 #else
2670     [self _setIntegerValue:storageBlockingPolicy forKey:WebKitStorageBlockingPolicyKey];
2671 #endif
2672 }
2673
2674 - (WebStorageBlockingPolicy)storageBlockingPolicy
2675 {
2676     return static_cast<WebStorageBlockingPolicy>([self _integerValueForKey:WebKitStorageBlockingPolicyKey]);
2677 }
2678
2679 - (BOOL)plugInSnapshottingEnabled
2680 {
2681     return [self _boolValueForKey:WebKitPlugInSnapshottingEnabledPreferenceKey];
2682 }
2683
2684 - (void)setPlugInSnapshottingEnabled:(BOOL)enabled
2685 {
2686     [self _setBoolValue:enabled forKey:WebKitPlugInSnapshottingEnabledPreferenceKey];
2687 }
2688
2689 - (BOOL)hiddenPageDOMTimerThrottlingEnabled
2690 {
2691     return [self _boolValueForKey:WebKitHiddenPageDOMTimerThrottlingEnabledPreferenceKey];
2692 }
2693
2694 - (void)setHiddenPageDOMTimerThrottlingEnabled:(BOOL)enabled
2695 {
2696     [self _setBoolValue:enabled forKey:WebKitHiddenPageDOMTimerThrottlingEnabledPreferenceKey];
2697 }
2698
2699 - (BOOL)hiddenPageCSSAnimationSuspensionEnabled
2700 {
2701     return [self _boolValueForKey:WebKitHiddenPageCSSAnimationSuspensionEnabledPreferenceKey];
2702 }
2703
2704 - (void)setHiddenPageCSSAnimationSuspensionEnabled:(BOOL)enabled
2705 {
2706     [self _setBoolValue:enabled forKey:WebKitHiddenPageCSSAnimationSuspensionEnabledPreferenceKey];
2707 }
2708
2709 - (BOOL)lowPowerVideoAudioBufferSizeEnabled
2710 {
2711     return [self _boolValueForKey:WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey];
2712 }
2713
2714 - (void)setLowPowerVideoAudioBufferSizeEnabled:(BOOL)enabled
2715 {
2716     [self _setBoolValue:enabled forKey:WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey];
2717 }
2718
2719 - (BOOL)useLegacyTextAlignPositionedElementBehavior
2720 {
2721     return [self _boolValueForKey:WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey];
2722 }
2723
2724 - (void)setUseLegacyTextAlignPositionedElementBehavior:(BOOL)enabled
2725 {
2726     [self _setBoolValue:enabled forKey:WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey];
2727 }
2728
2729 - (BOOL)mediaSourceEnabled
2730 {
2731     return [self _boolValueForKey:WebKitMediaSourceEnabledPreferenceKey];
2732 }
2733
2734 - (void)setMediaSourceEnabled:(BOOL)enabled
2735 {
2736     [self _setBoolValue:enabled forKey:WebKitMediaSourceEnabledPreferenceKey];
2737 }
2738
2739 - (BOOL)imageControlsEnabled
2740 {
2741     return [self _boolValueForKey:WebKitImageControlsEnabledPreferenceKey];
2742 }
2743
2744 - (void)setImageControlsEnabled:(BOOL)enabled
2745 {
2746     [self _setBoolValue:enabled forKey:WebKitImageControlsEnabledPreferenceKey];
2747 }
2748
2749 - (BOOL)serviceControlsEnabled
2750 {
2751     return [self _boolValueForKey:WebKitServiceControlsEnabledPreferenceKey];
2752 }
2753
2754 - (void)setServiceControlsEnabled:(BOOL)enabled
2755 {
2756     [self _setBoolValue:enabled forKey:WebKitServiceControlsEnabledPreferenceKey];
2757 }
2758
2759 - (BOOL)gamepadsEnabled
2760 {
2761     return [self _boolValueForKey:WebKitGamepadsEnabledPreferenceKey];
2762 }
2763
2764 - (void)setGamepadsEnabled:(BOOL)flag
2765 {
2766     [self _setBoolValue:flag forKey:WebKitGamepadsEnabledPreferenceKey];
2767 }
2768
2769 - (BOOL)shouldConvertPositionStyleOnCopy
2770 {
2771     return [self _boolValueForKey:WebKitShouldConvertPositionStyleOnCopyPreferenceKey];
2772 }
2773
2774 - (void)setShouldConvertPositionStyleOnCopy:(BOOL)enabled
2775 {
2776     [self _setBoolValue:enabled forKey:WebKitShouldConvertPositionStyleOnCopyPreferenceKey];
2777 }
2778
2779 - (NSString *)mediaKeysStorageDirectory
2780 {
2781     return [[self _stringValueForKey:WebKitMediaKeysStorageDirectoryKey] stringByStandardizingPath];
2782 }
2783
2784 - (void)setMediaKeysStorageDirectory:(NSString *)directory
2785 {
2786     [self _setStringValue:directory forKey:WebKitMediaKeysStorageDirectoryKey];
2787 }
2788
2789 - (BOOL)mediaDevicesEnabled
2790 {
2791     return [self _boolValueForKey:WebKitMediaDevicesEnabledPreferenceKey];
2792 }
2793
2794 - (void)setMediaDevicesEnabled:(BOOL)flag
2795 {
2796     [self _setBoolValue:flag forKey:WebKitMediaDevicesEnabledPreferenceKey];
2797 }
2798
2799 - (BOOL)mediaStreamEnabled
2800 {
2801     return [self _boolValueForKey:WebKitMediaStreamEnabledPreferenceKey];
2802 }
2803
2804 - (void)setMediaStreamEnabled:(BOOL)flag
2805 {
2806     [self _setBoolValue:flag forKey:WebKitMediaStreamEnabledPreferenceKey];
2807 }
2808
2809 - (BOOL)peerConnectionEnabled
2810 {
2811     return [self _boolValueForKey:WebKitPeerConnectionEnabledPreferenceKey];
2812 }
2813
2814 - (void)setPeerConnectionEnabled:(BOOL)flag
2815 {
2816     [self _setBoolValue:flag forKey:WebKitPeerConnectionEnabledPreferenceKey];
2817 }
2818
2819 - (BOOL)webRTCLegacyAPIEnabled
2820 {
2821     return [self _boolValueForKey:WebKitWebRTCLegacyAPIEnabledPreferenceKey];
2822 }
2823
2824 - (void)setWebRTCLegacyAPIEnabled:(BOOL)flag
2825 {
2826     [self _setBoolValue:flag forKey:WebKitWebRTCLegacyAPIEnabledPreferenceKey];
2827 }
2828
2829 - (BOOL)linkPreloadEnabled
2830 {
2831     return [self _boolValueForKey:WebKitLinkPreloadEnabledPreferenceKey];
2832 }
2833
2834 - (void)setLinkPreloadEnabled:(BOOL)flag
2835 {
2836     [self _setBoolValue:flag forKey:WebKitLinkPreloadEnabledPreferenceKey];
2837 }
2838
2839 - (BOOL)mediaPreloadingEnabled
2840 {
2841     return [self _boolValueForKey:WebKitMediaPreloadingEnabledPreferenceKey];
2842 }
2843
2844 - (void)setMediaPreloadingEnabled:(BOOL)flag
2845 {
2846     [self _setBoolValue:flag forKey:WebKitMediaPreloadingEnabledPreferenceKey];
2847 }
2848
2849 - (void)setMetaRefreshEnabled:(BOOL)enabled
2850 {
2851     [self setHTTPEquivEnabled:enabled];
2852 }
2853
2854 - (BOOL)metaRefreshEnabled
2855 {
2856     return [self httpEquivEnabled];
2857 }
2858
2859 - (void)setHTTPEquivEnabled:(BOOL)enabled
2860 {
2861     [self _setBoolValue:enabled forKey:WebKitHTTPEquivEnabledPreferenceKey];
2862 }
2863
2864 - (BOOL)httpEquivEnabled
2865 {
2866     return [self _boolValueForKey:WebKitHTTPEquivEnabledPreferenceKey];
2867 }
2868
2869 - (BOOL)javaScriptMarkupEnabled
2870 {
2871     return [self _boolValueForKey:WebKitJavaScriptMarkupEnabledPreferenceKey];
2872 }
2873
2874 - (void)setJavaScriptMarkupEnabled:(BOOL)flag
2875 {
2876     [self _setBoolValue:flag forKey:WebKitJavaScriptMarkupEnabledPreferenceKey];
2877 }
2878
2879 - (BOOL)mediaDataLoadsAutomatically
2880 {
2881     return [self _boolValueForKey:WebKitMediaDataLoadsAutomaticallyPreferenceKey];
2882 }
2883
2884 - (void)setMediaDataLoadsAutomatically:(BOOL)flag
2885 {
2886     [self _setBoolValue:flag forKey:WebKitMediaDataLoadsAutomaticallyPreferenceKey];
2887 }
2888
2889 - (BOOL)attachmentElementEnabled
2890 {
2891     return [self _boolValueForKey:WebKitAttachmentElementEnabledPreferenceKey];
2892 }
2893
2894 - (void)setAttachmentElementEnabled:(BOOL)flag
2895 {
2896     [self _setBoolValue:flag forKey:WebKitAttachmentElementEnabledPreferenceKey];
2897 }
2898
2899 - (BOOL)allowsInlineMediaPlaybackAfterFullscreen
2900 {
2901     return [self _boolValueForKey:WebKitAllowsInlineMediaPlaybackAfterFullscreenPreferenceKey];
2902 }
2903
2904 - (void)setAllowsInlineMediaPlaybackAfterFullscreen:(BOOL)flag
2905 {
2906     [self _setBoolValue:flag forKey:WebKitAllowsInlineMediaPlaybackAfterFullscreenPreferenceKey];
2907 }
2908
2909 - (BOOL)mockCaptureDevicesEnabled
2910 {
2911     return [self _boolValueForKey:WebKitMockCaptureDevicesEnabledPreferenceKey];
2912 }
2913
2914 - (void)setMockCaptureDevicesEnabled:(BOOL)flag
2915 {
2916     [self _setBoolValue:flag forKey:WebKitMockCaptureDevicesEnabledPreferenceKey];
2917 }
2918
2919 - (BOOL)mockCaptureDevicesPromptEnabled
2920 {
2921     return [self _boolValueForKey:WebKitMockCaptureDevicesPromptEnabledPreferenceKey];
2922 }
2923
2924 - (void)setMockCaptureDevicesPromptEnabled:(BOOL)flag
2925 {
2926     [self _setBoolValue:flag forKey:WebKitMockCaptureDevicesPromptEnabledPreferenceKey];
2927 }
2928
2929 - (BOOL)enumeratingAllNetworkInterfacesEnabled
2930 {
2931     return [self _boolValueForKey:WebKitEnumeratingAllNetworkInterfacesEnabledPreferenceKey];
2932 }
2933
2934 - (void)setEnumeratingAllNetworkInterfacesEnabled:(BOOL)flag
2935 {
2936     [self _setBoolValue:flag forKey:WebKitEnumeratingAllNetworkInterfacesEnabledPreferenceKey];
2937 }
2938
2939 - (BOOL)iceCandidateFilteringEnabled
2940 {
2941     return [self _boolValueForKey:WebKitICECandidateFilteringEnabledPreferenceKey];
2942 }
2943
2944 - (void)setIceCandidateFilteringEnabled:(BOOL)flag
2945 {
2946     [self _setBoolValue:flag forKey:WebKitICECandidateFilteringEnabledPreferenceKey];
2947 }
2948
2949 - (BOOL)mediaCaptureRequiresSecureConnection
2950 {
2951     return [self _boolValueForKey:WebKitMediaCaptureRequiresSecureConnectionPreferenceKey];
2952 }
2953
2954 - (void)setMediaCaptureRequiresSecureConnection:(BOOL)flag
2955 {
2956     [self _setBoolValue:flag forKey:WebKitMediaCaptureRequiresSecureConnectionPreferenceKey];
2957 }
2958
2959 - (BOOL)shadowDOMEnabled
2960 {
2961     return [self _boolValueForKey:WebKitShadowDOMEnabledPreferenceKey];
2962 }
2963
2964 - (void)setShadowDOMEnabled:(BOOL)flag
2965 {
2966     [self _setBoolValue:flag forKey:WebKitShadowDOMEnabledPreferenceKey];
2967 }
2968
2969 - (BOOL)customElementsEnabled
2970 {
2971     return [self _boolValueForKey:WebKitCustomElementsEnabledPreferenceKey];
2972 }
2973
2974 - (void)setCustomElementsEnabled:(BOOL)flag
2975 {
2976     [self _setBoolValue:flag forKey:WebKitCustomElementsEnabledPreferenceKey];
2977 }
2978
2979 - (BOOL)dataTransferItemsEnabled
2980 {
2981     return [self _boolValueForKey:WebKitDataTransferItemsEnabledPreferenceKey];
2982 }
2983
2984 - (void)setDataTransferItemsEnabled:(BOOL)flag
2985 {
2986     [self _setBoolValue:flag forKey:WebKitDataTransferItemsEnabledPreferenceKey];
2987 }
2988
2989 - (BOOL)customPasteboardDataEnabled
2990 {
2991     return [self _boolValueForKey:WebKitCustomPasteboardDataEnabledPreferenceKey];
2992 }
2993
2994 - (void)setCustomPasteboardDataEnabled:(BOOL)flag
2995 {
2996     [self _setBoolValue:flag forKey:WebKitCustomPasteboardDataEnabledPreferenceKey];
2997 }
2998
2999 - (BOOL)cacheAPIEnabled
3000 {
3001     return [self _boolValueForKey:WebKitCacheAPIEnabledPreferenceKey];
3002 }
3003
3004 - (void)setCacheAPIEnabled:(BOOL)flag
3005 {
3006     [self _setBoolValue:flag forKey:WebKitCacheAPIEnabledPreferenceKey];
3007 }
3008
3009 - (BOOL)fetchAPIEnabled
3010 {
3011     return [self _boolValueForKey:WebKitFetchAPIEnabledPreferenceKey];
3012 }
3013
3014 - (void)setFetchAPIEnabled:(BOOL)flag
3015 {
3016     [self _setBoolValue:flag forKey:WebKitFetchAPIEnabledPreferenceKey];
3017 }
3018
3019 - (BOOL)readableByteStreamAPIEnabled
3020 {
3021     return [self _boolValueForKey:WebKitReadableByteStreamAPIEnabledPreferenceKey];
3022 }
3023
3024 - (void)setReadableByteStreamAPIEnabled:(BOOL)flag
3025 {
3026     [self _setBoolValue:flag forKey:WebKitReadableByteStreamAPIEnabledPreferenceKey];
3027 }
3028
3029 - (BOOL)writableStreamAPIEnabled
3030 {
3031     return [self _boolValueForKey:WebKitWritableStreamAPIEnabledPreferenceKey];
3032 }
3033
3034 - (void)setWritableStreamAPIEnabled:(BOOL)flag
3035 {
3036     [self _setBoolValue:flag forKey:WebKitWritableStreamAPIEnabledPreferenceKey];
3037 }
3038
3039 - (BOOL)downloadAttributeEnabled
3040 {
3041     return [self _boolValueForKey:WebKitDownloadAttributeEnabledPreferenceKey];
3042 }
3043
3044 - (void)setDownloadAttributeEnabled:(BOOL)flag
3045 {
3046     [self _setBoolValue:flag forKey:WebKitDownloadAttributeEnabledPreferenceKey];
3047 }
3048
3049 - (void)setDirectoryUploadEnabled:(BOOL)flag
3050 {
3051     [self _setBoolValue:flag forKey:WebKitDirectoryUploadEnabledPreferenceKey];
3052 }
3053
3054 - (BOOL)directoryUploadEnabled
3055 {
3056     return [self _boolValueForKey:WebKitDirectoryUploadEnabledPreferenceKey];
3057 }
3058
3059 - (BOOL)isCSSGridLayoutEnabled
3060 {
3061     return [self _boolValueForKey:WebKitCSSGridLayoutEnabledPreferenceKey];
3062 }
3063
3064 - (void)setCSSGridLayoutEnabled:(BOOL)flag
3065 {
3066     [self _setBoolValue:flag forKey:WebKitCSSGridLayoutEnabledPreferenceKey];
3067 }
3068
3069 - (BOOL)visualViewportEnabled
3070 {
3071     return [self _boolValueForKey:WebKitVisualViewportEnabledPreferenceKey];
3072 }
3073
3074 - (void)setVisualViewportEnabled:(BOOL)flag
3075 {
3076     [self _setBoolValue:flag forKey:WebKitVisualViewportEnabledPreferenceKey];
3077 }
3078
3079 - (BOOL)visualViewportAPIEnabled
3080 {
3081     return [self _boolValueForKey:WebKitVisualViewportAPIEnabledPreferenceKey];
3082 }
3083
3084 - (void)setVisualViewportAPIEnabled:(BOOL)flag
3085 {
3086     [self _setBoolValue:flag forKey:WebKitVisualViewportAPIEnabledPreferenceKey];
3087 }
3088 - (BOOL)webAnimationsEnabled
3089 {
3090     return [self _boolValueForKey:WebKitWebAnimationsEnabledPreferenceKey];
3091 }
3092
3093 - (void)setWebAnimationsEnabled:(BOOL)flag
3094 {
3095     [self _setBoolValue:flag forKey:WebKitWebAnimationsEnabledPreferenceKey];
3096 }
3097
3098 - (BOOL)modernMediaControlsEnabled
3099 {
3100     return [self _boolValueForKey:WebKitModernMediaControlsEnabledPreferenceKey];
3101 }
3102
3103 - (void)setModernMediaControlsEnabled:(BOOL)flag
3104 {
3105     [self _setBoolValue:flag forKey:WebKitModernMediaControlsEnabledPreferenceKey];
3106 }
3107
3108 - (BOOL)intersectionObserverEnabled
3109 {
3110     return [self _boolValueForKey:WebKitIntersectionObserverEnabledPreferenceKey];
3111 }
3112
3113 - (void)setIntersectionObserverEnabled:(BOOL)flag
3114 {
3115     [self _setBoolValue:flag forKey:WebKitIntersectionObserverEnabledPreferenceKey];
3116 }
3117
3118 - (BOOL)menuItemElementEnabled
3119 {
3120     return [self _boolValueForKey:WebKitMenuItemElementEnabledPreferenceKey];
3121 }
3122
3123 - (void)setMenuItemElementEnabled:(BOOL)flag
3124 {
3125     [self _setBoolValue:flag forKey:WebKitMenuItemElementEnabledPreferenceKey];
3126 }
3127
3128 - (BOOL)displayContentsEnabled
3129 {
3130     return [self _boolValueForKey:WebKitDisplayContentsEnabledPreferenceKey];
3131 }
3132
3133 - (void)setDisplayContentsEnabled:(BOOL)flag
3134 {
3135     [self _setBoolValue:flag forKey:WebKitDisplayContentsEnabledPreferenceKey];
3136 }
3137
3138 - (BOOL)userTimingEnabled
3139 {
3140     return [self _boolValueForKey:WebKitUserTimingEnabledPreferenceKey];
3141 }
3142
3143 - (void)setUserTimingEnabled:(BOOL)flag
3144 {
3145     [self _setBoolValue:flag forKey:WebKitUserTimingEnabledPreferenceKey];
3146 }
3147
3148 - (BOOL)resourceTimingEnabled
3149 {
3150     return [self _boolValueForKey:WebKitResourceTimingEnabledPreferenceKey];
3151 }
3152
3153 - (void)setResourceTimingEnabled:(BOOL)flag
3154 {
3155     [self _setBoolValue:flag forKey:WebKitResourceTimingEnabledPreferenceKey];
3156 }
3157
3158 - (BOOL)webAuthenticationEnabled
3159 {
3160     return [self _boolValueForKey:WebKitWebAuthenticationEnabledPreferenceKey];
3161 }
3162
3163 - (void)setWebAuthenticationEnabled:(BOOL)flag
3164 {
3165     [self _setBoolValue:flag forKey:WebKitWebAuthenticationEnabledPreferenceKey];
3166 }
3167
3168 - (BOOL)mediaUserGestureInheritsFromDocument
3169 {
3170     return [self _boolValueForKey:WebKitMediaUserGestureInheritsFromDocument];
3171 }
3172
3173 - (void)setMediaUserGestureInheritsFromDocument:(BOOL)flag
3174 {
3175     [self _setBoolValue:flag forKey:WebKitMediaUserGestureInheritsFromDocument];
3176 }
3177
3178 #if PLATFORM(IOS)
3179 - (BOOL)quickLookDocumentSavingEnabled
3180 {
3181     return [self _boolValueForKey:WebKitQuickLookDocumentSavingPreferenceKey];
3182 }
3183
3184 - (void)setQuickLookDocumentSavingEnabled:(BOOL)flag
3185 {
3186     [self _setBoolValue:flag forKey:WebKitQuickLookDocumentSavingPreferenceKey];
3187 }
3188 #endif
3189
3190 - (NSString *)mediaContentTypesRequiringHardwareSupport
3191 {
3192     return [self _stringValueForKey:WebKitMediaContentTypesRequiringHardwareSupportPreferenceKey];
3193 }
3194
3195 - (void)setMediaContentTypesRequiringHardwareSupport:(NSString *)value
3196 {
3197     [self _setStringValue:value forKey:WebKitMediaContentTypesRequiringHardwareSupportPreferenceKey];
3198 }
3199
3200 - (BOOL)isSecureContextAttributeEnabled
3201 {
3202     return [self _boolValueForKey:WebKitIsSecureContextAttributeEnabledPreferenceKey];
3203 }
3204
3205 - (void)setIsSecureContextAttributeEnabled:(BOOL)flag
3206 {
3207     [self _setBoolValue:flag forKey:WebKitIsSecureContextAttributeEnabledPreferenceKey];
3208 }
3209
3210 - (BOOL)legacyEncryptedMediaAPIEnabled
3211 {
3212     return [self _boolValueForKey:WebKitLegacyEncryptedMediaAPIEnabledKey];
3213 }
3214
3215 - (void)setLegacyEncryptedMediaAPIEnabled:(BOOL)flag
3216 {
3217     [self _setBoolValue:flag forKey:WebKitLegacyEncryptedMediaAPIEnabledKey];
3218 }
3219
3220 - (BOOL)encryptedMediaAPIEnabled
3221 {
3222     return [self _boolValueForKey:WebKitEncryptedMediaAPIEnabledKey];
3223 }
3224
3225 - (void)setEncryptedMediaAPIEnabled:(BOOL)flag
3226 {
3227     [self _setBoolValue:flag forKey:WebKitEncryptedMediaAPIEnabledKey];
3228 }
3229
3230 - (BOOL)viewportFitEnabled
3231 {
3232     return [self _boolValueForKey:WebKitViewportFitEnabledPreferenceKey];
3233 }
3234
3235 - (void)setViewportFitEnabled:(BOOL)flag
3236 {
3237     [self _setBoolValue:flag forKey:WebKitViewportFitEnabledPreferenceKey];
3238 }
3239
3240 - (BOOL)constantPropertiesEnabled
3241 {
3242     return [self _boolValueForKey:WebKitConstantPropertiesEnabledPreferenceKey];
3243 }
3244
3245 - (void)setConstantPropertiesEnabled:(BOOL)flag
3246 {
3247     [self _setBoolValue:flag forKey:WebKitConstantPropertiesEnabledPreferenceKey];
3248 }
3249
3250 - (BOOL)allowMediaContentTypesRequiringHardwareSupportAsFallback
3251 {
3252     return [self _boolValueForKey:WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallbackKey];
3253 }
3254
3255 - (void)setAllowMediaContentTypesRequiringHardwareSupportAsFallback:(BOOL)flag
3256 {
3257     [self _setBoolValue:flag forKey:WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallbackKey];
3258 }
3259
3260 - (BOOL)inspectorAdditionsEnabled
3261 {
3262     return [self _boolValueForKey:WebKitInspectorAdditionsEnabledPreferenceKey];
3263 }
3264
3265 - (void)setInspectorAdditionsEnabled:(BOOL)flag
3266 {
3267     [self _setBoolValue:flag forKey:WebKitInspectorAdditionsEnabledPreferenceKey];
3268 }
3269
3270 - (BOOL)accessibilityObjectModelEnabled
3271 {
3272     return [self _boolValueForKey:WebKitAccessibilityObjectModelEnabledPreferenceKey];
3273 }
3274
3275 - (void)setAccessibilityObjectModelEnabled:(BOOL)flag
3276 {
3277     [self _setBoolValue:flag forKey:WebKitAccessibilityObjectModelEnabledPreferenceKey];
3278 }
3279
3280 - (BOOL)mediaCapabilitiesEnabled
3281 {
3282     return [self _boolValueForKey:WebKitMediaCapabilitiesEnabledPreferenceKey];
3283 }
3284
3285 - (void)setMediaCapabilitiesEnabled:(BOOL)flag
3286 {
3287     [self _setBoolValue:flag forKey:WebKitMediaCapabilitiesEnabledPreferenceKey];
3288 }
3289
3290 @end
3291
3292 @implementation WebPreferences (WebInternal)
3293
3294 + (NSString *)_IBCreatorID
3295 {
3296     return classIBCreatorID;
3297 }
3298
3299 + (NSString *)_concatenateKeyWithIBCreatorID:(NSString *)key
3300 {
3301     NSString *IBCreatorID = [WebPreferences _IBCreatorID];
3302     if (!IBCreatorID)
3303         return key;
3304     return [IBCreatorID stringByAppendingString:key];
3305 }
3306
3307 @end