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 "WebRuntimeFeatures.h"
33
34 #include "AbstractDatabase.h"
35 #include "RuntimeEnabledFeatures.h"
36 #include "WebMediaPlayerClientImpl.h"
37 #include "WebSocket.h"
38
39 using namespace WebCore;
40
41 namespace WebKit {
42
enableDatabase(bool enable)43 void WebRuntimeFeatures::enableDatabase(bool enable)
44 {
45 #if ENABLE(DATABASE)
46 AbstractDatabase::setIsAvailable(enable);
47 #endif
48 }
49
isDatabaseEnabled()50 bool WebRuntimeFeatures::isDatabaseEnabled()
51 {
52 #if ENABLE(DATABASE)
53 return AbstractDatabase::isAvailable();
54 #else
55 return false;
56 #endif
57 }
58
enableLocalStorage(bool enable)59 void WebRuntimeFeatures::enableLocalStorage(bool enable)
60 {
61 #if ENABLE(DOM_STORAGE)
62 RuntimeEnabledFeatures::setLocalStorageEnabled(enable);
63 #endif
64 }
65
isLocalStorageEnabled()66 bool WebRuntimeFeatures::isLocalStorageEnabled()
67 {
68 #if ENABLE(DOM_STORAGE)
69 return RuntimeEnabledFeatures::localStorageEnabled();
70 #else
71 return false;
72 #endif
73 }
74
enableSessionStorage(bool enable)75 void WebRuntimeFeatures::enableSessionStorage(bool enable)
76 {
77 #if ENABLE(DOM_STORAGE)
78 RuntimeEnabledFeatures::setSessionStorageEnabled(enable);
79 #endif
80 }
81
isSessionStorageEnabled()82 bool WebRuntimeFeatures::isSessionStorageEnabled()
83 {
84 #if ENABLE(DOM_STORAGE)
85 return RuntimeEnabledFeatures::sessionStorageEnabled();
86 #else
87 return false;
88 #endif
89 }
90
enableMediaPlayer(bool enable)91 void WebRuntimeFeatures::enableMediaPlayer(bool enable)
92 {
93 #if ENABLE(VIDEO)
94 WebMediaPlayerClientImpl::setIsEnabled(enable);
95 #endif
96 }
97
isMediaPlayerEnabled()98 bool WebRuntimeFeatures::isMediaPlayerEnabled()
99 {
100 #if ENABLE(VIDEO)
101 return WebMediaPlayerClientImpl::isEnabled();
102 #else
103 return false;
104 #endif
105 }
106
enableSockets(bool enable)107 void WebRuntimeFeatures::enableSockets(bool enable)
108 {
109 #if ENABLE(WEB_SOCKETS)
110 WebSocket::setIsAvailable(enable);
111 #endif
112 }
113
isSocketsEnabled()114 bool WebRuntimeFeatures::isSocketsEnabled()
115 {
116 #if ENABLE(WEB_SOCKETS)
117 return WebSocket::isAvailable();
118 #else
119 return false;
120 #endif
121 }
122
enableNotifications(bool enable)123 void WebRuntimeFeatures::enableNotifications(bool enable)
124 {
125 #if ENABLE(NOTIFICATIONS)
126 RuntimeEnabledFeatures::setWebkitNotificationsEnabled(enable);
127 #endif
128 }
129
isNotificationsEnabled()130 bool WebRuntimeFeatures::isNotificationsEnabled()
131 {
132 #if ENABLE(NOTIFICATIONS)
133 return RuntimeEnabledFeatures::webkitNotificationsEnabled();
134 #else
135 return false;
136 #endif
137 }
138
enableApplicationCache(bool enable)139 void WebRuntimeFeatures::enableApplicationCache(bool enable)
140 {
141 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
142 RuntimeEnabledFeatures::setApplicationCacheEnabled(enable);
143 #endif
144 }
145
isApplicationCacheEnabled()146 bool WebRuntimeFeatures::isApplicationCacheEnabled()
147 {
148 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
149 return RuntimeEnabledFeatures::applicationCacheEnabled();
150 #else
151 return false;
152 #endif
153 }
154
enableDataTransferItems(bool enable)155 void WebRuntimeFeatures::enableDataTransferItems(bool enable)
156 {
157 #if ENABLE(DATA_TRANSFER_ITEMS)
158 RuntimeEnabledFeatures::setDataTransferItemsEnabled(enable);
159 #endif
160 }
161
isDataTransferItemsEnabled()162 bool WebRuntimeFeatures::isDataTransferItemsEnabled()
163 {
164 #if ENABLE(DATA_TRANSFER_ITEMS)
165 return RuntimeEnabledFeatures::dataTransferItemsEnabled();
166 #else
167 return false;
168 #endif
169 }
170
enableGeolocation(bool enable)171 void WebRuntimeFeatures::enableGeolocation(bool enable)
172 {
173 #if ENABLE(GEOLOCATION)
174 RuntimeEnabledFeatures::setGeolocationEnabled(enable);
175 #endif
176 }
177
isGeolocationEnabled()178 bool WebRuntimeFeatures::isGeolocationEnabled()
179 {
180 #if ENABLE(GEOLOCATION)
181 return RuntimeEnabledFeatures::geolocationEnabled();
182 #else
183 return false;
184 #endif
185 }
186
enableIndexedDatabase(bool enable)187 void WebRuntimeFeatures::enableIndexedDatabase(bool enable)
188 {
189 #if ENABLE(INDEXED_DATABASE)
190 RuntimeEnabledFeatures::setWebkitIndexedDBEnabled(enable);
191 #endif
192 }
193
isIndexedDatabaseEnabled()194 bool WebRuntimeFeatures::isIndexedDatabaseEnabled()
195 {
196 #if ENABLE(INDEXED_DATABASE)
197 return RuntimeEnabledFeatures::webkitIndexedDBEnabled();
198 #else
199 return false;
200 #endif
201 }
202
enableWebAudio(bool enable)203 void WebRuntimeFeatures::enableWebAudio(bool enable)
204 {
205 #if ENABLE(WEB_AUDIO)
206 RuntimeEnabledFeatures::setWebkitAudioContextEnabled(enable);
207 #endif
208 }
209
isWebAudioEnabled()210 bool WebRuntimeFeatures::isWebAudioEnabled()
211 {
212 #if ENABLE(WEB_AUDIO)
213 return RuntimeEnabledFeatures::webkitAudioContextEnabled();
214 #else
215 return false;
216 #endif
217 }
218
enablePushState(bool enable)219 void WebRuntimeFeatures::enablePushState(bool enable)
220 {
221 RuntimeEnabledFeatures::setPushStateEnabled(enable);
222 }
223
isPushStateEnabled(bool enable)224 bool WebRuntimeFeatures::isPushStateEnabled(bool enable)
225 {
226 return RuntimeEnabledFeatures::pushStateEnabled();
227 }
228
enableTouch(bool enable)229 void WebRuntimeFeatures::enableTouch(bool enable)
230 {
231 #if ENABLE(TOUCH_EVENTS)
232 RuntimeEnabledFeatures::setTouchEnabled(enable);
233 #endif
234 }
235
isTouchEnabled()236 bool WebRuntimeFeatures::isTouchEnabled()
237 {
238 #if ENABLE(TOUCH_EVENTS)
239 return RuntimeEnabledFeatures::touchEnabled();
240 #else
241 return false;
242 #endif
243 }
244
enableDeviceMotion(bool enable)245 void WebRuntimeFeatures::enableDeviceMotion(bool enable)
246 {
247 RuntimeEnabledFeatures::setDeviceMotionEnabled(enable);
248 }
249
isDeviceMotionEnabled()250 bool WebRuntimeFeatures::isDeviceMotionEnabled()
251 {
252 return RuntimeEnabledFeatures::deviceMotionEnabled();
253 }
254
enableDeviceOrientation(bool enable)255 void WebRuntimeFeatures::enableDeviceOrientation(bool enable)
256 {
257 RuntimeEnabledFeatures::setDeviceOrientationEnabled(enable);
258 }
259
isDeviceOrientationEnabled()260 bool WebRuntimeFeatures::isDeviceOrientationEnabled()
261 {
262 return RuntimeEnabledFeatures::deviceOrientationEnabled();
263 }
264
enableSpeechInput(bool enable)265 void WebRuntimeFeatures::enableSpeechInput(bool enable)
266 {
267 RuntimeEnabledFeatures::setSpeechInputEnabled(enable);
268 }
269
isSpeechInputEnabled()270 bool WebRuntimeFeatures::isSpeechInputEnabled()
271 {
272 return RuntimeEnabledFeatures::speechInputEnabled();
273 }
274
enableXHRResponseBlob(bool enable)275 void WebRuntimeFeatures::enableXHRResponseBlob(bool enable)
276 {
277 #if ENABLE(XHR_RESPONSE_BLOB)
278 RuntimeEnabledFeatures::setXHRResponseBlobEnabled(enable);
279 #endif
280 }
281
isXHRResponseBlobEnabled()282 bool WebRuntimeFeatures::isXHRResponseBlobEnabled()
283 {
284 #if ENABLE(XHR_RESPONSE_BLOB)
285 return RuntimeEnabledFeatures::xhrResponseBlobEnabled();
286 #else
287 return false;
288 #endif
289 }
290
enableFileSystem(bool enable)291 void WebRuntimeFeatures::enableFileSystem(bool enable)
292 {
293 #if ENABLE(FILE_SYSTEM)
294 RuntimeEnabledFeatures::setFileSystemEnabled(enable);
295 #endif
296 }
297
isFileSystemEnabled()298 bool WebRuntimeFeatures::isFileSystemEnabled()
299 {
300 #if ENABLE(FILE_SYSTEM)
301 return RuntimeEnabledFeatures::fileSystemEnabled();
302 #else
303 return false;
304 #endif
305 }
306
enableJavaScriptI18NAPI(bool enable)307 void WebRuntimeFeatures::enableJavaScriptI18NAPI(bool enable)
308 {
309 #if ENABLE(JAVASCRIPT_I18N_API)
310 RuntimeEnabledFeatures::setJavaScriptI18NAPIEnabled(enable);
311 #endif
312 }
313
isJavaScriptI18NAPIEnabled()314 bool WebRuntimeFeatures::isJavaScriptI18NAPIEnabled()
315 {
316 #if ENABLE(JAVASCRIPT_I18N_API)
317 return RuntimeEnabledFeatures::javaScriptI18NAPIEnabled();
318 #else
319 return false;
320 #endif
321 }
322
enableQuota(bool enable)323 void WebRuntimeFeatures::enableQuota(bool enable)
324 {
325 #if ENABLE(QUOTA)
326 RuntimeEnabledFeatures::setQuotaEnabled(enable);
327 #endif
328 }
329
isQuotaEnabled()330 bool WebRuntimeFeatures::isQuotaEnabled()
331 {
332 #if ENABLE(QUOTA)
333 return RuntimeEnabledFeatures::quotaEnabled();
334 #else
335 return false;
336 #endif
337 }
338
339 } // namespace WebKit
340