[GTK] Allow passing extra data to web extensions
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jan 2014 14:57:45 +0000 (14:57 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jan 2014 14:57:45 +0000 (14:57 +0000)
commit2e4588230fb20aeefa8b68e242811b91a9b2ea8a
tree343f7ce05cf49625ba1df70847109f10baab6918
parent8e440ab7a5ed0ef8abd123c8f100a15070b0091d
[GTK] Allow passing extra data to web extensions
https://bugs.webkit.org/show_bug.cgi?id=125990

Patch by Adrian Perez de Castro <aperez@igalia.com> on 2014-01-21
Reviewed by Carlos Garcia Campos.

Allow passing additional information to the injected bundle. On top
of the string containing the path to the web extensions directory,
a GVariant can be set with additional data using
webkit_web_context_set_web_extensions_initialization_user_data().
Also, a new initialize-web-extensions signal is emitted before
launching a new WebProcess to allow setting different user data
for each process. The GVariant is serialized as a string, passed
to the injected bundle, and the injected bundle deserializes back
the data, which is passed to web extensions which define the
webkit_web_extension_initialize_with_user_data() function (for
backwards compatibility, webkit_web_extension_initialize() is
used as a fallback.)

Source/WebKit2:

* UIProcess/API/gtk/WebKitInjectedBundleClient.cpp:
(getInjectedBundleInitializationUserData): Define new callback
function which causes emission of the initialize-web-extensions
signal, and serializes the data to be passed to the web process.
(attachInjectedBundleClientToContext): Set the
getInjectedBundleInitializationUserData() callback.
* UIProcess/API/gtk/WebKitWebContext.cpp:
(webkit_web_context_class_init): Define the
initialize-web-extensions signal.
(webkit_web_context_set_web_extensions_directory):
Web extensions directory as now member of WebKitWebContextPrivate,
to be able to retrieve it later.
(webkit_web_context_set_web_extensions_initialization_user_data):
New API method to set the user data passed to the web extensions
when initialized.
(webkitWebContextInitializeWebExtensions): Private function used
to trigger emission of the initialize-web-extensions signal.
* UIProcess/API/gtk/WebKitWebContext.h:
Added prototype for new API method
webkit_web_context_set_web_extensions_initialization_user_data().
* UIProcess/API/gtk/WebKitWebContextPrivate.h:
Prototype of the new private function.
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt:
Add new public API bits to the documentation.
* WebProcess/gtk/WebGtkExtensionManager.cpp:
(WebKit::WebGtkExtensionManager::initialize):
Deserialize the data received from the UI process and pass it to
webkit_web_extension_initialize_with_user_data() if available,
keeping webkit_web_extension_initialize() as fallback.

Tools:

* TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp:
(initializeWebExtensions): Handles the initialize-web-extensions
signal, and sets the web extensions directory and the initialization
user data.
(testWebExtensionInitializationUserData): New test case for checking
the user data passed on initialization to web extensions.
* TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:
(methodCallCallback): Added implementation for the
GetInitializationUserData D-Bus method, used by
testWebExtensionInitializationUserData().
(webkit_web_extension_initialize_with_user_data): Define the
initialization function with the additional user data parameter.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162441 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/WebKitInjectedBundleClient.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.h
Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp
Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp
Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp