[GTK] Add support for loading web process extensions
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2013 11:27:49 +0000 (11:27 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2013 11:27:49 +0000 (11:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105631

Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2013-01-10
Reviewed by Gustavo Noronha Silva.

.:

* GNUmakefile.am: Add webkit2_web_extension_h_api.
* Source/autotools/symbols.filter: Export WebGtkExtensionManager
symbols required by the injected bundle lib.

Source/WebKit2:

* GNUmakefile.am: Link to libWebCoreDOM.la and build injected
bundle lib.
* GNUmakefile.list.am: Add new files to compilation.
* UIProcess/API/gtk/WebKitWebContext.cpp:
(injectedBundleDirectory): Helper funtion to get the injected
bundle directory.
(injectedBundleFilename): Helper funtion to get the injected undle
library full path.
(createDefaultWebContext): Create the WebContext with an injected
bundle path.
* UIProcess/API/gtk/WebKitWebView.cpp:
(webkit_web_view_get_page_id): Return the identifier of the web
page associated to the web view.
* UIProcess/API/gtk/WebKitWebView.h:
* UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new chapter for
web extensions.
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols.
* UIProcess/API/gtk/docs/webkit2gtk.types: Add new types.
* UIProcess/API/gtk/tests/GNUmakefile.am: Add new files to compilation.
* UIProcess/API/gtk/tests/TestMain.cpp:
(main):
* UIProcess/API/gtk/tests/TestWebExtensions.cpp: Added.
(testWebExtension):
(beforeAll):
(afterAll):
* UIProcess/API/gtk/tests/WebExtensionTest.cpp: Added.
(methodCallCallback):
(webkit_web_extension_initialize):
* UIProcess/API/gtk/tests/WebKitTestBus.cpp: Added.
(WebKitTestBus::WebKitTestBus):
(WebKitTestBus::run):
(WebKitTestBus::~WebKitTestBus):
(WebKitTestBus::connection):
(onNameAppeared):
(WebKitTestBus::createProxy):
* UIProcess/API/gtk/tests/WebKitTestBus.h: Added.
(WebKitTestBus):
* WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp: Added.
(_WebKitWebExtensionPrivate):
(webkitWebExtensionPageCreated): Create a WebKitWebPage for the
newly crated page and emit WebKitWebExtension::page-created
signals.
(webkitWebExtensionPageDestroy): Remove the page from the map.
(didCreatePage): Call webkitWebExtensionPageCreated().
(willDestroyPage): Call webkitWebExtensionPageDestroy().
(webkitWebExtensionCreate): Create a new WebKitWebExtension and
initialize the injected bundle client.
(webkit_web_extension_get_page): Return the WebKitWebPage for the
given page identifier.
* WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.h: Added.
(_WebKitWebExtension):
(_WebKitWebExtensionClass):
* WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionDefines.h: Added.
* WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionPrivate.h: Added.
* WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp: Added.
(_WebKitWebPagePrivate):
(webkit_web_page_class_init):
(webkitWebPageCreate): Create a new WebKitWebPage.
(webkit_web_page_get_dom_document): Return the WebKitDOMDocument
loaded in the WebKitWebPage.
* WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h: Added.
(_WebKitWebPage):
(_WebKitWebPageClass):
* WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h: Added.
* WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h: Added.
* WebProcess/gtk/WebGtkExtensionManager.cpp: Added.
(WebKit::WebGtkExtensionManager::shared): Return the global shared
instance.
(WebKit::WebGtkExtensionManager::WebGtkExtensionManager):
(WebKit::WebGtkExtensionManager::appendModuleDirectories): Add
directories to scan for modules.
(WebKit::WebGtkExtensionManager::scanModules): Scan for modules.
(WebKit::WebGtkExtensionManager::initialize): Load and initialize
the modules found.
* WebProcess/gtk/WebGtkExtensionManager.h: Added.
* WebProcess/gtk/WebGtkInjectedBundleMain.cpp: Added.
(WKBundleInitialize): Initialize WebGtkExtensionManager.

Tools:

* MiniBrowser/gtk/GNUmakefile.am:
* MiniBrowser/gtk/main.c:
(main): Set WEBKIT_INJECTED_BUNDLE env var to use the injected
bundle lib from build dir.
* Scripts/webkitpy/style/checker.py: Add exceptions for GTK+ API
located in WebProcess/InjectedBundle/API/gtk.
* gtk/generate-gtkdoc:
(get_webkit2_options): Scan also files in
WebProcess/InjectedBundle/API/gtk to generate API docs.
(get_webkit2_options.injected_bundle_src_path): Helper function to
build paths in WebProcess/InjectedBundle/API/gtk.

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

34 files changed:
ChangeLog
GNUmakefile.am
Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.am
Source/WebKit2/GNUmakefile.list.am
Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types
Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp
Source/WebKit2/UIProcess/API/gtk/tests/TestWebExtensions.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionDefines.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionPrivate.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h [new file with mode: 0644]
Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.h [new file with mode: 0644]
Source/WebKit2/WebProcess/gtk/WebGtkInjectedBundleMain.cpp [new file with mode: 0644]
Source/autotools/symbols.filter
Tools/ChangeLog
Tools/MiniBrowser/gtk/GNUmakefile.am
Tools/MiniBrowser/gtk/main.c
Tools/Scripts/webkitpy/style/checker.py
Tools/gtk/generate-gtkdoc

index 9440ae6..e4dc26d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-01-10  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Add support for loading web process extensions
+        https://bugs.webkit.org/show_bug.cgi?id=105631
+
+        Reviewed by Gustavo Noronha Silva.
+
+        * GNUmakefile.am: Add webkit2_web_extension_h_api.
+        * Source/autotools/symbols.filter: Export WebGtkExtensionManager
+        symbols required by the injected bundle lib.
+
 2013-01-10  Christophe Dumez  <christophe.dumez@intel.com>
 
         [EFL] Add gstreamer 1.0.5 to jhbuild
index 1862189..975448f 100644 (file)
@@ -98,6 +98,7 @@ webkit2_sources :=
 webkit2_built_sources :=
 webkit2gtk_h_api :=
 webkit2gtk_built_sources :=
+webkit2_web_extension_h_api :=
 webkit2_plugin_process_sources :=
 webkit2_plugin_process_built_sources :=
 webkittestrunner_built_sources :=
index 6a2c2b4..32e2b05 100644 (file)
@@ -1,3 +1,88 @@
+2013-01-10  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Add support for loading web process extensions
+        https://bugs.webkit.org/show_bug.cgi?id=105631
+
+        Reviewed by Gustavo Noronha Silva.
+
+        * GNUmakefile.am: Link to libWebCoreDOM.la and build injected
+        bundle lib.
+        * GNUmakefile.list.am: Add new files to compilation.
+        * UIProcess/API/gtk/WebKitWebContext.cpp:
+        (injectedBundleDirectory): Helper funtion to get the injected
+        bundle directory.
+        (injectedBundleFilename): Helper funtion to get the injected undle
+        library full path.
+        (createDefaultWebContext): Create the WebContext with an injected
+        bundle path.
+        * UIProcess/API/gtk/WebKitWebView.cpp:
+        (webkit_web_view_get_page_id): Return the identifier of the web
+        page associated to the web view.
+        * UIProcess/API/gtk/WebKitWebView.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new chapter for
+        web extensions.
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols.
+        * UIProcess/API/gtk/docs/webkit2gtk.types: Add new types.
+        * UIProcess/API/gtk/tests/GNUmakefile.am: Add new files to compilation.
+        * UIProcess/API/gtk/tests/TestMain.cpp:
+        (main):
+        * UIProcess/API/gtk/tests/TestWebExtensions.cpp: Added.
+        (testWebExtension):
+        (beforeAll):
+        (afterAll):
+        * UIProcess/API/gtk/tests/WebExtensionTest.cpp: Added.
+        (methodCallCallback):
+        (webkit_web_extension_initialize):
+        * UIProcess/API/gtk/tests/WebKitTestBus.cpp: Added.
+        (WebKitTestBus::WebKitTestBus):
+        (WebKitTestBus::run):
+        (WebKitTestBus::~WebKitTestBus):
+        (WebKitTestBus::connection):
+        (onNameAppeared):
+        (WebKitTestBus::createProxy):
+        * UIProcess/API/gtk/tests/WebKitTestBus.h: Added.
+        (WebKitTestBus):
+        * WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp: Added.
+        (_WebKitWebExtensionPrivate):
+        (webkitWebExtensionPageCreated): Create a WebKitWebPage for the
+        newly crated page and emit WebKitWebExtension::page-created
+        signals.
+        (webkitWebExtensionPageDestroy): Remove the page from the map.
+        (didCreatePage): Call webkitWebExtensionPageCreated().
+        (willDestroyPage): Call webkitWebExtensionPageDestroy().
+        (webkitWebExtensionCreate): Create a new WebKitWebExtension and
+        initialize the injected bundle client.
+        (webkit_web_extension_get_page): Return the WebKitWebPage for the
+        given page identifier.
+        * WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.h: Added.
+        (_WebKitWebExtension):
+        (_WebKitWebExtensionClass):
+        * WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionDefines.h: Added.
+        * WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionPrivate.h: Added.
+        * WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp: Added.
+        (_WebKitWebPagePrivate):
+        (webkit_web_page_class_init):
+        (webkitWebPageCreate): Create a new WebKitWebPage.
+        (webkit_web_page_get_dom_document): Return the WebKitDOMDocument
+        loaded in the WebKitWebPage.
+        * WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h: Added.
+        (_WebKitWebPage):
+        (_WebKitWebPageClass):
+        * WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h: Added.
+        * WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h: Added.
+        * WebProcess/gtk/WebGtkExtensionManager.cpp: Added.
+        (WebKit::WebGtkExtensionManager::shared): Return the global shared
+        instance.
+        (WebKit::WebGtkExtensionManager::WebGtkExtensionManager):
+        (WebKit::WebGtkExtensionManager::appendModuleDirectories): Add
+        directories to scan for modules.
+        (WebKit::WebGtkExtensionManager::scanModules): Scan for modules.
+        (WebKit::WebGtkExtensionManager::initialize): Load and initialize
+        the modules found.
+        * WebProcess/gtk/WebGtkExtensionManager.h: Added.
+        * WebProcess/gtk/WebGtkInjectedBundleMain.cpp: Added.
+        (WKBundleInitialize): Initialize WebGtkExtensionManager.
+
 2013-01-10  Huang Dongsung  <luxtella@company100.net>
 
         REGRESSION(r139189): pixel alignment must be performed in device units.
index 3be7be2..a0118b5 100644 (file)
@@ -23,7 +23,8 @@ nodist_libwebkit2gtkinclude_HEADERS = \
        DerivedSources/WebKit2/webkit2gtk/webkit2/WebKitVersion.h
 
 libwebkit2gtkinclude_HEADERS = \
-       $(webkit2gtk_h_api)
+       $(webkit2gtk_h_api) \
+       $(webkit2_web_extension_h_api)
 
 nodist_libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_SOURCES = \
        $(webkit2_built_sources) \
@@ -87,6 +88,7 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_CPP
        -I$(srcdir)/Source/WebKit2/WebProcess/InjectedBundle \
        -I$(srcdir)/Source/WebKit2/WebProcess/InjectedBundle/API \
        -I$(srcdir)/Source/WebKit2/WebProcess/InjectedBundle/API/c \
+       -I$(srcdir)/Source/WebKit2/WebProcess/InjectedBundle/API/gtk \
        -I$(srcdir)/Source/WebKit2/WebProcess/InjectedBundle/DOM \
        -I$(srcdir)/Source/WebKit2/WebProcess/InjectedBundle/gtk \
        -I$(srcdir)/Source/WebKit2/WebProcess/KeyValueStorage \
@@ -103,17 +105,21 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_CPP
        -I$(srcdir)/Source/WebKit2/WebProcess/WebCoreSupport/gtk \
        -I$(srcdir)/Source/WebKit2/WebProcess/WebCoreSupport/soup \
        -I$(srcdir)/Source/WebKit2/WebProcess/WebPage \
-    -I$(srcdir)/Source/WebKit2/WebProcess/WebPage/atk \
+       -I$(srcdir)/Source/WebKit2/WebProcess/WebPage/atk \
        -I$(srcdir)/Source/WebKit2/WebProcess/WebPage/gtk \
        -I$(top_builddir)/DerivedSources/WebKit2 \
        -I$(top_builddir)/DerivedSources/WebKit2/include \
        -I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk \
        -I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk/include \
        -I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk/webkit2 \
+       -I$(top_builddir)/DerivedSources/WebKit2/webkit2extension/include \
        -I$(top_builddir)/DerivedSources/WebKit2/include/JavaScriptCore \
        -I$(top_builddir)/DerivedSources/WebKit2/include/WebCore \
        -I$(top_builddir)/DerivedSources/WebKit2/include/WebKit2 \
+       -I$(top_builddir)/DerivedSources/webkitdom \
        -DLIBEXECDIR=\""$(libexecdir)"\" \
+       -DLIBDIR=\""$(libdir)"\" \
+       -DBUILDING_WEBKIT \
        -DWEBKIT2_COMPILATION \
        -DENABLE_PLUGIN_PROCESS=1 \
        $(webcore_cppflags) \
@@ -177,6 +183,7 @@ endif
 
 libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_LIBADD += \
        libjavascriptcoregtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
+       libWebCoreDOM.la \
        libWebCoreGtk.la \
        $(CAIRO_LIBS) \
        $(CLUTTER_LIBS) \
@@ -282,7 +289,13 @@ $(GENSOURCES_WEBKIT2)/webkit2gtk/include/webkit2: $(libwebkit2gtkinclude_HEADERS
        $(AM_V_GEN)mkdir -p $(GENSOURCES_WEBKIT2)/webkit2gtk/include \
        && ln -n -s -f ${shell pwd}/$(WebKit2)/UIProcess/API/gtk $@
 
-BUILT_SOURCES += $(GENSOURCES_WEBKIT2)/webkit2gtk/include/webkit2
+$(GENSOURCES_WEBKIT2)/webkit2extension/include/webkit2: $(libwebkit2gtkinclude_HEADERS)
+       $(AM_V_GEN)mkdir -p $(GENSOURCES_WEBKIT2)/webkit2extension/include \
+       && ln -n -s -f ${shell pwd}/$(WebKit2)/WebProcess/InjectedBundle/API/gtk $@
+
+BUILT_SOURCES += \
+       $(GENSOURCES_WEBKIT2)/webkit2extension/include/webkit2 \
+       $(GENSOURCES_WEBKIT2)/webkit2gtk/include/webkit2
 
 vpath %.messages.in = \
        $(WebKit2)/PluginProcess \
@@ -478,6 +491,32 @@ libWebCoreGtk2_la_CPPFLAGS = \
        $(XRENDER_CFLAGS) \
        $(XT_CFLAGS)
 
+# Injected Bundle
+injectedbundledir = $(libdir)/webkit2gtk-3.0/injected-bundle
+injectedbundle_LTLIBRARIES = libwebkit2gtkinjectedbundle.la
+
+libwebkit2gtkinjectedbundle_la_SOURCES = \
+       Source/WebKit2/WebProcess/gtk/WebGtkInjectedBundleMain.cpp
+
+libwebkit2gtkinjectedbundle_la_LDFLAGS = \
+       $(no_undefined) \
+       -module \
+       -avoid-version
+
+libwebkit2gtkinjectedbundle_la_CPPFLAGS = \
+       -fno-strict-aliasing \
+       -I$(srcdir)/Source/WebKit2/Platform \
+       -I$(srcdir)/Source/WebKit2/Shared \
+       -I$(srcdir)/Source/WebKit2/Shared/API/c \
+       -I$(srcdir)/Source/WebKit2/UIProcess/API/C \
+       -I$(srcdir)/Source/WebKit2/WebProcess/InjectedBundle \
+       -I$(srcdir)/Source/WebKit2/WebProcess/InjectedBundle/API/c \
+       -I$(top_builddir)/DerivedSources/InjectedBundle \
+       -I$(top_builddir)/DerivedSources/WebKit2/include \
+       $(global_cppflags) \
+       $(javascriptcore_cppflags) \
+       $(GLIB_CFLAGS)
+
 # Serialize linking of the plugin process with both webkit libraries.
 plugin_process_for_dep = Programs/WebKitPluginProcess
 $(plugin_process_for_dep): libwebkitgtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la libwebkit2gtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la
index 64f4a85..c74c5be 100644 (file)
@@ -132,6 +132,12 @@ webkit2gtk_h_api += \
        $(WebKit2)/UIProcess/API/gtk/WebKitWindowProperties.h \
        $(WebKit2)/UIProcess/API/gtk/webkit2.h
 
+webkit2_web_extension_h_api += \
+       $(WebKit2)/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.h \
+       $(WebKit2)/WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionDefines.h \
+       $(WebKit2)/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h \
+       $(WebKit2)/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h
+
 webkit2_built_sources += \
        DerivedSources/WebKit2/AuthenticationManagerMessageReceiver.cpp \
        DerivedSources/WebKit2/AuthenticationManagerMessages.h \
@@ -991,6 +997,8 @@ webkit2_sources += \
        Source/WebKit2/WebProcess/Geolocation/GeolocationPermissionRequestManager.h \
        Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp \
        Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.h \
+       Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp \
+       Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.h \
        Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp \
        Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.h \
        Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.cpp \
@@ -1033,6 +1041,14 @@ webkit2_sources += \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.h \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h \
+       Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp \
+       Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.h \
+       Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionPrivate.h \
+       Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionDefines.h \
+       Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp \
+       Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h \
+       Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h \
+       Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h \
        Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp \
        Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h \
        Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp \
@@ -1185,8 +1201,8 @@ webkit2_sources += \
        Source/WebKit2/WebProcess/WebPage/FindController.h \
        Source/WebKit2/WebProcess/WebPage/TapHighlightController.cpp \
        Source/WebKit2/WebProcess/WebPage/TapHighlightController.h \
-    Source/WebKit2/WebProcess/WebPage/atk/WebPageAccessibilityObject.h \
-    Source/WebKit2/WebProcess/WebPage/atk/WebPageAccessibilityObjectAtk.cpp \
+       Source/WebKit2/WebProcess/WebPage/atk/WebPageAccessibilityObject.h \
+       Source/WebKit2/WebProcess/WebPage/atk/WebPageAccessibilityObjectAtk.cpp \
        Source/WebKit2/WebProcess/WebPage/gtk/WebInspectorGtk.cpp \
        Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp \
        Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp \
index 6538b54..d8838cd 100644 (file)
@@ -166,12 +166,27 @@ static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass
                      WEBKIT_TYPE_DOWNLOAD);
 }
 
+static CString injectedBundleDirectory()
+{
+    if (const char* bundleDirectory = g_getenv("WEBKIT_INJECTED_BUNDLE_PATH"))
+        return bundleDirectory;
+
+    static const char* injectedBundlePath = LIBDIR""G_DIR_SEPARATOR_S"webkit2gtk-"WEBKITGTK_API_VERSION_STRING""G_DIR_SEPARATOR_S"injected-bundle"G_DIR_SEPARATOR_S;
+    return injectedBundlePath;
+}
+
+static CString injectedBundleFilename()
+{
+    GOwnPtr<char> bundleFilename(g_build_filename(injectedBundleDirectory().data(), "libwebkit2gtkinjectedbundle.so", NULL));
+    return bundleFilename.get();
+}
+
 static gpointer createDefaultWebContext(gpointer)
 {
     static GRefPtr<WebKitWebContext> webContext = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, NULL)));
     WebKitWebContextPrivate* priv = webContext->priv;
 
