707e0cc853702a6e4fd0903b9db903d7100bc166
[WebKit-https.git] / Source / WebCore / bindings / generic / RuntimeEnabledFeatures.cpp
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
43 namespace WebCore {
44
45 bool RuntimeEnabledFeatures::isLocalStorageEnabled = true;
46 bool RuntimeEnabledFeatures::isSessionStorageEnabled = true;
47 bool RuntimeEnabledFeatures::isWebkitNotificationsEnabled = false;
48 bool RuntimeEnabledFeatures::isApplicationCacheEnabled = true;
49 bool RuntimeEnabledFeatures::isDataTransferItemsEnabled = true;
50 bool RuntimeEnabledFeatures::isGeolocationEnabled = true;
51 bool RuntimeEnabledFeatures::isIndexedDBEnabled = false;
52 bool RuntimeEnabledFeatures::isWebAudioEnabled = false;
53 bool RuntimeEnabledFeatures::isTouchEnabled = true;
54 bool RuntimeEnabledFeatures::isDeviceMotionEnabled = true;
55 bool RuntimeEnabledFeatures::isDeviceOrientationEnabled = true;
56 bool RuntimeEnabledFeatures::isSpeechInputEnabled = true;
57 bool RuntimeEnabledFeatures::isCSSExclusionsEnabled = false;
58 bool RuntimeEnabledFeatures::isCSSRegionsEnabled = false;
59 bool RuntimeEnabledFeatures::isLangAttributeAwareFormControlUIEnabled = false;
60
61 #if ENABLE(SCRIPTED_SPEECH)
62 bool RuntimeEnabledFeatures::isScriptedSpeechEnabled = false;
63 #endif
64
65 #if ENABLE(MEDIA_STREAM)
66 bool RuntimeEnabledFeatures::isMediaStreamEnabled = true;
67 bool RuntimeEnabledFeatures::isPeerConnectionEnabled = true;
68 #endif
69
70 #if ENABLE(GAMEPAD)
71 bool RuntimeEnabledFeatures::isGamepadEnabled = false;
72 #endif
73
74 #if ENABLE(FILE_SYSTEM)
75 bool RuntimeEnabledFeatures::isFileSystemEnabled = false;
76
77 bool RuntimeEnabledFeatures::fileSystemEnabled()
78 {
79     return isFileSystemEnabled && AsyncFileSystem::isAvailable();
80 }
81 #endif
82
83 #if ENABLE(JAVASCRIPT_I18N_API)
84 bool RuntimeEnabledFeatures::isJavaScriptI18NAPIEnabled = false;
85
86 bool RuntimeEnabledFeatures::javaScriptI18NAPIEnabled()
87 {
88     return isJavaScriptI18NAPIEnabled;
89 }
90 #endif
91
92 #if ENABLE(VIDEO)
93
94 bool RuntimeEnabledFeatures::audioEnabled()
95 {
96     return MediaPlayer::isAvailable();
97 }
98
99 bool RuntimeEnabledFeatures::htmlMediaElementEnabled()
100 {
101     return MediaPlayer::isAvailable();
102 }
103
104 bool RuntimeEnabledFeatures::htmlAudioElementEnabled()
105 {
106     return MediaPlayer::isAvailable();
107 }
108
109 bool RuntimeEnabledFeatures::htmlVideoElementEnabled()
110 {
111     return MediaPlayer::isAvailable();
112 }
113
114 bool RuntimeEnabledFeatures::htmlSourceElementEnabled()
115 {
116     return MediaPlayer::isAvailable();
117 }
118
119 bool RuntimeEnabledFeatures::mediaControllerEnabled()
120 {
121     return MediaPlayer::isAvailable();
122 }
123
124 bool RuntimeEnabledFeatures::mediaErrorEnabled()
125 {
126     return MediaPlayer::isAvailable();
127 }
128
129 bool RuntimeEnabledFeatures::timeRangesEnabled()
130 {
131     return MediaPlayer::isAvailable();
132 }
133
134 #endif
135
136 #if ENABLE(SHARED_WORKERS)
137 bool RuntimeEnabledFeatures::sharedWorkerEnabled()
138 {
139     return SharedWorkerRepository::isAvailable();
140 }
141 #endif
142
143 #if ENABLE(WEB_SOCKETS)
144 bool RuntimeEnabledFeatures::webSocketEnabled()
145 {
146     return WebSocket::isAvailable();
147 }
148 #endif
149
150 #if ENABLE(SQL_DATABASE)
151 bool RuntimeEnabledFeatures::openDatabaseEnabled()
152 {
153     return DatabaseManager::manager().isAvailable();
154 }
155
156 bool RuntimeEnabledFeatures::openDatabaseSyncEnabled()
157 {
158     return DatabaseManager::manager().isAvailable();
159 }
160 #endif
161
162 #if ENABLE(QUOTA)
163 bool RuntimeEnabledFeatures::isQuotaEnabled = false;
164 #endif
165
166 #if ENABLE(FULLSCREEN_API)
167 bool RuntimeEnabledFeatures::isFullScreenAPIEnabled = true;
168 #endif
169
170 #if ENABLE(MEDIA_SOURCE)
171 bool RuntimeEnabledFeatures::isMediaSourceEnabled = false;
172 #endif
173
174 #if ENABLE(VIDEO_TRACK)
175 #if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(CHROMIUM) || PLATFORM(BLACKBERRY) || PLATFORM(WIN)
176     bool RuntimeEnabledFeatures::isVideoTrackEnabled = true;
177 #else
178     bool RuntimeEnabledFeatures::isVideoTrackEnabled = false;
179 #endif
180 #endif
181
182 #if ENABLE(ENCRYPTED_MEDIA)
183 bool RuntimeEnabledFeatures::isEncryptedMediaEnabled = false;
184 #endif
185
186 #if ENABLE(SHADOW_DOM)
187 bool RuntimeEnabledFeatures::isShadowDOMEnabled = false;
188
189 bool RuntimeEnabledFeatures::isAuthorShadowDOMForAnyElementEnabled = false;
190 #endif
191
192 #if ENABLE(STYLE_SCOPED)
193 bool RuntimeEnabledFeatures::isStyleScopedEnabled = false;
194 #endif
195
196 #if ENABLE(INPUT_TYPE_DATE)
197 bool RuntimeEnabledFeatures::isInputTypeDateEnabled = true;
198 #endif
199
200 #if ENABLE(INPUT_TYPE_DATETIME)
201 #if PLATFORM(CHROMIUM) && !OS(ANDROID)
202 bool RuntimeEnabledFeatures::isInputTypeDateTimeEnabled = false;
203 #else
204 bool RuntimeEnabledFeatures::isInputTypeDateTimeEnabled = true;
205 #endif
206 #endif
207
208 #if ENABLE(INPUT_TYPE_DATETIMELOCAL)
209 bool RuntimeEnabledFeatures::isInputTypeDateTimeLocalEnabled = true;
210 #endif
211
212 #if ENABLE(INPUT_TYPE_MONTH)
213 bool RuntimeEnabledFeatures::isInputTypeMonthEnabled = true;
214 #endif
215
216 #if ENABLE(INPUT_TYPE_TIME)
217 bool RuntimeEnabledFeatures::isInputTypeTimeEnabled = true;
218 #endif
219
220 #if ENABLE(INPUT_TYPE_WEEK)
221 bool RuntimeEnabledFeatures::isInputTypeWeekEnabled = true;
222 #endif
223
224 #if ENABLE(DIALOG_ELEMENT)
225 bool RuntimeEnabledFeatures::isDialogElementEnabled = false;
226 #endif
227
228 #if ENABLE(REQUEST_AUTOCOMPLETE)
229 bool RuntimeEnabledFeatures::isRequestAutocompleteEnabled = false;
230 #endif
231
232 #if ENABLE(CSP_NEXT)
233 bool RuntimeEnabledFeatures::areExperimentalContentSecurityPolicyFeaturesEnabled = false;
234 #endif
235
236 #if ENABLE(WEB_INTENTS)
237 bool RuntimeEnabledFeatures::isWebIntentsEnabled = true;
238 #endif
239
240 } // namespace WebCore