initial import
[vuplus_webkit] / Source / WebKit / mac / WebView / WebPreferences.h
1 /*
2  * Copyright (C) 2003, 2004, 2005 Apple Computer, Inc.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
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. 
16  *
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.
27  */
28
29 #import <Foundation/Foundation.h>
30
31 /*!
32 @enum WebCacheModel
33
34 @abstract Specifies a usage model for a WebView, which WebKit will use to 
35 determine its caching behavior.
36
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.
42
43 Examples: iChat, Mail, TextMate, Growl.
44
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.
50
51 Examples: Dictionary, Help Viewer, Coda.
52
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 
56 and/or on disk.
57
58 Examples: Safari, OmniWeb, Shiira.
59 */
60 enum {
61     WebCacheModelDocumentViewer = 0,
62     WebCacheModelDocumentBrowser = 1,
63     WebCacheModelPrimaryWebBrowser = 2
64 };
65 typedef NSUInteger WebCacheModel;
66
67 @class WebPreferencesPrivate;
68
69 extern NSString *WebPreferencesChangedNotification;
70
71 /*!
72     @class WebPreferences
73 */
74 @interface WebPreferences: NSObject <NSCoding>
75 {
76 @private
77     WebPreferencesPrivate *_private;
78 }
79
80 /*!
81     @method standardPreferences
82 */
83 + (WebPreferences *)standardPreferences;
84
85 /*!
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.
93 */
94 - (id)initWithIdentifier:(NSString *)anIdentifier;
95
96 /*!
97     @method identifier
98     @result Returns the identifier for this WebPreferences.
99 */
100 - (NSString *)identifier;
101
102 /*!
103     @method standardFontFamily
104 */
105 - (NSString *)standardFontFamily;
106
107 /*!
108     @method setStandardFontFamily:
109     @param family
110 */
111 - (void)setStandardFontFamily:(NSString *)family;
112
113 /*!
114     @method fixedFontFamily
115 */
116 - (NSString *)fixedFontFamily;
117
118 /*!
119     @method setFixedFontFamily:
120     @param family
121 */
122 - (void)setFixedFontFamily:(NSString *)family;
123
124 /*!
125     @method serifFontFamily
126 */
127 - (NSString *)serifFontFamily;
128
129 /*!
130     @method setSerifFontFamily:
131     @param family
132 */
133 - (void)setSerifFontFamily:(NSString *)family;
134
135 /*!
136     @method sansSerifFontFamily
137 */
138 - (NSString *)sansSerifFontFamily;
139
140 /*!
141     @method setSansSerifFontFamily:
142     @param family
143 */
144 - (void)setSansSerifFontFamily:(NSString *)family;
145
146 /*!
147     @method cursiveFontFamily
148 */
149 - (NSString *)cursiveFontFamily;
150
151 /*!
152     @method setCursiveFontFamily:
153     @param family
154 */
155 - (void)setCursiveFontFamily:(NSString *)family;
156
157 /*!
158     @method fantasyFontFamily
159 */
160 - (NSString *)fantasyFontFamily;
161
162 /*!
163     @method setFantasyFontFamily:
164     @param family
165 */
166 - (void)setFantasyFontFamily:(NSString *)family;
167
168 /*!
169     @method defaultFontSize
170 */
171 - (int)defaultFontSize;
172
173 /*!
174     @method setDefaultFontSize:
175     @param size
176 */
177 - (void)setDefaultFontSize:(int)size;
178
179 /*!
180     @method defaultFixedFontSize
181 */
182 - (int)defaultFixedFontSize;
183
184 /*!
185     @method setDefaultFixedFontSize:
186     @param size
187 */
188 - (void)setDefaultFixedFontSize:(int)size;
189
190 /*!
191     @method minimumFontSize
192 */
193 - (int)minimumFontSize;
194
195 /*!
196     @method setMinimumFontSize:
197     @param size
198 */
199 - (void)setMinimumFontSize:(int)size;
200
201 /*!
202     @method minimumLogicalFontSize
203 */
204 - (int)minimumLogicalFontSize;
205
206 /*!
207     @method setMinimumLogicalFontSize:
208     @param size
209 */
210 - (void)setMinimumLogicalFontSize:(int)size;
211
212 /*!
213     @method defaultTextEncodingName
214 */
215 - (NSString *)defaultTextEncodingName;
216
217 /*!
218     @method setDefaultTextEncodingName:
219     @param encoding
220 */
221 - (void)setDefaultTextEncodingName:(NSString *)encoding;
222
223 /*!
224     @method userStyleSheetEnabled
225 */
226 - (BOOL)userStyleSheetEnabled;
227
228 /*!
229     @method setUserStyleSheetEnabled:
230     @param flag
231 */
232 - (void)setUserStyleSheetEnabled:(BOOL)flag;
233
234 /*!
235     @method userStyleSheetLocation
236     @discussion The location of the user style sheet.
237 */
238 - (NSURL *)userStyleSheetLocation;
239
240 /*!
241     @method setUserStyleSheetLocation:
242     @param URL The location of the user style sheet.
243 */
244 - (void)setUserStyleSheetLocation:(NSURL *)URL;
245
246 /*!
247     @method isJavaEnabled
248 */
249 - (BOOL)isJavaEnabled;
250
251 /*!
252     @method setJavaEnabled:
253     @param flag
254 */
255 - (void)setJavaEnabled:(BOOL)flag;
256
257 /*!
258     @method isJavaScriptEnabled
259 */
260 - (BOOL)isJavaScriptEnabled;
261
262 /*!
263     @method setJavaScriptEnabled:
264     @param flag
265 */
266 - (void)setJavaScriptEnabled:(BOOL)flag;
267
268 /*!
269     @method JavaScriptCanOpenWindowsAutomatically
270 */
271 - (BOOL)javaScriptCanOpenWindowsAutomatically;
272
273 /*!
274     @method setJavaScriptCanOpenWindowsAutomatically:
275     @param flag
276 */
277 - (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag;
278
279 /*!
280     @method arePlugInsEnabled
281 */
282 - (BOOL)arePlugInsEnabled;
283
284 /*!
285     @method setPlugInsEnabled:
286     @param flag
287 */
288 - (void)setPlugInsEnabled:(BOOL)flag;
289
290 /*!
291     @method allowAnimatedImages
292 */
293 - (BOOL)allowsAnimatedImages;
294
295 /*!
296     @method setAllowAnimatedImages:
297     @param flag
298 */
299 - (void)setAllowsAnimatedImages:(BOOL)flag;
300
301 /*!
302     @method allowAnimatedImageLooping
303 */
304 - (BOOL)allowsAnimatedImageLooping;
305
306 /*!
307     @method setAllowAnimatedImageLooping:
308     @param flag
309 */
310 - (void)setAllowsAnimatedImageLooping: (BOOL)flag;
311
312 /*!
313     @method setWillLoadImagesAutomatically:
314     @param flag
315 */
316 - (void)setLoadsImagesAutomatically: (BOOL)flag;
317
318 /*!
319     @method willLoadImagesAutomatically
320 */
321 - (BOOL)loadsImagesAutomatically;
322
323 /*!
324     @method setAutosaves:
325     @param flag 
326     @discussion If autosave preferences is YES the settings represented by
327     WebPreferences will be stored in the user defaults database.
328 */
329 - (void)setAutosaves:(BOOL)flag;
330
331 /*!
332     @method autosaves
333     @result The value of the autosave preferences flag.
334 */
335 - (BOOL)autosaves;
336
337 /*!
338     @method setShouldPrintBackgrounds:
339     @param flag
340 */
341 - (void)setShouldPrintBackgrounds:(BOOL)flag;
342
343 /*!
344     @method shouldPrintBackgrounds
345     @result The value of the shouldPrintBackgrounds preferences flag
346 */
347 - (BOOL)shouldPrintBackgrounds;
348
349 /*!
350     @method setPrivateBrowsingEnabled:
351     @param flag 
352     @abstract If private browsing is enabled, WebKit will not store information
353     about sites the user visits.
354  */
355 - (void)setPrivateBrowsingEnabled:(BOOL)flag;
356
357 /*!
358     @method privateBrowsingEnabled
359  */
360 - (BOOL)privateBrowsingEnabled;
361
362 /*!
363     @method setTabsToLinks:
364     @param flag 
365     @abstract If tabsToLinks is YES, the tab key will focus links and form controls. 
366     The option key temporarily reverses this preference.
367 */
368 - (void)setTabsToLinks:(BOOL)flag;
369
370 /*!
371     @method tabsToLinks
372 */
373 - (BOOL)tabsToLinks;
374
375 /*!
376     @method setUsesPageCache:
377     @abstract Sets whether the receiver's associated WebViews use the shared 
378     page cache.
379     @param UsesPageCache Whether the receiver's associated WebViews use the 
380     shared page cache.
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.
385 */
386 - (void)setUsesPageCache:(BOOL)usesPageCache;
387
388 /*!
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.
396 */
397 - (BOOL)usesPageCache;
398
399 /*!
400 @method setCacheModel:
401
402 @abstract Specifies a usage model for a WebView, which WebKit will use to 
403 determine its caching behavior.
404
405 @param cacheModel The WebView's usage model for WebKit. If necessary, WebKit 
406 will prune its caches to match cacheModel.
407
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.
414
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.
419
420 If setCacheModel: is not called, WebKit will select a cache model automatically.
421 */
422 - (void)setCacheModel:(WebCacheModel)cacheModel;
423
424 /*!
425 @method cacheModel:
426
427 @abstract Returns the usage model according to which WebKit determines its 
428 caching behavior.
429
430 @result The usage model.
431 */
432 - (WebCacheModel)cacheModel;
433
434 @end