diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 06:42:01 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 06:42:01 +0000 |
commit | b1b1321e783506c11e306469179e8ae4830219d1 (patch) | |
tree | 5d744435b42d44224a2f9367ef0d4faba22dd4f5 /webkit | |
parent | 3a075e1fe68e5b79607e4a39d68f0256671d92d1 (diff) | |
download | chromium_src-b1b1321e783506c11e306469179e8ae4830219d1.zip chromium_src-b1b1321e783506c11e306469179e8ae4830219d1.tar.gz chromium_src-b1b1321e783506c11e306469179e8ae4830219d1.tar.bz2 |
Move various runtime enabled features into a WebRuntimeFeatures class.
There are separate functions to set/test each feature.
R=jorlow
BUG=25286
TEST=none
Review URL: http://codereview.chromium.org/343001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30564 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/api/public/WebKit.h | 11 | ||||
-rw-r--r-- | webkit/api/public/WebRuntimeFeatures.h | 65 | ||||
-rw-r--r-- | webkit/api/src/WebKit.cpp | 37 | ||||
-rw-r--r-- | webkit/api/src/WebMediaPlayerClientImpl.cpp | 11 | ||||
-rw-r--r-- | webkit/api/src/WebMediaPlayerClientImpl.h | 2 | ||||
-rw-r--r-- | webkit/api/src/WebRuntimeFeatures.cpp | 122 | ||||
-rw-r--r-- | webkit/glue/webpreferences.cc | 5 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_webkit_init.h | 10 | ||||
-rw-r--r-- | webkit/webkit.gyp | 3 |
9 files changed, 208 insertions, 58 deletions
diff --git a/webkit/api/public/WebKit.h b/webkit/api/public/WebKit.h index 3be1abe5..808e537 100644 --- a/webkit/api/public/WebKit.h +++ b/webkit/api/public/WebKit.h @@ -54,21 +54,10 @@ namespace WebKit { WEBKIT_API void setLayoutTestMode(bool); WEBKIT_API bool layoutTestMode(); - // Enables HTML5 media support. - WEBKIT_API void enableMediaPlayer(); - // Purge the plugin list cache. If |reloadPages| is true, any pages // containing plugins will be reloaded after refreshing the plugin list. WEBKIT_API void resetPluginCache(bool reloadPages); - // Enables HTML5 database support. - WEBKIT_API void enableDatabases(); - WEBKIT_API bool databasesEnabled(); - - // Enables HTML5 Web Sockets support. - WEBKIT_API void enableWebSockets(); - WEBKIT_API bool webSocketsEnabled(); - } // namespace WebKit #endif diff --git a/webkit/api/public/WebRuntimeFeatures.h b/webkit/api/public/WebRuntimeFeatures.h new file mode 100644 index 0000000..110665e --- /dev/null +++ b/webkit/api/public/WebRuntimeFeatures.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebRuntimeFeatures_h +#define WebRuntimeFeatures_h + +#include "WebCommon.h" + +namespace WebKit { + +// This class is used to enable runtime features of WebKit. It is unspecified +// whether a feature is enabled by default. In the future, a feature may be +// promoted from disabled by default to enabled by default once it reaches a +// certain level of maturity. +class WebRuntimeFeatures { +public: + WEBKIT_API static void enableDatabase(bool); + WEBKIT_API static bool isDatabaseEnabled(); + + WEBKIT_API static void enableLocalStorage(bool); + WEBKIT_API static bool isLocalStorageEnabled(); + + WEBKIT_API static void enableSessionStorage(bool); + WEBKIT_API static bool isSessionStorageEnabled(); + + WEBKIT_API static void enableMediaPlayer(bool); + WEBKIT_API static bool isMediaPlayerEnabled(); + + WEBKIT_API static void enableSockets(bool); + WEBKIT_API static bool isSocketsEnabled(); + +private: + WebRuntimeFeatures(); +}; + +} // namespace WebKit + +#endif diff --git a/webkit/api/src/WebKit.cpp b/webkit/api/src/WebKit.cpp index d5a9d3b..45af097 100644 --- a/webkit/api/src/WebKit.cpp +++ b/webkit/api/src/WebKit.cpp @@ -47,7 +47,6 @@ namespace WebKit { static WebKitClient* s_webKitClient = 0; static bool s_layoutTestMode = false; -static bool s_databasesEnabled = false; void initialize(WebKitClient* webKitClient) { @@ -95,45 +94,9 @@ bool layoutTestMode() return s_layoutTestMode; } -void enableMediaPlayer() -{ -#if ENABLE(VIDEO) - WebMediaPlayerClientImpl::setIsEnabled(true); -#endif -} - void resetPluginCache(bool reloadPages) { WebCore::Page::refreshPlugins(reloadPages); } -void enableDatabases() -{ -#if ENABLE(DATABASE) - s_databasesEnabled = true; - WebCore::RuntimeEnabledFeatures::setDatabaseEnabled(true); -#endif -} - -bool databasesEnabled() -{ - return s_databasesEnabled; -} - -void enableWebSockets() -{ -#if ENABLE(WEB_SOCKETS) - WebCore::WebSocket::setIsAvailable(true); -#endif -} - -bool webSocketsEnabled() -{ -#if ENABLE(WEB_SOCKETS) - return WebCore::WebSocket::isAvailable(); -#else - return false; -#endif -} - } // namespace WebKit diff --git a/webkit/api/src/WebMediaPlayerClientImpl.cpp b/webkit/api/src/WebMediaPlayerClientImpl.cpp index c7d6d3b..f0076e8 100644 --- a/webkit/api/src/WebMediaPlayerClientImpl.cpp +++ b/webkit/api/src/WebMediaPlayerClientImpl.cpp @@ -37,16 +37,21 @@ using namespace WebCore; namespace WebKit { -static bool s_isEnabled = false; +bool WebMediaPlayerClientImpl::m_isEnabled = false; + +bool WebMediaPlayerClientImpl::isEnabled() +{ + return m_isEnabled; +} void WebMediaPlayerClientImpl::setIsEnabled(bool isEnabled) { - s_isEnabled = isEnabled; + m_isEnabled = isEnabled; } void WebMediaPlayerClientImpl::registerSelf(MediaEngineRegistrar registrar) { - if (s_isEnabled) { + if (m_isEnabled) { registrar(WebMediaPlayerClientImpl::create, WebMediaPlayerClientImpl::getSupportedTypes, WebMediaPlayerClientImpl::supportsType); diff --git a/webkit/api/src/WebMediaPlayerClientImpl.h b/webkit/api/src/WebMediaPlayerClientImpl.h index 075a710..9793477 100644 --- a/webkit/api/src/WebMediaPlayerClientImpl.h +++ b/webkit/api/src/WebMediaPlayerClientImpl.h @@ -46,6 +46,7 @@ namespace WebKit { class WebMediaPlayerClientImpl : public WebMediaPlayerClient , public WebCore::MediaPlayerPrivateInterface { public: + static bool isEnabled(); static void setIsEnabled(bool); static void registerSelf(WebCore::MediaEngineRegistrar); @@ -103,6 +104,7 @@ namespace WebKit { WebCore::MediaPlayer* m_mediaPlayer; OwnPtr<WebMediaPlayer> m_webMediaPlayer; + static bool m_isEnabled; }; } // namespace WebKit diff --git a/webkit/api/src/WebRuntimeFeatures.cpp b/webkit/api/src/WebRuntimeFeatures.cpp new file mode 100644 index 0000000..fb51928 --- /dev/null +++ b/webkit/api/src/WebRuntimeFeatures.cpp @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebRuntimeFeatures.h" + +#include "RuntimeEnabledFeatures.h" +#include "WebMediaPlayerClientImpl.h" +#include "WebSocket.h" + +using namespace WebCore; + +namespace WebKit { + +void WebRuntimeFeatures::enableDatabase(bool enable) +{ +#if ENABLE(DATABASE) + RuntimeEnabledFeatures::setDatabaseEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isDatabaseEnabled() +{ +#if ENABLE(DATABASE) + return RuntimeEnabledFeatures::databaseEnabled(); +#else + return false; +#endif +} + +void WebRuntimeFeatures::enableLocalStorage(bool enable) +{ +#if ENABLE(DOM_STORAGE) + RuntimeEnabledFeatures::setLocalStorageEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isLocalStorageEnabled() +{ +#if ENABLE(DOM_STORAGE) + return RuntimeEnabledFeatures::localStorageEnabled(); +#else + return false; +#endif +} + +void WebRuntimeFeatures::enableSessionStorage(bool enable) +{ +#if ENABLE(DOM_STORAGE) + RuntimeEnabledFeatures::setSessionStorageEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isSessionStorageEnabled() +{ +#if ENABLE(DOM_STORAGE) + return RuntimeEnabledFeatures::sessionStorageEnabled(); +#else + return false; +#endif +} + +void WebRuntimeFeatures::enableMediaPlayer(bool enable) +{ +#if ENABLE(VIDEO) + WebMediaPlayerClientImpl::setIsEnabled(enable); +#endif +} + +bool WebRuntimeFeatures::isMediaPlayerEnabled() +{ +#if ENABLE(VIDEO) + return WebMediaPlayerClientImpl::isEnabled(); +#else + return false; +#endif +} + +void WebRuntimeFeatures::enableSockets(bool enable) +{ +#if ENABLE(WEB_SOCKETS) + WebSocket::setIsAvailable(enable); +#endif +} + +bool WebRuntimeFeatures::isSocketsEnabled() +{ +#if ENABLE(WEB_SOCKETS) + return WebSocket::isAvailable(); +#else + return false; +#endif +} + +} // namespace WebKit diff --git a/webkit/glue/webpreferences.cc b/webkit/glue/webpreferences.cc index cdb7260..0f17804 100644 --- a/webkit/glue/webpreferences.cc +++ b/webkit/glue/webpreferences.cc @@ -5,6 +5,7 @@ #include "webkit/glue/webpreferences.h" #include "base/string_util.h" +#include "webkit/api/public/WebRuntimeFeatures.h" #include "webkit/api/public/WebKit.h" #include "webkit/api/public/WebSettings.h" #include "webkit/api/public/WebString.h" @@ -12,6 +13,7 @@ #include "webkit/api/public/WebView.h" #include "webkit/glue/webkit_glue.h" +using WebKit::WebRuntimeFeatures; using WebKit::WebSettings; using WebKit::WebString; using WebKit::WebURL; @@ -50,7 +52,8 @@ void WebPreferences::Apply(WebView* web_view) const { settings->setDownloadableBinaryFontsEnabled(remote_fonts_enabled); settings->setXSSAuditorEnabled(xss_auditor_enabled); settings->setLocalStorageEnabled(local_storage_enabled); - settings->setDatabasesEnabled(WebKit::databasesEnabled() || databases_enabled); + settings->setDatabasesEnabled( + WebRuntimeFeatures::isDatabaseEnabled() || databases_enabled); settings->setSessionStorageEnabled(session_storage_enabled); settings->setOfflineWebApplicationCacheEnabled(application_cache_enabled); settings->setExperimentalNotificationsEnabled( diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h index 4ec7c55..9a4f053 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -12,6 +12,7 @@ #include "base/string_util.h" #include "media/base/media.h" #include "webkit/api/public/WebData.h" +#include "webkit/api/public/WebRuntimeFeatures.h" #include "webkit/api/public/WebKit.h" #include "webkit/api/public/WebScriptController.h" #include "webkit/api/public/WebSecurityPolicy.h" @@ -55,14 +56,13 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { extensions_v8::GearsExtension::Get()); WebKit::WebScriptController::registerExtension( extensions_v8::IntervalExtension::Get()); - WebKit::enableWebSockets(); + WebKit::WebRuntimeFeatures::enableSockets(true); // Load libraries for media and enable the media player. FilePath module_path; - if (PathService::Get(base::DIR_MODULE, &module_path) && - media::InitializeMediaLibrary(module_path)) { - WebKit::enableMediaPlayer(); - } + WebKit::WebRuntimeFeatures::enableMediaPlayer( + PathService::Get(base::DIR_MODULE, &module_path) && + media::InitializeMediaLibrary(module_path)); // Construct and initialize an appcache system for this scope. // A new empty temp directory is created to house any cached diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 39d8fa3..46ee1b8 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -136,6 +136,7 @@ 'api/public/WebPopupMenuInfo.h', 'api/public/WebRange.h', 'api/public/WebRect.h', + 'api/public/WebRuntimeFeatures.h', 'api/public/WebScreenInfo.h', 'api/public/WebScriptController.h', 'api/public/WebScriptSource.h', @@ -231,7 +232,6 @@ 'api/src/WebDataSourceImpl.cpp', 'api/src/WebDataSourceImpl.h', 'api/src/WebDragData.cpp', - 'api/src/WebKit.cpp', 'api/src/WebFileChooserCompletionImpl.cpp', 'api/src/WebFileChooserCompletionImpl.h', 'api/src/WebFontCache.cpp', @@ -259,6 +259,7 @@ 'api/src/WebPopupMenuImpl.cpp', 'api/src/WebPopupMenuImpl.h', 'api/src/WebRange.cpp', + 'api/src/WebRuntimeFeatures.cpp', 'api/src/WebScriptController.cpp', 'api/src/WebSearchableFormData.cpp', 'api/src/WebSecurityOrigin.cpp', |