[GStreamer] Do not automatically show PackageKit codec installation notifications
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Aug 2015 09:51:20 +0000 (09:51 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Aug 2015 09:51:20 +0000 (09:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135973

Reviewed by Philippe Normand.

Source/WebCore:

Add description parameter to requestInstallMissingPlugins() that
will be used by the API layer.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::requestInstallMissingPlugins):
* html/HTMLMediaElement.h:
* page/ChromeClient.h:
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::requestInstallMissingPlugins):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::handleMessage):

Source/WebKit2:

Add InstallMissingMediaPluginsPermissionRequest to ask the API
layer whether to allow or deny the installation of missing media
plugins. And add a GTK+ implementation based on current permission
request API. Replace the
PageClientImpl::createGstInstallPluginsContext() with
decicePolicyForInstallMissingMediaPluginsPermissionRequest() that
passes the InstallMissingMediaPluginsPermissionRequest object to
the API layer. The allow method receives the
GstInstallPluginsContext now, so that it can be created by the API implementation.

* PlatformEfl.cmake:
* PlatformGTK.cmake:
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::decicePolicyForInstallMissingMediaPluginsPermissionRequest):
* UIProcess/API/gtk/PageClientImpl.h:
* UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.cpp: Added.
(createGstInstallPluginsContext):
(webkitInstallMissingMediaPluginsPermissionRequestAllow):
(webkitInstallMissingMediaPluginsPermissionRequestDeny):
(webkit_permission_request_interface_init):
(webkitInstallMissingMediaPluginsPermissionRequestDispose):
(webkit_install_missing_media_plugins_permission_request_class_init):
(webkitInstallMissingMediaPluginsPermissionRequestCreate):
(webkit_install_missing_media_plugins_permission_request_get_description):
* UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.h: Added.
* UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequestPrivate.h: Added.
* UIProcess/API/gtk/WebKitWebView.cpp:
(webkitWebViewRequestInstallMissingMediaPlugins):
* UIProcess/API/gtk/WebKitWebViewPrivate.h:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
* UIProcess/API/gtk/docs/webkit2gtk-4.0.types:
* UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
* UIProcess/API/gtk/webkit2.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/efl/WebViewEfl.h:
* UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.cpp: Copied from Source/WebKit2/UIProcess/gstreamer/WebPageProxyGStreamer.cpp.
(WebKit::InstallMissingMediaPluginsPermissionRequest::InstallMissingMediaPluginsPermissionRequest):
(WebKit::InstallMissingMediaPluginsPermissionRequest::~InstallMissingMediaPluginsPermissionRequest):
(WebKit::InstallMissingMediaPluginsPermissionRequest::allow):
(WebKit::InstallMissingMediaPluginsPermissionRequest::deny):
(WebKit::InstallMissingMediaPluginsPermissionRequest::didEndRequestInstallMissingMediaPlugins):
* UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.h: Copied from Source/WebKit2/WebProcess/WebPage/gstreamer/WebPageGStreamer.cpp.
(WebKit::InstallMissingMediaPluginsPermissionRequest::create):
(WebKit::InstallMissingMediaPluginsPermissionRequest::page):
(WebKit::InstallMissingMediaPluginsPermissionRequest::details):
(WebKit::InstallMissingMediaPluginsPermissionRequest::description):
* UIProcess/gstreamer/WebPageProxyGStreamer.cpp:
(WebKit::WebPageProxy::requestInstallMissingMediaPlugins):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::requestInstallMissingMediaPlugins):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/gstreamer/WebPageGStreamer.cpp:
(WebKit::WebPage::requestInstallMissingMediaPlugins):

Tools:

Handle the missing media plugins installation permission request
in MiniBrowser and add a test case for the new API.

* MiniBrowser/gtk/BrowserWindow.c:
(webViewDecidePermissionRequest):
* TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt:
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp:
(permissionRequestCallback):
(testInstallMissingPluginsPermissionRequest):
(beforeAll):
* TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:
(methodCallCallback):

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

39 files changed:
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/PlatformEfl.cmake
Source/WebKit2/PlatformGTK.cmake
Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h
Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequestPrivate.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/gtk/WebKitNotificationPermissionRequest.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitUserMediaPermissionRequest.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0.types
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
Source/WebKit2/UIProcess/API/gtk/webkit2.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/efl/WebViewEfl.h
Source/WebKit2/UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.h [new file with mode: 0644]
Source/WebKit2/UIProcess/gstreamer/WebPageProxyGStreamer.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/gstreamer/WebPageGStreamer.cpp
Tools/ChangeLog
Tools/MiniBrowser/gtk/BrowserWindow.c
Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp
Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp

index 9a2a7b8..b954563 100644 (file)
@@ -1,3 +1,22 @@
+2015-08-07  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GStreamer] Do not automatically show PackageKit codec installation notifications
+        https://bugs.webkit.org/show_bug.cgi?id=135973
+
+        Reviewed by Philippe Normand.
+
+        Add description parameter to requestInstallMissingPlugins() that
+        will be used by the API layer.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::requestInstallMissingPlugins):
+        * html/HTMLMediaElement.h:
+        * page/ChromeClient.h:
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::requestInstallMissingPlugins):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::handleMessage):
+
 2015-08-07  Doug Russell  <d_russell@apple.com>
 
         AX: Bug 147737 is causing test failures in Mavericks WK1
index 98f30d4..26ae1fd 100644 (file)
@@ -6132,12 +6132,12 @@ double HTMLMediaElement::mediaPlayerRequestedPlaybackRate() const
 }
 
 #if USE(GSTREAMER)
-void HTMLMediaElement::requestInstallMissingPlugins(const String& details, MediaPlayerRequestInstallMissingPluginsCallback& callback)
+void HTMLMediaElement::requestInstallMissingPlugins(const String& details, const String& description, MediaPlayerRequestInstallMissingPluginsCallback& callback)
 {
     if (!document().page())
         return;
 
-    document().page()->chrome().client().requestInstallMissingMediaPlugins(details, callback);
+    document().page()->chrome().client().requestInstallMissingMediaPlugins(details, description, callback);
 }
 #endif
 
index 61737c4..c23a7c2 100644 (file)
@@ -615,7 +615,7 @@ private:
     virtual VideoFullscreenMode mediaPlayerFullscreenMode() const override final { return fullscreenMode(); }
 
 #if USE(GSTREAMER)
