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