Add settings to control the availability of the Web Audio API to WebKit and WebKit2.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Sep 2011 23:06:42 +0000 (23:06 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Sep 2011 23:06:42 +0000 (23:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68382

Source/WebCore:

Reviewed by Darin Adler.

Only create a AudioContext object if the Web Audio feature is runtime-enabled in Settings.

No new tests, as this feature is not yet enabled by default.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::webkitAudioContext):

Source/WebKit/mac:

Reviewed by Darin Adler.

Initialize the webAudioEnabled preference to NO by default.

* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):

Source/WebKit2:

Add support for the webAudioEnabled preference in WebKit2.

Reviewed by Darin Adler.

* Shared/WebPreferencesStore.h: Add WebAudioEnabled getter and setter macro.
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetWebAudioEnabled): Added.
(WKPreferencesGetWebAudioEnabled): Added.
* UIProcess/API/C/WKPreferences.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences): Update the webAudioEnabled preference.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@95678 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferences.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index fa4eb8a..bf3c4cb 100644 (file)
@@ -1,3 +1,17 @@
+2011-09-19  Jer Noble  <jer.noble@apple.com>
+
+        Add settings to control the availability of the Web Audio API to WebKit and WebKit2.
+        https://bugs.webkit.org/show_bug.cgi?id=68382
+
+        Reviewed by Darin Adler.
+
+        Only create a AudioContext object if the Web Audio feature is runtime-enabled in Settings.
+
+        No new tests, as this feature is not yet enabled by default.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::JSDOMWindow::webkitAudioContext):
+
 2011-09-21  Anders Carlsson  <andersca@apple.com>
 
         Remove checks for Leopard-only Objective-C APIs
index cb41dbc..477c6bc 100644 (file)
@@ -601,21 +601,30 @@ JSValue JSDOMWindow::sharedWorker(ExecState* exec) const
 }
 #endif
 
+#if ENABLE(WEB_AUDIO) || ENABLE(WEB_SOCKETS)
+static Settings* settingsForWindow(const JSDOMWindow* window)
+{
+    ASSERT(window);
+    if (Frame* frame = window->impl()->frame())
+        return frame->settings();
+    return 0;
+}
+#endif
+
 #if ENABLE(WEB_AUDIO)
 JSValue JSDOMWindow::webkitAudioContext(ExecState* exec) const
 {
-    return getDOMConstructor<JSAudioContextConstructor>(exec, this);
+    Settings* settings = settingsForWindow(this);
+    if (settings && settings->webAudioEnabled())
+        return getDOMConstructor<JSAudioContextConstructor>(exec, this);
+    return jsUndefined();
 }
 #endif
 
 #if ENABLE(WEB_SOCKETS)
 JSValue JSDOMWindow::webSocket(ExecState* exec) const
 {
-    Frame* frame = impl()->frame();
-    if (!frame)
-        return jsUndefined();
-    Settings* settings = frame->settings();
-    if (!settings)
+    if (!settingsForWindow(this))
         return jsUndefined();
     return getDOMConstructor<JSWebSocketConstructor>(exec, this);
 }
index bae88ea..7757792 100644 (file)
@@ -1,3 +1,15 @@
+2011-09-19  Jer Noble  <jer.noble@apple.com>
+
+        Add settings to control the availability of the Web Audio API to WebKit and WebKit2.
+        https://bugs.webkit.org/show_bug.cgi?id=68382
+
+        Reviewed by Darin Adler.
+
+        Initialize the webAudioEnabled preference to NO by default.
+
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+
 2011-09-21  Anders Carlsson  <andersca@apple.com>
 
         Remove checks for Leopard-only Objective-C APIs
index 91cad16..7a16c4f 100644 (file)
@@ -384,6 +384,7 @@ static WebCacheModel cacheModelForMainBundle(void)
         [NSNumber numberWithBool:YES],  WebKitHixie76WebSocketProtocolEnabledKey,
         [NSNumber numberWithBool:NO],   WebKitMediaPlaybackRequiresUserGesturePreferenceKey,
         [NSNumber numberWithBool:YES],  WebKitMediaPlaybackAllowsInlinePreferenceKey,
+        [NSNumber numberWithBool:NO],   WebKitWebAudioEnabledPreferenceKey,
 
         [NSNumber numberWithLongLong:ApplicationCacheStorage::noQuota()], WebKitApplicationCacheTotalQuota,
         [NSNumber numberWithLongLong:ApplicationCacheStorage::noQuota()], WebKitApplicationCacheDefaultOriginQuota,
index c881ba8..ecbdc6b 100644 (file)
@@ -1,3 +1,20 @@
+2011-09-19  Jer Noble  <jer.noble@apple.com>
+
+        Add settings to control the availability of the Web Audio API to WebKit and WebKit2.
+        https://bugs.webkit.org/show_bug.cgi?id=68382
+
+        Add support for the webAudioEnabled preference in WebKit2.
+
+        Reviewed by Darin Adler.
+
+        * Shared/WebPreferencesStore.h: Add WebAudioEnabled getter and setter macro.
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetWebAudioEnabled): Added.
+        (WKPreferencesGetWebAudioEnabled): Added.
+        * UIProcess/API/C/WKPreferences.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences): Update the webAudioEnabled preference.
+
 2011-09-21  Dan Bernstein  <mitz@apple.com>
 
         Use the prefix "WK" instead of "Web" for Objective-C classes defined in WebKit2.
index 16c51ee..2ac9ad7 100644 (file)
@@ -93,6 +93,7 @@ namespace WebKit {
     macro(InspectorStartsAttached, inspectorStartsAttached, Bool, bool, true) \
     macro(ShowsToolTipOverTruncatedText, showsToolTipOverTruncatedText, Bool, bool, false) \
     macro(MockScrollbarsEnabled, mockScrollbarsEnabled, Bool, bool, false) \
+    macro(WebAudioEnabled, webAudioEnabled, Bool, bool, false) \
     \
 
 #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
index 822cb54..d2158ce 100644 (file)
@@ -621,3 +621,13 @@ bool WKPreferencesGetMockScrollbarsEnabled(WKPreferencesRef preferencesRef)
 {
     return toImpl(preferencesRef)->mockScrollbarsEnabled();
 }
+
+void WKPreferencesSetWebAudioEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+    toImpl(preferencesRef)->setWebAudioEnabled(enabled);
+}
+
+bool WKPreferencesGetWebAudioEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->webAudioEnabled();
+}
index a336109..315bf6b 100644 (file)
@@ -165,6 +165,10 @@ WK_EXPORT bool WKPreferencesGetFullScreenEnabled(WKPreferencesRef preferencesRef
 WK_EXPORT void WKPreferencesSetAVFoundationEnabled(WKPreferencesRef preferencesRef, bool enabled);
 WK_EXPORT bool WKPreferencesGetAVFoundationEnabled(WKPreferencesRef preferencesRef);
 
+// Defaults to false
+WK_EXPORT void WKPreferencesSetWebAudioEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetWebAudioEnabled(WKPreferencesRef preferencesRef);
+
 #ifdef __cplusplus
 }
 #endif
index a3a9b2a..a1f00ae 100644 (file)
@@ -1624,6 +1624,10 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     settings->setUseHixie76WebSocketProtocol(store.getBoolValueForKey(WebPreferencesKey::hixie76WebSocketProtocolEnabledKey()));
 #endif
 
+#if ENABLE(WEB_AUDIO)
+    settings->setWebAudioEnabled(store.getBoolValueForKey(WebPreferencesKey::webAudioEnabledKey()));
+#endif
+
     platformPreferencesDidChange(store);
 }