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