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