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