-    virtual void requestInstallMissingPlugins(const String&, MediaPlayerRequestInstallMissingPluginsCallback&) override final;
+    virtual void requestInstallMissingPlugins(const String& details, const String& description, MediaPlayerRequestInstallMissingPluginsCallback&) override final;
 #endif
 
     void pendingActionTimerFired();
index a0a133c..ee0fb48 100644 (file)
@@ -457,7 +457,7 @@ public:
 #if ENABLE(VIDEO)
     virtual void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&) { }
 #if USE(GSTREAMER)
-    virtual void requestInstallMissingMediaPlugins(const String& /*details*/, MediaPlayerRequestInstallMissingPluginsCallback&) { };
+    virtual void requestInstallMissingMediaPlugins(const String& /*details*/, const String& /*description*/, MediaPlayerRequestInstallMissingPluginsCallback&) { };
 #endif
 #endif
 
index 00380f2..a013c86 100644 (file)
@@ -284,7 +284,7 @@ public:
     virtual Vector<String> mediaPlayerPreferredAudioCharacteristics() const { return Vector<String>(); }
 
 #if USE(GSTREAMER)
-    virtual void requestInstallMissingPlugins(const String&, MediaPlayerRequestInstallMissingPluginsCallback&) { };
+    virtual void requestInstallMissingPlugins(const String&, const String&, MediaPlayerRequestInstallMissingPluginsCallback&) { };
 #endif
 };
 
index 8929f2e..fb7fd5d 100644 (file)
@@ -1027,7 +1027,6 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
         break;
     case GST_MESSAGE_ELEMENT:
         if (gst_is_missing_plugin_message(message)) {
-            GUniquePtr<char> detail(gst_missing_plugin_message_get_installer_detail(message));
             if (gst_install_plugins_supported()) {
                 m_missingPluginsCallback = MediaPlayerRequestInstallMissingPluginsCallback::create([this](uint32_t result) {
                     m_missingPluginsCallback = nullptr;
@@ -1037,7 +1036,9 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
                     changePipelineState(GST_STATE_READY);
                     changePipelineState(GST_STATE_PAUSED);
                 });
-                m_player->client().requestInstallMissingPlugins(String::fromUTF8(detail.get()), *m_missingPluginsCallback);
+                GUniquePtr<char> detail(gst_missing_plugin_message_get_installer_detail(message));
+                GUniquePtr<char> description(gst_missing_plugin_message_get_description(message));
+                m_player->client().requestInstallMissingPlugins(String::fromUTF8(detail.get()), String::fromUTF8(description.get()), *m_missingPluginsCallback);
             }
         }
 #if ENABLE(VIDEO_TRACK) && USE(GSTREAMER_MPEGTS)
index 4f0cfb2..792a099 100644 (file)
@@ -1,3 +1,67 @@
+2015-08-07  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GStreamer] Do not automatically show PackageKit codec installation notifications
+        https://bugs.webkit.org/show_bug.cgi?id=135973
+
+        Reviewed by Philippe Normand.
+
+        Add InstallMissingMediaPluginsPermissionRequest to ask the API
+        layer whether to allow or deny the installation of missing media
+        plugins. And add a GTK+ implementation based on current permission
+        request API. Replace the
+        PageClientImpl::createGstInstallPluginsContext() with
+        decicePolicyForInstallMissingMediaPluginsPermissionRequest() that
+        passes the InstallMissingMediaPluginsPermissionRequest object to
+        the API layer. The allow method receives the
+        GstInstallPluginsContext now, so that it can be created by the API implementation.
+
+        * PlatformEfl.cmake:
+        * PlatformGTK.cmake:
+        * UIProcess/API/gtk/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::decicePolicyForInstallMissingMediaPluginsPermissionRequest):
+        * UIProcess/API/gtk/PageClientImpl.h:
+        * UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.cpp: Added.
+        (createGstInstallPluginsContext):
+        (webkitInstallMissingMediaPluginsPermissionRequestAllow):
+        (webkitInstallMissingMediaPluginsPermissionRequestDeny):
+        (webkit_permission_request_interface_init):
+        (webkitInstallMissingMediaPluginsPermissionRequestDispose):
+        (webkit_install_missing_media_plugins_permission_request_class_init):
+        (webkitInstallMissingMediaPluginsPermissionRequestCreate):
+        (webkit_install_missing_media_plugins_permission_request_get_description):
+        * UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.h: Added.
+        * UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequestPrivate.h: Added.
+        * UIProcess/API/gtk/WebKitWebView.cpp:
+        (webkitWebViewRequestInstallMissingMediaPlugins):
+        * UIProcess/API/gtk/WebKitWebViewPrivate.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
+        * UIProcess/API/gtk/docs/webkit2gtk-4.0.types:
+        * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
+        * UIProcess/API/gtk/webkit2.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/efl/WebViewEfl.h:
+        * UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.cpp: Copied from Source/WebKit2/UIProcess/gstreamer/WebPageProxyGStreamer.cpp.
+        (WebKit::InstallMissingMediaPluginsPermissionRequest::InstallMissingMediaPluginsPermissionRequest):
+        (WebKit::InstallMissingMediaPluginsPermissionRequest::~InstallMissingMediaPluginsPermissionRequest):
+        (WebKit::InstallMissingMediaPluginsPermissionRequest::allow):
+        (WebKit::InstallMissingMediaPluginsPermissionRequest::deny):
+        (WebKit::InstallMissingMediaPluginsPermissionRequest::didEndRequestInstallMissingMediaPlugins):
+        * UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.h: Copied from Source/WebKit2/WebProcess/WebPage/gstreamer/WebPageGStreamer.cpp.
+        (WebKit::InstallMissingMediaPluginsPermissionRequest::create):
+        (WebKit::InstallMissingMediaPluginsPermissionRequest::page):
+        (WebKit::InstallMissingMediaPluginsPermissionRequest::details):
+        (WebKit::InstallMissingMediaPluginsPermissionRequest::description):
+        * UIProcess/gstreamer/WebPageProxyGStreamer.cpp:
+        (WebKit::WebPageProxy::requestInstallMissingMediaPlugins):
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::requestInstallMissingMediaPlugins):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/gstreamer/WebPageGStreamer.cpp:
+        (WebKit::WebPage::requestInstallMissingMediaPlugins):
+
 2015-08-06  Beth Dakin  <bdakin@apple.com>
 
         TextIndicator can have stale contentImage data and crash
