1/*
2 Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef QWEBSETTINGS_H
21#define QWEBSETTINGS_H
22
23#include "qwebkitglobal.h"
24
25#include <QtCore/qstring.h>
26#include <QtGui/qpixmap.h>
27#include <QtGui/qicon.h>
28#include <QtCore/qshareddata.h>
29
30namespace WebCore {
31class Page;
32}
33
34class QWebPage;
35class QWebPluginDatabase;
36class QWebSettingsPrivate;
37QT_BEGIN_NAMESPACE
38class QUrl;
39QT_END_NAMESPACE
40
41QWEBKIT_EXPORT void qt_networkAccessAllowed(bool isAllowed);
42
43class QWEBKIT_EXPORT QWebSettings {
44public:
45 enum FontFamily {
46 StandardFont,
47 FixedFont,
48 SerifFont,
49 SansSerifFont,
50 CursiveFont,
51 FantasyFont
52 };
53 enum WebAttribute {
54 AutoLoadImages,
55 JavascriptEnabled,
56 JavaEnabled,
57 PluginsEnabled,
58 PrivateBrowsingEnabled,
59 JavascriptCanOpenWindows,
60 JavascriptCanAccessClipboard,
61 DeveloperExtrasEnabled,
62 LinksIncludedInFocusChain,
63 ZoomTextOnly,
64 PrintElementBackgrounds,
65 OfflineStorageDatabaseEnabled,
66 OfflineWebApplicationCacheEnabled,
67 LocalStorageEnabled,
68#if defined(QT_DEPRECATED) || defined(qdoc)
69 LocalStorageDatabaseEnabled = LocalStorageEnabled,
70#endif
71 LocalContentCanAccessRemoteUrls,
72 DnsPrefetchEnabled,
73 XSSAuditingEnabled,
74 AcceleratedCompositingEnabled,
75 SpatialNavigationEnabled,
76 LocalContentCanAccessFileUrls,
77 TiledBackingStoreEnabled,
78 FrameFlatteningEnabled,
79 SiteSpecificQuirksEnabled,
80 JavascriptCanCloseWindows,
81 WebGLEnabled,
82 CSSRegionsEnabled,
83 HyperlinkAuditingEnabled,
84 CSSGridLayoutEnabled,
85 ScrollAnimatorEnabled,
86 CaretBrowsingEnabled,
87 NotificationsEnabled,
88 WebAudioEnabled,
89 Accelerated2dCanvasEnabled,
90 MediaSourceEnabled,
91 MediaEnabled,
92 WebSecurityEnabled,
93 FullScreenSupportEnabled,
94 ImagesEnabled,
95 AllowRunningInsecureContent
96 };
97 enum WebGraphic {
98 MissingImageGraphic,
99 MissingPluginGraphic,
100 DefaultFrameIconGraphic,
101 TextAreaSizeGripCornerGraphic,
102 DeleteButtonGraphic,
103 InputSpeechButtonGraphic,
104 SearchCancelButtonGraphic,
105 SearchCancelButtonPressedGraphic
106 };
107 enum FontSize {
108 MinimumFontSize,
109 MinimumLogicalFontSize,
110 DefaultFontSize,
111 DefaultFixedFontSize
112 };
113 enum ThirdPartyCookiePolicy {
114 AlwaysAllowThirdPartyCookies,
115 AlwaysBlockThirdPartyCookies,
116 AllowThirdPartyWithExistingCookies
117 };
118
119 static QWebSettings *globalSettings();
120
121 void setFontFamily(FontFamily which, const QString &family);
122 QString fontFamily(FontFamily which) const;
123 void resetFontFamily(FontFamily which);
124
125 void setFontSize(FontSize type, int size);
126 int fontSize(FontSize type) const;
127 void resetFontSize(FontSize type);
128
129 void setAttribute(WebAttribute attr, bool on);
130 bool testAttribute(WebAttribute attr) const;
131 void resetAttribute(WebAttribute attr);
132
133 void setUserStyleSheetUrl(const QUrl &location);
134 QUrl userStyleSheetUrl() const;
135
136 void setDefaultTextEncoding(const QString &encoding);
137 QString defaultTextEncoding() const;
138
139 static void setIconDatabasePath(const QString &location);
140 static QString iconDatabasePath();
141 static void clearIconDatabase();
142 static QIcon iconForUrl(const QUrl &url);
143
144 static void setPluginSearchPaths(const QStringList& paths);
145 static QStringList pluginSearchPaths();
146
147 //static QWebPluginDatabase *pluginDatabase();
148
149 static void setWebGraphic(WebGraphic type, const QPixmap &graphic);
150 static QPixmap webGraphic(WebGraphic type);
151
152 static void setMaximumPagesInCache(int pages);
153 static int maximumPagesInCache();
154 static void setObjectCacheCapacities(int cacheMinDeadCapacity, int cacheMaxDead, int totalCapacity);
155
156 static void setOfflineStoragePath(const QString& path);
157 static QString offlineStoragePath();
158 static void setOfflineStorageDefaultQuota(qint64 maximumSize);
159 static qint64 offlineStorageDefaultQuota();
160
161 static void setOfflineWebApplicationCachePath(const QString& path);
162 static QString offlineWebApplicationCachePath();
163 static void setOfflineWebApplicationCacheQuota(qint64 maximumSize);
164 static qint64 offlineWebApplicationCacheQuota();
165
166 void setLocalStoragePath(const QString& path);
167 QString localStoragePath() const;
168
169 static void clearMemoryCaches();
170
171 static void enablePersistentStorage(const QString& path = QString());
172
173 void setThirdPartyCookiePolicy(ThirdPartyCookiePolicy);
174 QWebSettings::ThirdPartyCookiePolicy thirdPartyCookiePolicy() const;
175
176 void setCSSMediaType(const QString&);
177 QString cssMediaType() const;
178
179 inline QWebSettingsPrivate* handle() const { return d; }
180
181private:
182 friend class QWebPageAdapter;
183 friend class QWebPagePrivate;
184 friend class QWebSettingsPrivate;
185
186 Q_DISABLE_COPY(QWebSettings)
187
188 QWebSettings();
189 QWebSettings(WebCore::Page* page);
190 ~QWebSettings();
191
192 QWebSettingsPrivate *d;
193};
194
195#endif
196