summaryrefslogtreecommitdiff
path: root/Source/WebKit/blackberry/Api/WebSettings.h
blob: 651743a3ab6061777a2cb5bf71481c2e0dd1cbf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
/*
 * Copyright (C) 2009, 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef WebSettings_h
#define WebSettings_h

#include "BlackBerryGlobal.h"
#include "BlackBerryPlatformMisc.h"

namespace BlackBerry {
namespace WebKit {

class WebSettings;
class WebSettingsPrivate;

/*!
    @struct WebSettingsDelegate
    Defines the methods that must be implemented by a delegate of WebSettings.
*/
struct BLACKBERRY_EXPORT WebSettingsDelegate {
    virtual ~WebSettingsDelegate() { }

    /*!
        Sent when the value of a setting changed as well as on instantiation of a WebSettings object.
        @param settings The WebSettings object that sent the message.
    */
    virtual void didChangeSettings(WebSettings*) = 0;
};

/*!
    @class WebSettings
*/
class BLACKBERRY_EXPORT WebSettings {
public:
    static WebSettings* createFromStandardSettings(WebSettingsDelegate* = 0);
    ~WebSettings();

    static WebSettings* standardSettings();

    void setDelegate(WebSettingsDelegate*);
    WebSettingsDelegate* delegate();

    static void addSupportedObjectPluginMIMEType(const BlackBerry::Platform::String&);
    static bool isSupportedObjectMIMEType(const BlackBerry::Platform::String&);

    bool xssAuditorEnabled() const;
    void setXSSAuditorEnabled(bool);

    bool loadsImagesAutomatically() const;
    void setLoadsImagesAutomatically(bool);

    bool shouldDrawBorderWhileLoadingImages() const;
    void setShouldDrawBorderWhileLoadingImages(bool);

    bool isJavaScriptEnabled() const;
    void setJavaScriptEnabled(bool);

    bool isPrivateBrowsingEnabled() const;
    void setPrivateBrowsingEnabled(bool);

    void setDeviceSupportsMouse(bool);
    bool deviceSupportsMouse() const;

    int defaultFixedFontSize() const;
    void setDefaultFixedFontSize(int);

    int defaultFontSize() const;
    void setDefaultFontSize(int);

    int minimumFontSize() const;
    void setMinimumFontSize(int);

    BlackBerry::Platform::String serifFontFamily() const;
    void setSerifFontFamily(const BlackBerry::Platform::String&);
    BlackBerry::Platform::String fixedFontFamily() const;
    void setFixedFontFamily(const BlackBerry::Platform::String&);
    BlackBerry::Platform::String sansSerifFontFamily() const;
    void setSansSerifFontFamily(const BlackBerry::Platform::String&);
    BlackBerry::Platform::String standardFontFamily() const;
    void setStandardFontFamily(const BlackBerry::Platform::String&);

    void setDownloadableBinaryFontsEnabled(bool);
    bool downloadableBinaryFontsEnabled() const;

    BlackBerry::Platform::String userAgentString() const;
    void setUserAgentString(const BlackBerry::Platform::String&);

    BlackBerry::Platform::String defaultTextEncodingName() const;
    void setDefaultTextEncodingName(const BlackBerry::Platform::String&);

    bool isZoomToFitOnLoad() const;
    void setZoomToFitOnLoad(bool);

    enum TextReflowMode { TextReflowDisabled, TextReflowEnabled, TextReflowEnabledOnlyForBlockZoom };
    TextReflowMode textReflowMode() const;
    void setTextReflowMode(TextReflowMode);

    bool isScrollbarsEnabled() const;
    void setScrollbarsEnabled(bool);

    // FIXME: Consider renaming this method upstream, where it is called javaScriptCanOpenWindowsAutomatically.
    bool canJavaScriptOpenWindowsAutomatically() const;
    void setJavaScriptOpenWindowsAutomatically(bool);

    bool arePluginsEnabled() const;
    void setPluginsEnabled(bool);

    bool isGeolocationEnabled() const;
    void setGeolocationEnabled(bool);

    // Context info
    bool doesGetFocusNodeContext() const;
    void setGetFocusNodeContext(bool);

    BlackBerry::Platform::String userStyleSheetLocation();
    void setUserStyleSheetLocation(const BlackBerry::Platform::String&);

    // External link handlers
    bool areLinksHandledExternally() const;
    void setAreLinksHandledExternally(bool);

    // BrowserField2 settings
    void setAllowCrossSiteRequests(bool);
    bool allowCrossSiteRequests() const;
    bool isUserScalable() const;
    void setUserScalable(bool);
    int viewportWidth() const;
    void setViewportWidth(int);
    double initialScale() const;
    void setInitialScale(double);