-    priv->context = WebContext::create(String());
+    priv->context = WebContext::create(WebCore::filenameToString(injectedBundleFilename().data()));
     priv->requestManager = webContext->priv->context->supplement<WebSoupRequestManagerProxy>();
     priv->context->setCacheModel(CacheModelPrimaryWebBrowser);
     priv->tlsErrorsPolicy = WEBKIT_TLS_ERRORS_POLICY_IGNORE;
index d0ec8c9..b043d91 100644 (file)
@@ -1848,6 +1848,22 @@ void webkit_web_view_load_request(WebKitWebView* webView, WebKitURIRequest* requ
 }
 
 /**
+ * webkit_web_view_get_page_id:
+ * @web_view: a #WebKitWebView
+ *
+ * Get the identifier of the #WebKitWebPage corresponding to
+ * the #WebKitWebView
+ *
+ * Returns: the page ID of @web_view.
+ */
+guint64 webkit_web_view_get_page_id(WebKitWebView* webView)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+
+    return getPage(webView)->pageID();
+}
+
+/**
  * webkit_web_view_get_title:
  * @web_view: a #WebKitWebView
  *
index 42110ec..b679d9d 100644 (file)
@@ -261,6 +261,9 @@ webkit_web_view_stop_loading                         (WebKitWebView
 WEBKIT_API gboolean
 webkit_web_view_is_loading                           (WebKitWebView             *web_view);
 
+WEBKIT_API guint64
+webkit_web_view_get_page_id                          (WebKitWebView             *web_view);
+
 WEBKIT_API const gchar *
 webkit_web_view_get_title                            (WebKitWebView             *web_view);
 
index 6e97284..7c6c68d 100644 (file)
     <xi:include href="xml/WebKitSecurityManager.xml"/>
   </chapter>
 
+  <chapter>
+    <title>Web Extensions</title>
+    <xi:include href="xml/WebKitWebExtension.xml"/>
+    <xi:include href="xml/WebKitWebPage.xml"/>
+  </chapter>
+
   <index id="index-all">
     <title>Index</title>
   </index>
index 128e2b5..0f9fa31 100644 (file)
@@ -96,6 +96,7 @@ webkit_web_view_go_back
 webkit_web_view_can_go_forward
 webkit_web_view_go_forward
 webkit_web_view_get_title
+webkit_web_view_get_page_id
 webkit_web_view_reload
 webkit_web_view_reload_bypass_cache
 webkit_web_view_stop_loading
@@ -927,3 +928,42 @@ WEBKIT_SECURITY_MANAGER_GET_CLASS
 WebKitSecurityManagerPrivate
 webkit_security_manager_get_type
 </SECTION>
+
+<SECTION>
+<FILE>WebKitWebExtension</FILE>
+WebKitWebExtension
+WebKitWebExtensionInitializeFunction
+webkit_web_extension_get_page
+
+<SUBSECTION Standard>
+WebKitWebExtensionClass
+WEBKIT_TYPE_WEB_EXTENSION
+WEBKIT_WEB_EXTENSION
+WEBKIT_IS_WEB_EXTENSION
+WEBKIT_WEB_EXTENSION_CLASS
+WEBKIT_IS_WEB_EXTENSION_CLASS
+WEBKIT_WEB_EXTENSION_GET_CLASS
+
+<SUBSECTION Private>
+WebKitWebExtensionPrivate
+webkit_web_extension_get_type
+</SECTION>
+
+<SECTION>
+<FILE>WebKitWebPage</FILE>
+WebKitWebPage
+webkit_web_page_get_dom_document
+
+<SUBSECTION Standard>
+WebKitWebPageClass
+WEBKIT_TYPE_WEB_PAGE
+WEBKIT_WEB_PAGE
+WEBKIT_IS_WEB_PAGE
+WEBKIT_WEB_PAGE_CLASS
+WEBKIT_IS_WEB_PAGE_CLASS
+WEBKIT_WEB_PAGE_GET_CLASS
+
+<SUBSECTION Private>
+WebKitWebPagePrivate
+webkit_web_page_get_type
+</SECTION>
index 4d8843e..eb0f338 100644 (file)
@@ -21,3 +21,5 @@ webkit_web_inspector_get_type
 webkit_uri_scheme_request_get_type
 webkit_context_menu_get_type
 webkit_context_menu_item_get_type
+webkit_web_extension_get_type
+webkit_web_page_get_type
index a8f9976..fa0f663 100644 (file)
@@ -12,6 +12,7 @@ TEST_PROGS += \
        Programs/WebKit2APITests/TestPrinting \
        Programs/WebKit2APITests/TestResources \
        Programs/WebKit2APITests/TestSSL \
+       Programs/WebKit2APITests/TestWebExtensions \
        Programs/WebKit2APITests/TestWebKitVersion \
        Programs/WebKit2APITests/TestWebKitFaviconDatabase \
        Programs/WebKit2APITests/TestWebKitFindController \
@@ -34,6 +35,8 @@ webkit2_tests_cppflags = \
        -DWEBKIT_SRC_DIR=\"${shell pwd}/${srcdir}\" \
        -DWEBKIT_DERIVED_SRC_DIR=\"${shell pwd}/${top_builddir}/DerivedSources\" \
        -DWEBKIT_TEST_PLUGIN_DIR=\"${shell pwd}/${top_builddir}/TestNetscapePlugin/.libs\" \
+       -DWEBKIT_TEST_WEB_EXTENSIONS_DIR=\"${shell pwd}/${top_builddir}/Libraries/WebExtensions/.libs\" \
+       -DWEBKIT_INJECTED_BUNDLE_PATH=\"${shell pwd}/$(top_builddir)/.libs\" \
        $(javascriptcore_cppflags) \
        -I$(srcdir)/Source/JavaScriptCore \
        -I$(srcdir)/Source \
@@ -70,6 +73,8 @@ noinst_LTLIBRARIES += Libraries/libWebKit2APITestCore.la
 Libraries_libWebKit2APITestCore_la_SOURCES = \
        Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp \
        Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h \
+       Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.cpp \
+       Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.h \
        Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp \
        Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h \
        Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp \
@@ -78,6 +83,30 @@ Libraries_libWebKit2APITestCore_la_SOURCES = \
        Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h
 Libraries_libWebKit2APITestCore_la_CPPFLAGS = $(webkit2_tests_cppflags)
 
+noinst_LTLIBRARIES += Libraries/WebExtensions/libWebExtensionTest.la
+Libraries_WebExtensions_libWebExtensionTest_la_SOURCES = \
+       Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp
+
+Libraries_WebExtensions_libWebExtensionTest_la_LDFLAGS = \
+       -rpath ${shell pwd}/$(top_builddir)/Libraries/WebExtensions/.libs \
+       $(no_undefined) \
+       -avoid-version \
+       -module
+
+Libraries_WebExtensions_libWebExtensionTest_la_CPPFLAGS = \
+       -I$(srcdir)/Source/WebKit2/WebProcess/InjectedBundle/API/gtk \
+       -I$(top_builddir)/DerivedSources \
+       -I$(top_builddir)/DerivedSources/WebKit2/webkit2extension/include \
+       -DWEBKIT2_COMPILATION \
+       $(webkit2_tests_cppflags)
+
+Libraries_WebExtensions_libWebExtensionTest_la_CXXFLAGS = \
+        $(global_cxxflags)
+
+Libraries_WebExtensions_libWebExtensionTest_la_CFLAGS = \
+        $(global_cflags)
+
+
 EXTRA_DIST += \
        Source/WebKit2/UIProcess/API/gtk/tests/resources/test-cert.pem \
        Source/WebKit2/UIProcess/API/gtk/tests/resources/test-key.pem \
@@ -214,4 +243,10 @@ Programs_WebKit2APITests_TestSSL_CPPFLAGS = $(webkit2_tests_cppflags)
 Programs_WebKit2APITests_TestSSL_LDADD = $(webkit2_tests_ldadd)
 Programs_WebKit2APITests_TestSSL_LDFLAGS = $(webkit2_tests_ldflags)
 
+Programs_WebKit2APITests_TestWebExtensions_SOURCES = \
+        Source/WebKit2/UIProcess/API/gtk/tests/TestWebExtensions.cpp
+Programs_WebKit2APITests_TestWebExtensions_CPPFLAGS = $(webkit2_tests_cppflags)
+Programs_WebKit2APITests_TestWebExtensions_LDADD = $(webkit2_tests_ldadd)
+Programs_WebKit2APITests_TestWebExtensions_LDFLAGS = $(webkit2_tests_ldflags)
+
 endif # ENABLE_WEBKIT2
index 2044ab5..c1dce73 100644 (file)
@@ -39,6 +39,7 @@ int main(int argc, char** argv)
 {
     gtk_test_init(&argc, &argv, 0);
     g_setenv("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH, FALSE);
+    g_setenv("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH, FALSE);
     g_test_bug_base("https://bugs.webkit.org/");
 
     registerGResource();
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebExtensions.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebExtensions.cpp
new file mode 100644 (file)
index 0000000..0f9a184
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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 Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 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 "WebKitTestBus.h"
+#include "WebViewTest.h"
+#include <wtf/gobject/GRefPtr.h>
+
+static WebKitTestBus* bus;
+
+static void testWebExtension(WebViewTest* test, gconstpointer)
+{
+    test->loadHtml("<html><head><title>WebKitGTK+ Web Extensions Test</title></head><body></body></html>", 0);
+    test->waitUntilLoadFinished();
+
+    GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest",
+        "/org/webkit/gtk/WebExtensionTest" , "org.webkit.gtk.WebExtensionTest", test->m_mainLoop));
+    GRefPtr<GVariant> result = adoptGRef(g_dbus_proxy_call_sync(
+        proxy.get(),
+        "GetTitle",
+        g_variant_new("(t)", webkit_web_view_get_page_id(test->m_webView)),
+        G_DBUS_CALL_FLAGS_NONE,
+        -1, 0, 0));
+    g_assert(result);
+
+    const char* title;
+    g_variant_get(result.get(), "(&s)", &title);
+    g_assert_cmpstr(title, ==, "WebKitGTK+ Web Extensions Test");
+}
+
+void beforeAll()
+{
+    g_setenv("WEBKIT_WEB_EXTENSIONS_PATH", WEBKIT_TEST_WEB_EXTENSIONS_DIR, FALSE);
+    bus = new WebKitTestBus();
+    if (!bus->run())
+        return;
+
+    WebViewTest::add("WebKitWebExtension", "dom-document-title", testWebExtension);
+}
+
+void afterAll()
+{
+    delete bus;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/WebExtensionTest.cpp
new file mode 100644 (file)
index 0000000..eaf68c5
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+
+#include <gio/gio.h>
+#include <webkit2/webkit-web-extension.h>
+#include <wtf/gobject/GOwnPtr.h>
+
+static const char introspectionXML[] =
+    "<node>"
+    " <interface name='org.webkit.gtk.WebExtensionTest'>"
+    "  <method name='GetTitle'>"
+    "   <arg type='t' name='pageID' direction='in'/>"
+    "   <arg type='s' name='title' direction='out'/>"
+    "  </method>"
+    " </interface>"
+    "</node>";
+
+static void methodCallCallback(GDBusConnection*, const char* sender, const char* objectPath, const char* interfaceName, const char* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData)
+{
+    if (g_strcmp0(interfaceName, "org.webkit.gtk.WebExtensionTest"))
+        return;
+
+    if (!g_strcmp0(methodName, "GetTitle")) {
+        uint64_t pageID;
+        g_variant_get(parameters, "(t)", &pageID);
+
+        WebKitWebExtension* extension = WEBKIT_WEB_EXTENSION(userData);
+        WebKitWebPage* page = webkit_web_extension_get_page(extension, pageID);
+        if (!page) {
+            g_dbus_method_invocation_return_error(
+                invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
+                "Invalid page ID: %"G_GUINT64_FORMAT, pageID);
+            return;
+        }
+
+        WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+        GOwnPtr<char> title(webkit_dom_document_get_title(document));
+        g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", title.get()));
+    }
+}
+
+static const GDBusInterfaceVTable interfaceVirtualTable = {
+    methodCallCallback, 0, 0
+};
+
+static void busAcquiredCallback(GDBusConnection* connection, const char* name, gpointer userData)
+{
+    static GDBusNodeInfo *introspectionData = 0;
+    if (!introspectionData)
+        introspectionData = g_dbus_node_info_new_for_xml(introspectionXML, 0);
+
+    GOwnPtr<GError> error;
+    unsigned registrationID = g_dbus_connection_register_object(
+        connection,
+        "/org/webkit/gtk/WebExtensionTest",
+        introspectionData->interfaces[0],
+        &interfaceVirtualTable,
+        g_object_ref(userData),
+        static_cast<GDestroyNotify>(g_object_unref),
+        &error.outPtr());
+    if (!registrationID)
+        g_warning("Failed to register object: %s\n", error->message);
+}
+
+extern "C" void webkit_web_extension_initialize(WebKitWebExtension* extension)
+{
+    g_bus_own_name(
+        G_BUS_TYPE_SESSION,
+        "org.webkit.gtk.WebExtensionTest",
+        G_BUS_NAME_OWNER_FLAGS_NONE,
+        busAcquiredCallback,
+        0, 0,
+        g_object_ref(extension),
+        static_cast<GDestroyNotify>(g_object_unref));
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.cpp
new file mode 100644 (file)
index 0000000..ef84848
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WebKitTestBus.h"
+
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/text/WTFString.h>
+
+WebKitTestBus::WebKitTestBus()
+    : m_pid(-1)
+{
+}
+
+bool WebKitTestBus::run()
+{
+    // FIXME: Use GTestDBus when we bump glib to 2.34.
+    GOwnPtr<char> dbusLaunch(g_find_program_in_path("dbus-launch"));
+    if (!dbusLaunch) {
+        g_warning("Error starting DBUS daemon: dbus-launch not found in path");
+        return false;
+    }
+
+    GOwnPtr<char> output;
+    GOwnPtr<GError> error;
+    if (!g_spawn_command_line_sync(dbusLaunch.get(), &output.outPtr(), 0, 0, &error.outPtr())) {
+        g_warning("Error starting DBUS daemon: %s", error->message);
+        return false;
+    }
+
+    String outputString = String::fromUTF8(output.get());
+    Vector<String> lines;
+    outputString.split(UChar('\n'), /* allowEmptyEntries */ false, lines);
+    for (size_t i = 0; i < lines.size(); ++i) {
+        char** keyValue = g_strsplit(lines[i].utf8().data(), "=", 2);
+        g_assert_cmpuint(g_strv_length(keyValue), ==, 2);
+        if (!g_strcmp0(keyValue[0], "DBUS_SESSION_BUS_ADDRESS")) {
+            m_address = keyValue[1];
+            g_setenv("DBUS_SESSION_BUS_ADDRESS", keyValue[1], TRUE);
+        } else if (!g_strcmp0(keyValue[0], "DBUS_SESSION_BUS_PID"))
+            m_pid = g_ascii_strtoll(keyValue[1], 0, 10);
+        g_strfreev(keyValue);
+    }
+
+    return m_pid > 0;
+}
+
+WebKitTestBus::~WebKitTestBus()
+{
+    g_unsetenv("DBUS_SESSION_BUS_ADDRESS");
+
+    if (m_pid != -1)
+        kill(m_pid, SIGTERM);
+}
+
+GDBusConnection* WebKitTestBus::connection()
+{
+    if (m_connection)
+        return m_connection.get();
+
+    g_assert(!m_address.isNull());
+    m_connection = adoptGRef(g_dbus_connection_new_for_address_sync(m_address.data(),
+        static_cast<GDBusConnectionFlags>(G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION),
+        0, 0, 0));
+    return m_connection.get();
+}
+
+static void onNameAppeared(GDBusConnection*, const char*, const char*, gpointer userData)
+{
+    g_main_loop_quit(static_cast<GMainLoop*>(userData));
+}
+
+GDBusProxy* WebKitTestBus::createProxy(const char* serviceName, const char* objectPath, const char* interfaceName, GMainLoop* mainLoop)
+{
+    unsigned watcherID = g_bus_watch_name_on_connection(connection(), serviceName, G_BUS_NAME_WATCHER_FLAGS_NONE, onNameAppeared, 0, mainLoop, 0);
+    g_main_loop_run(mainLoop);
+    g_bus_unwatch_name(watcherID);
+
+    GDBusProxy* proxy = g_dbus_proxy_new_sync(
+        connection(),
+        G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+        0, // GDBusInterfaceInfo
+        serviceName,
+        objectPath,
+        interfaceName,
+        0, // GCancellable
+        0);
+    g_assert(proxy);
+    return proxy;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.h b/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestBus.h
new file mode 100644 (file)
index 0000000..5d9d9bb
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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 WebKitTestBus_h
+#define WebKitTestBus_h
+
+#include <gio/gio.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+class WebKitTestBus {
+public:
+    WebKitTestBus();
+    virtual ~WebKitTestBus();
+
+    bool run();
+    GDBusProxy* createProxy(const char* serviceName, const char* objectPath, const char* interfaceName, GMainLoop*);
+
+private:
+    GDBusConnection* connection();
+
+    pid_t m_pid;
+    CString m_address;
+    GRefPtr<GDBusConnection> m_connection;
+};
+
+#endif // WebKitTestBus_h
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp
new file mode 100644 (file)
index 0000000..bbd119f
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * 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 Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 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 "WebKitWebExtension.h"
+
+#include "WKBundleAPICast.h"
+#include "WKBundlePage.h"
+#include "WebKitPrivate.h"
+#include "WebKitWebExtensionPrivate.h"
+#include "WebKitWebPagePrivate.h"
+#include <wtf/HashMap.h>
+#include <wtf/gobject/GRefPtr.h>
+
+using namespace WebKit;
+
+enum {
+    PAGE_CREATED,
+
+    LAST_SIGNAL
+};
+
+typedef HashMap<WebPage*, GRefPtr<WebKitWebPage> > WebPageMap;
+
+struct _WebKitWebExtensionPrivate {
+    WebPageMap pages;
+};
+
+static guint signals[LAST_SIGNAL] = { 0, };
+
+WEBKIT_DEFINE_TYPE(WebKitWebExtension, webkit_web_extension, G_TYPE_OBJECT)
+
+static void webkit_web_extension_class_init(WebKitWebExtensionClass* klass)
+{
+    /**
+     * WebKitWebExtension::page-created:
+     * @extension: the #WebKitWebExtension on which the signal is emitted
+     * @web_page: the #WebKitWebPage created
+     *
+     * This signal is emitted when a new #WebKitWebPage is created in
+     * the Web Process.
+     */
+    signals[PAGE_CREATED] = g_signal_new(
+        "page-created",
+        G_TYPE_FROM_CLASS(klass),
+        G_SIGNAL_RUN_LAST,
+        0, 0, 0,
+        g_cclosure_marshal_VOID__OBJECT,
+        G_TYPE_NONE, 1,
+        WEBKIT_TYPE_WEB_PAGE);
+}
+
+static void webkitWebExtensionPageCreated(WebKitWebExtension* extension, WebPage* page)
+{
+    GRefPtr<WebKitWebPage> webPage = adoptGRef(webkitWebPageCreate(page));
+    extension->priv->pages.add(page, webPage);
+    g_signal_emit(extension, signals[PAGE_CREATED], 0, webPage.get());
+}
+
+static void webkitWebExtensionPageDestroy(WebKitWebExtension* extension, WebPage* page)
+{
+    extension->priv->pages.remove(page);
+}
+
+static void didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
+{
+    webkitWebExtensionPageCreated(WEBKIT_WEB_EXTENSION(clientInfo), toImpl(page));
+}
+
+static void willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
+{
+    webkitWebExtensionPageDestroy(WEBKIT_WEB_EXTENSION(clientInfo), toImpl(page));
+}
+
+WebKitWebExtension* webkitWebExtensionCreate(InjectedBundle* bundle)
+{
+    WebKitWebExtension* extension = WEBKIT_WEB_EXTENSION(g_object_new(WEBKIT_TYPE_WEB_EXTENSION, NULL));
+
+    WKBundleClient wkBundleClient = {
+        kWKBundleClientCurrentVersion,
+        extension, // clientInfo
+        didCreatePage,
+        willDestroyPage,
+        0, // didInitializePageGroup
+        0, // didReceiveMessage
+        0 // didReceiveMessageToPage
+    };
+    WKBundleSetClient(toAPI(bundle), &wkBundleClient);
+
+    return extension;
+}
+
+/**
+ * webkit_web_extension_get_page:
+ * @extension: a #WebKitWebExtension
+ * @page_id: the identifier of the #WebKitWebPage to get
+ *
+ * Get the web page of the given @page_id.
+ *
+ * Returns: (transfer none): the #WebKitWebPage for the given @page_id, or %NULL if the
+ *    identifier doesn't correspond to an exsiting web page.
+ */
+WebKitWebPage* webkit_web_extension_get_page(WebKitWebExtension* extension, guint64 pageID)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_EXTENSION(extension), 0);
+
+    WebKitWebExtensionPrivate* priv = extension->priv;
+    WebPageMap::const_iterator end = priv->pages.end();
+    for (WebPageMap::const_iterator it = priv->pages.begin(); it != end; ++it)
+        if (it->key->pageID() == pageID)
+            return it->value.get();
+
+    return 0;
+}
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.h
new file mode 100644 (file)
index 0000000..7042476
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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 Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 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(__WEBKIT_WEB_EXTENSION_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit-web-extension.h> can be included directly."
+#endif
+
+#ifndef WebKitWebExtension_h
+#define WebKitWebExtension_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitWebExtensionDefines.h>
+#include <webkit2/WebKitWebPage.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_EXTENSION            (webkit_web_extension_get_type())
+#define WEBKIT_WEB_EXTENSION(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_EXTENSION, WebKitWebExtension))
+#define WEBKIT_IS_WEB_EXTENSION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_EXTENSION))
+#define WEBKIT_WEB_EXTENSION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_WEB_EXTENSION, WebKitWebExtensionClass))
+#define WEBKIT_IS_WEB_EXTENSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_WEB_EXTENSION))
+#define WEBKIT_WEB_EXTENSION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_WEB_EXTENSION, WebKitWebExtensionClass))
+
+typedef struct _WebKitWebExtension        WebKitWebExtension;
+typedef struct _WebKitWebExtensionClass   WebKitWebExtensionClass;
+typedef struct _WebKitWebExtensionPrivate WebKitWebExtensionPrivate;
+
+/**
+ * WebKitWebExtensionInitializeFunction:
+ * @extension: a #WebKitWebExtension
+ *
+ * Type definition for a function that will be called to initialize
+ * the web extension when the web process starts.
+ */
+typedef void (* WebKitWebExtensionInitializeFunction) (WebKitWebExtension *extension);
+
+struct _WebKitWebExtension {
+    GObject parent;
+
+    WebKitWebExtensionPrivate *priv;
+};
+
+struct _WebKitWebExtensionClass {
+    GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_web_extension_get_type (void);
+
+WEBKIT_API WebKitWebPage *
+webkit_web_extension_get_page (WebKitWebExtension *extension,
+                               guint64             page_id);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionDefines.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionDefines.h
new file mode 100644 (file)
index 0000000..a1a6359
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#if !defined(__WEBKIT_WEB_EXTENSION_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit-web-extension.h> can be included directly."
+#endif
+
+#ifndef WebKitWebExtensionDefines_h
+#define WebKitWebExtensionDefines_h
+
+#include <glib.h>
+
+#ifdef G_OS_WIN32
+#    ifdef BUILDING_WEBKIT
+#        define WEBKIT_API __declspec(dllexport)
+#    else
+#        define WEBKIT_API __declspec(dllimport)
+#    endif
+#    define WEBKIT_OBSOLETE_API WEBKIT_API
+#else
+#    define WEBKIT_API __attribute__((visibility("default")))
+#    define WEBKIT_OBSOLETE_API WEBKIT_API __attribute__((deprecated))
+#endif
+
+#endif // WebKitWebExtensionDefines_h
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionPrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtensionPrivate.h
new file mode 100644 (file)
index 0000000..ff7d13c
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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 WebKitWebExtensionPrivate_h
+#define WebKitWebExtensionPrivate_h
+
+#include "InjectedBundle.h"
+#include "WebKitWebExtension.h"
+
+WebKitWebExtension* webkitWebExtensionCreate(WebKit::InjectedBundle*);
+
+#endif // WebKitWebExtensionPrivate_h
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp
new file mode 100644 (file)
index 0000000..24213c6
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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 Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 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 "WebKitWebPage.h"
+
+#include "WebKitDOMDocumentPrivate.h"
+#include "WebKitPrivate.h"
+#include "WebKitWebPagePrivate.h"
+#include <WebCore/Frame.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+struct _WebKitWebPagePrivate {
+    WebPage* webPage;
+};
+
+WEBKIT_DEFINE_TYPE(WebKitWebPage, webkit_web_page, G_TYPE_OBJECT)
+
+static void webkit_web_page_class_init(WebKitWebPageClass* klass)
+{
+}
+
+WebKitWebPage* webkitWebPageCreate(WebPage* webPage)
+{
+    WebKitWebPage* page = WEBKIT_WEB_PAGE(g_object_new(WEBKIT_TYPE_WEB_PAGE, NULL));
+    page->priv->webPage = webPage;
+    return page;
+}
+
+/**
+ * webkit_web_page_get_dom_document:
+ * @web_page: a #WebKitWebPage
+ *
+ * Get the #WebKitDOMDocument currently loaded in @web_page
+ *
+ * Returns: the #WebKitDOMDocument currently loaded, or %NULL
+ *    if no document is currently loaded.
+ */
+WebKitDOMDocument* webkit_web_page_get_dom_document(WebKitWebPage* webPage)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_PAGE(webPage), 0);
+
+    Frame* coreFrame = webPage->priv->webPage->mainFrame();
+    if (!coreFrame)
+        return 0;
+
+    return kit(coreFrame->document());
+}
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.h
new file mode 100644 (file)
index 0000000..d8f6236
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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 Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 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(__WEBKIT_WEB_EXTENSION_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit-web-extension.h> can be included directly."
+#endif
+
+#ifndef WebKitWebPage_h
+#define WebKitWebPage_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitWebExtensionDefines.h>
+#include <webkitdom/webkitdom.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_PAGE            (webkit_web_page_get_type())
+#define WEBKIT_WEB_PAGE(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_PAGE, WebKitWebPage))
+#define WEBKIT_IS_WEB_PAGE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_PAGE))
+#define WEBKIT_WEB_PAGE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_WEB_PAGE, WebKitWebPageClass))
+#define WEBKIT_IS_WEB_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_WEB_PAGE))
+#define WEBKIT_WEB_PAGE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_WEB_PAGE, WebKitWebPageClass))
+
+typedef struct _WebKitWebPage        WebKitWebPage;
+typedef struct _WebKitWebPageClass   WebKitWebPageClass;
+typedef struct _WebKitWebPagePrivate WebKitWebPagePrivate;
+
+struct _WebKitWebPage {
+    GObject parent;
+
+    WebKitWebPagePrivate *priv;
+};
+
+struct _WebKitWebPageClass {
+    GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_web_page_get_type         (void);
+
+WEBKIT_API WebKitDOMDocument *
+webkit_web_page_get_dom_document (WebKitWebPage *web_page);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPagePrivate.h
new file mode 100644 (file)
index 0000000..0d3da30
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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 WebKitWebPagePrivate_h
+#define WebKitWebPagePrivate_h
+
+#include "WebKitWebPage.h"
+#include "WebPage.h"
+
+WebKitWebPage* webkitWebPageCreate(WebKit::WebPage*);
+
+#endif // WebKitWebPagePrivate_h
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h b/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h
new file mode 100644 (file)
index 0000000..e5ef35a
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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 Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 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 __WebKitWebExtension_h
+#define __WebKitWebExtension_h
+
+#define __WEBKIT_WEB_EXTENSION_H_INSIDE__
+
+#include <webkit2/WebKitWebExtension.h>
+#include <webkit2/WebKitWebPage.h>
+
+#undef __WEBKIT_WEB_EXTENSION_H_INSIDE__
+
+#endif
diff --git a/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp b/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp
new file mode 100644 (file)
index 0000000..95a29af
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WebGtkExtensionManager.h"
+
+#include "InjectedBundle.h"
+#include "WKBundleAPICast.h"
+#include "WebKitWebExtensionPrivate.h"
+#include <WebCore/FileSystem.h>
+#include <wtf/OwnPtr.h>
+
+namespace WebKit {
+
+WebGtkExtensionManager& WebGtkExtensionManager::shared()
+{
+    DEFINE_STATIC_LOCAL(WebGtkExtensionManager, extensionManager, ());
+    return extensionManager;
+}
+
+WebGtkExtensionManager::WebGtkExtensionManager()
+{
+}
+
+void WebGtkExtensionManager::appendModuleDirectories(Vector<String>& directories)
+{
+    String extensionPaths(getenv("WEBKIT_WEB_EXTENSIONS_PATH"));
+    if (!extensionPaths.isEmpty()) {
+        Vector<String> paths;
+        extensionPaths.split(UChar(':'), /* allowEmptyEntries */ false, paths);
+        directories.append(paths);
+    }
+
+    static const char* extensionDefaultDirectory = LIBDIR""G_DIR_SEPARATOR_S"webkitgtk-"WEBKITGTK_API_VERSION_STRING""G_DIR_SEPARATOR_S"web-extensions"G_DIR_SEPARATOR_S;
+    directories.append(WebCore::filenameToString(extensionDefaultDirectory));
+}
+
+void WebGtkExtensionManager::scanModules(Vector<String>& modules)
+{
+    Vector<String> moduleDirectories;
+    appendModuleDirectories(moduleDirectories);
+    for (size_t i = 0; i < moduleDirectories.size(); ++i) {
+        Vector<String> modulePaths = WebCore::listDirectory(moduleDirectories[i], String("*.so"));
+        for (size_t j = 0; j < modulePaths.size(); ++j) {
+            if (WebCore::fileExists(modulePaths[j]))
+                modules.append(modulePaths[j]);
+        }
+    }
+}
+
+void WebGtkExtensionManager::initialize(WKBundleRef bundle)
+{
+    m_extension = adoptGRef(webkitWebExtensionCreate(toImpl(bundle)));
+
+    Vector<String> modulePaths;
+    scanModules(modulePaths);
+    for (size_t i = 0; i < modulePaths.size(); ++i) {
+        OwnPtr<Module> module = adoptPtr(new Module(modulePaths[i]));
+        if (!module->load())
+            continue;
+
+        WebKitWebExtensionInitializeFunction initializeFunction =
+            module->functionPointer<WebKitWebExtensionInitializeFunction>("webkit_web_extension_initialize");
+        if (!initializeFunction)
+            continue;
+
+        // FIXME: check we don't load the same module twice from different paths.
+        m_extensionModules.append(module.leakPtr());
+        initializeFunction(m_extension.get());
+    }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.h b/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.h
new file mode 100644 (file)
index 0000000..13b77a9
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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 WebGtkExtensionManager_h
+#define WebGtkExtensionManager_h
+
+#include "Module.h"
+#include "WKBundle.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
+#include <wtf/gobject/GRefPtr.h>
+
+typedef struct _WebKitWebExtension WebKitWebExtension;
+
+namespace WTF {
+class String;
+}
+
+namespace WebKit {
+
+class WebGtkExtensionManager {
+    WTF_MAKE_NONCOPYABLE(WebGtkExtensionManager);
+
+public:
+    static WebGtkExtensionManager& shared();
+
+    void initialize(WKBundleRef);
+
+private:
+    WebGtkExtensionManager();
+
+    void appendModuleDirectories(Vector<String>&);
+    void scanModules(Vector<String>&);
+
+    Vector<Module*> m_extensionModules;
+    GRefPtr<WebKitWebExtension> m_extension;
+};
+
+} // namespace WebKit
+
+#endif // WebGtkExtensionManager_h
diff --git a/Source/WebKit2/WebProcess/gtk/WebGtkInjectedBundleMain.cpp b/Source/WebKit2/WebProcess/gtk/WebGtkInjectedBundleMain.cpp
new file mode 100644 (file)
index 0000000..2198050
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2013 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 "WebGtkExtensionManager.h"
+#include <WebKit2/WKBundleInitialize.h>
+
+using namespace WebKit;
+
+#if defined(WIN32) || defined(_WIN32)
+extern "C" __declspec(dllexport)
+#else
+extern "C"
+#endif
+void WKBundleInitialize(WKBundleRef bundle, WKTypeRef)
+{
+    WebGtkExtensionManager::shared().initialize(bundle);
+}
index 5761ca8..63ea7dd 100644 (file)
@@ -237,6 +237,8 @@ _ZN7WebCore18StyleSheetContentsD1Ev;
 _ZN7WebCore28DocumentStyleSheetCollection12addUserSheetEN3WTF10PassRefPtrINS_18StyleSheetContentsEEE;
 _ZN7WebCore28DocumentStyleSheetCollection14addAuthorSheetEN3WTF10PassRefPtrINS_18StyleSheetContentsEEE;
 _ZN7WebCore4KURL10invalidateEv;
+_ZN6WebKit22WebGtkExtensionManager10initializeEPK14OpaqueWKBundle;
+_ZN6WebKit22WebGtkExtensionManager6sharedEv;
 
 local:
 _Z*;
index 3292a17..558a45a 100644 (file)
@@ -1,3 +1,22 @@
+2013-01-10  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Add support for loading web process extensions
+        https://bugs.webkit.org/show_bug.cgi?id=105631
+
+        Reviewed by Gustavo Noronha Silva.
+
+        * MiniBrowser/gtk/GNUmakefile.am:
+        * MiniBrowser/gtk/main.c:
+        (main): Set WEBKIT_INJECTED_BUNDLE env var to use the injected
+        bundle lib from build dir.
+        * Scripts/webkitpy/style/checker.py: Add exceptions for GTK+ API
+        located in WebProcess/InjectedBundle/API/gtk.
+        * gtk/generate-gtkdoc:
+        (get_webkit2_options): Scan also files in
+        WebProcess/InjectedBundle/API/gtk to generate API docs.
+        (get_webkit2_options.injected_bundle_src_path): Helper function to
+        build paths in WebProcess/InjectedBundle/API/gtk.
+
 2013-01-10  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
 
         [EFL][WK2] Writing immediately to created windows (open) fails
index 50974ae..575deb2 100644 (file)
@@ -9,6 +9,7 @@ Programs_MiniBrowser_CPPFLAGS = \
        -I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk \
        -I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk/include \
        -DWEBKIT_EXEC_PATH=\"${shell pwd}/$(top_builddir)/Programs/\" \
+       -DWEBKIT_INJECTED_BUNDLE_PATH=\"${shell pwd}/$(top_builddir)/.libs\" \
        $(global_cppflags) \
        $(javascriptcore_cppflags) \
        $(GLIB_CFLAGS) \
index c7367df..17e46f4 100644 (file)
@@ -226,6 +226,7 @@ int main(int argc, char *argv[])
 #ifdef WEBKIT_EXEC_PATH
     g_setenv("WEBKIT_INSPECTOR_PATH", WEBKIT_EXEC_PATH "resources/inspector", FALSE);
 #endif /* WEBKIT_EXEC_PATH */
+    g_setenv("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH, FALSE);
 
     // Enable the favicon database, by specifying the default directory.
     webkit_web_context_set_favicon_database_directory(webkit_web_context_get_default(), NULL);
index 5ae290c..3ef67ac 100644 (file)
@@ -180,7 +180,8 @@ _PATH_RULES_SPECIFIER = [
 
     ([# The GTK+ API use upper case, underscore separated, words in
       # certain types of enums (e.g. signals, properties).
-      "Source/WebKit2/UIProcess/API/gtk"],
+      "Source/WebKit2/UIProcess/API/gtk",
+      "Source/WebKit2/WebProcess/InjectedBundle/API/gtk"],
      ["-readability/enum_casing"]),
 
     ([# Header files in ForwardingHeaders have no header guards or
@@ -329,7 +330,9 @@ _SKIPPED_FILES_WITH_WARNING = [
     # except those ending in ...Private.h are GTK+ API headers,
     # which differ greatly from WebKit coding style.
     re.compile(r'Source/WebKit2/UIProcess/API/gtk/WebKit(?!.*Private\.h).*\.h$'),
-    'Source/WebKit2/UIProcess/API/gtk/webkit2.h']
+    re.compile(r'Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKit(?!.*Private\.h).*\.h$'),
+    'Source/WebKit2/UIProcess/API/gtk/webkit2.h',
+    'Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h']
 
 # Files to skip that are more common or obvious.
 #
index 5af2fc1..b0cab31 100755 (executable)
@@ -77,6 +77,8 @@ def get_webkit2_options():
         return common.build_path(*(('DerivedSources', 'WebKit2') + args))
     def src_path(*args):
         return common.top_level_path(*(('Source', 'WebKit2', 'UIProcess', 'API', 'gtk') + args))
+    def injected_bundle_src_path(*args):
+        return common.top_level_path(*(('Source', 'WebKit2', 'WebProcess', 'InjectedBundle', 'API', 'gtk') + args))
 
     xref_deps = get_common_xref_deps().copy()
     xref_deps.update({
@@ -88,7 +90,7 @@ def get_webkit2_options():
         'module_name' : 'webkit2gtk',
         'doc_dir' : src_path('docs'),
         'output_dir' : common.build_path('Documentation', 'webkit2gtk'),
-        'source_dirs' : [src_path(), derived_sources_path('webkit2gtk', 'webkit2')],
+        'source_dirs' : [src_path(), derived_sources_path('webkit2gtk', 'webkit2'), injected_bundle_src_path()],
         'cflags' : ' -I' + derived_sources_path('webkit2gtk', 'include') + \
                    ' -I' + derived_sources_path('webkit2gtk') + \
                    ' -I' + derived_sources_path('include') + \
@@ -96,6 +98,7 @@ def get_webkit2_options():
                    ' -I' + src_path(),
         'cross_reference_deps' : get_gtkdoc_module_paths(xref_deps),
         'ignored_files': glob.glob(src_path('*Private.h')) + \
+                         glob.glob(injected_bundle_src_path('*Private.h')) + \
                          glob.glob(src_path('*Client*')) + \
                          glob.glob(src_path('WebKit2GtkAuthenticationDialog.*')) + \
                          glob.glob(src_path('WebKitGeolocationProvider.*')) + \