2 * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
3 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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 Computer, 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.
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.
30 #import "WebPreferencesPrivate.h"
31 #import "WebPreferenceKeysPrivate.h"
33 #import "WebApplicationCache.h"
34 #import "WebKitLogging.h"
35 #import "WebKitNSStringExtras.h"
36 #import "WebKitSystemBits.h"
37 #import "WebKitSystemInterface.h"
38 #import "WebKitVersionChecks.h"
39 #import "WebNSDictionaryExtras.h"
40 #import "WebNSURLExtras.h"
41 #import <WebCore/ApplicationCacheStorage.h>
43 NSString *WebPreferencesChangedNotification = @"WebPreferencesChangedNotification";
44 NSString *WebPreferencesRemovedNotification = @"WebPreferencesRemovedNotification";
46 #define KEY(x) (_private->identifier ? [_private->identifier stringByAppendingString:(x)] : (x))
48 enum { WebPreferencesVersion = 1 };
50 static WebPreferences *_standardPreferences;
51 static NSMutableDictionary *webPreferencesInstances;
53 static bool contains(const char* const array[], int count, const char* item)
58 for (int i = 0; i < count; i++)
59 if (!strcasecmp(array[i], item))
64 static WebCacheModel cacheModelForMainBundle(void)
66 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
68 // Apps that probably need the small setting
69 static const char* const documentViewerIDs[] = {
70 "Microsoft/com.microsoft.Messenger",
72 "com.alientechnology.Proteus",
75 "com.barebones.bbedit",
76 "com.barebones.textwrangler",
77 "com.barebones.yojimbo",
79 "com.growl.growlframework",
80 "com.intrarts.PandoraMan",
81 "com.karelia.Sandvox",
82 "com.macromates.textmate",
83 "com.realmacsoftware.rapidweaverpro",
84 "com.red-sweater.marsedit",
85 "com.yahoo.messenger3",
86 "de.codingmonkeys.SubEthaEdit",
92 // Apps that probably need the medium setting
93 static const char* const documentBrowserIDs[] = {
94 "com.apple.Dictionary",
96 "com.apple.dashboard.client",
97 "com.apple.helpviewer",
98 "com.culturedcode.xyle",
99 "com.macrabbit.CSSEdit",
101 "com.ranchero.NetNewsWire",
102 "com.thinkmac.NewsLife",
103 "org.xlife.NewsFire",
104 "uk.co.opencommunity.vienna2",
107 // Apps that probably need the large setting
108 static const char* const primaryWebBrowserIDs[] = {
109 "com.app4mac.KidsBrowser"
110 "com.app4mac.wKiosk",
111 "com.freeverse.bumpercar",
112 "com.omnigroup.OmniWeb5",
113 "com.sunrisebrowser.Sunrise",
114 "net.hmdt-web.Shiira",
117 WebCacheModel cacheModel;
119 const char* bundleID = [[[NSBundle mainBundle] bundleIdentifier] UTF8String];
120 if (contains(documentViewerIDs, sizeof(documentViewerIDs) / sizeof(documentViewerIDs[0]), bundleID))
121 cacheModel = WebCacheModelDocumentViewer;
122 else if (contains(documentBrowserIDs, sizeof(documentBrowserIDs) / sizeof(documentBrowserIDs[0]), bundleID))
123 cacheModel = WebCacheModelDocumentBrowser;
124 else if (contains(primaryWebBrowserIDs, sizeof(primaryWebBrowserIDs) / sizeof(primaryWebBrowserIDs[0]), bundleID))
125 cacheModel = WebCacheModelPrimaryWebBrowser;
127 bool isLegacyApp = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_CACHE_MODEL_API);
129 cacheModel = WebCacheModelDocumentBrowser; // To avoid regressions in apps that depended on old WebKit's large cache.
131 cacheModel = WebCacheModelDocumentViewer; // To save memory.
139 @interface WebPreferencesPrivate : NSObject
142 NSMutableDictionary *values;
143 NSString *identifier;
144 NSString *IBCreatorID;
146 BOOL automaticallyDetectsCacheModel;
147 unsigned numWebViews;
151 @implementation WebPreferencesPrivate
155 [identifier release];
156 [IBCreatorID release];
161 @interface WebPreferences (WebInternal)
162 + (NSString *)_concatenateKeyWithIBCreatorID:(NSString *)key;
163 + (NSString *)_IBCreatorID;
166 @interface WebPreferences (WebForwardDeclarations)
167 // This pseudo-category is needed so these methods can be used from within other category implementations
168 // without being in the public header file.
169 - (BOOL)_boolValueForKey:(NSString *)key;
170 - (void)_setBoolValue:(BOOL)value forKey:(NSString *)key;
171 - (int)_integerValueForKey:(NSString *)key;
172 - (void)_setIntegerValue:(int)value forKey:(NSString *)key;
173 - (float)_floatValueForKey:(NSString *)key;
174 - (void)_setFloatValue:(float)value forKey:(NSString *)key;
175 - (void)_setLongLongValue:(long long)value forKey:(NSString *)key;
176 - (long long)_longLongValueForKey:(NSString *)key;
177 - (void)_setUnsignedLongLongValue:(unsigned long long)value forKey:(NSString *)key;
178 - (unsigned long long)_unsignedLongLongValueForKey:(NSString *)key;
181 @implementation WebPreferences
185 // Create fake identifier
186 static int instanceCount = 1;
187 NSString *fakeIdentifier;
189 // At least ensure that identifier hasn't been already used.
190 fakeIdentifier = [NSString stringWithFormat:@"WebPreferences%d", instanceCount++];
191 while ([[self class] _getInstanceForIdentifier:fakeIdentifier]){
192 fakeIdentifier = [NSString stringWithFormat:@"WebPreferences%d", instanceCount++];
195 return [self initWithIdentifier:fakeIdentifier];
198 - (id)initWithIdentifier:(NSString *)anIdentifier
204 _private = [[WebPreferencesPrivate alloc] init];
205 _private->IBCreatorID = [[WebPreferences _IBCreatorID] retain];
207 WebPreferences *instance = [[self class] _getInstanceForIdentifier:anIdentifier];
210 return [instance retain];
213 _private->values = [[NSMutableDictionary alloc] init];
214 _private->identifier = [anIdentifier copy];
215 _private->automaticallyDetectsCacheModel = YES;
217 [[self class] _setInstance:self forIdentifier:_private->identifier];
219 [self _postPreferencesChangesNotification];
224 - (id)initWithCoder:(NSCoder *)decoder
230 _private = [[WebPreferencesPrivate alloc] init];
231 _private->IBCreatorID = [[WebPreferences _IBCreatorID] retain];
232 _private->automaticallyDetectsCacheModel = YES;
237 if ([decoder allowsKeyedCoding]) {
238 identifier = [decoder decodeObjectForKey:@"Identifier"];
239 values = [decoder decodeObjectForKey:@"Values"];
242 [decoder decodeValueOfObjCType:@encode(int) at:&version];
244 identifier = [decoder decodeObject];
245 values = [decoder decodeObject];
249 if ([identifier isKindOfClass:[NSString class]])
250 _private->identifier = [identifier copy];
251 if ([values isKindOfClass:[NSDictionary class]])
252 _private->values = [values mutableCopy]; // ensure dictionary is mutable
254 LOG(Encoding, "Identifier = %@, Values = %@\n", _private->identifier, _private->values);
260 // If we load a nib multiple times, or have instances in multiple
261 // nibs with the same name, the first guy up wins.
262 WebPreferences *instance = [[self class] _getInstanceForIdentifier:_private->identifier];
265 self = [instance retain];
267 [[self class] _setInstance:self forIdentifier:_private->identifier];
273 - (void)encodeWithCoder:(NSCoder *)encoder
275 if ([encoder allowsKeyedCoding]){
276 [encoder encodeObject:_private->identifier forKey:@"Identifier"];
277 [encoder encodeObject:_private->values forKey:@"Values"];
278 LOG (Encoding, "Identifier = %@, Values = %@\n", _private->identifier, _private->values);
281 int version = WebPreferencesVersion;
282 [encoder encodeValueOfObjCType:@encode(int) at:&version];
283 [encoder encodeObject:_private->identifier];
284 [encoder encodeObject:_private->values];
288 + (WebPreferences *)standardPreferences
290 if (_standardPreferences == nil) {
291 _standardPreferences = [[WebPreferences alloc] initWithIdentifier:nil];
292 [_standardPreferences setAutosaves:YES];
295 return _standardPreferences;
298 // if we ever have more than one WebPreferences object, this would move to init
301 NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
302 @"Times", WebKitStandardFontPreferenceKey,
303 @"Courier", WebKitFixedFontPreferenceKey,
304 @"Times", WebKitSerifFontPreferenceKey,
305 @"Helvetica", WebKitSansSerifFontPreferenceKey,
306 @"Apple Chancery", WebKitCursiveFontPreferenceKey,
307 @"Papyrus", WebKitFantasyFontPreferenceKey,
308 @"1", WebKitMinimumFontSizePreferenceKey,
309 @"9", WebKitMinimumLogicalFontSizePreferenceKey,
310 @"16", WebKitDefaultFontSizePreferenceKey,
311 @"13", WebKitDefaultFixedFontSizePreferenceKey,
312 @"ISO-8859-1", WebKitDefaultTextEncodingNamePreferenceKey,
313 [NSNumber numberWithBool:NO], WebKitUsesEncodingDetectorPreferenceKey,
314 [NSNumber numberWithBool:NO], WebKitUserStyleSheetEnabledPreferenceKey,
315 @"", WebKitUserStyleSheetLocationPreferenceKey,
316 [NSNumber numberWithBool:NO], WebKitShouldPrintBackgroundsPreferenceKey,
317 [NSNumber numberWithBool:NO], WebKitTextAreasAreResizablePreferenceKey,
318 [NSNumber numberWithBool:NO], WebKitShrinksStandaloneImagesToFitPreferenceKey,
319 [NSNumber numberWithBool:YES], WebKitJavaEnabledPreferenceKey,
320 [NSNumber numberWithBool:YES], WebKitJavaScriptEnabledPreferenceKey,
321 [NSNumber numberWithBool:YES], WebKitWebSecurityEnabledPreferenceKey,
322 [NSNumber numberWithBool:YES], WebKitAllowUniversalAccessFromFileURLsPreferenceKey,
323 [NSNumber numberWithBool:YES], WebKitAllowFileAccessFromFileURLsPreferenceKey,
324 [NSNumber numberWithBool:YES], WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey,
325 [NSNumber numberWithBool:YES], WebKitPluginsEnabledPreferenceKey,
326 [NSNumber numberWithBool:YES], WebKitDatabasesEnabledPreferenceKey,
327 [NSNumber numberWithBool:YES], WebKitLocalStorageEnabledPreferenceKey,
328 [NSNumber numberWithBool:NO], WebKitExperimentalNotificationsEnabledPreferenceKey,
329 [NSNumber numberWithBool:YES], WebKitAllowAnimatedImagesPreferenceKey,
330 [NSNumber numberWithBool:YES], WebKitAllowAnimatedImageLoopingPreferenceKey,
331 [NSNumber numberWithBool:YES], WebKitDisplayImagesKey,
332 @"1800", WebKitBackForwardCacheExpirationIntervalKey,
333 [NSNumber numberWithBool:NO], WebKitTabToLinksPreferenceKey,
334 [NSNumber numberWithBool:NO], WebKitPrivateBrowsingEnabledPreferenceKey,
335 [NSNumber numberWithBool:NO], WebKitRespectStandardStyleKeyEquivalentsPreferenceKey,
336 [NSNumber numberWithBool:NO], WebKitShowsURLsInToolTipsPreferenceKey,
337 @"1", WebKitPDFDisplayModePreferenceKey,
338 @"0", WebKitPDFScaleFactorPreferenceKey,
339 @"0", WebKitUseSiteSpecificSpoofingPreferenceKey,
340 [NSNumber numberWithInt:WebKitEditableLinkDefaultBehavior], WebKitEditableLinkBehaviorPreferenceKey,
341 [NSNumber numberWithInt:WebKitEditingMacBehavior], WebKitEditingBehaviorPreferenceKey,
342 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
343 [NSNumber numberWithInt:WebTextDirectionSubmenuAutomaticallyIncluded],
345 [NSNumber numberWithInt:WebTextDirectionSubmenuNeverIncluded],
347 WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey,
348 [NSNumber numberWithBool:NO], WebKitDOMPasteAllowedPreferenceKey,
349 [NSNumber numberWithBool:YES], WebKitUsesPageCachePreferenceKey,
350 [NSNumber numberWithInt:cacheModelForMainBundle()], WebKitCacheModelPreferenceKey,
351 [NSNumber numberWithBool:NO], WebKitDeveloperExtrasEnabledPreferenceKey,
352 [NSNumber numberWithBool:YES], WebKitAuthorAndUserStylesEnabledPreferenceKey,
353 [NSNumber numberWithBool:NO], WebKitApplicationChromeModeEnabledPreferenceKey,
354 [NSNumber numberWithBool:NO], WebKitWebArchiveDebugModeEnabledPreferenceKey,
355 [NSNumber numberWithBool:NO], WebKitLocalFileContentSniffingEnabledPreferenceKey,
356 [NSNumber numberWithBool:NO], WebKitOfflineWebApplicationCacheEnabledPreferenceKey,
357 [NSNumber numberWithBool:YES], WebKitZoomsTextOnlyPreferenceKey,
358 [NSNumber numberWithBool:NO], WebKitJavaScriptCanAccessClipboardPreferenceKey,
359 [NSNumber numberWithBool:YES], WebKitXSSAuditorEnabledPreferenceKey,
360 [NSNumber numberWithBool:YES], WebKitAcceleratedCompositingEnabledPreferenceKey,
361 [NSNumber numberWithBool:NO], WebKitShowDebugBordersPreferenceKey,
362 [NSNumber numberWithBool:NO], WebKitShowRepaintCounterPreferenceKey,
363 [NSNumber numberWithBool:NO], WebKitWebGLEnabledPreferenceKey,
364 [NSNumber numberWithBool:NO], WebKitUsesProxiedOpenPanelPreferenceKey,
365 [NSNumber numberWithUnsignedInt:4], WebKitPluginAllowedRunTimePreferenceKey,
366 [NSNumber numberWithBool:NO], WebKitFrameFlatteningEnabledPreferenceKey,
367 [NSNumber numberWithBool:YES], WebKitHTML5ParserEnabledPreferenceKey,
368 [NSNumber numberWithBool:NO], WebKitHTML5TreeBuilderEnabledPreferenceKey,
369 [NSNumber numberWithBool:YES], WebKitDNSPrefetchingEnabledPreferenceKey,
370 [NSNumber numberWithBool:NO], WebKitMemoryInfoEnabledPreferenceKey,
371 [NSNumber numberWithLongLong:WebCore::ApplicationCacheStorage::noQuota()], WebKitApplicationCacheTotalQuota,
372 [NSNumber numberWithLongLong:WebCore::ApplicationCacheStorage::noQuota()], WebKitApplicationCacheDefaultOriginQuota,
375 // This value shouldn't ever change, which is assumed in the initialization of WebKitPDFDisplayModePreferenceKey above
376 ASSERT(kPDFDisplaySinglePageContinuous == 1);
377 [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
386 - (NSString *)identifier
388 return _private->identifier;
391 - (id)_valueForKey:(NSString *)key
393 NSString *_key = KEY(key);
394 id o = [_private->values objectForKey:_key];
397 o = [[NSUserDefaults standardUserDefaults] objectForKey:_key];
398 if (!o && key != _key)
399 o = [[NSUserDefaults standardUserDefaults] objectForKey:key];
403 - (NSString *)_stringValueForKey:(NSString *)key
405 id s = [self _valueForKey:key];
406 return [s isKindOfClass:[NSString class]] ? (NSString *)s : nil;
409 - (void)_setStringValue:(NSString *)value forKey:(NSString *)key
411 if ([[self _stringValueForKey:key] isEqualToString:value])
413 NSString *_key = KEY(key);
414 [_private->values setObject:value forKey:_key];
415 if (_private->autosaves)
416 [[NSUserDefaults standardUserDefaults] setObject:value forKey:_key];
417 [self _postPreferencesChangesNotification];
420 - (int)_integerValueForKey:(NSString *)key
422 id o = [self _valueForKey:key];
423 return [o respondsToSelector:@selector(intValue)] ? [o intValue] : 0;
426 - (void)_setIntegerValue:(int)value forKey:(NSString *)key
428 if ([self _integerValueForKey:key] == value)
430 NSString *_key = KEY(key);
431 [_private->values _webkit_setInt:value forKey:_key];
432 if (_private->autosaves)
433 [[NSUserDefaults standardUserDefaults] setInteger:value forKey:_key];
434 [self _postPreferencesChangesNotification];
437 - (float)_floatValueForKey:(NSString *)key
439 id o = [self _valueForKey:key];
440 return [o respondsToSelector:@selector(floatValue)] ? [o floatValue] : 0.0f;
443 - (void)_setFloatValue:(float)value forKey:(NSString *)key
445 if ([self _floatValueForKey:key] == value)
447 NSString *_key = KEY(key);
448 [_private->values _webkit_setFloat:value forKey:_key];
449 if (_private->autosaves)
450 [[NSUserDefaults standardUserDefaults] setFloat:value forKey:_key];
451 [self _postPreferencesChangesNotification];
454 - (BOOL)_boolValueForKey:(NSString *)key
456 return [self _integerValueForKey:key] != 0;
459 - (void)_setBoolValue:(BOOL)value forKey:(NSString *)key
461 if ([self _boolValueForKey:key] == value)
463 NSString *_key = KEY(key);
464 [_private->values _webkit_setBool:value forKey:_key];
465 if (_private->autosaves)
466 [[NSUserDefaults standardUserDefaults] setBool:value forKey:_key];
467 [self _postPreferencesChangesNotification];
470 - (long long)_longLongValueForKey:(NSString *)key
472 id o = [self _valueForKey:key];
473 return [o respondsToSelector:@selector(longLongValue)] ? [o longLongValue] : 0;
476 - (void)_setLongLongValue:(long long)value forKey:(NSString *)key
478 if ([self _longLongValueForKey:key] == value)
480 NSString *_key = KEY(key);
481 [_private->values _webkit_setLongLong:value forKey:_key];
482 if (_private->autosaves)
483 [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithLongLong:value] forKey:_key];
484 [self _postPreferencesChangesNotification];
487 - (unsigned long long)_unsignedLongLongValueForKey:(NSString *)key
489 id o = [self _valueForKey:key];
490 return [o respondsToSelector:@selector(unsignedLongLongValue)] ? [o unsignedLongLongValue] : 0;
493 - (void)_setUnsignedLongLongValue:(unsigned long long)value forKey:(NSString *)key
495 if ([self _unsignedLongLongValueForKey:key] == value)
497 NSString *_key = KEY(key);
498 [_private->values _webkit_setUnsignedLongLong:value forKey:_key];
499 if (_private->autosaves)
500 [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedLongLong:value] forKey:_key];
501 [self _postPreferencesChangesNotification];
504 - (NSString *)standardFontFamily
506 return [self _stringValueForKey: WebKitStandardFontPreferenceKey];
509 - (void)setStandardFontFamily:(NSString *)family
511 [self _setStringValue: family forKey: WebKitStandardFontPreferenceKey];
514 - (NSString *)fixedFontFamily
516 return [self _stringValueForKey: WebKitFixedFontPreferenceKey];
519 - (void)setFixedFontFamily:(NSString *)family
521 [self _setStringValue: family forKey: WebKitFixedFontPreferenceKey];
524 - (NSString *)serifFontFamily
526 return [self _stringValueForKey: WebKitSerifFontPreferenceKey];
529 - (void)setSerifFontFamily:(NSString *)family
531 [self _setStringValue: family forKey: WebKitSerifFontPreferenceKey];
534 - (NSString *)sansSerifFontFamily
536 return [self _stringValueForKey: WebKitSansSerifFontPreferenceKey];
539 - (void)setSansSerifFontFamily:(NSString *)family
541 [self _setStringValue: family forKey: WebKitSansSerifFontPreferenceKey];
544 - (NSString *)cursiveFontFamily
546 return [self _stringValueForKey: WebKitCursiveFontPreferenceKey];
549 - (void)setCursiveFontFamily:(NSString *)family
551 [self _setStringValue: family forKey: WebKitCursiveFontPreferenceKey];
554 - (NSString *)fantasyFontFamily
556 return [self _stringValueForKey: WebKitFantasyFontPreferenceKey];
559 - (void)setFantasyFontFamily:(NSString *)family
561 [self _setStringValue: family forKey: WebKitFantasyFontPreferenceKey];
564 - (int)defaultFontSize
566 return [self _integerValueForKey: WebKitDefaultFontSizePreferenceKey];
569 - (void)setDefaultFontSize:(int)size
571 [self _setIntegerValue: size forKey: WebKitDefaultFontSizePreferenceKey];
574 - (int)defaultFixedFontSize
576 return [self _integerValueForKey: WebKitDefaultFixedFontSizePreferenceKey];
579 - (void)setDefaultFixedFontSize:(int)size
581 [self _setIntegerValue: size forKey: WebKitDefaultFixedFontSizePreferenceKey];
584 - (int)minimumFontSize
586 return [self _integerValueForKey: WebKitMinimumFontSizePreferenceKey];
589 - (void)setMinimumFontSize:(int)size
591 [self _setIntegerValue: size forKey: WebKitMinimumFontSizePreferenceKey];
594 - (int)minimumLogicalFontSize
596 return [self _integerValueForKey: WebKitMinimumLogicalFontSizePreferenceKey];
599 - (void)setMinimumLogicalFontSize:(int)size
601 [self _setIntegerValue: size forKey: WebKitMinimumLogicalFontSizePreferenceKey];
604 - (NSString *)defaultTextEncodingName
606 return [self _stringValueForKey: WebKitDefaultTextEncodingNamePreferenceKey];
609 - (void)setDefaultTextEncodingName:(NSString *)encoding
611 [self _setStringValue: encoding forKey: WebKitDefaultTextEncodingNamePreferenceKey];
614 - (BOOL)userStyleSheetEnabled
616 return [self _boolValueForKey: WebKitUserStyleSheetEnabledPreferenceKey];
619 - (void)setUserStyleSheetEnabled:(BOOL)flag
621 [self _setBoolValue: flag forKey: WebKitUserStyleSheetEnabledPreferenceKey];
624 - (NSURL *)userStyleSheetLocation
626 NSString *locationString = [self _stringValueForKey: WebKitUserStyleSheetLocationPreferenceKey];
628 if ([locationString _webkit_looksLikeAbsoluteURL]) {
629 return [NSURL _web_URLWithDataAsString:locationString];
631 locationString = [locationString stringByExpandingTildeInPath];
632 return [NSURL fileURLWithPath:locationString];
636 - (void)setUserStyleSheetLocation:(NSURL *)URL
638 NSString *locationString;
640 if ([URL isFileURL]) {
641 locationString = [[URL path] _web_stringByAbbreviatingWithTildeInPath];
643 locationString = [URL _web_originalDataAsString];
646 [self _setStringValue:locationString forKey: WebKitUserStyleSheetLocationPreferenceKey];
649 - (BOOL)shouldPrintBackgrounds
651 return [self _boolValueForKey: WebKitShouldPrintBackgroundsPreferenceKey];
654 - (void)setShouldPrintBackgrounds:(BOOL)flag
656 [self _setBoolValue: flag forKey: WebKitShouldPrintBackgroundsPreferenceKey];
659 - (BOOL)isJavaEnabled
661 return [self _boolValueForKey: WebKitJavaEnabledPreferenceKey];
664 - (void)setJavaEnabled:(BOOL)flag
666 [self _setBoolValue: flag forKey: WebKitJavaEnabledPreferenceKey];
669 - (BOOL)isJavaScriptEnabled
671 return [self _boolValueForKey: WebKitJavaScriptEnabledPreferenceKey];
674 - (void)setJavaScriptEnabled:(BOOL)flag
676 [self _setBoolValue: flag forKey: WebKitJavaScriptEnabledPreferenceKey];
679 - (BOOL)javaScriptCanOpenWindowsAutomatically
681 return [self _boolValueForKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
684 - (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag
686 [self _setBoolValue: flag forKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
689 - (BOOL)arePlugInsEnabled
691 return [self _boolValueForKey: WebKitPluginsEnabledPreferenceKey];
694 - (void)setPlugInsEnabled:(BOOL)flag
696 [self _setBoolValue: flag forKey: WebKitPluginsEnabledPreferenceKey];
699 - (BOOL)allowsAnimatedImages
701 return [self _boolValueForKey: WebKitAllowAnimatedImagesPreferenceKey];
704 - (void)setAllowsAnimatedImages:(BOOL)flag
706 [self _setBoolValue: flag forKey: WebKitAllowAnimatedImagesPreferenceKey];
709 - (BOOL)allowsAnimatedImageLooping
711 return [self _boolValueForKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
714 - (void)setAllowsAnimatedImageLooping: (BOOL)flag
716 [self _setBoolValue: flag forKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
719 - (void)setLoadsImagesAutomatically: (BOOL)flag
721 [self _setBoolValue: flag forKey: WebKitDisplayImagesKey];
724 - (BOOL)loadsImagesAutomatically
726 return [self _boolValueForKey: WebKitDisplayImagesKey];
729 - (void)setAutosaves:(BOOL)flag
731 _private->autosaves = flag;
736 return _private->autosaves;
739 - (void)setTabsToLinks:(BOOL)flag
741 [self _setBoolValue: flag forKey: WebKitTabToLinksPreferenceKey];
746 return [self _boolValueForKey:WebKitTabToLinksPreferenceKey];
749 - (void)setPrivateBrowsingEnabled:(BOOL)flag
751 [self _setBoolValue:flag forKey:WebKitPrivateBrowsingEnabledPreferenceKey];
754 - (BOOL)privateBrowsingEnabled
756 return [self _boolValueForKey:WebKitPrivateBrowsingEnabledPreferenceKey];
759 - (void)setUsesPageCache:(BOOL)usesPageCache
761 [self _setBoolValue:usesPageCache forKey:WebKitUsesPageCachePreferenceKey];
764 - (BOOL)usesPageCache
766 return [self _boolValueForKey:WebKitUsesPageCachePreferenceKey];
769 - (void)setCacheModel:(WebCacheModel)cacheModel
771 [self _setIntegerValue:cacheModel forKey:WebKitCacheModelPreferenceKey];
772 [self setAutomaticallyDetectsCacheModel:NO];
775 - (WebCacheModel)cacheModel
777 return [self _integerValueForKey:WebKitCacheModelPreferenceKey];
782 @implementation WebPreferences (WebPrivate)
784 - (BOOL)isDNSPrefetchingEnabled
786 return [self _boolValueForKey:WebKitDNSPrefetchingEnabledPreferenceKey];
789 - (void)setDNSPrefetchingEnabled:(BOOL)flag
791 [self _setBoolValue:flag forKey:WebKitDNSPrefetchingEnabledPreferenceKey];
794 - (BOOL)developerExtrasEnabled
796 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
797 if ([defaults boolForKey:@"DisableWebKitDeveloperExtras"])
800 if ([defaults boolForKey:@"WebKitDeveloperExtras"] || [defaults boolForKey:@"IncludeDebugMenu"])
802 return [self _boolValueForKey:WebKitDeveloperExtrasEnabledPreferenceKey];
804 return YES; // always enable in debug builds
808 - (void)setDeveloperExtrasEnabled:(BOOL)flag
810 [self _setBoolValue:flag forKey:WebKitDeveloperExtrasEnabledPreferenceKey];
813 - (BOOL)authorAndUserStylesEnabled
815 return [self _boolValueForKey:WebKitAuthorAndUserStylesEnabledPreferenceKey];
818 - (void)setAuthorAndUserStylesEnabled:(BOOL)flag
820 [self _setBoolValue:flag forKey:WebKitAuthorAndUserStylesEnabledPreferenceKey];
823 - (BOOL)applicationChromeModeEnabled
825 return [self _boolValueForKey:WebKitApplicationChromeModeEnabledPreferenceKey];
828 - (void)setApplicationChromeModeEnabled:(BOOL)flag
830 [self _setBoolValue:flag forKey:WebKitApplicationChromeModeEnabledPreferenceKey];
833 - (BOOL)webArchiveDebugModeEnabled
835 return [self _boolValueForKey:WebKitWebArchiveDebugModeEnabledPreferenceKey];
838 - (void)setWebArchiveDebugModeEnabled:(BOOL)flag
840 [self _setBoolValue:flag forKey:WebKitWebArchiveDebugModeEnabledPreferenceKey];
843 - (BOOL)localFileContentSniffingEnabled
845 return [self _boolValueForKey:WebKitLocalFileContentSniffingEnabledPreferenceKey];
848 - (void)setLocalFileContentSniffingEnabled:(BOOL)flag
850 [self _setBoolValue:flag forKey:WebKitLocalFileContentSniffingEnabledPreferenceKey];
853 - (BOOL)offlineWebApplicationCacheEnabled
855 return [self _boolValueForKey:WebKitOfflineWebApplicationCacheEnabledPreferenceKey];
858 - (void)setOfflineWebApplicationCacheEnabled:(BOOL)flag
860 [self _setBoolValue:flag forKey:WebKitOfflineWebApplicationCacheEnabledPreferenceKey];
863 - (BOOL)zoomsTextOnly
865 return [self _boolValueForKey:WebKitZoomsTextOnlyPreferenceKey];
868 - (void)setZoomsTextOnly:(BOOL)flag
870 [self _setBoolValue:flag forKey:WebKitZoomsTextOnlyPreferenceKey];
873 - (BOOL)javaScriptCanAccessClipboard
875 return [self _boolValueForKey:WebKitJavaScriptCanAccessClipboardPreferenceKey];
878 - (void)setJavaScriptCanAccessClipboard:(BOOL)flag
880 [self _setBoolValue:flag forKey:WebKitJavaScriptCanAccessClipboardPreferenceKey];
883 - (BOOL)isXSSAuditorEnabled
885 return [self _boolValueForKey:WebKitXSSAuditorEnabledPreferenceKey];
888 - (void)setXSSAuditorEnabled:(BOOL)flag
890 [self _setBoolValue:flag forKey:WebKitXSSAuditorEnabledPreferenceKey];
893 - (BOOL)respectStandardStyleKeyEquivalents
895 return [self _boolValueForKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
898 - (void)setRespectStandardStyleKeyEquivalents:(BOOL)flag
900 [self _setBoolValue:flag forKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
903 - (BOOL)showsURLsInToolTips
905 return [self _boolValueForKey:WebKitShowsURLsInToolTipsPreferenceKey];
908 - (void)setShowsURLsInToolTips:(BOOL)flag
910 [self _setBoolValue:flag forKey:WebKitShowsURLsInToolTipsPreferenceKey];
913 - (BOOL)textAreasAreResizable
915 return [self _boolValueForKey: WebKitTextAreasAreResizablePreferenceKey];
918 - (void)setTextAreasAreResizable:(BOOL)flag
920 [self _setBoolValue: flag forKey: WebKitTextAreasAreResizablePreferenceKey];
923 - (BOOL)shrinksStandaloneImagesToFit
925 return [self _boolValueForKey:WebKitShrinksStandaloneImagesToFitPreferenceKey];
928 - (void)setShrinksStandaloneImagesToFit:(BOOL)flag
930 [self _setBoolValue:flag forKey:WebKitShrinksStandaloneImagesToFitPreferenceKey];
933 - (BOOL)automaticallyDetectsCacheModel
935 return _private->automaticallyDetectsCacheModel;
938 - (void)setAutomaticallyDetectsCacheModel:(BOOL)automaticallyDetectsCacheModel
940 _private->automaticallyDetectsCacheModel = automaticallyDetectsCacheModel;
943 - (BOOL)usesEncodingDetector
945 return [self _boolValueForKey: WebKitUsesEncodingDetectorPreferenceKey];
948 - (void)setUsesEncodingDetector:(BOOL)flag
950 [self _setBoolValue: flag forKey: WebKitUsesEncodingDetectorPreferenceKey];
953 - (BOOL)isWebSecurityEnabled
955 return [self _boolValueForKey: WebKitWebSecurityEnabledPreferenceKey];
958 - (void)setWebSecurityEnabled:(BOOL)flag
960 [self _setBoolValue: flag forKey: WebKitWebSecurityEnabledPreferenceKey];
963 - (BOOL)allowUniversalAccessFromFileURLs
965 return [self _boolValueForKey: WebKitAllowUniversalAccessFromFileURLsPreferenceKey];
968 - (void)setAllowUniversalAccessFromFileURLs:(BOOL)flag
970 [self _setBoolValue: flag forKey: WebKitAllowUniversalAccessFromFileURLsPreferenceKey];
973 - (BOOL)allowFileAccessFromFileURLs
975 return [self _boolValueForKey: WebKitAllowFileAccessFromFileURLsPreferenceKey];
978 - (void)setAllowFileAccessFromFileURLs:(BOOL)flag
980 [self _setBoolValue: flag forKey: WebKitAllowFileAccessFromFileURLsPreferenceKey];
983 - (NSTimeInterval)_backForwardCacheExpirationInterval
985 // FIXME: There's probably no good reason to read from the standard user defaults instead of self.
986 return (NSTimeInterval)[[NSUserDefaults standardUserDefaults] floatForKey:WebKitBackForwardCacheExpirationIntervalKey];
989 - (float)PDFScaleFactor
991 return [self _floatValueForKey:WebKitPDFScaleFactorPreferenceKey];
994 - (void)setPDFScaleFactor:(float)factor
996 [self _setFloatValue:factor forKey:WebKitPDFScaleFactorPreferenceKey];
999 - (int64_t)applicationCacheTotalQuota
1001 return [self _longLongValueForKey:WebKitApplicationCacheTotalQuota];
1004 - (void)setApplicationCacheTotalQuota:(int64_t)quota
1006 [self _setLongLongValue:quota forKey:WebKitApplicationCacheTotalQuota];
1008 // Application Cache Preferences are stored on the global cache storage manager, not in Settings.
1009 [WebApplicationCache setMaximumSize:quota];
1012 - (int64_t)applicationCacheDefaultOriginQuota
1014 return [self _longLongValueForKey:WebKitApplicationCacheDefaultOriginQuota];
1017 - (void)setApplicationCacheDefaultOriginQuota:(int64_t)quota
1019 [self _setLongLongValue:quota forKey:WebKitApplicationCacheDefaultOriginQuota];
1022 - (PDFDisplayMode)PDFDisplayMode
1024 PDFDisplayMode value = [self _integerValueForKey:WebKitPDFDisplayModePreferenceKey];
1025 if (value != kPDFDisplaySinglePage && value != kPDFDisplaySinglePageContinuous && value != kPDFDisplayTwoUp && value != kPDFDisplayTwoUpContinuous) {
1026 // protect against new modes from future versions of OS X stored in defaults
1027 value = kPDFDisplaySinglePageContinuous;
1032 - (void)setPDFDisplayMode:(PDFDisplayMode)mode
1034 [self _setIntegerValue:mode forKey:WebKitPDFDisplayModePreferenceKey];
1037 - (WebKitEditableLinkBehavior)editableLinkBehavior
1039 WebKitEditableLinkBehavior value = static_cast<WebKitEditableLinkBehavior> ([self _integerValueForKey:WebKitEditableLinkBehaviorPreferenceKey]);
1040 if (value != WebKitEditableLinkDefaultBehavior &&
1041 value != WebKitEditableLinkAlwaysLive &&
1042 value != WebKitEditableLinkNeverLive &&
1043 value != WebKitEditableLinkOnlyLiveWithShiftKey &&
1044 value != WebKitEditableLinkLiveWhenNotFocused) {
1045 // ensure that a valid result is returned
1046 value = WebKitEditableLinkDefaultBehavior;
1052 - (void)setEditableLinkBehavior:(WebKitEditableLinkBehavior)behavior
1054 [self _setIntegerValue:behavior forKey:WebKitEditableLinkBehaviorPreferenceKey];
1057 - (WebTextDirectionSubmenuInclusionBehavior)textDirectionSubmenuInclusionBehavior
1059 WebTextDirectionSubmenuInclusionBehavior value = static_cast<WebTextDirectionSubmenuInclusionBehavior>([self _integerValueForKey:WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey]);
1060 if (value != WebTextDirectionSubmenuNeverIncluded &&
1061 value != WebTextDirectionSubmenuAutomaticallyIncluded &&
1062 value != WebTextDirectionSubmenuAlwaysIncluded) {
1063 // Ensure that a valid result is returned.
1064 value = WebTextDirectionSubmenuNeverIncluded;
1069 - (void)setTextDirectionSubmenuInclusionBehavior:(WebTextDirectionSubmenuInclusionBehavior)behavior
1071 [self _setIntegerValue:behavior forKey:WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey];
1074 - (BOOL)_useSiteSpecificSpoofing
1076 return [self _boolValueForKey:WebKitUseSiteSpecificSpoofingPreferenceKey];
1079 - (void)_setUseSiteSpecificSpoofing:(BOOL)newValue
1081 [self _setBoolValue:newValue forKey:WebKitUseSiteSpecificSpoofingPreferenceKey];
1084 - (BOOL)databasesEnabled
1086 return [self _boolValueForKey:WebKitDatabasesEnabledPreferenceKey];
1089 - (void)setDatabasesEnabled:(BOOL)databasesEnabled
1091 [self _setBoolValue:databasesEnabled forKey:WebKitDatabasesEnabledPreferenceKey];
1094 - (BOOL)localStorageEnabled
1096 return [self _boolValueForKey:WebKitLocalStorageEnabledPreferenceKey];
1099 - (void)setLocalStorageEnabled:(BOOL)localStorageEnabled
1101 [self _setBoolValue:localStorageEnabled forKey:WebKitLocalStorageEnabledPreferenceKey];
1104 - (BOOL)experimentalNotificationsEnabled
1106 return [self _boolValueForKey:WebKitExperimentalNotificationsEnabledPreferenceKey];
1109 - (void)setExperimentalNotificationsEnabled:(BOOL)experimentalNotificationsEnabled
1111 [self _setBoolValue:experimentalNotificationsEnabled forKey:WebKitExperimentalNotificationsEnabledPreferenceKey];
1114 + (WebPreferences *)_getInstanceForIdentifier:(NSString *)ident
1116 LOG(Encoding, "requesting for %@\n", ident);
1119 return _standardPreferences;
1121 WebPreferences *instance = [webPreferencesInstances objectForKey:[self _concatenateKeyWithIBCreatorID:ident]];
1126 + (void)_setInstance:(WebPreferences *)instance forIdentifier:(NSString *)ident
1128 if (!webPreferencesInstances)
1129 webPreferencesInstances = [[NSMutableDictionary alloc] init];
1131 [webPreferencesInstances setObject:instance forKey:[self _concatenateKeyWithIBCreatorID:ident]];
1132 LOG(Encoding, "recording %p for %@\n", instance, [self _concatenateKeyWithIBCreatorID:ident]);
1136 + (void)_checkLastReferenceForIdentifier:(id)identifier
1138 // FIXME: This won't work at all under garbage collection because retainCount returns a constant.
1139 // We may need to change WebPreferences API so there's an explicit way to end the lifetime of one.
1140 WebPreferences *instance = [webPreferencesInstances objectForKey:identifier];
1141 if ([instance retainCount] == 1)
1142 [webPreferencesInstances removeObjectForKey:identifier];
1145 + (void)_removeReferenceForIdentifier:(NSString *)ident
1148 [self performSelector:@selector(_checkLastReferenceForIdentifier:) withObject:[self _concatenateKeyWithIBCreatorID:ident] afterDelay:0.1];
1151 - (void)_postPreferencesChangesNotification
1153 if (!pthread_main_np()) {
1154 [self performSelectorOnMainThread:_cmd withObject:nil waitUntilDone:NO];
1158 [[NSNotificationCenter defaultCenter]
1159 postNotificationName:WebPreferencesChangedNotification object:self
1163 + (CFStringEncoding)_systemCFStringEncoding
1165 return WKGetWebDefaultCFStringEncoding();
1168 + (void)_setInitialDefaultTextEncodingToSystemEncoding
1170 NSString *systemEncodingName = (NSString *)CFStringConvertEncodingToIANACharSetName([self _systemCFStringEncoding]);
1172 // CFStringConvertEncodingToIANACharSetName() returns cp949 for kTextEncodingDOSKorean AKA "extended EUC-KR" AKA windows-949.
1173 // ICU uses this name for a different encoding, so we need to change the name to a value that actually gives us windows-949.
1174 // In addition, this value must match what is used in Safari, see <rdar://problem/5579292>.
1175 // On some OS versions, the result is CP949 (uppercase).
1176 if ([systemEncodingName _webkit_isCaseInsensitiveEqualToString:@"cp949"])
1177 systemEncodingName = @"ks_c_5601-1987";
1178 [[NSUserDefaults standardUserDefaults] registerDefaults:
1179 [NSDictionary dictionaryWithObject:systemEncodingName forKey:WebKitDefaultTextEncodingNamePreferenceKey]];
1182 static NSString *classIBCreatorID = nil;
1184 + (void)_setIBCreatorID:(NSString *)string
1186 NSString *old = classIBCreatorID;
1187 classIBCreatorID = [string copy];
1191 - (BOOL)isDOMPasteAllowed
1193 return [self _boolValueForKey:WebKitDOMPasteAllowedPreferenceKey];
1196 - (void)setDOMPasteAllowed:(BOOL)DOMPasteAllowed
1198 [self _setBoolValue:DOMPasteAllowed forKey:WebKitDOMPasteAllowedPreferenceKey];
1201 - (NSString *)_localStorageDatabasePath
1203 return [[self _stringValueForKey:WebKitLocalStorageDatabasePathPreferenceKey] stringByStandardizingPath];
1206 - (void)_setLocalStorageDatabasePath:(NSString *)path
1208 [self _setStringValue:[path stringByStandardizingPath] forKey:WebKitLocalStorageDatabasePathPreferenceKey];
1211 - (NSString *)_ftpDirectoryTemplatePath
1213 return [[self _stringValueForKey:WebKitFTPDirectoryTemplatePath] stringByStandardizingPath];
1216 - (void)_setFTPDirectoryTemplatePath:(NSString *)path
1218 [self _setStringValue:[path stringByStandardizingPath] forKey:WebKitFTPDirectoryTemplatePath];
1221 - (BOOL)_forceFTPDirectoryListings
1223 return [self _boolValueForKey:WebKitForceFTPDirectoryListings];
1226 - (void)_setForceFTPDirectoryListings:(BOOL)force
1228 [self _setBoolValue:force forKey:WebKitForceFTPDirectoryListings];
1231 - (BOOL)acceleratedCompositingEnabled
1233 return [self _boolValueForKey:WebKitAcceleratedCompositingEnabledPreferenceKey];
1236 - (void)setAcceleratedCompositingEnabled:(BOOL)enabled
1238 [self _setBoolValue:enabled forKey:WebKitAcceleratedCompositingEnabledPreferenceKey];
1241 - (BOOL)showDebugBorders
1243 return [self _boolValueForKey:WebKitShowDebugBordersPreferenceKey];
1246 - (void)setShowDebugBorders:(BOOL)enabled
1248 [self _setBoolValue:enabled forKey:WebKitShowDebugBordersPreferenceKey];
1251 - (BOOL)showRepaintCounter
1253 return [self _boolValueForKey:WebKitShowRepaintCounterPreferenceKey];
1256 - (void)setShowRepaintCounter:(BOOL)enabled
1258 [self _setBoolValue:enabled forKey:WebKitShowRepaintCounterPreferenceKey];
1261 - (BOOL)webGLEnabled
1263 return [self _boolValueForKey:WebKitWebGLEnabledPreferenceKey];
1266 - (void)setWebGLEnabled:(BOOL)enabled
1268 [self _setBoolValue:enabled forKey:WebKitWebGLEnabledPreferenceKey];
1271 - (BOOL)usesProxiedOpenPanel
1273 return [self _boolValueForKey:WebKitUsesProxiedOpenPanelPreferenceKey];
1276 - (void)setUsesProxiedOpenPanel:(BOOL)enabled
1278 [self _setBoolValue:enabled forKey:WebKitUsesProxiedOpenPanelPreferenceKey];
1281 - (unsigned)pluginAllowedRunTime
1283 return [self _integerValueForKey:WebKitPluginAllowedRunTimePreferenceKey];
1286 - (void)setPluginAllowedRunTime:(unsigned)allowedRunTime
1288 return [self _setIntegerValue:allowedRunTime forKey:WebKitPluginAllowedRunTimePreferenceKey];
1291 - (BOOL)isFrameFlatteningEnabled
1293 return [self _boolValueForKey:WebKitFrameFlatteningEnabledPreferenceKey];
1296 - (void)setFrameFlatteningEnabled:(BOOL)flag
1298 [self _setBoolValue:flag forKey:WebKitFrameFlatteningEnabledPreferenceKey];
1301 - (BOOL)html5ParserEnabled
1303 return [self _boolValueForKey:WebKitHTML5ParserEnabledPreferenceKey];
1306 - (void)setHTML5ParserEnabled:(BOOL)flag
1308 [self _setBoolValue:flag forKey:WebKitHTML5ParserEnabledPreferenceKey];
1311 - (BOOL)html5TreeBuilderEnabled
1313 return [self _boolValueForKey:WebKitHTML5TreeBuilderEnabledPreferenceKey];
1316 - (void)setHTML5TreeBuilderEnabled:(BOOL)flag
1318 [self _setBoolValue:flag forKey:WebKitHTML5TreeBuilderEnabledPreferenceKey];
1321 - (BOOL)paginateDuringLayoutEnabled
1323 return [self _boolValueForKey:WebKitPaginateDuringLayoutEnabledPreferenceKey];
1326 - (void)setPaginateDuringLayoutEnabled:(BOOL)flag
1328 [self _setBoolValue:flag forKey:WebKitPaginateDuringLayoutEnabledPreferenceKey];
1331 - (BOOL)memoryInfoEnabled
1333 return [self _boolValueForKey:WebKitMemoryInfoEnabledPreferenceKey];
1336 - (void)setMemoryInfoEnabled:(BOOL)flag
1338 [self _setBoolValue:flag forKey:WebKitMemoryInfoEnabledPreferenceKey];
1341 - (WebKitEditingBehavior)editingBehavior
1343 return static_cast<WebKitEditingBehavior>([self _integerValueForKey:WebKitEditingBehaviorPreferenceKey]);
1346 - (void)setEditingBehavior:(WebKitEditingBehavior)behavior
1348 [self _setIntegerValue:behavior forKey:WebKitEditingBehaviorPreferenceKey];
1351 - (void)didRemoveFromWebView
1353 ASSERT(_private->numWebViews);
1354 if (--_private->numWebViews == 0)
1355 [[NSNotificationCenter defaultCenter]
1356 postNotificationName:WebPreferencesRemovedNotification
1361 - (void)willAddToWebView
1363 ++_private->numWebViews;
1366 - (void)_setPreferenceForTestWithValue:(NSString *)value forKey:(NSString *)key
1368 [self _setStringValue:value forKey:key];
1373 @implementation WebPreferences (WebInternal)
1375 + (NSString *)_IBCreatorID
1377 return classIBCreatorID;
1380 + (NSString *)_concatenateKeyWithIBCreatorID:(NSString *)key
1382 NSString *IBCreatorID = [WebPreferences _IBCreatorID];
1385 return [IBCreatorID stringByAppendingString:key];