1 /* 2 * Copyright (C) 2013 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 "RuntimeEnabledFeatures.h" 35 #include "WebMediaPlayerClientImpl.h" 36 37 using namespace WebCore; 38 39 namespace WebKit { 40 41 void WebRuntimeFeatures::enableStableFeatures(bool enable) 42 { 43 RuntimeEnabledFeatures::setStableFeaturesEnabled(enable); 44 // FIXME: enableMediaPlayer does not use RuntimeEnabledFeatures 45 // and does not belong as part of WebRuntimeFeatures. 46 enableMediaPlayer(enable); 47 } 48 49 void WebRuntimeFeatures::enableExperimentalFeatures(bool enable) 50 { 51 RuntimeEnabledFeatures::setExperimentalFeaturesEnabled(enable); 52 } 53 54 void WebRuntimeFeatures::enableTestOnlyFeatures(bool enable) 55 { 56 RuntimeEnabledFeatures::setTestFeaturesEnabled(enable); 57 } 58 59 void WebRuntimeFeatures::enableApplicationCache(bool enable) 60 { 61 RuntimeEnabledFeatures::setApplicationCacheEnabled(enable); 62 } 63 64 bool WebRuntimeFeatures::isApplicationCacheEnabled() 65 { 66 return RuntimeEnabledFeatures::applicationCacheEnabled(); 67 } 68 69 void WebRuntimeFeatures::enableDatabase(bool enable) 70 { 71 RuntimeEnabledFeatures::setDatabaseEnabled(enable); 72 } 73 74 bool WebRuntimeFeatures::isDatabaseEnabled() 75 { 76 return RuntimeEnabledFeatures::databaseEnabled(); 77 } 78 79 void WebRuntimeFeatures::enableDeviceMotion(bool enable) 80 { 81 RuntimeEnabledFeatures::setDeviceMotionEnabled(enable); 82 } 83 84 bool WebRuntimeFeatures::isDeviceMotionEnabled() 85 { 86 return RuntimeEnabledFeatures::deviceMotionEnabled(); 87 } 88 89 void WebRuntimeFeatures::enableDeviceOrientation(bool enable) 90 { 91 RuntimeEnabledFeatures::setDeviceOrientationEnabled(enable); 92 } 93 94 bool WebRuntimeFeatures::isDeviceOrientationEnabled() 95 { 96 return RuntimeEnabledFeatures::deviceOrientationEnabled(); 97 } 98 99 void WebRuntimeFeatures::enableEncryptedMedia(bool enable) 100 { 101 RuntimeEnabledFeatures::setEncryptedMediaEnabled(enable); 102 // FIXME: Hack to allow MediaKeyError to be enabled for either version. 103 RuntimeEnabledFeatures::setEncryptedMediaAnyVersionEnabled( 104 RuntimeEnabledFeatures::encryptedMediaEnabled() 105 || RuntimeEnabledFeatures::legacyEncryptedMediaEnabled()); 106 } 107 108 bool WebRuntimeFeatures::isEncryptedMediaEnabled() 109 { 110 return RuntimeEnabledFeatures::encryptedMediaEnabled(); 111 } 112 113 void WebRuntimeFeatures::enableLegacyEncryptedMedia(bool enable) 114 { 115 RuntimeEnabledFeatures::setLegacyEncryptedMediaEnabled(enable); 116 // FIXME: Hack to allow MediaKeyError to be enabled for either version. 117 RuntimeEnabledFeatures::setEncryptedMediaAnyVersionEnabled( 118 RuntimeEnabledFeatures::encryptedMediaEnabled() 119 || RuntimeEnabledFeatures::legacyEncryptedMediaEnabled()); 120 } 121 122 bool WebRuntimeFeatures::isLegacyEncryptedMediaEnabled() 123 { 124 return RuntimeEnabledFeatures::legacyEncryptedMediaEnabled(); 125 } 126 127 void WebRuntimeFeatures::enableExperimentalCanvasFeatures(bool enable) 128 { 129 RuntimeEnabledFeatures::setExperimentalCanvasFeaturesEnabled(enable); 130 } 131 132 bool WebRuntimeFeatures::isExperimentalCanvasFeaturesEnabled() 133 { 134 return RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled(); 135 } 136 137 void WebRuntimeFeatures::enableFileSystem(bool enable) 138 { 139 RuntimeEnabledFeatures::setFileSystemEnabled(enable); 140 } 141 142 bool WebRuntimeFeatures::isFileSystemEnabled() 143 { 144 return RuntimeEnabledFeatures::fileSystemEnabled(); 145 } 146 147 void WebRuntimeFeatures::enableFullscreen(bool enable) 148 { 149 RuntimeEnabledFeatures::setFullscreenEnabled(enable); 150 } 151 152 bool WebRuntimeFeatures::isFullscreenEnabled() 153 { 154 return RuntimeEnabledFeatures::fullscreenEnabled(); 155 } 156 157 void WebRuntimeFeatures::enableGamepad(bool enable) 158 { 159 RuntimeEnabledFeatures::setGamepadEnabled(enable); 160 } 161 162 bool WebRuntimeFeatures::isGamepadEnabled() 163 { 164 return RuntimeEnabledFeatures::gamepadEnabled(); 165 } 166 167 void WebRuntimeFeatures::enableGeolocation(bool enable) 168 { 169 RuntimeEnabledFeatures::setGeolocationEnabled(enable); 170 } 171 172 bool WebRuntimeFeatures::isGeolocationEnabled() 173 { 174 return RuntimeEnabledFeatures::geolocationEnabled(); 175 } 176 177 void WebRuntimeFeatures::enableLazyLayout(bool enable) 178 { 179 RuntimeEnabledFeatures::setLazyLayoutEnabled(enable); 180 } 181 182 bool WebRuntimeFeatures::isLazyLayoutEnabled() 183 { 184 return RuntimeEnabledFeatures::lazyLayoutEnabled(); 185 } 186 187 void WebRuntimeFeatures::enableLocalStorage(bool enable) 188 { 189 RuntimeEnabledFeatures::setLocalStorageEnabled(enable); 190 } 191 192 bool WebRuntimeFeatures::isLocalStorageEnabled() 193 { 194 return RuntimeEnabledFeatures::localStorageEnabled(); 195 } 196 197 void WebRuntimeFeatures::enableMediaPlayer(bool enable) 198 { 199 RuntimeEnabledFeatures::setMediaEnabled(enable); 200 } 201 202 bool WebRuntimeFeatures::isMediaPlayerEnabled() 203 { 204 return RuntimeEnabledFeatures::mediaEnabled(); 205 } 206 207 void WebRuntimeFeatures::enableWebKitMediaSource(bool enable) 208 { 209 RuntimeEnabledFeatures::setWebKitMediaSourceEnabled(enable); 210 } 211 212 bool WebRuntimeFeatures::isWebKitMediaSourceEnabled() 213 { 214 return RuntimeEnabledFeatures::webKitMediaSourceEnabled(); 215 } 216 217 void WebRuntimeFeatures::enableMediaStream(bool enable) 218 { 219 RuntimeEnabledFeatures::setMediaStreamEnabled(enable); 220 } 221 222 bool WebRuntimeFeatures::isMediaStreamEnabled() 223 { 224 return RuntimeEnabledFeatures::mediaStreamEnabled(); 225 } 226 227 void WebRuntimeFeatures::enableNotifications(bool enable) 228 { 229 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) 230 RuntimeEnabledFeatures::setNotificationsEnabled(enable); 231 #endif 232 } 233 234 bool WebRuntimeFeatures::isNotificationsEnabled() 235 { 236 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) 237 return RuntimeEnabledFeatures::notificationsEnabled(); 238 #else 239 return false; 240 #endif 241 } 242 243 void WebRuntimeFeatures::enablePagePopup(bool enable) 244 { 245 RuntimeEnabledFeatures::setPagePopupEnabled(enable); 246 } 247 248 bool WebRuntimeFeatures::isPagePopupEnabled() 249 { 250 return RuntimeEnabledFeatures::pagePopupEnabled(); 251 } 252 253 void WebRuntimeFeatures::enablePeerConnection(bool enable) 254 { 255 RuntimeEnabledFeatures::setPeerConnectionEnabled(enable); 256 } 257 258 bool WebRuntimeFeatures::isPeerConnectionEnabled() 259 { 260 return RuntimeEnabledFeatures::peerConnectionEnabled(); 261 } 262 263 void WebRuntimeFeatures::enableRequestAutocomplete(bool enable) 264 { 265 RuntimeEnabledFeatures::setRequestAutocompleteEnabled(enable); 266 } 267 268 bool WebRuntimeFeatures::isRequestAutocompleteEnabled() 269 { 270 return RuntimeEnabledFeatures::requestAutocompleteEnabled(); 271 } 272 273 void WebRuntimeFeatures::enableScriptedSpeech(bool enable) 274 { 275 RuntimeEnabledFeatures::setScriptedSpeechEnabled(enable); 276 } 277 278 bool WebRuntimeFeatures::isScriptedSpeechEnabled() 279 { 280 return RuntimeEnabledFeatures::scriptedSpeechEnabled(); 281 } 282 283 void WebRuntimeFeatures::enableSessionStorage(bool enable) 284 { 285 RuntimeEnabledFeatures::setSessionStorageEnabled(enable); 286 } 287 288 bool WebRuntimeFeatures::isSessionStorageEnabled() 289 { 290 return RuntimeEnabledFeatures::sessionStorageEnabled(); 291 } 292 293 void WebRuntimeFeatures::enableSpeechInput(bool enable) 294 { 295 RuntimeEnabledFeatures::setSpeechInputEnabled(enable); 296 } 297 298 bool WebRuntimeFeatures::isSpeechInputEnabled() 299 { 300 return RuntimeEnabledFeatures::speechInputEnabled(); 301 } 302 303 void WebRuntimeFeatures::enableSpeechSynthesis(bool enable) 304 { 305 RuntimeEnabledFeatures::setSpeechSynthesisEnabled(enable); 306 } 307 308 bool WebRuntimeFeatures::isSpeechSynthesisEnabled() 309 { 310 return RuntimeEnabledFeatures::speechSynthesisEnabled(); 311 } 312 313 void WebRuntimeFeatures::enableTouch(bool enable) 314 { 315 RuntimeEnabledFeatures::setTouchEnabled(enable); 316 } 317 318 bool WebRuntimeFeatures::isTouchEnabled() 319 { 320 return RuntimeEnabledFeatures::touchEnabled(); 321 } 322 323 void WebRuntimeFeatures::enableWebAnimationsCSS() 324 { 325 RuntimeEnabledFeatures::setWebAnimationsEnabled(true); 326 RuntimeEnabledFeatures::setWebAnimationsCSSEnabled(true); 327 } 328 329 void WebRuntimeFeatures::enableWebAnimationsSVG() 330 { 331 RuntimeEnabledFeatures::setWebAnimationsEnabled(true); 332 RuntimeEnabledFeatures::setWebAnimationsSVGEnabled(true); 333 } 334 335 void WebRuntimeFeatures::enableWebAudio(bool enable) 336 { 337 RuntimeEnabledFeatures::setWebAudioEnabled(enable); 338 } 339 340 bool WebRuntimeFeatures::isWebAudioEnabled() 341 { 342 return RuntimeEnabledFeatures::webAudioEnabled(); 343 } 344 345 void WebRuntimeFeatures::enableWebGLDraftExtensions(bool enable) 346 { 347 RuntimeEnabledFeatures::setWebGLDraftExtensionsEnabled(enable); 348 } 349 350 bool WebRuntimeFeatures::isWebGLDraftExtensionsEnabled() 351 { 352 return RuntimeEnabledFeatures::webGLDraftExtensionsEnabled(); 353 } 354 355 void WebRuntimeFeatures::enableWebMIDI(bool enable) 356 { 357 return RuntimeEnabledFeatures::setWebMIDIEnabled(enable); 358 } 359 360 bool WebRuntimeFeatures::isWebMIDIEnabled() 361 { 362 return RuntimeEnabledFeatures::webMIDIEnabled(); 363 } 364 365 void WebRuntimeFeatures::enableDataListElement(bool enable) 366 { 367 RuntimeEnabledFeatures::setDataListElementEnabled(enable); 368 } 369 370 bool WebRuntimeFeatures::isDataListElementEnabled() 371 { 372 return RuntimeEnabledFeatures::dataListElementEnabled(); 373 } 374 375 void WebRuntimeFeatures::enableHTMLImports(bool enable) 376 { 377 RuntimeEnabledFeatures::setHTMLImportsEnabled(enable); 378 } 379 380 bool WebRuntimeFeatures::isHTMLImportsEnabled() 381 { 382 return RuntimeEnabledFeatures::htmlImportsEnabled(); 383 } 384 385 // FIXME: Remove this when embedders switch to enableEmbedderCustomElements. 386 void WebRuntimeFeatures::enableCustomElements(bool enable) 387 { 388 RuntimeEnabledFeatures::setCustomDOMElementsEnabled(enable); 389 enableEmbedderCustomElements(enable); 390 } 391 392 void WebRuntimeFeatures::enableEmbedderCustomElements(bool enable) 393 { 394 RuntimeEnabledFeatures::setEmbedderCustomElementsEnabled(enable); 395 } 396 397 void WebRuntimeFeatures::enableOverlayScrollbars(bool enable) 398 { 399 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(enable); 400 } 401 402 } // namespace WebKit 403