Add ENABLE_DIALOG_ELEMENT and skeleton files
[WebKit-https.git] / Source / WebKit / chromium / src / WebRuntimeFeatures.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 "WebRuntimeFeatures.h"
33
34 #include "AbstractDatabase.h"
35 #include "RuntimeEnabledFeatures.h"
36 #include "WebMediaPlayerClientImpl.h"
37 #include "Modules/websockets/WebSocket.h"
38
39 #include <wtf/UnusedParam.h>
40
41 using namespace WebCore;
42
43 namespace WebKit {
44
45 void WebRuntimeFeatures::enableDatabase(bool enable)
46 {
47 #if ENABLE(SQL_DATABASE)
48     AbstractDatabase::setIsAvailable(enable);
49 #endif
50 }
51
52 bool WebRuntimeFeatures::isDatabaseEnabled()
53 {
54 #if ENABLE(SQL_DATABASE)
55     return AbstractDatabase::isAvailable();
56 #else
57     return false;
58 #endif
59 }
60
61 // FIXME: Remove the ability to enable this feature at runtime.
62 void WebRuntimeFeatures::enableLocalStorage(bool enable)
63 {
64     RuntimeEnabledFeatures::setLocalStorageEnabled(enable);
65 }
66
67 // FIXME: Remove the ability to enable this feature at runtime.
68 bool WebRuntimeFeatures::isLocalStorageEnabled()
69 {
70     return RuntimeEnabledFeatures::localStorageEnabled();
71 }
72
73 // FIXME: Remove the ability to enable this feature at runtime.
74 void WebRuntimeFeatures::enableSessionStorage(bool enable)
75 {
76     RuntimeEnabledFeatures::setSessionStorageEnabled(enable);
77 }
78
79 // FIXME: Remove the ability to enable this feature at runtime.
80 bool WebRuntimeFeatures::isSessionStorageEnabled()
81 {
82     return RuntimeEnabledFeatures::sessionStorageEnabled();
83 }
84
85 void WebRuntimeFeatures::enableMediaPlayer(bool enable)
86 {
87 #if ENABLE(VIDEO)
88     WebMediaPlayerClientImpl::setIsEnabled(enable);
89 #endif
90 }
91
92 bool WebRuntimeFeatures::isMediaPlayerEnabled()
93 {
94 #if ENABLE(VIDEO)
95     return WebMediaPlayerClientImpl::isEnabled();
96 #else
97     return false;
98 #endif
99 }
100
101 void WebRuntimeFeatures::enableSockets(bool enable)
102 {
103 #if ENABLE(WEB_SOCKETS)
104     WebCore::WebSocket::setIsAvailable(enable);
105 #endif
106 }
107
108 bool WebRuntimeFeatures::isSocketsEnabled()
109 {
110 #if ENABLE(WEB_SOCKETS)
111     return WebSocket::isAvailable();
112 #else
113     return false;
114 #endif
115 }
116
117 void WebRuntimeFeatures::enableNotifications(bool enable)
118 {
119 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
120     RuntimeEnabledFeatures::setWebkitNotificationsEnabled(enable);
121 #endif
122 }
123
124 bool WebRuntimeFeatures::isNotificationsEnabled()
125 {
126 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
127     return RuntimeEnabledFeatures::webkitNotificationsEnabled();
128 #else
129     return false;
130 #endif
131 }
132
133 void WebRuntimeFeatures::enableApplicationCache(bool enable)
134 {
135     RuntimeEnabledFeatures::setApplicationCacheEnabled(enable);
136 }
137
138 bool WebRuntimeFeatures::isApplicationCacheEnabled()
139 {
140     return RuntimeEnabledFeatures::applicationCacheEnabled();
141 }
142
143 void WebRuntimeFeatures::enableDataTransferItems(bool enable)
144 {
145 #if ENABLE(DATA_TRANSFER_ITEMS)
146     RuntimeEnabledFeatures::setDataTransferItemsEnabled(enable);
147 #endif
148 }
149
150 bool WebRuntimeFeatures::isDataTransferItemsEnabled()
151 {
152 #if ENABLE(DATA_TRANSFER_ITEMS)
153     return RuntimeEnabledFeatures::dataTransferItemsEnabled();
154 #else
155     return false;
156 #endif
157 }
158
159 void WebRuntimeFeatures::enableGeolocation(bool enable)
160 {
161 #if ENABLE(GEOLOCATION)
162     RuntimeEnabledFeatures::setGeolocationEnabled(enable);
163 #endif
164 }
165
166 bool WebRuntimeFeatures::isGeolocationEnabled()
167 {
168 #if ENABLE(GEOLOCATION)
169     return RuntimeEnabledFeatures::geolocationEnabled();
170 #else
171     return false;
172 #endif
173 }
174
175 void WebRuntimeFeatures::enableIndexedDatabase(bool enable)
176 {
177 #if ENABLE(INDEXED_DATABASE)
178     RuntimeEnabledFeatures::setWebkitIndexedDBEnabled(enable);
179 #endif
180 }
181
182 bool WebRuntimeFeatures::isIndexedDatabaseEnabled()
183 {
184 #if ENABLE(INDEXED_DATABASE)
185     return RuntimeEnabledFeatures::webkitIndexedDBEnabled();
186 #else
187     return false;
188 #endif
189 }
190
191 void WebRuntimeFeatures::enableWebAudio(bool enable)
192 {
193 #if ENABLE(WEB_AUDIO)
194     RuntimeEnabledFeatures::setWebkitAudioContextEnabled(enable);
195 #endif
196 }
197
198 bool WebRuntimeFeatures::isWebAudioEnabled()
199 {
200 #if ENABLE(WEB_AUDIO)
201     return RuntimeEnabledFeatures::webkitAudioContextEnabled();
202 #else
203     return false;
204 #endif
205 }
206
207 void WebRuntimeFeatures::enablePushState(bool enable)
208 {
209     RuntimeEnabledFeatures::setPushStateEnabled(enable);
210 }
211
212 bool WebRuntimeFeatures::isPushStateEnabled(bool enable)
213 {
214     return RuntimeEnabledFeatures::pushStateEnabled();
215 }
216
217 void WebRuntimeFeatures::enableTouch(bool enable)
218 {
219 #if ENABLE(TOUCH_EVENTS)
220     RuntimeEnabledFeatures::setTouchEnabled(enable);
221 #endif
222 }
223
224 bool WebRuntimeFeatures::isTouchEnabled()
225 {
226 #if ENABLE(TOUCH_EVENTS)
227     return RuntimeEnabledFeatures::touchEnabled();
228 #else
229     return false;
230 #endif
231 }
232
233 void WebRuntimeFeatures::enableDeviceMotion(bool enable)
234 {
235     RuntimeEnabledFeatures::setDeviceMotionEnabled(enable);
236 }
237
238 bool WebRuntimeFeatures::isDeviceMotionEnabled()
239 {
240     return RuntimeEnabledFeatures::deviceMotionEnabled();
241 }
242
243 void WebRuntimeFeatures::enableDeviceOrientation(bool enable)
244 {
245     RuntimeEnabledFeatures::setDeviceOrientationEnabled(enable);
246 }
247
248 bool WebRuntimeFeatures::isDeviceOrientationEnabled()
249 {
250     return RuntimeEnabledFeatures::deviceOrientationEnabled();
251 }
252
253 void WebRuntimeFeatures::enableSpeechInput(bool enable)
254 {
255     RuntimeEnabledFeatures::setSpeechInputEnabled(enable);
256 }
257
258 bool WebRuntimeFeatures::isSpeechInputEnabled()
259 {
260     return RuntimeEnabledFeatures::speechInputEnabled();
261 }
262
263 void WebRuntimeFeatures::enableScriptedSpeech(bool enable)
264 {
265 #if ENABLE(SCRIPTED_SPEECH)
266     RuntimeEnabledFeatures::setScriptedSpeechEnabled(enable);
267 #endif
268 }
269
270 bool WebRuntimeFeatures::isScriptedSpeechEnabled()
271 {
272 #if ENABLE(SCRIPTED_SPEECH)
273     return RuntimeEnabledFeatures::scriptedSpeechEnabled();
274 #else
275     return false;
276 #endif
277 }
278
279 void WebRuntimeFeatures::enableXHRResponseBlob(bool enable)
280 {
281 }
282
283 bool WebRuntimeFeatures::isXHRResponseBlobEnabled()
284 {
285     return true;
286 }
287
288 void WebRuntimeFeatures::enableFileSystem(bool enable)
289 {
290 #if ENABLE(FILE_SYSTEM)
291     RuntimeEnabledFeatures::setFileSystemEnabled(enable);
292 #endif
293 }
294
295 bool WebRuntimeFeatures::isFileSystemEnabled()
296 {
297 #if ENABLE(FILE_SYSTEM)
298     return RuntimeEnabledFeatures::fileSystemEnabled();
299 #else
300     return false;
301 #endif
302 }
303
304 void WebRuntimeFeatures::enableJavaScriptI18NAPI(bool enable)
305 {
306 #if ENABLE(JAVASCRIPT_I18N_API)
307     RuntimeEnabledFeatures::setJavaScriptI18NAPIEnabled(enable);
308 #endif
309 }
310
311 bool WebRuntimeFeatures::isJavaScriptI18NAPIEnabled()
312 {
313 #if ENABLE(JAVASCRIPT_I18N_API)
314     return RuntimeEnabledFeatures::javaScriptI18NAPIEnabled();
315 #else
316     return false;
317 #endif
318 }
319
320 void WebRuntimeFeatures::enableQuota(bool enable)
321 {
322 #if ENABLE(QUOTA)
323     RuntimeEnabledFeatures::setQuotaEnabled(enable);
324 #endif
325 }
326
327 bool WebRuntimeFeatures::isQuotaEnabled()
328 {
329 #if ENABLE(QUOTA)
330     return RuntimeEnabledFeatures::quotaEnabled();
331 #else
332     return false;
333 #endif
334 }
335
336 void WebRuntimeFeatures::enableMediaStream(bool enable)
337 {
338 #if ENABLE(MEDIA_STREAM)
339     RuntimeEnabledFeatures::setMediaStreamEnabled(enable);
340 #else
341     UNUSED_PARAM(enable);
342 #endif
343 }
344
345 bool WebRuntimeFeatures::isMediaStreamEnabled()
346 {
347 #if ENABLE(MEDIA_STREAM)
348     return RuntimeEnabledFeatures::mediaStreamEnabled();
349 #else
350     return false;
351 #endif
352 }
353
354 void WebRuntimeFeatures::enablePeerConnection(bool enable)
355 {
356 #if ENABLE(MEDIA_STREAM)
357     RuntimeEnabledFeatures::setPeerConnectionEnabled(enable);
358 #else
359     UNUSED_PARAM(enable);
360 #endif
361 }
362
363 bool WebRuntimeFeatures::isPeerConnectionEnabled()
364 {
365 #if ENABLE(MEDIA_STREAM)
366     return RuntimeEnabledFeatures::peerConnectionEnabled();
367 #else
368     return false;
369 #endif
370 }
371
372 void WebRuntimeFeatures::enableFullScreenAPI(bool enable)
373 {
374 #if ENABLE(FULLSCREEN_API)
375     RuntimeEnabledFeatures::setWebkitFullScreenAPIEnabled(enable);
376 #else
377     UNUSED_PARAM(enable);
378 #endif
379 }
380
381 bool WebRuntimeFeatures::isFullScreenAPIEnabled()
382 {
383 #if ENABLE(FULLSCREEN_API)
384     return RuntimeEnabledFeatures::webkitFullScreenAPIEnabled();
385 #else
386     return false;
387 #endif
388 }
389
390 void WebRuntimeFeatures::enablePointerLock(bool enable)
391 {
392 #if ENABLE(POINTER_LOCK)
393     RuntimeEnabledFeatures::setPointerLockEnabled(enable);
394 #else
395     UNUSED_PARAM(enable);
396 #endif
397 }
398
399 bool WebRuntimeFeatures::isPointerLockEnabled()
400 {
401 #if ENABLE(POINTER_LOCK)
402     return RuntimeEnabledFeatures::pointerLockEnabled();
403 #else
404     return false;
405 #endif
406 }
407
408 void WebRuntimeFeatures::enableMediaSource(bool enable)
409 {
410 #if ENABLE(MEDIA_SOURCE)
411     RuntimeEnabledFeatures::setMediaSourceEnabled(enable);
412 #else
413     UNUSED_PARAM(enable);
414 #endif
415 }
416
417 bool WebRuntimeFeatures::isMediaSourceEnabled()
418 {
419 #if ENABLE(MEDIA_SOURCE)
420     return RuntimeEnabledFeatures::mediaSourceEnabled();
421 #else
422     return false;
423 #endif
424 }
425
426 void WebRuntimeFeatures::enableEncryptedMedia(bool enable)
427 {
428 #if ENABLE(ENCRYPTED_MEDIA)
429     RuntimeEnabledFeatures::setEncryptedMediaEnabled(enable);
430 #else
431     UNUSED_PARAM(enable);
432 #endif
433 }
434
435 bool WebRuntimeFeatures::isEncryptedMediaEnabled()
436 {
437 #if ENABLE(ENCRYPTED_MEDIA)
438     return RuntimeEnabledFeatures::encryptedMediaEnabled();
439 #else
440     return false;
441 #endif
442 }
443
444 void WebRuntimeFeatures::enableVideoTrack(bool enable)
445 {
446 #if ENABLE(VIDEO_TRACK)
447     RuntimeEnabledFeatures::setWebkitVideoTrackEnabled(enable);
448 #else
449     UNUSED_PARAM(enable);
450 #endif
451 }
452
453 bool WebRuntimeFeatures::isVideoTrackEnabled()
454 {
455 #if ENABLE(VIDEO_TRACK)
456     return RuntimeEnabledFeatures::webkitVideoTrackEnabled();
457 #else
458     return false;
459 #endif
460 }
461
462 void WebRuntimeFeatures::enableGamepad(bool enable)
463 {
464 #if ENABLE(GAMEPAD)
465     RuntimeEnabledFeatures::setWebkitGamepadsEnabled(enable);
466 #else
467     UNUSED_PARAM(enable);
468 #endif
469 }
470
471 bool WebRuntimeFeatures::isGamepadEnabled()
472 {
473 #if ENABLE(GAMEPAD)
474     return RuntimeEnabledFeatures::webkitGamepadsEnabled();
475 #else
476     return false;
477 #endif
478 }
479
480 void WebRuntimeFeatures::enableShadowDOM(bool enable)
481 {
482 #if ENABLE(SHADOW_DOM)
483     RuntimeEnabledFeatures::setShadowDOMEnabled(enable);
484 #else
485     UNUSED_PARAM(enable);
486 #endif
487 }
488
489 bool WebRuntimeFeatures::isShadowDOMEnabled()
490 {
491 #if ENABLE(SHADOW_DOM)
492     return RuntimeEnabledFeatures::shadowDOMEnabled();
493 #else
494     return false;
495 #endif
496 }
497
498 void WebRuntimeFeatures::enableStyleScoped(bool enable)
499 {
500 #if ENABLE(STYLE_SCOPED)
501     RuntimeEnabledFeatures::setStyleScopedEnabled(enable);
502 #else
503     UNUSED_PARAM(enable);
504 #endif
505 }
506
507 bool WebRuntimeFeatures::isStyleScopedEnabled()
508 {
509 #if ENABLE(STYLE_SCOPED)
510     return RuntimeEnabledFeatures::styleScopedEnabled();
511 #else
512     return false;
513 #endif
514 }
515
516 void WebRuntimeFeatures::enableInputTypeDate(bool enable)
517 {
518 #if ENABLE(INPUT_TYPE_DATE)
519     RuntimeEnabledFeatures::setInputTypeDateEnabled(enable);
520 #else
521     UNUSED_PARAM(enable);
522 #endif
523 }
524
525 bool WebRuntimeFeatures::isInputTypeDateEnabled()
526 {
527 #if ENABLE(INPUT_TYPE_DATE)
528     return RuntimeEnabledFeatures::inputTypeDateEnabled();
529 #else
530     return false;
531 #endif
532 }
533
534 void WebRuntimeFeatures::enableDialogElement(bool enable)
535 {
536 #if ENABLE(DIALOG_ELEMENT)
537     RuntimeEnabledFeatures::setDialogElementEnabled(enable);
538 #else
539     UNUSED_PARAM(enable);
540 #endif
541 }
542
543 bool WebRuntimeFeatures::isDialogElementEnabled()
544 {
545 #if ENABLE(DIALOG_ELEMENT)
546     return RuntimeEnabledFeatures::dialogElementEnabled();
547 #else
548     return false;
549 #endif
550 }
551
552
553 } // namespace WebKit