index e435e81..ed0f0d8 100644 (file)
@@ -183,6 +183,7 @@ list(APPEND WebKit2_SOURCES
     UIProcess/efl/WebUIPopupMenuClient.cpp
     UIProcess/efl/WebViewEfl.cpp
 
+    UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.cpp
     UIProcess/gstreamer/WebPageProxyGStreamer.cpp
 
     UIProcess/soup/WebCookieManagerProxySoup.cpp
index 6113e61..b3b790b 100644 (file)
@@ -169,6 +169,9 @@ list(APPEND WebKit2_SOURCES
     UIProcess/API/gtk/WebKitHitTestResultPrivate.h
     UIProcess/API/gtk/WebKitInjectedBundleClient.cpp
     UIProcess/API/gtk/WebKitInjectedBundleClient.h
+    UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.cpp
+    UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.h
+    UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequestPrivate.h
     UIProcess/API/gtk/WebKitJavascriptResult.cpp
     UIProcess/API/gtk/WebKitJavascriptResult.h
     UIProcess/API/gtk/WebKitJavascriptResultPrivate.h
@@ -290,6 +293,7 @@ list(APPEND WebKit2_SOURCES
 
     UIProcess/cairo/BackingStoreCairo.cpp
 
+    UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.cpp
     UIProcess/gstreamer/WebPageProxyGStreamer.cpp
 
     UIProcess/gtk/DragAndDropHandler.cpp
@@ -393,6 +397,7 @@ set(WebKit2GTK_INSTALLED_HEADERS
     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitForwardDeclarations.h
     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.h
     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitHitTestResult.h
+    ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.h
     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitJavascriptResult.h
     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitMimeInfo.h
     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNavigationAction.h
@@ -500,6 +505,7 @@ list(APPEND WebKit2_INCLUDE_DIRECTORIES
     "${WEBKIT2_DIR}/UIProcess/API/gtk"
     "${WEBKIT2_DIR}/UIProcess/Network/CustomProtocols/soup"
     "${WEBKIT2_DIR}/UIProcess/Plugins/gtk"
+    "${WEBKIT2_DIR}/UIProcess/gstreamer"
     "${WEBKIT2_DIR}/UIProcess/gtk"
     "${WEBKIT2_DIR}/UIProcess/soup"
     "${WEBKIT2_DIR}/WebProcess/InjectedBundle/API/gtk"
index 5070ae2..aafc3e5 100644 (file)
 #include <WebCore/Cursor.h>
 #include <WebCore/EventNames.h>
 #include <WebCore/GtkUtilities.h>
-#include <WebCore/PlatformDisplay.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
-#if PLATFORM(X11)
-#include <gdk/gdkx.h>
-#endif
-
 using namespace WebCore;
 
 namespace WebKit {
@@ -448,17 +443,15 @@ void PageClientImpl::derefView()
     g_object_unref(m_viewWidget);
 }
 
-GUniquePtr<GstInstallPluginsContext> PageClientImpl::createGstInstallPluginsContext()
+#if ENABLE(VIDEO)
+bool PageClientImpl::decicePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest& request)
 {
-#if PLATFORM(X11)
-    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11) {
-        GUniquePtr<GstInstallPluginsContext> context(gst_install_plugins_context_new());
-        gst_install_plugins_context_set_xid(context.get(), GDK_WINDOW_XID(gtk_widget_get_window(m_viewWidget)));
-        return context;
-    }
-#endif
+    if (!WEBKIT_IS_WEB_VIEW(m_viewWidget))
+        return false;
 
-    return nullptr;
+    webkitWebViewRequestInstallMissingMediaPlugins(WEBKIT_WEB_VIEW(m_viewWidget), request);
+    return true;
 }
+#endif
 
 } // namespace WebKit
index 0259031..ce58759 100644 (file)
@@ -142,7 +142,9 @@ private:
     virtual void refView() override;
     virtual void derefView() override;
 
-    virtual GUniquePtr<GstInstallPluginsContext> createGstInstallPluginsContext() override;
+#if ENABLE(VIDEO)
+    virtual bool decicePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&) override;
+#endif
 
     // Members of PageClientImpl class
     GtkWidget* m_viewWidget;
index f780daf..871c3cf 100644 (file)
@@ -35,6 +35,9 @@ using namespace WebKit;
  * WebKitGeolocationPermissionRequest represents a request for
  * permission to decide whether WebKit should provide the user's
  * location to a website when requested throught the Geolocation API.
+ *
+ * When a WebKitGeolocationPermissionRequest is not handled by the user,
+ * it is denied by default.
  */
 
 static void webkit_permission_request_interface_init(WebKitPermissionRequestIface*);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.cpp
new file mode 100644 (file)
index 0000000..9d40ac7
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitInstallMissingMediaPluginsPermissionRequest.h"
+
+#include "WebKitInstallMissingMediaPluginsPermissionRequestPrivate.h"
+#include "WebKitPermissionRequest.h"
+#include "WebPageProxy.h"
+
+#if ENABLE(VIDEO)
+#include <WebCore/PlatformDisplay.h>
+#include <gtk/gtk.h>
+#if PLATFORM(X11)
+#include <gdk/gdkx.h>
+#endif
+#endif
+
+using namespace WebKit;
+using namespace WebCore;
+
+/**
+ * SECTION: WebKitInstallMissingMediaPluginsPermissionRequest
+ * @Short_description: A permission request for installing missing media plugins
+ * @Title: WebKitInstallMissingMediaPluginsPermissionRequest
+ * @See_also: #WebKitPermissionRequest, #WebKitWebView
+ *
+ * WebKitInstallMissingMediaPluginsPermissionRequest represents a request for
+ * permission to decide whether WebKit should try to start a helper application to
+ * install missing media plugins when the media backend couldn't play a media because
+ * the required plugins were not available.
+ *
+ * When a WebKitInstallMissingMediaPluginsPermissionRequest is not handled by the user,
+ * it is allowed by default.
+ *
+ * Since: 2.10
+ */
+
+static void webkit_permission_request_interface_init(WebKitPermissionRequestIface*);
+
+struct _WebKitInstallMissingMediaPluginsPermissionRequestPrivate {
+#if ENABLE(VIDEO)
+    RefPtr<InstallMissingMediaPluginsPermissionRequest> request;
+#endif
+    CString description;
+    bool madeDecision;
+};
+
+WEBKIT_DEFINE_TYPE_WITH_CODE(
+    WebKitInstallMissingMediaPluginsPermissionRequest, webkit_install_missing_media_plugins_permission_request, G_TYPE_OBJECT,
+    G_IMPLEMENT_INTERFACE(WEBKIT_TYPE_PERMISSION_REQUEST, webkit_permission_request_interface_init))
+
+#if ENABLE(VIDEO)
+static GUniquePtr<GstInstallPluginsContext> createGstInstallPluginsContext(GtkWidget* widget)
+{
+#if PLATFORM(X11)
+    if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11) {
+        GUniquePtr<GstInstallPluginsContext> context(gst_install_plugins_context_new());
+        gst_install_plugins_context_set_xid(context.get(), GDK_WINDOW_XID(gtk_widget_get_window(widget)));
+        return context;
+    }
+#endif
+
+    return nullptr;
+}
+#endif
+
+static void webkitInstallMissingMediaPluginsPermissionRequestAllow(WebKitPermissionRequest* request)
+{
+    ASSERT(WEBKIT_IS_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST(request));
+
+    WebKitInstallMissingMediaPluginsPermissionRequestPrivate* priv = WEBKIT_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST(request)->priv;
+
+    // Only one decision at a time.
+    if (priv->madeDecision)
+        return;
+#if ENABLE(VIDEO)
+    priv->request->allow(createGstInstallPluginsContext(priv->request->page().viewWidget()));
+#endif
+    priv->madeDecision = true;
+}
+
+static void webkitInstallMissingMediaPluginsPermissionRequestDeny(WebKitPermissionRequest* request)
+{
+    ASSERT(WEBKIT_IS_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST(request));
+
+    WebKitInstallMissingMediaPluginsPermissionRequestPrivate* priv = WEBKIT_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST(request)->priv;
+
+    // Only one decision at a time.
+    if (priv->madeDecision)
+        return;
+
+#if ENABLE(VIDEO)
+    priv->request->deny();
+#endif
+    priv->madeDecision = true;
+}
+
+static void webkit_permission_request_interface_init(WebKitPermissionRequestIface* iface)
+{
+    iface->allow = webkitInstallMissingMediaPluginsPermissionRequestAllow;
+    iface->deny = webkitInstallMissingMediaPluginsPermissionRequestDeny;
+}
+
+static void webkitInstallMissingMediaPluginsPermissionRequestDispose(GObject* object)
+{
+    // Default behaviour when no decision has been made is allowing the request for backwards compatibility.
+    webkitInstallMissingMediaPluginsPermissionRequestDeny(WEBKIT_PERMISSION_REQUEST(object));
+    G_OBJECT_CLASS(webkit_install_missing_media_plugins_permission_request_parent_class)->dispose(object);
+}
+
+static void webkit_install_missing_media_plugins_permission_request_class_init(WebKitInstallMissingMediaPluginsPermissionRequestClass* klass)
+{
+    GObjectClass* objectClass = G_OBJECT_CLASS(klass);
+    objectClass->dispose = webkitInstallMissingMediaPluginsPermissionRequestDispose;
+}
+
+#if ENABLE(VIDEO)
+WebKitInstallMissingMediaPluginsPermissionRequest* webkitInstallMissingMediaPluginsPermissionRequestCreate(InstallMissingMediaPluginsPermissionRequest& request)
+{
+    WebKitInstallMissingMediaPluginsPermissionRequest* permissionRequest = WEBKIT_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST(g_object_new(WEBKIT_TYPE_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST, nullptr));
+    permissionRequest->priv->request = &request;
+    return permissionRequest;
+}
+#endif
+
+/**
+ * webkit_install_missing_media_plugins_permission_request_get_description:
+ * @request: a #WebKitInstallMissingMediaPluginsPermissionRequest
+ *
+ * Gets the description about the missing plugins provided by the media backend when a media couldn't be played.
+ *
+ * Returns: a string with the description provided by the media backend.
+ *
+ * Since: 2.10
+ */
+const char* webkit_install_missing_media_plugins_permission_request_get_description(WebKitInstallMissingMediaPluginsPermissionRequest* request)
+{
+    g_return_val_if_fail(WEBKIT_IS_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST(request), nullptr);
+
+#if ENABLE(VIDEO)
+    if (!request->priv->description.isNull())
+        return request->priv->description.data();
+
+    const auto& description = request->priv->request->description();
+    ASSERT(!details.isEmpty());
+    request->priv->description = request->priv->request->description().utf8();
+#endif
+    return request->priv->description.data();
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.h
new file mode 100644 (file)
index 0000000..e0632af
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitInstallMissingMediaPluginsPermissionRequest_h
+#define WebKitInstallMissingMediaPluginsPermissionRequest_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST            (webkit_install_missing_media_plugins_permission_request_get_type())
+#define WEBKIT_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST, WebKitInstallMissingMediaPluginsPermissionRequest))
+#define WEBKIT_IS_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST))
+#define WEBKIT_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST, WebKitInstallMissingMediaPluginsPermissionRequestClass))
+#define WEBKIT_IS_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST))
+#define WEBKIT_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST, WebKitInstallMissingMediaPluginsPermissionRequestClass))
+
+typedef struct _WebKitInstallMissingMediaPluginsPermissionRequest        WebKitInstallMissingMediaPluginsPermissionRequest;
+typedef struct _WebKitInstallMissingMediaPluginsPermissionRequestClass   WebKitInstallMissingMediaPluginsPermissionRequestClass;
+typedef struct _WebKitInstallMissingMediaPluginsPermissionRequestPrivate WebKitInstallMissingMediaPluginsPermissionRequestPrivate;
+
+struct _WebKitInstallMissingMediaPluginsPermissionRequest {
+    GObject parent;
+
+    WebKitInstallMissingMediaPluginsPermissionRequestPrivate *priv;
+};
+
+struct _WebKitInstallMissingMediaPluginsPermissionRequestClass {
+    GObjectClass parent_class;
+
+    void (*_webkit_reserved0) (void);
+    void (*_webkit_reserved1) (void);
+    void (*_webkit_reserved2) (void);
+    void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_install_missing_media_plugins_permission_request_get_type        (void);
+
+WEBKIT_API const gchar *
+webkit_install_missing_media_plugins_permission_request_get_description (WebKitInstallMissingMediaPluginsPermissionRequest *request);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequestPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequestPrivate.h
new file mode 100644 (file)
index 0000000..2c7e3bc
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitInstallMissingMediaPluginsPermissionRequestPrivate_h
+#define WebKitInstallMissingMediaPluginsPermissionRequestPrivate_h
+
+#include "InstallMissingMediaPluginsPermissionRequest.h"
+#include "WebKitInstallMissingMediaPluginsPermissionRequest.h"
+#include "WebKitPrivate.h"
+
+#if ENABLE(VIDEO)
+WebKitInstallMissingMediaPluginsPermissionRequest* webkitInstallMissingMediaPluginsPermissionRequestCreate(WebKit::InstallMissingMediaPluginsPermissionRequest&);
+#endif
+
+#endif // WebKitInstallMissingMediaPluginsPermissionRequestPrivate_h
index 44e0e08..2df4474 100644 (file)
@@ -35,6 +35,11 @@ using namespace WebKit;
  * WebKitNotificationPermissionRequest represents a request for
  * permission to decide whether WebKit should provide the user with
  * notifications through the Web Notification API.
+ *
+ * When a WebKitNotificationPermissionRequest is not handled by the user,
+ * it is denied by default.
+ *
+ * Since: 2.8
  */
 
 static void webkit_permission_request_interface_init(WebKitPermissionRequestIface*);
index 05b2e64..25038a4 100644 (file)
@@ -36,6 +36,9 @@ using namespace WebKit;
  * permission to decide whether WebKit should be allowed to access the user's
  * audio and video source devices when requested throught the getUserMedia API.
  *
+ * When a WebKitUserMediaPermissionRequest is not handled by the user,
+ * it is denied by default.
+ *
  * Since: 2.8
  */
 
index eb84b61..03225da 100644 (file)
@@ -42,6 +42,7 @@
 #include "WebKitFormClient.h"
 #include "WebKitFullscreenClient.h"
 #include "WebKitHitTestResultPrivate.h"
+#include "WebKitInstallMissingMediaPluginsPermissionRequestPrivate.h"
 #include "WebKitJavascriptResultPrivate.h"
 #include "WebKitLoaderClient.h"
 #include "WebKitMarshal.h"
@@ -1351,9 +1352,10 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
      * request has not been handled, webkit_permission_request_deny()
      * will be the default action.
      *
-     * By default, if the signal is not handled,
-     * webkit_permission_request_deny() will be called over the
-     * #WebKitPermissionRequest.
+     * If the signal is not handled, the @request will be completed automatically
+     * by the specific #WebKitPermissionRequest that could allow or deny it. Check the
+     * documentation of classes implementing #WebKitPermissionRequest interface to know
+     * their default action.
      *
      * Returns: %TRUE to stop other handlers from being invoked for the event.
      *   %FALSE to propagate the event further.
@@ -2145,6 +2147,16 @@ void webkitWebViewSelectionDidChange(WebKitWebView* webView)
     webkitEditorStateChanged(webView->priv->editorState.get(), getPage(webView)->editorState());
 }
 
+void webkitWebViewRequestInstallMissingMediaPlugins(WebKitWebView* webView, InstallMissingMediaPluginsPermissionRequest& request)
+{
+#if ENABLE(VIDEO)
+    GRefPtr<WebKitInstallMissingMediaPluginsPermissionRequest> installMediaPluginsPermissionRequest = adoptGRef(webkitInstallMissingMediaPluginsPermissionRequestCreate(request));
+    webkitWebViewMakePermissionRequest(webView, WEBKIT_PERMISSION_REQUEST(installMediaPluginsPermissionRequest.get()));
+#else
+    ASSERT_NOT_REACHED();
+#endif
+}
+
 /**
  * webkit_web_view_new:
  *
index a788653..ece4bed 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef WebKitWebViewPrivate_h
 #define WebKitWebViewPrivate_h
 
+#include "InstallMissingMediaPluginsPermissionRequest.h"
 #include "WebContextMenuItemData.h"
 #include "WebHitTestResult.h"
 #include "WebImage.h"
@@ -63,5 +64,6 @@ bool webkitWebViewEmitRunColorChooser(WebKitWebView*, WebKitColorChooserRequest*
 void webkitWebViewWebProcessCrashed(WebKitWebView*);
 void webkitWebViewIsPlayingAudioChanged(WebKitWebView*);
 void webkitWebViewSelectionDidChange(WebKitWebView*);
+void webkitWebViewRequestInstallMissingMediaPlugins(WebKitWebView*, WebKit::InstallMissingMediaPluginsPermissionRequest&);
 
 #endif // WebKitWebViewPrivate_h
index 1864efd..3274995 100644 (file)
@@ -593,6 +593,25 @@ webkit_geolocation_permission_request_get_type
 </SECTION>
 
 <SECTION>
+<FILE>WebKitInstallMissingMediaPluginsPermissionRequest</FILE>
+WebKitInstallMissingMediaPluginsPermissionRequest
+webkit_install_missing_media_plugins_permission_request_get_description
+
+<SUBSECTION Standard>
+WebKitInstallMissingMediaPluginsPermissionRequestClass
+WEBKIT_TYPE_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST
+WEBKIT_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST
+WEBKIT_IS_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST
+WEBKIT_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST_CLASS
+WEBKIT_IS_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST_CLASS
+WEBKIT_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST_GET_CLASS
+
+<SUBSECTION Private>
+WebKitInstallMissingMediaPluginsPermissionRequestPrivate
+webkit_install_missing_media_plugins_permission_request_get_type
+</SECTION>
+
+<SECTION>
 <FILE>WebKitNavigationAction</FILE>
 WebKitNavigationAction
 webkit_navigation_action_copy
index 9cdc098..f22748e 100644 (file)
@@ -31,3 +31,4 @@ webkit_user_content_manager_get_type
 webkit_web_hit_test_result_get_type
 webkit_website_data_manager_get_type
 webkit_editor_state_get_type
+webkit_install_missing_media_plugins_permission_request_get_type
index 03eec27..756aa0e 100644 (file)
@@ -23,6 +23,7 @@
     <xi:include href="xml/WebKitDownload.xml"/>
     <xi:include href="xml/WebKitPermissionRequest.xml"/>
     <xi:include href="xml/WebKitGeolocationPermissionRequest.xml"/>
+    <xi:include href="xml/WebKitInstallMissingMediaPluginsPermissionRequest.xml"/>
     <xi:include href="xml/WebKitNavigationAction.xml"/>
     <xi:include href="xml/WebKitUserMediaPermissionRequest.xml"/>
     <xi:include href="xml/WebKitPolicyDecision.xml"/>
index cea4ea8..7e08a65 100644 (file)
@@ -48,6 +48,7 @@
 #include <webkit2/WebKitFormSubmissionRequest.h>
 #include <webkit2/WebKitGeolocationPermissionRequest.h>
 #include <webkit2/WebKitHitTestResult.h>
+#include <webkit2/WebKitInstallMissingMediaPluginsPermissionRequest.h>
 #include <webkit2/WebKitJavascriptResult.h>
 #include <webkit2/WebKitMimeInfo.h>
 #include <webkit2/WebKitNavigationAction.h>
index f0269eb..6785360 100644 (file)
 #include <WebCore/EditorClient.h>
 #include <wtf/Forward.h>
 
-#if USE(GSTREAMER)
-#include <WebCore/GUniquePtrGStreamer.h>
-#endif
-
 #if PLATFORM(COCOA)
 #include "PluginComplexTextInputState.h"
 
@@ -79,6 +75,10 @@ class WebColorPicker;
 class WebFullScreenManagerProxyClient;
 #endif
 
+#if USE(GSTREAMER)
+class InstallMissingMediaPluginsPermissionRequest;
+#endif
+
 #if PLATFORM(COCOA)
 struct ColorSpaceData;
 #endif
@@ -341,7 +341,7 @@ public:
     virtual void derefView() = 0;
 
 #if USE(GSTREAMER)
-    virtual GUniquePtr<GstInstallPluginsContext> createGstInstallPluginsContext() = 0;
+    virtual bool decicePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&) = 0;
 #endif
 };
 
index 2be1384..63b8a6d 100644 (file)
@@ -1478,7 +1478,7 @@ private:
 #if ENABLE(VIDEO)
     void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&);
 #if USE(GSTREAMER)
-    void requestInstallMissingMediaPlugins(const String& details);
+    void requestInstallMissingMediaPlugins(const String& details, const String& description);
 #endif
 #endif
 
index 2ca54ea..d5cc211 100644 (file)
@@ -453,6 +453,6 @@ messages -> WebPageProxy {
     FixedLayoutSizeDidChange(WebCore::IntSize fixedLayoutSize)
 
 #if ENABLE(VIDEO) && USE(GSTREAMER)
-    RequestInstallMissingMediaPlugins(String details)
+    RequestInstallMissingMediaPlugins(String details, String description)
 #endif
 }
index 5e3e9a0..d11a1fe 100644 (file)
@@ -98,7 +98,7 @@ private:
     virtual void derefView() override final { }
 
 #if USE(GSTREAMER)
-    virtual GUniquePtr<GstInstallPluginsContext> createGstInstallPluginsContext() override final { return nullptr; };
+    virtual bool decicePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&) override final { return false; };
 #endif
 
 private:
diff --git a/Source/WebKit2/UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.cpp b/Source/WebKit2/UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.cpp
new file mode 100644 (file)
index 0000000..11d759e
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "InstallMissingMediaPluginsPermissionRequest.h"
+
+#if ENABLE(VIDEO) && USE(GSTREAMER)
+#include "WebPageMessages.h"
+#include "WebPageProxy.h"
+#include <wtf/text/CString.h>
+
+namespace WebKit {
+
+InstallMissingMediaPluginsPermissionRequest::InstallMissingMediaPluginsPermissionRequest(WebPageProxy& page,  const String& details, const String& description)
+    : m_page(&page)
+    , m_details(details)
+    , m_description(description)
+{
+}
+
+InstallMissingMediaPluginsPermissionRequest::~InstallMissingMediaPluginsPermissionRequest()
+{
+}
+
+void InstallMissingMediaPluginsPermissionRequest::allow(GUniquePtr<GstInstallPluginsContext>&& context)
+{
+    if (!m_page->isValid())
+        return;
+
+    CString detail = m_details.utf8();
+    const char* detailArray[2] = { detail.data(), nullptr };
+    ref();
+    GstInstallPluginsReturn result = gst_install_plugins_async(detailArray, context.get(), [](GstInstallPluginsReturn result, gpointer userData) {
+        RefPtr<InstallMissingMediaPluginsPermissionRequest> request = adoptRef(static_cast<InstallMissingMediaPluginsPermissionRequest*>(userData));
+        request->didEndRequestInstallMissingMediaPlugins(static_cast<uint32_t>(result));
+        }, this);
+
+    if (result != GST_INSTALL_PLUGINS_STARTED_OK) {
+        // If the installer didn't start, the callback will not be called, so remove the ref manually.
+        deref();
+        didEndRequestInstallMissingMediaPlugins(static_cast<uint32_t>(result));
+        WTFLogAlways("Missing GStreamer Plugin: %s\n", detail.data());
+    }
+}
+
+void InstallMissingMediaPluginsPermissionRequest::deny()
+{
+    didEndRequestInstallMissingMediaPlugins(static_cast<uint32_t>(GST_INSTALL_PLUGINS_USER_ABORT));
+}
+
+void InstallMissingMediaPluginsPermissionRequest::didEndRequestInstallMissingMediaPlugins(uint32_t result)
+{
+    if (!m_page->isValid())
+        return;
+
+    m_page->send(Messages::WebPage::DidEndRequestInstallMissingMediaPlugins(result));
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(VIDEO) && USE(GSTREAMER)
diff --git a/Source/WebKit2/UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.h b/Source/WebKit2/UIProcess/gstreamer/InstallMissingMediaPluginsPermissionRequest.h
new file mode 100644 (file)
index 0000000..e381589
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 InstallMissingMediaPluginsPermissionRequest_h
+#define InstallMissingMediaPluginsPermissionRequest_h
+
+#if ENABLE(VIDEO) && USE(GSTREAMER)
+#include <WebCore/GUniquePtrGStreamer.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class InstallMissingMediaPluginsPermissionRequest : public RefCounted<InstallMissingMediaPluginsPermissionRequest> {
+public:
+    static Ref<InstallMissingMediaPluginsPermissionRequest> create(WebPageProxy& page, const String& details, const String& description)
+    {
+        return adoptRef(*new InstallMissingMediaPluginsPermissionRequest(page, details, description));
+    }
+    ~InstallMissingMediaPluginsPermissionRequest();
+
+    void allow(GUniquePtr<GstInstallPluginsContext>&& = nullptr);
+    void deny();
+
+    WebPageProxy& page() const { return *m_page; }
+    const String& details() const { return m_details; }
+    const String& description() const { return m_description; }
+
+private:
+    InstallMissingMediaPluginsPermissionRequest(WebPageProxy&, const String& details, const String& description);
+
+    void didEndRequestInstallMissingMediaPlugins(uint32_t result);
+
+    RefPtr<WebPageProxy> m_page;
+    String m_details;
+    String m_description;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(VIDEO) && USE(GSTREAMER)
+#endif // InstallMissingMediaPluginsPermissionRequest_h
index 3013482..a97dcaa 100644 (file)
 #include "WebPageProxy.h"
 
 #if ENABLE(VIDEO) && USE(GSTREAMER)
-
+#include "InstallMissingMediaPluginsPermissionRequest.h"
 #include "PageClient.h"
-#include "WebPageMessages.h"
 
 namespace WebKit {
 
-void WebPageProxy::requestInstallMissingMediaPlugins(const String& details)
+void WebPageProxy::requestInstallMissingMediaPlugins(const String& details, const String& description)
 {
-    CString detail = details.utf8();
-    const char* detailArray[2] = { detail.data(), nullptr };
-    ref();
-    GUniquePtr<GstInstallPluginsContext> context = m_pageClient.createGstInstallPluginsContext();
-    GstInstallPluginsReturn result = gst_install_plugins_async(detailArray, context.get(), [](GstInstallPluginsReturn result, gpointer userData) {
-        RefPtr<WebPageProxy> page = adoptRef(static_cast<WebPageProxy*>(userData));
-        if (page->isValid())
-            page->send(Messages::WebPage::DidEndRequestInstallMissingMediaPlugins(static_cast<uint32_t>(result)));
-    }, this);
+    RefPtr<InstallMissingMediaPluginsPermissionRequest> request = InstallMissingMediaPluginsPermissionRequest::create(*this, details, description);
+    if (m_pageClient.decicePolicyForInstallMissingMediaPluginsPermissionRequest(*request))
+        return;
 
-    if (result != GST_INSTALL_PLUGINS_STARTED_OK) {
-        // If the installer didn't start, the callback will not be called, so remove the ref manually.
-        deref();
-        send(Messages::WebPage::DidEndRequestInstallMissingMediaPlugins(static_cast<uint32_t>(result)));
-        WTFLogAlways("Missing GStreamer Plugin: %s\n", detail.data());
-    }
+    request->deny();
 }
 
 } // namespace WebKit
index d5a05ab..ac82ad1 100644 (file)
@@ -1170,9 +1170,9 @@ void WebChromeClient::mediaDocumentNaturalSizeChanged(const WebCore::IntSize& ne
 }
 
 #if USE(GSTREAMER)
-void WebChromeClient::requestInstallMissingMediaPlugins(const String& details, WebCore::MediaPlayerRequestInstallMissingPluginsCallback& callback)
+void WebChromeClient::requestInstallMissingMediaPlugins(const String& details, const String& description, WebCore::MediaPlayerRequestInstallMissingPluginsCallback& callback)
 {
-    m_page->requestInstallMissingMediaPlugins(details, callback);
+    m_page->requestInstallMissingMediaPlugins(details, description, callback);
 }
 #endif
 #endif // ENABLE(VIDEO)
index ec25d23..c1ed387 100644 (file)
@@ -327,7 +327,7 @@ private:
 #if ENABLE(VIDEO)
     virtual void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&) override;
 #if USE(GSTREAMER)
-    virtual void requestInstallMissingMediaPlugins(const String&, WebCore::MediaPlayerRequestInstallMissingPluginsCallback&) override;
+    virtual void requestInstallMissingMediaPlugins(const String& /*details*/, const String& /*description*/, WebCore::MediaPlayerRequestInstallMissingPluginsCallback&) override;
 #endif
 #endif
 
