1/*
2 * Copyright (C) 2009 Google 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 are
6 * met:
7 *
8 *     * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *     * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 *     * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include "config.h"
32#include "RuntimeEnabledFeatures.h"
33
34#include "DatabaseManager.h"
35#include "MediaPlayer.h"
36#include "SharedWorkerRepository.h"
37#include "WebSocket.h"
38
39#if ENABLE(FILE_SYSTEM)
40#include "AsyncFileSystem.h"
41#endif
42
43namespace WebCore {
44
45bool RuntimeEnabledFeatures::isLocalStorageEnabled = true;
46bool RuntimeEnabledFeatures::isSessionStorageEnabled = true;
47bool RuntimeEnabledFeatures::isWebkitNotificationsEnabled = false;
48bool RuntimeEnabledFeatures::isApplicationCacheEnabled = true;
49bool RuntimeEnabledFeatures::isDataTransferItemsEnabled = true;
50bool RuntimeEnabledFeatures::isGeolocationEnabled = true;
51bool RuntimeEnabledFeatures::isIndexedDBEnabled = false;
52bool RuntimeEnabledFeatures::isTouchEnabled = true;
53bool RuntimeEnabledFeatures::isDeviceMotionEnabled = true;
54bool RuntimeEnabledFeatures::isDeviceOrientationEnabled = true;
55bool RuntimeEnabledFeatures::isSpeechInputEnabled = true;
56bool RuntimeEnabledFeatures::isCanvasPathEnabled = false;
57bool RuntimeEnabledFeatures::isCSSExclusionsEnabled = true;
58bool RuntimeEnabledFeatures::isCSSShapesEnabled = true;
59bool RuntimeEnabledFeatures::isCSSRegionsEnabled = false;
60bool RuntimeEnabledFeatures::isCSSCompositingEnabled = false;
61bool RuntimeEnabledFeatures::isLangAttributeAwareFormControlUIEnabled = false;
62
63#if ENABLE(SCRIPTED_SPEECH)
64bool RuntimeEnabledFeatures::isScriptedSpeechEnabled = false;
65#endif
66
67#if ENABLE(MEDIA_STREAM)
68bool RuntimeEnabledFeatures::isMediaStreamEnabled = true;
69bool RuntimeEnabledFeatures::isPeerConnectionEnabled = true;
70#endif
71
72#if ENABLE(LEGACY_CSS_VENDOR_PREFIXES)
73bool RuntimeEnabledFeatures::isLegacyCSSVendorPrefixesEnabled = false;
74#endif
75
76#if ENABLE(GAMEPAD)
77bool RuntimeEnabledFeatures::isGamepadEnabled = false;
78#endif
79
80#if ENABLE(FILE_SYSTEM)
81bool RuntimeEnabledFeatures::isFileSystemEnabled = false;
82
83bool RuntimeEnabledFeatures::fileSystemEnabled()
84{
85    return isFileSystemEnabled && AsyncFileSystem::isAvailable();
86}
87#endif
88
89#if ENABLE(JAVASCRIPT_I18N_API)
90bool RuntimeEnabledFeatures::isJavaScriptI18NAPIEnabled = false;
91
92bool RuntimeEnabledFeatures::javaScriptI18NAPIEnabled()
93{
94    return isJavaScriptI18NAPIEnabled;
95}
96#endif
97
98#if ENABLE(VIDEO)
99
100bool RuntimeEnabledFeatures::audioEnabled()
101{
102    return MediaPlayer::isAvailable();
103}
104
105bool RuntimeEnabledFeatures::htmlMediaElementEnabled()
106{
107    return MediaPlayer::isAvailable();
108}
109
110bool RuntimeEnabledFeatures::htmlAudioElementEnabled()
111{
112    return MediaPlayer::isAvailable();
113}
114
115bool RuntimeEnabledFeatures::htmlVideoElementEnabled()
116{
117    return MediaPlayer::isAvailable();
118}
119
120bool RuntimeEnabledFeatures::htmlSourceElementEnabled()
121{
122    return MediaPlayer::isAvailable();
123}
124
125bool RuntimeEnabledFeatures::mediaControllerEnabled()
126{
127    return MediaPlayer::isAvailable();
128}
129
130bool RuntimeEnabledFeatures::mediaErrorEnabled()
131{
132    return MediaPlayer::isAvailable();
133}
134
135bool RuntimeEnabledFeatures::timeRangesEnabled()
136{
137    return MediaPlayer::isAvailable();
138}
139
140#endif
141
142#if ENABLE(SHARED_WORKERS)
143bool RuntimeEnabledFeatures::sharedWorkerEnabled()
144{
145    return SharedWorkerRepository::isAvailable();
146}
147#endif
148
149#if ENABLE(WEB_SOCKETS)
150bool RuntimeEnabledFeatures::webSocketEnabled()
151{
152    return WebSocket::isAvailable();
153}
154#endif
155
156#if ENABLE(SQL_DATABASE)
157bool RuntimeEnabledFeatures::openDatabaseEnabled()
158{
159    return DatabaseManager::manager().isAvailable();
160}
161
162bool RuntimeEnabledFeatures::openDatabaseSyncEnabled()
163{
164    return DatabaseManager::manager().isAvailable();
165}
166#endif
167
168#if ENABLE(QUOTA)
169bool RuntimeEnabledFeatures::isQuotaEnabled = false;
170#endif
171
172#if ENABLE(FULLSCREEN_API)
173bool RuntimeEnabledFeatures::isFullScreenAPIEnabled = true;
174#endif
175
176#if ENABLE(MEDIA_SOURCE)
177bool RuntimeEnabledFeatures::isMediaSourceEnabled = false;
178#endif
179
180#if ENABLE(VIDEO_TRACK)
181#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(BLACKBERRY) || PLATFORM(WIN) || PLATFORM(QT)
182    bool RuntimeEnabledFeatures::isVideoTrackEnabled = true;
183#else
184    bool RuntimeEnabledFeatures::isVideoTrackEnabled = false;
185#endif
186#endif
187
188#if ENABLE(ENCRYPTED_MEDIA)
189bool RuntimeEnabledFeatures::isEncryptedMediaEnabled = false;
190#endif
191
192#if ENABLE(SHADOW_DOM)
193bool RuntimeEnabledFeatures::isShadowDOMEnabled = false;
194
195bool RuntimeEnabledFeatures::isAuthorShadowDOMForAnyElementEnabled = false;
196#endif
197
198#if ENABLE(CUSTOM_ELEMENTS)
199bool RuntimeEnabledFeatures::isCustomDOMElementsEnabled = false;
200#endif
201
202#if ENABLE(STYLE_SCOPED)
203bool RuntimeEnabledFeatures::isStyleScopedEnabled = false;
204#endif
205
206#if ENABLE(INPUT_TYPE_DATE)
207bool RuntimeEnabledFeatures::isInputTypeDateEnabled = true;
208#endif
209
210#if ENABLE(INPUT_TYPE_DATETIME_INCOMPLETE)
211bool RuntimeEnabledFeatures::isInputTypeDateTimeEnabled = false;
212#endif
213
214#if ENABLE(INPUT_TYPE_DATETIMELOCAL)
215bool RuntimeEnabledFeatures::isInputTypeDateTimeLocalEnabled = true;
216#endif
217
218#if ENABLE(INPUT_TYPE_MONTH)
219bool RuntimeEnabledFeatures::isInputTypeMonthEnabled = true;
220#endif
221
222#if ENABLE(INPUT_TYPE_TIME)
223bool RuntimeEnabledFeatures::isInputTypeTimeEnabled = true;
224#endif
225
226#if ENABLE(INPUT_TYPE_WEEK)
227bool RuntimeEnabledFeatures::isInputTypeWeekEnabled = true;
228#endif
229
230#if ENABLE(DIALOG_ELEMENT)
231bool RuntimeEnabledFeatures::isDialogElementEnabled = false;
232#endif
233
234#if ENABLE(CSP_NEXT)
235bool RuntimeEnabledFeatures::areExperimentalContentSecurityPolicyFeaturesEnabled = false;
236#endif
237
238#if ENABLE(IFRAME_SEAMLESS)
239bool RuntimeEnabledFeatures::areSeamlessIFramesEnabled = false;
240#endif
241
242#if ENABLE(FONT_LOAD_EVENTS)
243bool RuntimeEnabledFeatures::isFontLoadEventsEnabled = false;
244#endif
245
246} // namespace WebCore
247