2 * Copyright (C) 2003, 2004, 2005 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #import <Foundation/Foundation.h>
34 @abstract Specifies a usage model for a WebView, which WebKit will use to
35 determine its caching behavior.
37 @constant WebCacheModelDocumentViewer Appropriate for a WebView displaying
38 a fixed document -- like a splash screen, a chat document, or a word processing
39 document -- with no UI for navigation. The WebView will behave like any other
40 view, releasing resources when they are no longer referenced. Remote resources,
41 if any, will be cached to disk. This is the most memory-efficient setting.
43 Examples: iChat, Mail, TextMate, Growl.
45 @constant WebCacheModelDocumentBrowser Appropriate for a WebView displaying
46 a browsable series of documents with a UI for navigating between them -- for
47 example, a reference materials browser or a website designer. The WebView will
48 cache a reasonable number of resources and previously viewed documents in
49 memory and/or on disk.
51 Examples: Dictionary, Help Viewer, Coda.
53 @constant WebCacheModelPrimaryWebBrowser Appropriate for a WebView in the
54 application that acts as the user's primary web browser. The WebView will cache
55 a very large number of resources and previously viewed documents in memory
58 Examples: Safari, OmniWeb, Shiira.
61 WebCacheModelDocumentViewer = 0,
62 WebCacheModelDocumentBrowser = 1,
63 WebCacheModelPrimaryWebBrowser = 2
65 typedef NSUInteger WebCacheModel;
67 @class WebPreferencesPrivate;
69 extern NSString *WebPreferencesChangedNotification;
74 @interface WebPreferences: NSObject <NSCoding>
77 WebPreferencesPrivate *_private;
81 @method standardPreferences
83 + (WebPreferences *)standardPreferences;
86 @method initWithIdentifier:
87 @param anIdentifier A string used to identify the WebPreferences.
88 @discussion WebViews can share instances of WebPreferences by using an instance of WebPreferences with
89 the same identifier. Typically, instance are not created directly. Instead you set the preferences
90 identifier on a WebView. The identifier is used as a prefix that is added to the user defaults keys
91 for the WebPreferences.
92 @result Returns a new instance of WebPreferences or a previously allocated instance with the same identifier.
94 - (id)initWithIdentifier:(NSString *)anIdentifier;
98 @result Returns the identifier for this WebPreferences.
100 - (NSString *)identifier;
103 @method standardFontFamily
105 - (NSString *)standardFontFamily;
108 @method setStandardFontFamily:
111 - (void)setStandardFontFamily:(NSString *)family;
114 @method fixedFontFamily
116 - (NSString *)fixedFontFamily;
119 @method setFixedFontFamily:
122 - (void)setFixedFontFamily:(NSString *)family;
125 @method serifFontFamily
127 - (NSString *)serifFontFamily;
130 @method setSerifFontFamily:
133 - (void)setSerifFontFamily:(NSString *)family;
136 @method sansSerifFontFamily
138 - (NSString *)sansSerifFontFamily;
141 @method setSansSerifFontFamily:
144 - (void)setSansSerifFontFamily:(NSString *)family;
147 @method cursiveFontFamily
149 - (NSString *)cursiveFontFamily;
152 @method setCursiveFontFamily:
155 - (void)setCursiveFontFamily:(NSString *)family;
158 @method fantasyFontFamily
160 - (NSString *)fantasyFontFamily;
163 @method setFantasyFontFamily:
166 - (void)setFantasyFontFamily:(NSString *)family;
169 @method defaultFontSize
171 - (int)defaultFontSize;
174 @method setDefaultFontSize:
177 - (void)setDefaultFontSize:(int)size;
180 @method defaultFixedFontSize
182 - (int)defaultFixedFontSize;
185 @method setDefaultFixedFontSize:
188 - (void)setDefaultFixedFontSize:(int)size;
191 @method minimumFontSize
193 - (int)minimumFontSize;
196 @method setMinimumFontSize:
199 - (void)setMinimumFontSize:(int)size;
202 @method minimumLogicalFontSize
204 - (int)minimumLogicalFontSize;
207 @method setMinimumLogicalFontSize:
210 - (void)setMinimumLogicalFontSize:(int)size;
213 @method defaultTextEncodingName
215 - (NSString *)defaultTextEncodingName;
218 @method setDefaultTextEncodingName:
221 - (void)setDefaultTextEncodingName:(NSString *)encoding;
224 @method userStyleSheetEnabled
226 - (BOOL)userStyleSheetEnabled;
229 @method setUserStyleSheetEnabled:
232 - (void)setUserStyleSheetEnabled:(BOOL)flag;
235 @method userStyleSheetLocation
236 @discussion The location of the user style sheet.
238 - (NSURL *)userStyleSheetLocation;
241 @method setUserStyleSheetLocation:
242 @param URL The location of the user style sheet.
244 - (void)setUserStyleSheetLocation:(NSURL *)URL;
247 @method isJavaEnabled
249 - (BOOL)isJavaEnabled;
252 @method setJavaEnabled:
255 - (void)setJavaEnabled:(BOOL)flag;
258 @method isJavaScriptEnabled
260 - (BOOL)isJavaScriptEnabled;
263 @method setJavaScriptEnabled:
266 - (void)setJavaScriptEnabled:(BOOL)flag;
269 @method JavaScriptCanOpenWindowsAutomatically
271 - (BOOL)javaScriptCanOpenWindowsAutomatically;
274 @method setJavaScriptCanOpenWindowsAutomatically:
277 - (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag;
280 @method arePlugInsEnabled
282 - (BOOL)arePlugInsEnabled;
285 @method setPlugInsEnabled:
288 - (void)setPlugInsEnabled:(BOOL)flag;
291 @method allowAnimatedImages
293 - (BOOL)allowsAnimatedImages;
296 @method setAllowAnimatedImages:
299 - (void)setAllowsAnimatedImages:(BOOL)flag;
302 @method allowAnimatedImageLooping
304 - (BOOL)allowsAnimatedImageLooping;
307 @method setAllowAnimatedImageLooping:
310 - (void)setAllowsAnimatedImageLooping: (BOOL)flag;
313 @method setWillLoadImagesAutomatically:
316 - (void)setLoadsImagesAutomatically: (BOOL)flag;
319 @method willLoadImagesAutomatically
321 - (BOOL)loadsImagesAutomatically;
324 @method setAutosaves:
326 @discussion If autosave preferences is YES the settings represented by
327 WebPreferences will be stored in the user defaults database.
329 - (void)setAutosaves:(BOOL)flag;
333 @result The value of the autosave preferences flag.
338 @method setShouldPrintBackgrounds:
341 - (void)setShouldPrintBackgrounds:(BOOL)flag;
344 @method shouldPrintBackgrounds
345 @result The value of the shouldPrintBackgrounds preferences flag
347 - (BOOL)shouldPrintBackgrounds;
350 @method setPrivateBrowsingEnabled:
352 @abstract If private browsing is enabled, WebKit will not store information
353 about sites the user visits.
355 - (void)setPrivateBrowsingEnabled:(BOOL)flag;
358 @method privateBrowsingEnabled
360 - (BOOL)privateBrowsingEnabled;
363 @method setTabsToLinks:
365 @abstract If tabsToLinks is YES, the tab key will focus links and form controls.
366 The option key temporarily reverses this preference.
368 - (void)setTabsToLinks:(BOOL)flag;
376 @method setUsesPageCache:
377 @abstract Sets whether the receiver's associated WebViews use the shared
379 @param UsesPageCache Whether the receiver's associated WebViews use the
381 @discussion Pages are cached as they are added to a WebBackForwardList, and
382 removed from the cache as they are removed from a WebBackForwardList. Because
383 the page cache is global, caching a page in one WebBackForwardList may cause
384 a page in another WebBackForwardList to be evicted from the cache.
386 - (void)setUsesPageCache:(BOOL)usesPageCache;
389 @method usesPageCache
390 @abstract Returns whether the receiver should use the shared page cache.
391 @result Whether the receiver should use the shared page cache.
392 @discussion Pages are cached as they are added to a WebBackForwardList, and
393 removed from the cache as they are removed from a WebBackForwardList. Because
394 the page cache is global, caching a page in one WebBackForwardList may cause
395 a page in another WebBackForwardList to be evicted from the cache.
397 - (BOOL)usesPageCache;
400 @method setCacheModel:
402 @abstract Specifies a usage model for a WebView, which WebKit will use to
403 determine its caching behavior.
405 @param cacheModel The WebView's usage model for WebKit. If necessary, WebKit
406 will prune its caches to match cacheModel.
408 @discussion Research indicates that users tend to browse within clusters of
409 documents that hold resources in common, and to revisit previously visited
410 documents. WebKit and the frameworks below it include built-in caches that take
411 advantage of these patterns, substantially improving document load speed in
412 browsing situations. The WebKit cache model controls the behaviors of all of
413 these caches, including NSURLCache and the various WebCore caches.
415 Applications with a browsing interface can improve document load speed
416 substantially by specifying WebCacheModelDocumentBrowser. Applications without
417 a browsing interface can reduce memory usage substantially by specifying
418 WebCacheModelDocumentViewer.
420 If setCacheModel: is not called, WebKit will select a cache model automatically.
422 - (void)setCacheModel:(WebCacheModel)cacheModel;
427 @abstract Returns the usage model according to which WebKit determines its
430 @result The usage model.
432 - (WebCacheModel)cacheModel;