Diff
Modified: trunk/Source/WebKit2/ChangeLog (177495 => 177496)
--- trunk/Source/WebKit2/ChangeLog 2014-12-18 14:41:44 UTC (rev 177495)
+++ trunk/Source/WebKit2/ChangeLog 2014-12-18 14:57:36 UTC (rev 177496)
@@ -1,3 +1,31 @@
+2014-12-18 Adrian Perez de Castro <[email protected]>
+
+ [GTK] Implement webkit_web_view_is_playing_audio()
+ https://bugs.webkit.org/show_bug.cgi?id=138918
+
+ Reviewed by Carlos Garcia Campos.
+
+ Implements webkit_web_view_is_playing_audio(), and overrides
+ UIClient::isPlayingAudioDidChange() to be able to emit change
+ notification signals for the new WebKitWebView::is-playing-audio
+ property.
+
+ * UIProcess/API/gtk/WebKitUIClient.cpp:
+ (isPlayingAudioDidChange): Added.
+ * UIProcess/API/gtk/WebKitWebView.cpp:
+ (webkitWebViewIsPlayingAudioChanged): Helper function to emit the
+ emit the notify::is-playing-audio signal when needed.
+ (webkitWebViewGetProperty): Handle the WebKitWebView::is-playing-audio
+ property.
+ (webkit_web_view_class_init): Install the
+ WebKitWebView::is-playing-audio property.
+ (webkit_web_view_is_playing_audio): Added.
+ * UIProcess/API/gtk/WebKitWebView.h:
+ * UIProcess/API/gtk/WebKitWebViewPrivate.h:
+ * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add
+ webkit_web_view_is_playing_audio() to the list of public API
+ functions.
+
2014-12-18 Carlos Garcia Campos <[email protected]>
[GTK] Allow to build with ENABLE_NETWORK_CACHE
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp (177495 => 177496)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp 2014-12-18 14:41:44 UTC (rev 177495)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp 2014-12-18 14:57:36 UTC (rev 177496)
@@ -186,6 +186,11 @@
webkitWebViewRunAsModal(m_webView);
}
+ virtual void isPlayingAudioDidChange(WebPageProxy& page) override
+ {
+ webkitWebViewIsPlayingAudioChanged(m_webView);
+ }
+
WebKitWebView* m_webView;
};
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (177495 => 177496)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2014-12-18 14:41:44 UTC (rev 177495)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2014-12-18 14:57:36 UTC (rev 177496)
@@ -148,7 +148,8 @@
PROP_FAVICON,
PROP_URI,
PROP_ZOOM_LEVEL,
- PROP_IS_LOADING
+ PROP_IS_LOADING,
+ PROP_IS_PLAYING_AUDIO
};
typedef HashMap<uint64_t, GRefPtr<WebKitWebResource> > LoadingResourcesMap;
@@ -230,6 +231,11 @@
g_object_notify(G_OBJECT(webView), "is-loading");
}
+void webkitWebViewIsPlayingAudioChanged(WebKitWebView* webView)
+{
+ g_object_notify(G_OBJECT(webView), "is-playing-audio");
+}
+
class PageLoadStateObserver final : public PageLoadState::Observer {
public:
PageLoadStateObserver(WebKitWebView* webView)
@@ -721,6 +727,9 @@
case PROP_IS_LOADING:
g_value_set_boolean(value, webkit_web_view_is_loading(webView));
break;
+ case PROP_IS_PLAYING_AUDIO:
+ g_value_set_boolean(value, webkit_web_view_is_playing_audio(webView));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
}
@@ -932,6 +941,26 @@
WEBKIT_PARAM_READABLE));
/**
+ * WebKitWebView::is-playing-audio:
+ *
+ * Whether the #WebKitWebView is currently playing audio from a page.
+ * This property becomes %TRUE as soon as web content starts playing any
+ * kind of audio. When a page is no longer playing any kind of sound,
+ * the property is set back to %FALSE.
+ *
+ * Since: 2.8
+ */
+ g_object_class_install_property(
+ gObjectClass,
+ PROP_IS_PLAYING_AUDIO,
+ g_param_spec_boolean(
+ "is-playing-audio",
+ "Is Playing Audio",
+ _("Whether the view is playing audio"),
+ FALSE,
+ WEBKIT_PARAM_READABLE));
+
+ /**
* WebKitWebView::load-changed:
* @web_view: the #WebKitWebView on which the signal is emitted
* @load_event: the #WebKitLoadEvent
@@ -2454,6 +2483,27 @@
}
/**
+ * webkit_web_view_is_playing_audio:
+ * @web_view: a #WebKitWebView
+ *
+ * Gets the value of the #WebKitWebView::is-playing-audio property.
+ * You can monitor when a page in a #WebKitWebView is playing audio by
+ * connecting to the notify::is-playing-audio signal of @web_view. This
+ * is useful when the application wants to provide visual feedback when a
+ * page is producing sound.
+ *
+ * Returns: %TRUE if a page in @web_view is playing audio or %FALSE otherwise.
+ *
+ * Since: 2.8
+ */
+gboolean webkit_web_view_is_playing_audio(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
+
+ return getPage(webView)->isPlayingAudio();
+}
+
+/**
* webkit_web_view_go_back:
* @web_view: a #WebKitWebView
*
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h (177495 => 177496)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2014-12-18 14:41:44 UTC (rev 177495)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2014-12-18 14:57:36 UTC (rev 177496)
@@ -305,6 +305,9 @@
WEBKIT_API gboolean
webkit_web_view_is_loading (WebKitWebView *web_view);
+WEBKIT_API gboolean
+webkit_web_view_is_playing_audio (WebKitWebView *web_view);
+
WEBKIT_API guint64
webkit_web_view_get_page_id (WebKitWebView *web_view);
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h (177495 => 177496)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h 2014-12-18 14:41:44 UTC (rev 177495)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h 2014-12-18 14:57:36 UTC (rev 177496)
@@ -60,5 +60,6 @@
bool webkitWebViewEmitShowNotification(WebKitWebView*, WebKitNotification*);
void webkitWebViewEmitCloseNotification(WebKitWebView*, WebKitNotification*);
void webkitWebViewWebProcessCrashed(WebKitWebView*);
+void webkitWebViewIsPlayingAudioChanged(WebKitWebView*);
#endif // WebKitWebViewPrivate_h
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (177495 => 177496)
--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2014-12-18 14:41:44 UTC (rev 177495)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2014-12-18 14:57:36 UTC (rev 177496)
@@ -167,6 +167,7 @@
webkit_web_view_reload_bypass_cache
webkit_web_view_stop_loading
webkit_web_view_is_loading
+webkit_web_view_is_playing_audio
webkit_web_view_get_estimated_load_progress
webkit_web_view_get_custom_charset
webkit_web_view_set_custom_charset
Modified: trunk/Tools/ChangeLog (177495 => 177496)
--- trunk/Tools/ChangeLog 2014-12-18 14:41:44 UTC (rev 177495)
+++ trunk/Tools/ChangeLog 2014-12-18 14:57:36 UTC (rev 177496)
@@ -1,3 +1,28 @@
+2014-12-18 Adrian Perez de Castro <[email protected]>
+
+ [GTK] Implement webkit_web_view_is_playing_audio()
+ https://bugs.webkit.org/show_bug.cgi?id=138918
+
+ Reviewed by Carlos Garcia Campos.
+
+ Add test case case for webkit_web_view_is_playing_audio() and the
+ WebKitWebView::is-playing-audio property.
+
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:
+ (urlForResource): Utility function to get URLs pointing to resources
+ under the Tools/TestWebKitAPI/Tests/WebKit2/ directory.
+ (testWebViewIsPlayingAudio): Added.
+ (beforeAll):
+ * TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h:
+ (getResourcesDir): Allow passing a flag to choose from the WebKit2 GTK
+ API tests resources directory, or the WebKit2 C API tests resources
+ directory. The default value of the flag is to use the WebKit2 GTK
+ one, to avoid having to change existing tests.
+ * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp:
+ (isPlayingAudioChanged): Added.
+ (WebViewTest::waitUntilIsPlayingAudioChanged): Added.
+ * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h:
+
2014-12-18 Carlos Alberto Lopez Perez <[email protected]>
[GTK] [EFL] Enable per_test_timeout
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp (177495 => 177496)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp 2014-12-18 14:41:44 UTC (rev 177495)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp 2014-12-18 14:57:36 UTC (rev 177496)
@@ -26,6 +26,23 @@
#include <glib/gstdio.h>
#include <wtf/gobject/GRefPtr.h>
+class IsPlayingAudioWebViewTest : public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(IsPlayingAudioWebViewTest);
+
+ static void isPlayingAudioChanged(GObject*, GParamSpec*, IsPlayingAudioWebViewTest* test)
+ {
+ g_signal_handlers_disconnect_by_func(test->m_webView, reinterpret_cast<void*>(isPlayingAudioChanged), test);
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ void waitUntilIsPlayingAudioChanged()
+ {
+ g_signal_connect(m_webView, "notify::is-playing-audio", G_CALLBACK(isPlayingAudioChanged), this);
+ g_main_loop_run(m_mainLoop);
+ }
+};
+
static WebKitTestServer* gServer;
static void testWebViewWebContext(WebViewTest* test, gconstpointer)
@@ -702,6 +719,31 @@
g_assert(test->m_event == NotificationWebViewTest::Cancelled);
}
+static void testWebViewIsPlayingAudio(IsPlayingAudioWebViewTest* test, gconstpointer)
+{
+ // The web view must be realized for the video to start playback and
+ // trigger changes in WebKitWebView::is-playing-audio.
+ test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+
+ // Initially, web views should always report no audio being played.
+ g_assert(!webkit_web_view_is_playing_audio(test->m_webView));
+
+ GUniquePtr<char> resourcePath(g_build_filename(Test::getResourcesDir(Test::WebKit2Resources).data(), "file-with-video.html", nullptr));
+ GUniquePtr<char> resourceURL(g_filename_to_uri(resourcePath.get(), nullptr, nullptr));
+ webkit_web_view_load_uri(test->m_webView, resourceURL.get());
+ test->waitUntilLoadFinished();
+ g_assert(!webkit_web_view_is_playing_audio(test->m_webView));
+
+ webkit_web_view_run_javascript(test->m_webView, "playVideo();", nullptr, nullptr, nullptr);
+ test->waitUntilIsPlayingAudioChanged();
+ g_assert(webkit_web_view_is_playing_audio(test->m_webView));
+
+ // Pause the video, and check again.
+ webkit_web_view_run_javascript(test->m_webView, "document.getElementById('test-video').pause();", nullptr, nullptr, nullptr);
+ test->waitUntilIsPlayingAudioChanged();
+ g_assert(!webkit_web_view_is_playing_audio(test->m_webView));
+}
+
static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
{
if (message->method != SOUP_METHOD_GET) {
@@ -733,6 +775,7 @@
SnapshotWebViewTest::add("WebKitWebView", "snapshot", testWebViewSnapshot);
WebViewTest::add("WebKitWebView", "page-visibility", testWebViewPageVisibility);
NotificationWebViewTest::add("WebKitWebView", "notification", testWebViewNotification);
+ IsPlayingAudioWebViewTest::add("WebKitWebView", "is-playing-audio", testWebViewIsPlayingAudio);
}
void afterAll()
Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h (177495 => 177496)
--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h 2014-12-18 14:41:44 UTC (rev 177495)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h 2014-12-18 14:57:36 UTC (rev 177496)
@@ -107,10 +107,24 @@
g_object_weak_ref(object, reinterpret_cast<GWeakNotify>(objectFinalized), this);
}
- static CString getResourcesDir()
+
+ enum ResourcesDir {
+ WebKit2GTKResources,
+ WebKit2Resources,
+ };
+
+ static CString getResourcesDir(ResourcesDir resourcesDir = WebKit2GTKResources)
{
- GUniquePtr<char> resourcesDir(g_build_filename(WEBKIT_SRC_DIR, "Tools", "TestWebKitAPI", "Tests", "WebKit2Gtk", "resources", nullptr));
- return resourcesDir.get();
+ switch (resourcesDir) {
+ case WebKit2GTKResources: {
+ GUniquePtr<char> resourcesDir(g_build_filename(WEBKIT_SRC_DIR, "Tools", "TestWebKitAPI", "Tests", "WebKit2Gtk", "resources", nullptr));
+ return resourcesDir.get();
+ }
+ case WebKit2Resources: {
+ GUniquePtr<char> resourcesDir(g_build_filename(WEBKIT_SRC_DIR, "Tools", "TestWebKitAPI", "Tests", "WebKit2", nullptr));
+ return resourcesDir.get();
+ }
+ }
}
void addLogFatalFlag(unsigned flag)