index 5c4c8be..d240b3a 100644 (file)
@@ -909,7 +909,7 @@ public:
 #if ENABLE(VIDEO)
     void mediaDocumentNaturalSizeChanged(const WebCore::IntSize&);
 #if USE(GSTREAMER)
-    void requestInstallMissingMediaPlugins(const String& details, WebCore::MediaPlayerRequestInstallMissingPluginsCallback&);
+    void requestInstallMissingMediaPlugins(const String& details, const String& description, WebCore::MediaPlayerRequestInstallMissingPluginsCallback&);
 #endif
 #endif
 
index f5a45ff..50545b3 100644 (file)
@@ -34,7 +34,7 @@
 
 namespace WebKit {
 
-void WebPage::requestInstallMissingMediaPlugins(const String& details, WebCore::MediaPlayerRequestInstallMissingPluginsCallback& callback)
+void WebPage::requestInstallMissingMediaPlugins(const String& details, const String& description, WebCore::MediaPlayerRequestInstallMissingPluginsCallback& callback)
 {
     if (m_installMediaPluginsCallback) {
         callback.complete(GST_INSTALL_PLUGINS_INSTALL_IN_PROGRESS);
@@ -42,7 +42,7 @@ void WebPage::requestInstallMissingMediaPlugins(const String& details, WebCore::
     }
 
     m_installMediaPluginsCallback = &callback;
-    send(Messages::WebPageProxy::RequestInstallMissingMediaPlugins(details));
+    send(Messages::WebPageProxy::RequestInstallMissingMediaPlugins(details, description));
 }
 
 void WebPage::didEndRequestInstallMissingMediaPlugins(uint32_t result)
index a5be206..6dd59ff 100644 (file)
@@ -1,3 +1,23 @@
+2015-08-07  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GStreamer] Do not automatically show PackageKit codec installation notifications
+        https://bugs.webkit.org/show_bug.cgi?id=135973
+
+        Reviewed by Philippe Normand.
+
+        Handle the missing media plugins installation permission request
+        in MiniBrowser and add a test case for the new API.
+
+        * MiniBrowser/gtk/BrowserWindow.c:
+        (webViewDecidePermissionRequest):
+        * TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt:
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp:
+        (permissionRequestCallback):
+        (testInstallMissingPluginsPermissionRequest):
+        (beforeAll):
+        * TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:
+        (methodCallCallback):
+
 2015-08-06  Filip Pizlo  <fpizlo@apple.com>
 
         Unreviewed, reduce the duration of a Lock unit test. It was timing out.
index 9a4902e..45db680 100644 (file)
@@ -454,6 +454,10 @@ static gboolean webViewDecidePermissionRequest(WebKitWebView *webView, WebKitPer
                 dialog_message = "audio";
         } else if (is_for_video_device)
             dialog_message = "video";
+    } else if (WEBKIT_IS_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST(request)) {
+        dialog_title = "Media plugin missing request";
+        dialog_message_format = "The media backend was unable to find a plugin to play the requested media:\n%s.\nAllow to search and install the missing plugin?";
+        dialog_message = webkit_install_missing_media_plugins_permission_request_get_description(WEBKIT_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST(request));
     } else
         return FALSE;
 