    int firstScheduledLayoutDelay() const;
    void setFirstScheduledLayoutDelay(int);

    // Whether to include pattern: in the list of string patterns.
    bool shouldHandlePatternUrls() const;
    void setShouldHandlePatternUrls(bool);

    bool areCookiesEnabled() const;
    void setAreCookiesEnabled(bool);

    // Web storage settings
    bool isLocalStorageEnabled() const;
    void setIsLocalStorageEnabled(bool);

    bool isDatabasesEnabled() const;
    void setIsDatabasesEnabled(bool);

    bool isAppCacheEnabled() const;
    void setIsAppCacheEnabled(bool);

    unsigned long long localStorageQuota() const;
    void setLocalStorageQuota(unsigned long long);
    unsigned long long sessionStorageQuota() const;
    void setSessionStorageQuota(unsigned long long);

    // Page cache
    void setMaximumPagesInCache(int);
    int maximumPagesInCache() const;

    BlackBerry::Platform::String localStoragePath() const;
    void setLocalStoragePath(const BlackBerry::Platform::String&);

    BlackBerry::Platform::String indexedDataBasePath() const;
    void setIndexedDataBasePath(const BlackBerry::Platform::String&);

    BlackBerry::Platform::String databasePath() const;
    void setDatabasePath(const BlackBerry::Platform::String&);

    BlackBerry::Platform::String appCachePath() const;
    void setAppCachePath(const BlackBerry::Platform::String&);

    BlackBerry::Platform::String pageGroupName() const;
    void setPageGroupName(const BlackBerry::Platform::String&);

    // FIXME: We shouldn't have an email mode. Instead, we should expose all email-related settings
    // so that the email client can toggle them directly.
    bool isEmailMode() const;
    void setEmailMode(bool enable);

    bool shouldRenderAnimationsOnScrollOrZoom() const;
    void setShouldRenderAnimationsOnScrollOrZoom(bool enable);

    unsigned overScrollColor() const;
    void setOverScrollColor(unsigned);

    bool isEnableDefaultOverScrollBackground() const;
    void setEnableDefaultOverScrollBackground(bool);

    unsigned backgroundColor() const;
    void setBackgroundColor(unsigned);

    bool isWritingDirectionRTL() const;
    void setWritingDirectionRTL(bool);

    bool useWebKitCache() const;
    void setUseWebKitCache(bool);

    bool isFrameFlatteningEnabled() const;
    void setFrameFlatteningEnabled(bool);

    unsigned maxPluginInstances() const;
    void setMaxPluginInstances(unsigned num);

    bool areWebSocketsEnabled() const;
    void setWebSocketsEnabled(bool);

    bool isSpatialNavigationEnabled() const;
    void setSpatialNavigationEnabled(bool);

    bool isAsynchronousSpellCheckingEnabled() const;
    void setAsynchronousSpellCheckingEnabled(bool) const;

    bool fullScreenVideoCapable() const;
    void setFullScreenVideoCapable(bool);

    bool isCredentialAutofillEnabled() const;
    void setCredentialAutofillEnabled(bool);

    bool isFormAutofillEnabled() const;
    void setFormAutofillEnabled(bool);

    double devicePixelRatio() const;
    void setDevicePixelRatio(double);

    bool isBackingStoreEnabled() const;
    void setBackingStoreEnabled(bool);

    bool applyDeviceScaleFactorInCompositor() const;
    void setApplyDeviceScaleFactorInCompositor(bool);

    bool isTextAutosizingEnabled() const;
    void setTextAutosizingEnabled(bool);

private:
    WebSettingsPrivate* m_private;
    WebSettings();
    DISABLE_COPY(WebSettings);
};

/*!
    @class WebSettingsTransaction
    Defines a scope guard that suppresses didChangeSettings messages within its scope.
    On destruction the guarded WebSettings object will dispatch exactly one didChangeSettings message.
*/
class BLACKBERRY_EXPORT WebSettingsTransaction {
public:
    WebSettingsTransaction(WebSettings* settings)
        : m_settings(settings)
        , m_savedDelegate(0)
    {
        if (!settings)
            return;
        m_savedDelegate = settings->delegate();
        settings->setDelegate(0);
    }

    ~WebSettingsTransaction()
    {
        if (!m_settings || !m_savedDelegate)
            return;
        m_settings->setDelegate(m_savedDelegate);
        m_savedDelegate->didChangeSettings(m_settings);
    }

private:
    WebSettingsTransaction(const WebSettingsTransaction&);
    WebSettingsTransaction& operator=(const WebSettingsTransaction&);

    WebSettings* m_settings;
    WebSettingsDelegate* m_savedDelegate;
};

} // namespace WebKit
} // namespace BlackBerry

#endif // WebSettings_h