• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006, 2007, 2008, 2009 Apple 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  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef WebPreferences_H
27 #define WebPreferences_H
28 
29 #include "WebKit.h"
30 #include <CoreFoundation/CoreFoundation.h>
31 #include <WebCore/BString.h>
32 #include <wtf/RetainPtr.h>
33 
34 class WebPreferences : public IWebPreferences, public IWebPreferencesPrivate {
35 public:
36     static WebPreferences* createInstance();
37 protected:
38     WebPreferences();
39     ~WebPreferences();
40 
41 public:
42     // IUnknown
43     virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
44     virtual ULONG STDMETHODCALLTYPE AddRef(void);
45     virtual ULONG STDMETHODCALLTYPE Release(void);
46 
47     // IWebPreferences
48     virtual HRESULT STDMETHODCALLTYPE standardPreferences(
49         /* [retval][out] */ IWebPreferences** standardPreferences);
50 
51     virtual HRESULT STDMETHODCALLTYPE initWithIdentifier(
52         /* [in] */ BSTR anIdentifier,
53         /* [retval][out] */ IWebPreferences** preferences);
54 
55     virtual HRESULT STDMETHODCALLTYPE identifier(
56         /* [retval][out] */ BSTR* ident);
57 
58     virtual HRESULT STDMETHODCALLTYPE standardFontFamily(
59         /* [retval][out] */ BSTR* family);
60 
61     virtual HRESULT STDMETHODCALLTYPE setStandardFontFamily(
62         /* [in] */ BSTR family);
63 
64     virtual HRESULT STDMETHODCALLTYPE fixedFontFamily(
65         /* [retval][out] */ BSTR* family);
66 
67     virtual HRESULT STDMETHODCALLTYPE setFixedFontFamily(
68         /* [in] */ BSTR family);
69 
70     virtual HRESULT STDMETHODCALLTYPE serifFontFamily(
71         /* [retval][out] */ BSTR* fontFamily);
72 
73     virtual HRESULT STDMETHODCALLTYPE setSerifFontFamily(
74         /* [in] */ BSTR family);
75 
76     virtual HRESULT STDMETHODCALLTYPE sansSerifFontFamily(
77         /* [retval][out] */ BSTR* family);
78 
79     virtual HRESULT STDMETHODCALLTYPE setSansSerifFontFamily(
80         /* [in] */ BSTR family);
81 
82     virtual HRESULT STDMETHODCALLTYPE cursiveFontFamily(
83         /* [retval][out] */ BSTR* family);
84 
85     virtual HRESULT STDMETHODCALLTYPE setCursiveFontFamily(
86         /* [in] */ BSTR family);
87 
88     virtual HRESULT STDMETHODCALLTYPE fantasyFontFamily(
89         /* [retval][out] */ BSTR* family);
90 
91     virtual HRESULT STDMETHODCALLTYPE setFantasyFontFamily(
92         /* [in] */ BSTR family);
93 
94     virtual HRESULT STDMETHODCALLTYPE defaultFontSize(
95         /* [retval][out] */ int* fontSize);
96 
97     virtual HRESULT STDMETHODCALLTYPE setDefaultFontSize(
98         /* [in] */ int fontSize);
99 
100     virtual HRESULT STDMETHODCALLTYPE defaultFixedFontSize(
101         /* [retval][out] */ int* fontSize);
102 
103     virtual HRESULT STDMETHODCALLTYPE setDefaultFixedFontSize(
104         /* [in] */ int fontSize);
105 
106     virtual HRESULT STDMETHODCALLTYPE minimumFontSize(
107         /* [retval][out] */ int* fontSize);
108 
109     virtual HRESULT STDMETHODCALLTYPE setMinimumFontSize(
110         /* [in] */ int fontSize);
111 
112     virtual HRESULT STDMETHODCALLTYPE minimumLogicalFontSize(
113         /* [retval][out] */ int* fontSize);
114 
115     virtual HRESULT STDMETHODCALLTYPE setMinimumLogicalFontSize(
116         /* [in] */ int fontSize);
117 
118     virtual HRESULT STDMETHODCALLTYPE defaultTextEncodingName(
119         /* [retval][out] */ BSTR* name);
120 
121     virtual HRESULT STDMETHODCALLTYPE setDefaultTextEncodingName(
122         /* [in] */ BSTR name);
123 
124     virtual HRESULT STDMETHODCALLTYPE userStyleSheetEnabled(
125         /* [retval][out] */ BOOL* enabled);
126 
127     virtual HRESULT STDMETHODCALLTYPE setUserStyleSheetEnabled(
128         /* [in] */ BOOL enabled);
129 
130     virtual HRESULT STDMETHODCALLTYPE userStyleSheetLocation(
131         /* [retval][out] */ BSTR* location);
132 
133     virtual HRESULT STDMETHODCALLTYPE setUserStyleSheetLocation(
134         /* [in] */ BSTR location);
135 
136     virtual HRESULT STDMETHODCALLTYPE isJavaEnabled(
137         /* [retval][out] */ BOOL* enabled);
138 
139     virtual HRESULT STDMETHODCALLTYPE setJavaEnabled(
140         /* [in] */ BOOL enabled);
141 
142     virtual HRESULT STDMETHODCALLTYPE isJavaScriptEnabled(
143         /* [retval][out] */ BOOL* enabled);
144 
145     virtual HRESULT STDMETHODCALLTYPE setJavaScriptEnabled(
146         /* [in] */ BOOL enabled);
147 
148     virtual HRESULT STDMETHODCALLTYPE javaScriptCanOpenWindowsAutomatically(
149         /* [retval][out] */ BOOL* enabled);
150 
151     virtual HRESULT STDMETHODCALLTYPE setJavaScriptCanOpenWindowsAutomatically(
152         /* [in] */ BOOL enabled);
153 
154     virtual HRESULT STDMETHODCALLTYPE arePlugInsEnabled(
155         /* [retval][out] */ BOOL* enabled);
156 
157     virtual HRESULT STDMETHODCALLTYPE setPlugInsEnabled(
158         /* [in] */ BOOL enabled);
159 
160     virtual HRESULT STDMETHODCALLTYPE allowsAnimatedImages(
161         /* [retval][out] */ BOOL* enabled);
162 
163     virtual HRESULT STDMETHODCALLTYPE setAllowsAnimatedImages(
164         /* [in] */ BOOL enabled);
165 
166     virtual HRESULT STDMETHODCALLTYPE allowAnimatedImageLooping(
167         /* [retval][out] */ BOOL* enabled);
168 
169     virtual HRESULT STDMETHODCALLTYPE setAllowAnimatedImageLooping(
170         /* [in] */ BOOL enabled);
171 
172     virtual HRESULT STDMETHODCALLTYPE setLoadsImagesAutomatically(
173         /* [in] */ BOOL enabled);
174 
175     virtual HRESULT STDMETHODCALLTYPE loadsImagesAutomatically(
176         /* [retval][out] */ BOOL* enabled);
177 
178     virtual HRESULT STDMETHODCALLTYPE setAutosaves(
179         /* [in] */ BOOL enabled);
180 
181     virtual HRESULT STDMETHODCALLTYPE autosaves(
182         /* [retval][out] */ BOOL* enabled);
183 
184     virtual HRESULT STDMETHODCALLTYPE setShouldPrintBackgrounds(
185         /* [in] */ BOOL enabled);
186 
187     virtual HRESULT STDMETHODCALLTYPE shouldPrintBackgrounds(
188         /* [retval][out] */ BOOL* enabled);
189 
190     virtual HRESULT STDMETHODCALLTYPE setPrivateBrowsingEnabled(
191         /* [in] */ BOOL enabled);
192 
193     virtual HRESULT STDMETHODCALLTYPE privateBrowsingEnabled(
194         /* [retval][out] */ BOOL* enabled);
195 
196     virtual HRESULT STDMETHODCALLTYPE setTabsToLinks(
197         /* [in] */ BOOL enabled);
198 
199     virtual HRESULT STDMETHODCALLTYPE tabsToLinks(
200         /* [retval][out] */ BOOL* enabled);
201 
202     virtual HRESULT STDMETHODCALLTYPE textAreasAreResizable(
203         /* [retval][out] */ BOOL *enabled);
204 
205     virtual HRESULT STDMETHODCALLTYPE setTextAreasAreResizable(
206         /* [in] */ BOOL enabled);
207 
208     virtual HRESULT STDMETHODCALLTYPE usesPageCache(
209         /* [retval][out] */ BOOL *usesPageCache);
210 
211     virtual HRESULT STDMETHODCALLTYPE setUsesPageCache(
212         /* [in] */ BOOL usesPageCache);
213 
214     virtual HRESULT STDMETHODCALLTYPE unused1();
215     virtual HRESULT STDMETHODCALLTYPE unused2();
216 
217     virtual HRESULT STDMETHODCALLTYPE iconDatabaseLocation(
218         /* [retval][out] */ BSTR* location);
219 
220     virtual HRESULT STDMETHODCALLTYPE setIconDatabaseLocation(
221         /* [in] */ BSTR location);
222 
223     virtual HRESULT STDMETHODCALLTYPE iconDatabaseEnabled(
224         /* [retval][out] */ BOOL* enabled);
225 
226     virtual HRESULT STDMETHODCALLTYPE setIconDatabaseEnabled(
227         /* [in] */ BOOL enabled);
228 
229     virtual HRESULT STDMETHODCALLTYPE fontSmoothing(
230         /* [retval][out] */ FontSmoothingType* smoothingType);
231 
232     virtual HRESULT STDMETHODCALLTYPE setFontSmoothing(
233         /* [in] */ FontSmoothingType smoothingType);
234 
235     virtual HRESULT STDMETHODCALLTYPE editableLinkBehavior(
236         /* [retval][out] */ WebKitEditableLinkBehavior* behavior);
237 
238     virtual HRESULT STDMETHODCALLTYPE setEditableLinkBehavior(
239         /* [in] */ WebKitEditableLinkBehavior behavior);
240 
241     virtual HRESULT STDMETHODCALLTYPE editingBehavior(
242         /* [retval][out] */ WebKitEditingBehavior* behavior);
243 
244     virtual HRESULT STDMETHODCALLTYPE setEditingBehavior(
245         /* [in] */ WebKitEditingBehavior behavior);
246 
247     virtual HRESULT STDMETHODCALLTYPE cookieStorageAcceptPolicy(
248         /* [retval][out] */ WebKitCookieStorageAcceptPolicy *acceptPolicy);
249 
250     virtual HRESULT STDMETHODCALLTYPE setCookieStorageAcceptPolicy(
251         /* [in] */ WebKitCookieStorageAcceptPolicy acceptPolicy);
252 
253     virtual HRESULT STDMETHODCALLTYPE continuousSpellCheckingEnabled(
254         /* [retval][out] */ BOOL *enabled);
255 
256     virtual HRESULT STDMETHODCALLTYPE setContinuousSpellCheckingEnabled(
257         /* [in] */ BOOL enabled);
258 
259     virtual HRESULT STDMETHODCALLTYPE grammarCheckingEnabled(
260         /* [retval][out] */ BOOL *enabled);
261 
262     virtual HRESULT STDMETHODCALLTYPE setGrammarCheckingEnabled(
263         /* [in] */ BOOL enabled);
264 
265     virtual HRESULT STDMETHODCALLTYPE allowContinuousSpellChecking(
266         /* [retval][out] */ BOOL *enabled);
267 
268     virtual HRESULT STDMETHODCALLTYPE setAllowContinuousSpellChecking(
269         /* [in] */ BOOL enabled);
270 
271     virtual HRESULT STDMETHODCALLTYPE isDOMPasteAllowed(
272         /* [retval][out] */ BOOL *enabled);
273 
274     virtual HRESULT STDMETHODCALLTYPE setDOMPasteAllowed(
275         /* [in] */ BOOL enabled);
276 
277     virtual HRESULT STDMETHODCALLTYPE cacheModel(
278      /* [retval][out] */ WebCacheModel* cacheModel);
279 
280     virtual HRESULT STDMETHODCALLTYPE setCacheModel(
281      /* [in] */ WebCacheModel cacheModel);
282 
283     virtual HRESULT STDMETHODCALLTYPE setShouldPaintCustomScrollbars(
284     /* [in] */ BOOL shouldPaint);
285 
286     virtual HRESULT STDMETHODCALLTYPE shouldPaintCustomScrollbars(
287     /* [retval][out] */ BOOL *shouldPaint);
288 
289     // IWebPreferencesPrivate
290     virtual HRESULT STDMETHODCALLTYPE setDeveloperExtrasEnabled(
291         /* [in] */ BOOL);
292 
293     virtual HRESULT STDMETHODCALLTYPE developerExtrasEnabled(
294         /* [retval][out] */ BOOL*);
295 
296      virtual HRESULT STDMETHODCALLTYPE setAutomaticallyDetectsCacheModel(
297          /* [in] */ BOOL automaticallyDetectsCacheModel);
298 
299      virtual HRESULT STDMETHODCALLTYPE automaticallyDetectsCacheModel(
300          /* [out, retval] */ BOOL* automaticallyDetectsCacheModel);
301 
302     virtual HRESULT STDMETHODCALLTYPE setAuthorAndUserStylesEnabled(BOOL);
303     virtual HRESULT STDMETHODCALLTYPE authorAndUserStylesEnabled(BOOL*);
304 
305     virtual HRESULT STDMETHODCALLTYPE inApplicationChromeMode(
306         /* [retval][out] */ BOOL *enabled);
307 
308     virtual HRESULT STDMETHODCALLTYPE setApplicationChromeMode(
309         /* [in] */ BOOL enabled);
310 
311     virtual HRESULT STDMETHODCALLTYPE setOfflineWebApplicationCacheEnabled(
312         /* [in] */ BOOL enabled);
313 
314     virtual HRESULT STDMETHODCALLTYPE offlineWebApplicationCacheEnabled(
315         /* [retval][out] */ BOOL *enabled);
316 
317     virtual HRESULT STDMETHODCALLTYPE setDatabasesEnabled(
318         /* [in] */ BOOL enabled);
319 
320     virtual HRESULT STDMETHODCALLTYPE databasesEnabled(
321         /* [retval][out] */ BOOL *enabled);
322 
323     virtual HRESULT STDMETHODCALLTYPE setLocalStorageEnabled(
324         /* [in] */ BOOL enabled);
325 
326     virtual HRESULT STDMETHODCALLTYPE localStorageEnabled(
327         /* [retval][out] */ BOOL *enabled);
328 
329     virtual HRESULT STDMETHODCALLTYPE localStorageDatabasePath(
330         /* [out, retval] */ BSTR* location);
331 
332     virtual HRESULT STDMETHODCALLTYPE setLocalStorageDatabasePath(
333         /* [in] */ BSTR location);
334 
335     virtual HRESULT STDMETHODCALLTYPE experimentalNotificationsEnabled(
336         /* [retval][out] */ BOOL *enabled);
337 
338     virtual HRESULT STDMETHODCALLTYPE setExperimentalNotificationsEnabled(
339         /* [in] */ BOOL enabled);
340 
341     virtual HRESULT STDMETHODCALLTYPE setShouldPaintNativeControls(
342     /* [in] */ BOOL shouldPaint);
343 
344     virtual HRESULT STDMETHODCALLTYPE shouldPaintNativeControls(
345     /* [retval][out] */ BOOL *shouldPaint);
346 
347     virtual HRESULT STDMETHODCALLTYPE setZoomsTextOnly(
348     /* [retval][out] */ BOOL zoomsTextOnly);
349 
350     virtual HRESULT STDMETHODCALLTYPE zoomsTextOnly(
351     /* [retval][out] */ BOOL *zoomsTextOnly);
352 
353     virtual HRESULT STDMETHODCALLTYPE fontSmoothingContrast(
354     /* [retval][out] */ float* contrast);
355 
356     virtual HRESULT STDMETHODCALLTYPE setFontSmoothingContrast(
357     /* [in] */ float contrast);
358 
359     virtual HRESULT STDMETHODCALLTYPE isWebSecurityEnabled(
360     /* [retval][out] */ BOOL* enabled);
361 
362     virtual HRESULT STDMETHODCALLTYPE setWebSecurityEnabled(
363     /* [in] */ BOOL enabled);
364 
365     virtual HRESULT STDMETHODCALLTYPE allowUniversalAccessFromFileURLs(
366     /* [retval][out] */ BOOL* allowAccess);
367 
368     virtual HRESULT STDMETHODCALLTYPE setAllowUniversalAccessFromFileURLs(
369     /* [in] */ BOOL allowAccess);
370 
371     virtual HRESULT STDMETHODCALLTYPE allowFileAccessFromFileURLs(
372     /* [retval][out] */ BOOL* allowAccess);
373 
374     virtual HRESULT STDMETHODCALLTYPE setAllowFileAccessFromFileURLs(
375     /* [in] */ BOOL allowAccess);
376 
377     virtual HRESULT STDMETHODCALLTYPE javaScriptCanAccessClipboard(
378     /* [retval][out] */ BOOL* enabled);
379 
380     virtual HRESULT STDMETHODCALLTYPE setJavaScriptCanAccessClipboard(
381     /* [in] */ BOOL enabled);
382 
383     virtual HRESULT STDMETHODCALLTYPE isXSSAuditorEnabled(
384     /* [retval][out] */ BOOL* enabled);
385 
386     virtual HRESULT STDMETHODCALLTYPE setXSSAuditorEnabled(
387     /* [in] */ BOOL enabled);
388 
389     virtual HRESULT STDMETHODCALLTYPE setShouldUseHighResolutionTimers(
390     /* [in] */ BOOL useHighResolutionTimers);
391 
392     virtual HRESULT STDMETHODCALLTYPE shouldUseHighResolutionTimers(
393     /* [retval][out] */ BOOL* useHighResolutionTimers);
394 
395     virtual HRESULT STDMETHODCALLTYPE setPluginAllowedRunTime(
396     /* [in] */ UINT allowedRunTime);
397 
398     virtual HRESULT STDMETHODCALLTYPE pluginAllowedRunTime(
399     /* [retval][out] */ UINT* allowedRunTime);
400 
401     virtual HRESULT STDMETHODCALLTYPE isFrameFlatteningEnabled(
402     /* [retval][out] */ BOOL* enabled);
403 
404     virtual HRESULT STDMETHODCALLTYPE setFrameFlatteningEnabled(
405     /* [in] */ BOOL enabled);
406 
407     virtual HRESULT STDMETHODCALLTYPE setPreferenceForTest(
408     /* [in] */ BSTR key,
409     /* [in] */ BSTR value);
410 
411     virtual HRESULT STDMETHODCALLTYPE setAcceleratedCompositingEnabled(BOOL);
412     virtual HRESULT STDMETHODCALLTYPE acceleratedCompositingEnabled(BOOL*);
413 
414     virtual HRESULT STDMETHODCALLTYPE setCustomDragCursorsEnabled(BOOL);
415     virtual HRESULT STDMETHODCALLTYPE customDragCursorsEnabled(BOOL*);
416 
417     virtual HRESULT STDMETHODCALLTYPE setShowDebugBorders(BOOL);
418     virtual HRESULT STDMETHODCALLTYPE showDebugBorders(BOOL*);
419 
420     virtual HRESULT STDMETHODCALLTYPE setShowRepaintCounter(BOOL);
421     virtual HRESULT STDMETHODCALLTYPE showRepaintCounter(BOOL*);
422 
423     virtual HRESULT STDMETHODCALLTYPE setDNSPrefetchingEnabled(BOOL);
424     virtual HRESULT STDMETHODCALLTYPE isDNSPrefetchingEnabled(BOOL*);
425 
426     virtual HRESULT STDMETHODCALLTYPE setMemoryInfoEnabled(BOOL);
427     virtual HRESULT STDMETHODCALLTYPE memoryInfoEnabled(BOOL*);
428 
429     virtual HRESULT STDMETHODCALLTYPE hyperlinkAuditingEnabled(BOOL*);
430     virtual HRESULT STDMETHODCALLTYPE setHyperlinkAuditingEnabled(BOOL);
431 
432     virtual HRESULT STDMETHODCALLTYPE loadsSiteIconsIgnoringImageLoadingPreference(BOOL*);
433     virtual HRESULT STDMETHODCALLTYPE setLoadsSiteIconsIgnoringImageLoadingPreference(BOOL);
434 
435     // WebPreferences
436 
437     // This method accesses a different preference key than developerExtrasEnabled.
438     // See <rdar://5343767> for the justification.
439     bool developerExtrasDisabledByOverride();
440 
441     static BSTR webPreferencesChangedNotification();
442     static BSTR webPreferencesRemovedNotification();
443 
444     static void setInstance(WebPreferences* instance, BSTR identifier);
445     static void removeReferenceForIdentifier(BSTR identifier);
446     static WebPreferences* sharedStandardPreferences();
447 
448     // From WebHistory.h
449     HRESULT historyItemLimit(int* limit);
450     HRESULT setHistoryItemLimit(int limit);
451     HRESULT historyAgeInDaysLimit(int* limit);
452     HRESULT setHistoryAgeInDaysLimit(int limit);
453 
454      void willAddToWebView();
455      void didRemoveFromWebView();
456 
457     HRESULT postPreferencesChangesNotification();
458 
459 protected:
460     void setValueForKey(CFStringRef key, CFPropertyListRef value);
461     RetainPtr<CFPropertyListRef> valueForKey(CFStringRef key);
462     BSTR stringValueForKey(CFStringRef key);
463     int integerValueForKey(CFStringRef key);
464     BOOL boolValueForKey(CFStringRef key);
465     float floatValueForKey(CFStringRef key);
466     LONGLONG longlongValueForKey(CFStringRef key);
467     void setStringValue(CFStringRef key, LPCTSTR value);
468     void setIntegerValue(CFStringRef key, int value);
469     void setBoolValue(CFStringRef key, BOOL value);
470     void setFloatValue(CFStringRef key, float value);
471     void setLongLongValue(CFStringRef key, LONGLONG value);
472     static WebPreferences* getInstanceForIdentifier(BSTR identifier);
473     static void initializeDefaultSettings();
474     void save();
475     void load();
476     void migrateWebKitPreferencesToCFPreferences();
477     void copyWebKitPreferencesToCFPreferences(CFDictionaryRef);
478 
479 protected:
480     ULONG m_refCount;
481     RetainPtr<CFMutableDictionaryRef> m_privatePrefs;
482     WebCore::BString m_identifier;
483     bool m_autoSaves;
484     bool m_automaticallyDetectsCacheModel;
485     unsigned m_numWebViews;
486 };
487 
488 #endif
489