index 1bbf52d..74d5250 100644 (file)
@@ -26,6 +26,7 @@ include_directories(
 include_directories(SYSTEM
     ${ATSPI_INCLUDE_DIRS}
     ${GLIB_INCLUDE_DIRS}
+    ${GSTREAMER_INCLUDE_DIRS}
     ${GTK3_INCLUDE_DIRS}
     ${GTK_UNIX_PRINT_INCLUDE_DIRS}
     ${LIBSOUP_INCLUDE_DIRS}
index 82d3ec3..8278010 100644 (file)
@@ -180,6 +180,36 @@ static void testWebExtensionIsolatedWorld(WebViewTest* test, gconstpointer)
     g_signal_handler_disconnect(test->m_webView, scriptDialogID);
 }
 
+static gboolean permissionRequestCallback(WebKitWebView*, WebKitPermissionRequest* request, WebViewTest* test)
+{
+    if (!WEBKIT_IS_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST(request))
+        return FALSE;
+
+    test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+    WebKitInstallMissingMediaPluginsPermissionRequest* missingPluginsRequest = WEBKIT_INSTALL_MISSING_MEDIA_PLUGINS_PERMISSION_REQUEST(request);
+    g_assert(webkit_install_missing_media_plugins_permission_request_get_description(missingPluginsRequest));
+    webkit_permission_request_deny(request);
+    test->quitMainLoop();
+}
+
+static void testInstallMissingPluginsPermissionRequest(WebViewTest* test, gconstpointer)
+{
+    GUniquePtr<char> extensionBusName(g_strdup_printf("org.webkit.gtk.WebExtensionTest%u", Test::s_webExtensionID));
+    GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy(extensionBusName.get(),
+        "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", test->m_mainLoop));
+    GRefPtr<GVariant> result = adoptGRef(g_dbus_proxy_call_sync(proxy.get(), "RemoveAVPluginsFromGSTRegistry",
+        nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr));
+
+    test->showInWindowAndWaitUntilMapped();
+
+    gulong permissionRequestSignalID = g_signal_connect(test->m_webView, "permission-request", G_CALLBACK(permissionRequestCallback), test);
+    // FIXME: the base URI needs to finish with / to work, that shouldn't happen.
+    GUniquePtr<char> baseURI(g_strconcat("file://", Test::getResourcesDir(Test::WebKit2Resources).data(), "/", nullptr));
+    test->loadHtml("<html><body><video src=\"test.mp4\" autoplay></video></body></html>", baseURI.get());
+    g_main_loop_run(test->m_mainLoop);
+    g_signal_handler_disconnect(test->m_webView, permissionRequestSignalID);
+}
+
 void beforeAll()
 {
     bus = new WebKitTestBus();
@@ -191,6 +221,7 @@ void beforeAll()
     WebViewTest::add("WebKitWebView", "web-process-crashed", testWebKitWebViewProcessCrashed);
     WebViewTest::add("WebKitWebExtension", "window-object-cleared", testWebExtensionWindowObjectCleared);
     WebViewTest::add("WebKitWebExtension", "isolated-world", testWebExtensionIsolatedWorld);
+    WebViewTest::add("WebKitWebView", "install-missing-plugins-permission-request", testInstallMissingPluginsPermissionRequest);
 }
 
 void afterAll()
