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