• 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 cookieStorageAcceptPolicy(
242         /* [retval][out] */ WebKitCookieStorageAcceptPolicy *acceptPolicy);
243 
244     virtual HRESULT STDMETHODCALLTYPE setCookieStorageAcceptPolicy(
245         /* [in] */ WebKitCookieStorageAcceptPolicy acceptPolicy);
246 
247     virtual HRESULT STDMETHODCALLTYPE continuousSpellCheckingEnabled(
248         /* [retval][out] */ BOOL *enabled);
249 
250     virtual HRESULT STDMETHODCALLTYPE setContinuousSpellCheckingEnabled(
251         /* [in] */ BOOL enabled);
252 
253     virtual HRESULT STDMETHODCALLTYPE grammarCheckingEnabled(
254         /* [retval][out] */ BOOL *enabled);
255 
256     virtual HRESULT STDMETHODCALLTYPE setGrammarCheckingEnabled(
257         /* [in] */ BOOL enabled);
258 
259     virtual HRESULT STDMETHODCALLTYPE allowContinuousSpellChecking(
260         /* [retval][out] */ BOOL *enabled);
261 
262     virtual HRESULT STDMETHODCALLTYPE setAllowContinuousSpellChecking(
263         /* [in] */ BOOL enabled);
264 
265     virtual HRESULT STDMETHODCALLTYPE isDOMPasteAllowed(
266         /* [retval][out] */ BOOL *enabled);
267 
268     virtual HRESULT STDMETHODCALLTYPE setDOMPasteAllowed(
269         /* [in] */ BOOL enabled);
270 
271     virtual HRESULT STDMETHODCALLTYPE cacheModel(
272      /* [retval][out] */ WebCacheModel* cacheModel);
273 
274     virtual HRESULT STDMETHODCALLTYPE setCacheModel(
275      /* [in] */ WebCacheModel cacheModel);
276 
277     virtual HRESULT STDMETHODCALLTYPE setShouldPaintCustomScrollbars(
278     /* [in] */ BOOL shouldPaint);
279 
280     virtual HRESULT STDMETHODCALLTYPE shouldPaintCustomScrollbars(
281     /* [retval][out] */ BOOL *shouldPaint);
282 
283     // IWebPreferencesPrivate
284     virtual HRESULT STDMETHODCALLTYPE setDeveloperExtrasEnabled(
285         /* [in] */ BOOL);
286 
287     virtual HRESULT STDMETHODCALLTYPE developerExtrasEnabled(
288         /* [retval][out] */ BOOL*);
289 
290      virtual HRESULT STDMETHODCALLTYPE setAutomaticallyDetectsCacheModel(
291          /* [in] */ BOOL automaticallyDetectsCacheModel);
292 
293      virtual HRESULT STDMETHODCALLTYPE automaticallyDetectsCacheModel(
294          /* [out, retval] */ BOOL* automaticallyDetectsCacheModel);
295 
296     virtual HRESULT STDMETHODCALLTYPE setAuthorAndUserStylesEnabled(BOOL);
297     virtual HRESULT STDMETHODCALLTYPE authorAndUserStylesEnabled(BOOL*);
298 
299     virtual HRESULT STDMETHODCALLTYPE inApplicationChromeMode(
300         /* [retval][out] */ BOOL *enabled);
301 
302     virtual HRESULT STDMETHODCALLTYPE setApplicationChromeMode(
303         /* [in] */ BOOL enabled);
304 
305     virtual HRESULT STDMETHODCALLTYPE setOfflineWebApplicationCacheEnabled(
306         /* [in] */ BOOL enabled);
307 
308     virtual HRESULT STDMETHODCALLTYPE offlineWebApplicationCacheEnabled(
309         /* [retval][out] */ BOOL *enabled);
310 
311     virtual HRESULT STDMETHODCALLTYPE setDatabasesEnabled(
312         /* [in] */ BOOL enabled);
313 
314     virtual HRESULT STDMETHODCALLTYPE databasesEnabled(
315         /* [retval][out] */ BOOL *enabled);
316 
317     virtual HRESULT STDMETHODCALLTYPE setLocalStorageEnabled(
318         /* [in] */ BOOL enabled);
319 
320     virtual HRESULT STDMETHODCALLTYPE localStorageEnabled(
321         /* [retval][out] */ BOOL *enabled);
322 
323     virtual HRESULT STDMETHODCALLTYPE localStorageDatabasePath(
324         /* [out, retval] */ BSTR* location);
325 
326     virtual HRESULT STDMETHODCALLTYPE setLocalStorageDatabasePath(
327         /* [in] */ BSTR location);
328 
329     virtual HRESULT STDMETHODCALLTYPE setShouldPaintNativeControls(
330     /* [in] */ BOOL shouldPaint);
331 
332     virtual HRESULT STDMETHODCALLTYPE shouldPaintNativeControls(
333     /* [retval][out] */ BOOL *shouldPaint);
334 
335     virtual HRESULT STDMETHODCALLTYPE setZoomsTextOnly(
336     /* [retval][out] */ BOOL zoomsTextOnly);
337 
338     virtual HRESULT STDMETHODCALLTYPE zoomsTextOnly(
339     /* [retval][out] */ BOOL *zoomsTextOnly);
340 
341     virtual HRESULT STDMETHODCALLTYPE fontSmoothingContrast(
342     /* [retval][out] */ float* contrast);
343 
344     virtual HRESULT STDMETHODCALLTYPE setFontSmoothingContrast(
345     /* [in] */ float contrast);
346 
347     // WebPreferences
348 
349     // This method accesses a different preference key than developerExtrasEnabled.
350     // See <rdar://5343767> for the justification.
351     bool developerExtrasDisabledByOverride();
352 
353     static BSTR webPreferencesChangedNotification();
354     static BSTR webPreferencesRemovedNotification();
355 
356     static void setInstance(WebPreferences* instance, BSTR identifier);
357     static void removeReferenceForIdentifier(BSTR identifier);
358     static WebPreferences* sharedStandardPreferences();
359 
360     // From WebHistory.h
361     HRESULT historyItemLimit(int* limit);
362     HRESULT setHistoryItemLimit(int limit);
363     HRESULT historyAgeInDaysLimit(int* limit);
364     HRESULT setHistoryAgeInDaysLimit(int limit);
365 
366      void willAddToWebView();
367      void didRemoveFromWebView();
368 
369     HRESULT postPreferencesChangesNotification();
370 
371 protected:
372     void setValueForKey(CFStringRef key, CFPropertyListRef value);
373     RetainPtr<CFPropertyListRef> valueForKey(CFStringRef key);
374     BSTR stringValueForKey(CFStringRef key);
375     int integerValueForKey(CFStringRef key);
376     BOOL boolValueForKey(CFStringRef key);
377     float floatValueForKey(CFStringRef key);
378     LONGLONG longlongValueForKey(CFStringRef key);
379     void setStringValue(CFStringRef key, LPCTSTR value);
380     void setIntegerValue(CFStringRef key, int value);
381     void setBoolValue(CFStringRef key, BOOL value);
382     void setFloatValue(CFStringRef key, float value);
383     void setLongLongValue(CFStringRef key, LONGLONG value);
384     static WebPreferences* getInstanceForIdentifier(BSTR identifier);
385     static void initializeDefaultSettings();
386     void save();
387     void load();
388     void migrateWebKitPreferencesToCFPreferences();
389     void copyWebKitPreferencesToCFPreferences(CFDictionaryRef);
390 
391 protected:
392     ULONG m_refCount;
393     RetainPtr<CFMutableDictionaryRef> m_privatePrefs;
394     WebCore::BString m_identifier;
395     bool m_autoSaves;
396     bool m_automaticallyDetectsCacheModel;
397     unsigned m_numWebViews;
398 };
399 
400 #endif
401