index 51bd637..38c7d94 100644 (file)
@@ -22,6 +22,7 @@
 #include <JavaScriptCore/JSContextRef.h>
 #include <JavaScriptCore/JSRetainPtr.h>
 #include <gio/gio.h>
+#include <gst/gst.h>
 #include <stdlib.h>
 #include <string.h>
 #include <webkit2/webkit-web-extension.h>
@@ -52,6 +53,8 @@ static const char introspectionXML[] =
     "  <method name='GetProcessIdentifier'>"
     "   <arg type='u' name='identifier' direction='out'/>"
     "  </method>"
+    "  <method name='RemoveAVPluginsFromGSTRegistry'>"
+    "  </method>"
     "  <signal name='DocumentLoaded'/>"
     "  <signal name='URIChanged'>"
     "   <arg type='s' name='uri' direction='out'/>"
@@ -301,6 +304,17 @@ static void methodCallCallback(GDBusConnection* connection, const char* sender,
     } else if (!g_strcmp0(methodName, "GetProcessIdentifier")) {
         g_dbus_method_invocation_return_value(invocation,
             g_variant_new("(u)", static_cast<guint32>(getCurrentProcessID())));
+    } else if (!g_strcmp0(methodName, "RemoveAVPluginsFromGSTRegistry")) {
+        gst_init(nullptr, nullptr);
+        static const char* avPlugins[] = { "libav", "omx", "vaapi", nullptr };
+        GstRegistry* registry = gst_registry_get();
+        for (unsigned i = 0; avPlugins[i]; ++i) {
+            if (GstPlugin* plugin = gst_registry_find_plugin(registry, avPlugins[i])) {
+                gst_registry_remove_plugin(registry, plugin);
+                gst_object_unref(plugin);
+            }
+        }
+        g_dbus_method_invocation_return_value(invocation, nullptr);
     }
 }