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