[epiphany/carlosgc/wk-user-messages: 2/2] Stop using DBus for web extensions communication
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/carlosgc/wk-user-messages: 2/2] Stop using DBus for web extensions communication
- Date: Mon, 14 Oct 2019 15:45:57 +0000 (UTC)
commit 87578a124becb345b0079879562203a2674f243b
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Mon Oct 14 17:36:13 2019 +0200
Stop using DBus for web extensions communication
Use the new WebKit user messages API instead.
embed/ephy-embed-shell.c | 377 ++---------------
embed/ephy-embed-shell.h | 1 -
embed/ephy-web-process-extension-proxy.c | 338 ---------------
embed/ephy-web-process-extension-proxy.h | 54 ---
embed/ephy-web-view.c | 129 ++++++
embed/meson.build | 1 -
.../ephy-web-process-extension-main.c | 9 +-
.../ephy-web-process-extension.c | 460 ++++++++++-----------
.../ephy-web-process-extension.h | 1 -
embed/web-process-extension/resources/js/ephy.js | 9 +-
10 files changed, 380 insertions(+), 999 deletions(-)
---
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index f9dca716e..97082d770 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -23,7 +23,6 @@
#include "ephy-embed-shell.h"
#include "ephy-about-handler.h"
-#include "ephy-dbus-util.h"
#include "ephy-debug.h"
#include "ephy-downloads-manager.h"
#include "ephy-embed-container.h"
@@ -66,9 +65,6 @@ typedef struct {
EphyAboutHandler *about_handler;
EphyViewSourceHandler *source_handler;
char *guid;
- GDBusServer *dbus_server;
- GList *web_process_extensions;
- GHashTable *web_process_extension_page_map;
EphyFiltersManager *filters_manager;
EphySearchEngineManager *search_engine_manager;
GCancellable *cancellable;
@@ -135,22 +131,6 @@ ephy_embed_shell_get_view_for_page_id (EphyEmbedShell *self,
return NULL;
}
-static EphyWebProcessExtensionProxy *
-ephy_embed_shell_get_extension_proxy_for_page_id (EphyEmbedShell *self,
- guint64 page_id,
- const char *origin)
-{
- EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (self);
-
- if (!priv->web_process_extension_page_map)
- return NULL;
-
- if (!ephy_embed_shell_get_view_for_page_id (self, page_id, origin))
- return NULL;
-
- return g_hash_table_lookup (priv->web_process_extension_page_map, GSIZE_TO_POINTER (page_id));
-}
-
static GList *
tabs_catalog_get_tabs_info (EphyTabsCatalog *catalog)
{
@@ -202,11 +182,6 @@ ephy_embed_shell_dispose (GObject *object)
g_clear_object (&priv->cancellable);
}
- if (priv->web_process_extensions) {
- g_list_free_full (priv->web_process_extensions, g_object_unref);
- priv->web_process_extensions = NULL;
- }
-
g_clear_object (&priv->encodings);
g_clear_object (&priv->page_setup);
g_clear_object (&priv->print_settings);
@@ -220,10 +195,8 @@ ephy_embed_shell_dispose (GObject *object)
g_clear_object (&priv->permissions_manager);
g_clear_object (&priv->web_context);
g_clear_pointer (&priv->guid, g_free);
- g_clear_object (&priv->dbus_server);
g_clear_object (&priv->filters_manager);
g_clear_object (&priv->search_engine_manager);
- g_clear_pointer (&priv->web_process_extension_page_map, g_hash_table_destroy);
G_OBJECT_CLASS (ephy_embed_shell_parent_class)->dispose (object);
}
@@ -254,18 +227,22 @@ history_service_query_urls_cb (EphyHistoryService *service,
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
GList *l;
+ GVariantBuilder builder;
if (!success)
return;
- for (l = priv->web_process_extensions; l; l = g_list_next (l)) {
- EphyWebProcessExtensionProxy *web_process_extension = (EphyWebProcessExtensionProxy *)l->data;
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ss)"));
+ for (l = urls; l; l = g_list_next (l)) {
+ EphyHistoryURL *url = (EphyHistoryURL *)l->data;
- ephy_web_process_extension_proxy_history_set_urls (web_process_extension, urls);
+ g_variant_builder_add (&builder, "(ss)", url->url, url->title);
+ ephy_embed_shell_schedule_thumbnail_update (shell, (EphyHistoryURL *)l->data);
}
- for (l = urls; l; l = g_list_next (l))
- ephy_embed_shell_schedule_thumbnail_update (shell, (EphyHistoryURL *)l->data);
+ webkit_web_context_send_message_to_all_extensions (priv->web_context,
+ webkit_user_message_new ("History.SetURLs",
+ g_variant_builder_end
(&builder)));
}
static void
@@ -348,46 +325,6 @@ web_process_extension_about_apps_message_received_cb (WebKitUserContentManager *
ephy_web_application_delete (app_id);
}
-typedef struct {
- EphyEmbedShell *shell;
- char *origin;
- gint32 promise_id;
- guint64 page_id;
- guint64 frame_id;
-} PasswordManagerData;
-
-static void
-password_manager_data_free (PasswordManagerData *data)
-{
- g_object_unref (data->shell);
- g_free (data->origin);
- g_free (data);
-}
-
-static void
-password_manager_query_finished_cb (GList *records,
- PasswordManagerData *data)
-{
- EphyWebProcessExtensionProxy *proxy;
- EphyPasswordRecord *record;
- const char *username = NULL;
- const char *password = NULL;
-
- record = records && records->data ? EPHY_PASSWORD_RECORD (records->data) : NULL;
- if (record) {
- username = ephy_password_record_get_username (record);
- password = ephy_password_record_get_password (record);
- }
-
- proxy = ephy_embed_shell_get_extension_proxy_for_page_id (data->shell,
- data->page_id,
- data->origin);
- if (proxy)
- ephy_web_process_extension_proxy_password_query_response (proxy, username, password, data->promise_id,
data->frame_id);
-
- password_manager_data_free (data);
-}
-
static char *
property_to_string_or_null (JSCValue *value,
const char *name)
@@ -414,51 +351,6 @@ property_to_uint64 (JSCValue *value,
return (guint64)jsc_value_to_double (prop);
}
-static void
-web_process_extension_password_manager_query_received_cb (WebKitUserContentManager *manager,
- WebKitJavascriptResult *message,
- EphyEmbedShell *shell)
-{
- EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
- JSCValue *value = webkit_javascript_result_get_js_value (message);
- g_autofree char *origin = property_to_string_or_null (value, "origin");
- g_autofree char *target_origin = property_to_string_or_null (value, "targetOrigin");
- g_autofree char *username = property_to_string_or_null (value, "username");
- g_autofree char *username_field = property_to_string_or_null (value, "usernameField");
- g_autofree char *password_field = property_to_string_or_null (value, "passwordField");
- gint32 promise_id = property_to_int32 (value, "promiseID");
- guint64 page_id = property_to_uint64 (value, "pageID");
- guint64 frame_id = property_to_uint64 (value, "frameID");
- PasswordManagerData *data;
-
- if (!origin || !target_origin || !password_field)
- return;
-
- /* Don't include username_field in queries unless we actually have a username
- * to go along with it, or the query will fail because we don't save
- * username_field without a corresponding username.
- */
- if (!username && username_field)
- g_clear_pointer (&username_field, g_free);
-
- data = g_new (PasswordManagerData, 1);
- data->shell = g_object_ref (shell);
- data->promise_id = promise_id;
- data->page_id = page_id;
- data->frame_id = frame_id;
- data->origin = g_strdup (origin);
-
- ephy_password_manager_query (priv->password_manager,
- NULL,
- origin,
- target_origin,
- username,
- username_field,
- password_field,
- (EphyPasswordManagerQueryCallback)password_manager_query_finished_cb,
- data);
-}
-
typedef struct {
EphyPasswordManager *password_manager;
EphyPermissionsManager *permissions_manager;
@@ -585,30 +477,6 @@ web_process_extension_password_manager_request_save_received_cb (WebKitUserConte
web_process_extension_password_manager_save_real (shell, value, TRUE);
}
-static void
-web_process_extension_password_manager_query_usernames_received_cb (WebKitUserContentManager *manager,
- WebKitJavascriptResult *message,
- EphyEmbedShell *shell)
-{
- EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
- JSCValue *value = webkit_javascript_result_get_js_value (message);
- g_autofree char *origin = property_to_string_or_null (value, "origin");
- gint32 promise_id = property_to_int32 (value, "promiseID");
- guint64 page_id = property_to_uint64 (value, "pageID");
- guint64 frame_id = property_to_uint64 (value, "frameID");
- GList *usernames;
- EphyWebProcessExtensionProxy *proxy;
-
- if (!origin)
- return;
-
- usernames = ephy_password_manager_get_usernames_for_origin (priv->password_manager, origin);
-
- proxy = ephy_embed_shell_get_extension_proxy_for_page_id (shell, page_id, origin);
- if (proxy)
- ephy_web_process_extension_proxy_password_query_usernames_response (proxy, usernames, promise_id,
frame_id);
-}
-
static void
history_service_url_title_changed_cb (EphyHistoryService *service,
const char *url,
@@ -616,13 +484,10 @@ history_service_url_title_changed_cb (EphyHistoryService *service,
EphyEmbedShell *shell)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
- GList *l;
- for (l = priv->web_process_extensions; l; l = g_list_next (l)) {
- EphyWebProcessExtensionProxy *web_process_extension = (EphyWebProcessExtensionProxy *)l->data;
-
- ephy_web_process_extension_proxy_history_set_url_title (web_process_extension, url, title);
- }
+ webkit_web_context_send_message_to_all_extensions (priv->web_context,
+ webkit_user_message_new ("History.SetURLTitle",
+ g_variant_new ("(ss)", url,
title)));
}
static void
@@ -631,13 +496,10 @@ history_service_url_deleted_cb (EphyHistoryService *service,
EphyEmbedShell *shell)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
- GList *l;
-
- for (l = priv->web_process_extensions; l; l = g_list_next (l)) {
- EphyWebProcessExtensionProxy *web_process_extension = (EphyWebProcessExtensionProxy *)l->data;
- ephy_web_process_extension_proxy_history_delete_url (web_process_extension, url->url);
- }
+ webkit_web_context_send_message_to_all_extensions (priv->web_context,
+ webkit_user_message_new ("History.DeleteURL",
+ g_variant_new ("s", url)));
}
static void
@@ -646,16 +508,12 @@ history_service_host_deleted_cb (EphyHistoryService *service,
EphyEmbedShell *shell)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
- GList *l;
g_autoptr (SoupURI) deleted_uri = NULL;
deleted_uri = soup_uri_new (deleted_url);
-
- for (l = priv->web_process_extensions; l; l = g_list_next (l)) {
- EphyWebProcessExtensionProxy *web_process_extension = (EphyWebProcessExtensionProxy *)l->data;
-
- ephy_web_process_extension_proxy_history_delete_host (web_process_extension, soup_uri_get_host
(deleted_uri));
- }
+ webkit_web_context_send_message_to_all_extensions (priv->web_context,
+ webkit_user_message_new ("History.DeleteHost",
+ g_variant_new ("s",
soup_uri_get_host (deleted_uri))));
}
static void
@@ -663,60 +521,10 @@ history_service_cleared_cb (EphyHistoryService *service,
EphyEmbedShell *shell)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
- GList *l;
-
- for (l = priv->web_process_extensions; l; l = g_list_next (l)) {
- EphyWebProcessExtensionProxy *web_process_extension = (EphyWebProcessExtensionProxy *)l->data;
- ephy_web_process_extension_proxy_history_clear (web_process_extension);
- }
-}
-
-typedef struct {
- EphyWebProcessExtensionProxy *extension;
- char *url;
- char *path;
-} DelayedThumbnailUpdateData;
-
-static DelayedThumbnailUpdateData *
-delayed_thumbnail_update_data_new (EphyWebProcessExtensionProxy *extension,
- const char *url,
- const char *path)
-{
- DelayedThumbnailUpdateData *data = g_new (DelayedThumbnailUpdateData, 1);
- data->extension = extension;
- data->url = g_strdup (url);
- data->path = g_strdup (path);
- g_object_add_weak_pointer (G_OBJECT (extension), (gpointer *)&data->extension);
- return data;
-}
-
-static void
-delayed_thumbnail_update_data_free (DelayedThumbnailUpdateData *data)
-{
- if (data->extension)
- g_object_remove_weak_pointer (G_OBJECT (data->extension), (gpointer *)&data->extension);
- g_free (data->url);
- g_free (data->path);
- g_free (data);
-}
-
-static gboolean
-delayed_thumbnail_update_cb (DelayedThumbnailUpdateData *data)
-{
- if (!data->extension) {
- delayed_thumbnail_update_data_free (data);
- return G_SOURCE_REMOVE;
- }
-
- if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (data->extension), "initialized"))) {
- ephy_web_process_extension_proxy_history_set_url_thumbnail (data->extension, data->url, data->path);
- delayed_thumbnail_update_data_free (data);
- return G_SOURCE_REMOVE;
- }
-
- /* Web process extension is not initialized yet, try again later.... */
- return G_SOURCE_CONTINUE;
+ webkit_web_context_send_message_to_all_extensions (priv->web_context,
+ webkit_user_message_new ("History.Clear",
+ NULL));
}
void
@@ -725,17 +533,10 @@ ephy_embed_shell_set_thumbnail_path (EphyEmbedShell *shell,
const char *path)
{
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
- GList *l;
- for (l = priv->web_process_extensions; l; l = g_list_next (l)) {
- EphyWebProcessExtensionProxy *web_process_extension = (EphyWebProcessExtensionProxy *)l->data;
- if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (web_process_extension), "initialized"))) {
- ephy_web_process_extension_proxy_history_set_url_thumbnail (web_process_extension, url, path);
- } else {
- DelayedThumbnailUpdateData *data = delayed_thumbnail_update_data_new (web_process_extension, url,
path);
- g_timeout_add (50, (GSourceFunc)delayed_thumbnail_update_cb, data);
- }
- }
+ webkit_web_context_send_message_to_all_extensions (priv->web_context,
+ webkit_user_message_new ("History.SetURLThumbnail",
+ g_variant_new ("(ss)", url,
path)));
}
static void
@@ -948,7 +749,6 @@ initialize_web_process_extensions (WebKitWebContext *web_context,
g_autoptr (GVariant) user_data = NULL;
gboolean private_profile;
gboolean browser_mode;
- const char *address;
#if DEVELOPER_MODE
webkit_web_context_set_web_extensions_directory (web_context, BUILD_ROOT "/embed/web-process-extension");
@@ -956,13 +756,10 @@ initialize_web_process_extensions (WebKitWebContext *web_context,
webkit_web_context_set_web_extensions_directory (web_context, EPHY_WEB_PROCESS_EXTENSIONS_DIR);
#endif
- address = priv->dbus_server ? g_dbus_server_get_client_address (priv->dbus_server) : NULL;
-
private_profile = priv->mode == EPHY_EMBED_SHELL_MODE_PRIVATE || priv->mode ==
EPHY_EMBED_SHELL_MODE_INCOGNITO || priv->mode == EPHY_EMBED_SHELL_MODE_AUTOMATION;
browser_mode = priv->mode == EPHY_EMBED_SHELL_MODE_BROWSER;
- user_data = g_variant_new ("(smsmsbb)",
+ user_data = g_variant_new ("(smsbb)",
priv->guid,
- address,
ephy_profile_dir_is_default () ? NULL : ephy_profile_dir (),
private_profile,
browser_mode);
@@ -984,104 +781,6 @@ initialize_notification_permissions (WebKitWebContext *web_context,
webkit_web_context_initialize_notification_permissions (web_context, permitted_origins, denied_origins);
}
-static void
-web_process_extension_page_created (EphyWebProcessExtensionProxy *extension,
- guint64 page_id,
- EphyEmbedShell *shell)
-{
- EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
-
- g_object_set_data (G_OBJECT (extension), "initialized", GINT_TO_POINTER (TRUE));
- g_hash_table_insert (priv->web_process_extension_page_map, GSIZE_TO_POINTER (page_id), extension);
-}
-
-static gboolean
-find_extension (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- return value == user_data;
-}
-
-static void
-web_process_extension_connection_closed (EphyWebProcessExtensionProxy *extension,
- EphyEmbedShell *shell)
-{
- EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
-
- priv->web_process_extensions = g_list_remove (priv->web_process_extensions, extension);
- g_hash_table_foreach_remove (priv->web_process_extension_page_map, find_extension, extension);
- g_object_unref (extension);
-}
-
-static gboolean
-new_connection_cb (GDBusServer *server,
- GDBusConnection *connection,
- EphyEmbedShell *shell)
-{
- EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
- g_autoptr (EphyWebProcessExtensionProxy) extension = NULL;
-
- extension = ephy_web_process_extension_proxy_new (connection);
-
- g_signal_connect_object (extension, "page-created",
- G_CALLBACK (web_process_extension_page_created), shell, 0);
- g_signal_connect_object (extension, "connection-closed",
- G_CALLBACK (web_process_extension_connection_closed), shell, 0);
-
- priv->web_process_extensions = g_list_prepend (priv->web_process_extensions, g_steal_pointer (&extension));
-
- return TRUE;
-}
-
-static gboolean
-authorize_authenticated_peer_cb (GDBusAuthObserver *observer,
- GIOStream *stream,
- GCredentials *credentials,
- EphyEmbedShell *shell)
-{
- return ephy_dbus_peer_is_authorized (credentials);
-}
-
-static void
-ephy_embed_shell_setup_web_process_extensions_server (EphyEmbedShell *shell)
-{
- EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
- g_autoptr (GDBusAuthObserver) observer = NULL;
- g_autofree char *address = NULL;
- g_autoptr (GError) error = NULL;
-
- /* Due to the bubblewrap sandbox, we cannot use any abstract sockets here.
- * This means that unix:tmpdir= or unix:abstract= addresses will not work.
- * Using unix:dir= guarantees that abstract sockets won't be used.
- */
- address = g_strdup_printf ("unix:dir=%s", ephy_file_tmp_dir ());
-
- observer = g_dbus_auth_observer_new ();
-
- g_signal_connect_object (observer, "authorize-authenticated-peer",
- G_CALLBACK (authorize_authenticated_peer_cb), shell, 0);
-
- /* Why sync?
- *
- * (a) The server must be started before web process extensions try to connect.
- * (b) Gio actually has no async version. Don't know why.
- */
- priv->dbus_server = g_dbus_server_new_sync (address,
- G_DBUS_SERVER_FLAGS_NONE,
- priv->guid,
- observer,
- NULL,
- &error);
-
- if (error)
- g_error ("Failed to start embed shell D-Bus server on %s: %s", address, error->message);
-
- g_signal_connect_object (priv->dbus_server, "new-connection",
- G_CALLBACK (new_connection_cb), shell, 0);
- g_dbus_server_start (priv->dbus_server);
-}
-
static void
ephy_embed_shell_create_web_context (EphyEmbedShell *shell)
{
@@ -1148,8 +847,6 @@ ephy_embed_shell_startup (GApplication *application)
ephy_embed_shell_create_web_context (shell);
- ephy_embed_shell_setup_web_process_extensions_server (shell);
-
/* User content manager */
if (priv->mode != EPHY_EMBED_SHELL_MODE_TEST)
priv->user_content = webkit_user_content_manager_new ();
@@ -1186,20 +883,6 @@ ephy_embed_shell_startup (GApplication *application)
G_CALLBACK (web_process_extension_about_apps_message_received_cb),
shell, 0);
- webkit_user_content_manager_register_script_message_handler_in_world (priv->user_content,
- "passwordManagerQuery",
- priv->guid);
- g_signal_connect_object (priv->user_content, "script-message-received::passwordManagerQuery",
- G_CALLBACK (web_process_extension_password_manager_query_received_cb),
- shell, 0);
-
- webkit_user_content_manager_register_script_message_handler_in_world (priv->user_content,
- "passwordManagerQueryUsernames",
- priv->guid);
- g_signal_connect_object (priv->user_content, "script-message-received::passwordManagerQueryUsernames",
- G_CALLBACK (web_process_extension_password_manager_query_usernames_received_cb),
- shell, 0);
-
webkit_user_content_manager_register_script_message_handler_in_world (priv->user_content,
"passwordManagerSave",
priv->guid);
@@ -1226,7 +909,6 @@ ephy_embed_shell_startup (GApplication *application)
webkit_web_context_add_path_to_sandbox (priv->web_context, BUILD_ROOT, TRUE);
#endif
- priv->web_process_extension_page_map = g_hash_table_new (g_direct_hash, g_direct_equal);
g_signal_connect_object (priv->web_context, "initialize-web-extensions",
G_CALLBACK (initialize_web_process_extensions),
shell, 0);
@@ -1315,9 +997,6 @@ ephy_embed_shell_shutdown (GApplication *application)
G_APPLICATION_CLASS (ephy_embed_shell_parent_class)->shutdown (application);
- if (priv->dbus_server)
- g_dbus_server_stop (priv->dbus_server);
-
webkit_user_content_manager_unregister_script_message_handler_in_world (priv->user_content,
"overview",
priv->guid);
@@ -1332,15 +1011,9 @@ ephy_embed_shell_shutdown (GApplication *application)
"passwordFormFocused",
priv->guid);
webkit_user_content_manager_unregister_script_message_handler (priv->user_content, "aboutApps");
- webkit_user_content_manager_unregister_script_message_handler_in_world (priv->user_content,
- "passwordManagerQuery",
- priv->guid);
webkit_user_content_manager_unregister_script_message_handler_in_world (priv->user_content,
"passwordManagerSave",
priv->guid);
- webkit_user_content_manager_unregister_script_message_handler_in_world (priv->user_content,
- "passwordManagerQueryUsernames",
- priv->guid);
g_object_unref (ephy_embed_prefs_get_settings ());
ephy_embed_utils_shutdown ();
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index 0d46b4264..6abfddbc0 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -31,7 +31,6 @@
#include "ephy-password-manager.h"
#include "ephy-permissions-manager.h"
#include "ephy-search-engine-manager.h"
-#include "ephy-web-process-extension-proxy.h"
G_BEGIN_DECLS
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index e2c2f2a54..6cd4f07fe 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -2892,6 +2892,131 @@ authenticate_cb (WebKitWebView *web_view,
return FALSE;
}
+typedef struct {
+ WebKitWebView *web_view;
+ char *origin;
+ WebKitUserMessage *message;
+} PasswordManagerData;
+
+static void
+password_manager_data_free (PasswordManagerData *data)
+{
+ g_object_unref (data->web_view);
+ g_object_unref (data->message);
+ g_free (data);
+}
+
+static void
+password_manager_query_finished_cb (GList *records,
+ PasswordManagerData *data)
+{
+ EphyPasswordRecord *record;
+ const char *origin;
+ const char *username = NULL;
+ const char *password = NULL;
+ g_autofree char *real_origin = NULL;
+
+ record = records && records->data ? EPHY_PASSWORD_RECORD (records->data) : NULL;
+ if (record) {
+ username = ephy_password_record_get_username (record);
+ password = ephy_password_record_get_password (record);
+ }
+
+ g_variant_get (webkit_user_message_get_parameters (data->message), "(&s@sm@sm@s@s)", &origin, NULL, NULL,
NULL, NULL);
+ real_origin = ephy_uri_to_security_origin (webkit_web_view_get_uri (data->web_view));
+ if (g_strcmp0 (real_origin, origin) != 0) {
+ g_debug ("Extension's origin '%s' doesn't match real origin '%s'", origin, real_origin);
+ password_manager_data_free (data);
+ return;
+ }
+
+ webkit_user_message_send_reply (data->message,
+ webkit_user_message_new ("PasswordManager.QueryPasswordResponse",
+ g_variant_new ("(msms)", username, password)));
+
+ password_manager_data_free (data);
+}
+
+
+static gboolean
+user_message_received_cb (WebKitWebView *web_view,
+ WebKitUserMessage *message)
+{
+ const char *name;
+
+ name = webkit_user_message_get_name (message);
+ if (g_strcmp0 (name, "PasswordManager.QueryUsernames") == 0) {
+ GVariant *parameters;
+ const char *origin;
+ EphyPasswordManager *password_manager;
+ GList *usernames, *l;
+ GVariantBuilder builder;
+ g_autofree char *real_origin = NULL;
+
+ parameters = webkit_user_message_get_parameters (message);
+ if (!parameters)
+ return FALSE;
+
+ g_variant_get (parameters, "&s", &origin);
+ real_origin = ephy_uri_to_security_origin (webkit_web_view_get_uri (web_view));
+ if (g_strcmp0 (real_origin, origin) != 0) {
+ g_debug ("Extension's origin '%s' doesn't match real origin '%s'", origin, real_origin);
+ return FALSE;
+ }
+
+ password_manager = ephy_embed_shell_get_password_manager (ephy_embed_shell_get_default ());
+ usernames = ephy_password_manager_get_usernames_for_origin (password_manager, origin);
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
+ for (l = usernames; l != NULL; l = g_list_next (l))
+ g_variant_builder_add (&builder, "s", l->data);
+
+ webkit_user_message_send_reply (message, webkit_user_message_new
("PasswordManager.QueryUsernamesResponse",
+ g_variant_builder_end (&builder)));
+ } else if (g_strcmp0 (name, "PasswordManager.QueryPassword") == 0) {
+ GVariant *parameters;
+ const char *origin;
+ const char *target_origin;
+ const char *username;
+ const char *username_field;
+ const char *password_field;
+ EphyPasswordManager *password_manager;
+ PasswordManagerData *data;
+
+ parameters = webkit_user_message_get_parameters (message);
+ if (!parameters)
+ return FALSE;
+
+ g_variant_get (parameters, "(&s&sm&sm&s&s)", &origin, &target_origin, &username, &username_field,
&password_field);
+
+ /* Don't include username_field in queries unless we actually have a username
+ * to go along with it, or the query will fail because we don't save
+ * username_field without a corresponding username.
+ */
+ if (!username && username_field)
+ username_field = NULL;
+
+ data = g_new (PasswordManagerData, 1);
+ data->web_view = g_object_ref (web_view);
+ data->message = g_object_ref (message);
+
+ password_manager = ephy_embed_shell_get_password_manager (ephy_embed_shell_get_default ());
+ ephy_password_manager_query (password_manager,
+ NULL,
+ origin,
+ target_origin,
+ username,
+ username_field,
+ password_field,
+ (EphyPasswordManagerQueryCallback)password_manager_query_finished_cb,
+ data);
+ } else {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void
ephy_web_view_init (EphyWebView *web_view)
{
@@ -2976,6 +3101,10 @@ ephy_web_view_init (EphyWebView *web_view)
G_CALLBACK (authenticate_cb),
NULL);
+ g_signal_connect (web_view, "user-message-received",
+ G_CALLBACK (user_message_received_cb),
+ NULL);
+
g_signal_connect_object (shell, "password-form-focused",
G_CALLBACK (password_form_focused_cb),
web_view, 0);
diff --git a/embed/meson.build b/embed/meson.build
index 05a064090..47a38c499 100644
--- a/embed/meson.build
+++ b/embed/meson.build
@@ -28,7 +28,6 @@ libephyembed_sources = [
'ephy-find-toolbar.c',
'ephy-view-source-handler.c',
'ephy-web-view.c',
- 'ephy-web-process-extension-proxy.c',
enums
]
diff --git a/embed/web-process-extension/ephy-web-process-extension-main.c
b/embed/web-process-extension/ephy-web-process-extension-main.c
index f235dd2dc..530e961a8 100644
--- a/embed/web-process-extension/ephy-web-process-extension-main.c
+++ b/embed/web-process-extension/ephy-web-process-extension-main.c
@@ -35,18 +35,12 @@ webkit_web_extension_initialize_with_user_data (WebKitWebExtension *webkit_exten
GVariant *user_data)
{
const char *guid;
- const char *server_address;
const char *profile_dir;
gboolean private_profile;
gboolean browser_mode;
g_autoptr (GError) error = NULL;
- g_variant_get (user_data, "(&sm&sm&sbb)", &guid, &server_address, &profile_dir, &private_profile,
&browser_mode);
-
- if (!server_address) {
- g_warning ("UI process did not start D-Bus server, giving up.");
- return;
- }
+ g_variant_get (user_data, "(&sm&sbb)", &guid, &profile_dir, &private_profile, &browser_mode);
if (!ephy_file_helpers_init (profile_dir, 0, &error))
g_warning ("Failed to initialize file helpers: %s", error->message);
@@ -58,7 +52,6 @@ webkit_web_extension_initialize_with_user_data (WebKitWebExtension *webkit_exten
ephy_web_process_extension_initialize (extension,
webkit_extension,
guid,
- server_address,
private_profile,
browser_mode);
}
diff --git a/embed/web-process-extension/ephy-web-process-extension.c
b/embed/web-process-extension/ephy-web-process-extension.c
index 60c47354f..0226f62f8 100644
--- a/embed/web-process-extension/ephy-web-process-extension.c
+++ b/embed/web-process-extension/ephy-web-process-extension.c
@@ -21,8 +21,6 @@
#include "config.h"
#include "ephy-web-process-extension.h"
-#include "ephy-dbus-names.h"
-#include "ephy-dbus-util.h"
#include "ephy-debug.h"
#include "ephy-file-helpers.h"
#include "ephy-permissions-manager.h"
@@ -47,9 +45,6 @@ struct _EphyWebProcessExtension {
WebKitWebExtension *extension;
gboolean initialized;
- GDBusConnection *dbus_connection;
- GArray *page_created_signals_pending;
-
EphyWebOverviewModel *overview_model;
EphyPermissionsManager *permissions_manager;
@@ -60,44 +55,6 @@ struct _EphyWebProcessExtension {
GHashTable *frames_map;
};
-static const char introspection_xml[] =
- "<node>"
- " <interface name='org.gnome.Epiphany.WebProcessExtension'>"
- " <signal name='PageCreated'>"
- " <arg type='t' name='page_id' direction='out'/>"
- " </signal>"
- " <method name='HistorySetURLs'>"
- " <arg type='a(ss)' name='urls' direction='in'/>"
- " </method>"
- " <method name='HistorySetURLThumbnail'>"
- " <arg type='s' name='url' direction='in'/>"
- " <arg type='s' name='path' direction='in'/>"
- " </method>"
- " <method name='HistorySetURLTitle'>"
- " <arg type='s' name='url' direction='in'/>"
- " <arg type='s' name='title' direction='in'/>"
- " </method>"
- " <method name='HistoryDeleteURL'>"
- " <arg type='s' name='url' direction='in'/>"
- " </method>"
- " <method name='HistoryDeleteHost'>"
- " <arg type='s' name='host' direction='in'/>"
- " </method>"
- " <method name='HistoryClear'/>"
- " <method name='PasswordQueryResponse'>"
- " <arg type='s' name='username' direction='in'/>"
- " <arg type='s' name='password' direction='in'/>"
- " <arg type='i' name='promise_id' direction='in'/>"
- " <arg type='t' name='frame_id' direction='in'/>"
- " </method>"
- " <method name='PasswordQueryUsernamesResponse'>"
- " <arg type='as' name='users' direction='in'/>"
- " <arg type='i' name='promise_id' direction='in'/>"
- " <arg type='t' name='frame_id' direction='in'/>"
- " </method>"
- " </interface>"
- "</node>";
-
G_DEFINE_TYPE (EphyWebProcessExtension, ephy_web_process_extension, G_TYPE_OBJECT)
static gboolean
@@ -267,67 +224,15 @@ web_page_context_menu (WebKitWebPage *web_page,
return TRUE;
}
-static void
-ephy_web_process_extension_emit_page_created (EphyWebProcessExtension *extension,
- guint64 page_id)
-{
- g_autoptr (GError) error = NULL;
-
- g_dbus_connection_emit_signal (extension->dbus_connection,
- NULL,
- EPHY_WEB_PROCESS_EXTENSION_OBJECT_PATH,
- EPHY_WEB_PROCESS_EXTENSION_INTERFACE,
- "PageCreated",
- g_variant_new ("(t)", page_id),
- &error);
- if (error)
- g_warning ("Error emitting signal PageCreated: %s\n", error->message);
-}
-
-static void
-ephy_web_process_extension_emit_page_created_signals_pending (EphyWebProcessExtension *extension)
-{
- guint i;
-
- if (!extension->page_created_signals_pending)
- return;
-
- for (i = 0; i < extension->page_created_signals_pending->len; i++) {
- guint64 page_id;
-
- page_id = g_array_index (extension->page_created_signals_pending, guint64, i);
- ephy_web_process_extension_emit_page_created (extension, page_id);
- }
-
- g_array_free (extension->page_created_signals_pending, TRUE);
- extension->page_created_signals_pending = NULL;
-}
-
-static void
-ephy_web_process_extension_queue_page_created_signal_emission (EphyWebProcessExtension *extension,
- guint64 page_id)
-{
- if (!extension->page_created_signals_pending)
- extension->page_created_signals_pending = g_array_new (FALSE, FALSE, sizeof (guint64));
- extension->page_created_signals_pending = g_array_append_val (extension->page_created_signals_pending,
page_id);
-}
-
static void
ephy_web_process_extension_page_created_cb (EphyWebProcessExtension *extension,
WebKitWebPage *web_page)
{
- guint64 page_id;
g_autoptr (JSCContext) js_context = NULL;
/* Enforce the creation of the script world global context in the main frame */
js_context = webkit_frame_get_js_context_for_script_world (webkit_web_page_get_main_frame (web_page),
extension->script_world);
- page_id = webkit_web_page_get_id (web_page);
- if (extension->dbus_connection)
- ephy_web_process_extension_emit_page_created (extension, page_id);
- else
- ephy_web_process_extension_queue_page_created_signal_emission (extension, page_id);
-
g_signal_connect (web_page, "send-request",
G_CALLBACK (web_page_send_request),
extension);
@@ -342,48 +247,26 @@ ephy_web_process_extension_page_created_cb (EphyWebProcessExtension *extension,
extension);
}
-static JSCValue *
-get_password_manager (EphyWebProcessExtension *self,
- guint64 frame_id)
-{
- WebKitFrame *frame;
- g_autoptr (JSCContext) js_context = NULL;
- g_autoptr (JSCValue) js_ephy = NULL;
-
- frame = g_hash_table_lookup (self->frames_map, GINT_TO_POINTER (frame_id));
- if (!frame)
- return NULL;
-
- js_context = webkit_frame_get_js_context_for_script_world (frame, self->script_world);
- js_ephy = jsc_context_get_value (js_context, "Ephy");
-
- return jsc_value_object_get_property (js_ephy, "passwordManager");
-}
-
static void
-handle_method_call (GDBusConnection *connection,
- const char *sender,
- const char *object_path,
- const char *interface_name,
- const char *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
+ephy_web_process_extension_user_message_received_cb (EphyWebProcessExtension *extension,
+ WebKitUserMessage *message)
{
- EphyWebProcessExtension *extension = EPHY_WEB_PROCESS_EXTENSION (user_data);
+ const char *name = webkit_user_message_get_name (message);
- if (g_strcmp0 (interface_name, EPHY_WEB_PROCESS_EXTENSION_INTERFACE) != 0)
- return;
-
- if (g_strcmp0 (method_name, "HistorySetURLs") == 0) {
+ if (g_strcmp0 (name, "History.SetURLs") == 0) {
if (extension->overview_model) {
+ GVariant *parameters;
GVariantIter iter;
- g_autoptr (GVariant) array = NULL;
const char *url;
const char *title;
GList *items = NULL;
+ g_autoptr (GVariant) array = NULL;
- g_variant_get (parameters, "(@a(ss))", &array);
+ parameters = webkit_user_message_get_parameters (message);
+ if (!parameters)
+ return;
+
+ g_variant_get (parameters, "@a(ss)", &array);
g_variant_iter_init (&iter, array);
while (g_variant_iter_loop (&iter, "(&s&s)", &url, &title))
@@ -391,83 +274,79 @@ handle_method_call (GDBusConnection *connection,
ephy_web_overview_model_set_urls (extension->overview_model, g_list_reverse (items));
}
- g_dbus_method_invocation_return_value (invocation, NULL);
- } else if (g_strcmp0 (method_name, "HistorySetURLThumbnail") == 0) {
+ } else if (g_strcmp0 (name, "History.SetURLThumbnail") == 0) {
if (extension->overview_model) {
+ GVariant *parameters;
const char *url;
const char *path;
+ parameters = webkit_user_message_get_parameters (message);
+ if (!parameters)
+ return;
+
g_variant_get (parameters, "(&s&s)", &url, &path);
ephy_web_overview_model_set_url_thumbnail (extension->overview_model, url, path, TRUE);
}
- g_dbus_method_invocation_return_value (invocation, NULL);
- } else if (g_strcmp0 (method_name, "HistorySetURLTitle") == 0) {
+ } else if (g_strcmp0 (name, "History.SetURLTitle") == 0) {
if (extension->overview_model) {
+ GVariant *parameters;
const char *url;
const char *title;
+ parameters = webkit_user_message_get_parameters (message);
+ if (!parameters)
+ return;
+
g_variant_get (parameters, "(&s&s)", &url, &title);
ephy_web_overview_model_set_url_title (extension->overview_model, url, title);
}
- g_dbus_method_invocation_return_value (invocation, NULL);
- } else if (g_strcmp0 (method_name, "HistoryDeleteURL") == 0) {
+ } else if (g_strcmp0 (name, "History.DeleteURL") == 0) {
if (extension->overview_model) {
+ GVariant *parameters;
const char *url;
- g_variant_get (parameters, "(&s)", &url);
+ parameters = webkit_user_message_get_parameters (message);
+ if (!parameters)
+ return;
+
+ g_variant_get (parameters, "&s", &url);
ephy_web_overview_model_delete_url (extension->overview_model, url);
}
- g_dbus_method_invocation_return_value (invocation, NULL);
- } else if (g_strcmp0 (method_name, "HistoryDeleteHost") == 0) {
+ } else if (g_strcmp0 (name, "History.DeleteHost") == 0) {
if (extension->overview_model) {
+ GVariant *parameters;
const char *host;
- g_variant_get (parameters, "(&s)", &host);
+ parameters = webkit_user_message_get_parameters (message);
+ if (!parameters)
+ return;
+
+ g_variant_get (parameters, "&s", &host);
ephy_web_overview_model_delete_host (extension->overview_model, host);
}
- g_dbus_method_invocation_return_value (invocation, NULL);
- } else if (g_strcmp0 (method_name, "HistoryClear") == 0) {
+ } else if (g_strcmp0 (name, "History.Clear") == 0) {
if (extension->overview_model)
ephy_web_overview_model_clear (extension->overview_model);
- g_dbus_method_invocation_return_value (invocation, NULL);
- } else if (g_strcmp0 (method_name, "PasswordQueryUsernamesResponse") == 0) {
- g_autofree const char **users;
- g_autoptr (JSCValue) ret = NULL;
- g_autoptr (JSCValue) password_manager = NULL;
- gint32 promise_id;
- guint64 frame_id;
-
- users = g_variant_get_strv (g_variant_get_child_value (parameters, 0), NULL);
- g_variant_get_child (parameters, 1, "i", &promise_id);
- g_variant_get_child (parameters, 2, "t", &frame_id);
-
- password_manager = get_password_manager (extension, frame_id);
- if (password_manager != NULL)
- ret = jsc_value_object_invoke_method (password_manager, "_onQueryUsernamesResponse",
- G_TYPE_STRV, users, G_TYPE_INT, promise_id, G_TYPE_NONE);
- } else if (g_strcmp0 (method_name, "PasswordQueryResponse") == 0) {
- const char *username;
- const char *password;
- gint32 promise_id;
- guint64 frame_id;
- g_autoptr (JSCValue) ret = NULL;
- g_autoptr (JSCValue) password_manager = NULL;
-
- g_variant_get (parameters, "(&s&sit)", &username, &password, &promise_id, &frame_id);
- password_manager = get_password_manager (extension, frame_id);
- if (password_manager != NULL)
- ret = jsc_value_object_invoke_method (password_manager, "_onQueryResponse",
- G_TYPE_STRING, username,
- G_TYPE_STRING, password,
- G_TYPE_INT, promise_id, G_TYPE_NONE);
}
}
-static const GDBusInterfaceVTable interface_vtable = {
- handle_method_call,
- NULL,
- NULL
-};
+static JSCValue *
+get_password_manager (EphyWebProcessExtension *self,
+ guint64 frame_id)
+{
+ WebKitFrame *frame;
+ g_autoptr (JSCContext) js_context = NULL;
+ g_autoptr (JSCValue) js_ephy = NULL;
+
+ frame = g_hash_table_lookup (self->frames_map, GINT_TO_POINTER (frame_id));
+ if (!frame)
+ return NULL;
+
+ js_context = webkit_frame_get_js_context_for_script_world (frame, self->script_world);
+ js_ephy = jsc_context_get_value (js_context, "Ephy");
+
+ return jsc_value_object_get_property (js_ephy, "passwordManager");
+}
static void
drop_frame_weak_ref (gpointer key,
@@ -485,13 +364,7 @@ ephy_web_process_extension_dispose (GObject *object)
g_clear_object (&extension->overview_model);
g_clear_object (&extension->permissions_manager);
- if (extension->page_created_signals_pending) {
- g_array_free (extension->page_created_signals_pending, TRUE);
- extension->page_created_signals_pending = NULL;
- }
-
g_clear_object (&extension->script_world);
- g_clear_object (&extension->dbus_connection);
g_clear_object (&extension->extension);
if (extension->frames_map) {
@@ -529,47 +402,6 @@ ephy_web_process_extension_get (void)
return EPHY_WEB_PROCESS_EXTENSION (g_once (&once_init, ephy_web_process_extension_create_instance, NULL));
}
-static void
-dbus_connection_created_cb (GObject *source_object,
- GAsyncResult *result,
- EphyWebProcessExtension *extension)
-{
- static GDBusNodeInfo *introspection_data = NULL;
- g_autoptr (GDBusConnection) connection = NULL;
- guint registration_id;
- g_autoptr (GError) error = NULL;
-
- if (!introspection_data)
- introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
-
- connection = g_dbus_connection_new_for_address_finish (result, &error);
- if (error)
- g_error ("Failed to connect to UI process: %s", error->message);
-
- registration_id =
- g_dbus_connection_register_object (connection,
- EPHY_WEB_PROCESS_EXTENSION_OBJECT_PATH,
- introspection_data->interfaces[0],
- &interface_vtable,
- extension,
- NULL,
- &error);
- if (!registration_id)
- g_error ("Failed to register web process extension object: %s\n", error->message);
-
- extension->dbus_connection = g_steal_pointer (&connection);
- ephy_web_process_extension_emit_page_created_signals_pending (extension);
-}
-
-static gboolean
-authorize_authenticated_peer_cb (GDBusAuthObserver *observer,
- GIOStream *stream,
- GCredentials *credentials,
- EphyWebProcessExtension *extension)
-{
- return ephy_dbus_peer_is_authorized (credentials);
-}
-
static void
js_log (const char *message)
{
@@ -596,6 +428,149 @@ js_auto_fill (JSCValue *js_element,
webkit_dom_element_html_input_element_set_editing_value (element, value);
}
+typedef struct {
+ EphyWebProcessExtension *extension;
+ guint64 promise_id;
+ guint64 frame_id;
+} PasswordManagerQueryData;
+
+static void
+web_view_query_usernames_ready_cb (WebKitWebPage *web_page, GAsyncResult *result, PasswordManagerQueryData
*data)
+{
+ WebKitUserMessage *reply;
+ GVariant *parameters;
+ const char **usernames;
+ g_autoptr (JSCValue) password_manager = NULL;
+ g_autoptr (GError) error = NULL;
+
+ reply = webkit_web_page_send_message_to_view_finish (web_page, result, &error);
+ if (error) {
+ g_warning ("Error getting usernames from WebView: %s\n", error->message);
+ g_free (data);
+ return;
+ }
+
+ parameters = webkit_user_message_get_parameters (reply);
+ if (!parameters) {
+ g_free (data);
+ return;
+ }
+
+ usernames = g_variant_get_strv (parameters, NULL);
+ password_manager = get_password_manager (data->extension, data->frame_id);
+ if (password_manager) {
+ g_autoptr (JSCValue) ret = NULL;
+
+ ret = jsc_value_object_invoke_method (password_manager, "_onQueryUsernamesResponse",
+ G_TYPE_STRV, usernames,
+ G_TYPE_UINT64, data->promise_id,
+ G_TYPE_NONE);
+ }
+
+ g_free (usernames);
+ g_free (data);
+}
+
+static void
+js_query_usernames (const char *origin,
+ guint64 promise_id,
+ guint64 page_id,
+ guint64 frame_id,
+ EphyWebProcessExtension *extension)
+{
+ WebKitWebPage *web_page;
+ WebKitUserMessage *message;
+ PasswordManagerQueryData *data;
+
+ if (!origin)
+ return;
+
+ web_page = webkit_web_extension_get_page (extension->extension, page_id);
+ if (!web_page)
+ return;
+
+ data = g_new0 (PasswordManagerQueryData, 1);
+ data->extension = extension;
+ data->promise_id = promise_id;
+ data->frame_id = frame_id;
+ message = webkit_user_message_new ("PasswordManager.QueryUsernames",
+ g_variant_new ("s", origin));
+ webkit_web_page_send_message_to_view (web_page, message, NULL,
+ (GAsyncReadyCallback)web_view_query_usernames_ready_cb,
+ data);
+}
+
+static void
+web_view_query_password_ready_cb (WebKitWebPage *web_page, GAsyncResult *result, PasswordManagerQueryData
*data)
+{
+ WebKitUserMessage *reply;
+ GVariant *parameters;
+ const char *username;
+ const char *password;
+ g_autoptr (JSCValue) password_manager = NULL;
+ g_autoptr (GError) error = NULL;
+
+ reply = webkit_web_page_send_message_to_view_finish (web_page, result, &error);
+ if (error) {
+ g_warning ("Error getting password from WebView: %s\n", error->message);
+ g_free (data);
+ return;
+ }
+
+ parameters = webkit_user_message_get_parameters (reply);
+ if (!parameters) {
+ g_free (data);
+ return;
+ }
+
+ g_variant_get (parameters, "(m&sm&s)", &username, &password);
+ password_manager = get_password_manager (data->extension, data->frame_id);
+ if (password_manager) {
+ g_autoptr (JSCValue) ret = NULL;
+
+ ret = jsc_value_object_invoke_method (password_manager, "_onQueryResponse",
+ G_TYPE_STRING, username,
+ G_TYPE_STRING, password,
+ G_TYPE_UINT64, data->promise_id,
+ G_TYPE_NONE);
+ }
+
+ g_free (data);
+}
+
+static void
+js_query_password (const char *origin,
+ const char *target_origin,
+ const char *username,
+ const char *username_field,
+ const char *password_field,
+ guint64 promise_id,
+ guint64 page_id,
+ guint64 frame_id,
+ EphyWebProcessExtension *extension)
+{
+ WebKitWebPage *web_page;
+ WebKitUserMessage *message;
+ PasswordManagerQueryData *data;
+
+ if (!origin || !target_origin || !password_field)
+ return;
+
+ web_page = webkit_web_extension_get_page (extension->extension, page_id);
+ if (!web_page)
+ return;
+
+ data = g_new0 (PasswordManagerQueryData, 1);
+ data->extension = extension;
+ data->promise_id = promise_id;
+ data->frame_id = frame_id;
+ message = webkit_user_message_new ("PasswordManager.QueryPassword",
+ g_variant_new ("(ssmsmss)", origin, target_origin, username,
username_field, password_field));
+ webkit_web_page_send_message_to_view (web_page, message, NULL,
+ (GAsyncReadyCallback)web_view_query_password_ready_cb,
+ data);
+}
+
static gboolean
js_is_web_application (void)
{
@@ -715,6 +690,28 @@ window_object_cleared_cb (WebKitScriptWorld *world,
JSC_TYPE_VALUE, G_TYPE_STRING);
jsc_value_object_set_property (js_ephy, "autoFill", js_function);
g_clear_object (&js_function);
+
+ js_function = jsc_value_new_function (js_context,
+ "queryUsernames",
+ G_CALLBACK (js_query_usernames),
+ extension, NULL,
+ G_TYPE_NONE, 4,
+ G_TYPE_STRING, G_TYPE_UINT64,
+ G_TYPE_UINT64, G_TYPE_UINT64);
+ jsc_value_object_set_property (js_ephy, "queryUsernames", js_function);
+ g_clear_object (&js_function);
+
+ js_function = jsc_value_new_function (js_context,
+ "queryPassword",
+ G_CALLBACK (js_query_password),
+ extension, NULL,
+ G_TYPE_NONE, 8,
+ G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_UINT64,
+ G_TYPE_UINT64, G_TYPE_UINT64);
+ jsc_value_object_set_property (js_ephy, "queryPassword", js_function);
+ g_clear_object (&js_function);
}
js_function = jsc_value_new_function (js_context,
@@ -745,12 +742,9 @@ void
ephy_web_process_extension_initialize (EphyWebProcessExtension *extension,
WebKitWebExtension *wk_extension,
const char *guid,
- const char *server_address,
gboolean is_private_profile,
gboolean is_browser_mode)
{
- g_autoptr (GDBusAuthObserver) observer = NULL;
-
g_assert (EPHY_IS_WEB_PROCESS_EXTENSION (extension));
if (extension->initialized)
@@ -770,21 +764,13 @@ ephy_web_process_extension_initialize (EphyWebProcessExtension *extension,
extension->permissions_manager = ephy_permissions_manager_new ();
+ g_signal_connect_swapped (extension->extension, "user-message-received",
+ G_CALLBACK (ephy_web_process_extension_user_message_received_cb),
+ extension);
g_signal_connect_swapped (extension->extension, "page-created",
G_CALLBACK (ephy_web_process_extension_page_created_cb),
extension);
- observer = g_dbus_auth_observer_new ();
- g_signal_connect (observer, "authorize-authenticated-peer",
- G_CALLBACK (authorize_authenticated_peer_cb), extension);
-
- g_dbus_connection_new_for_address (server_address,
- G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
- observer,
- NULL,
- (GAsyncReadyCallback)dbus_connection_created_cb,
- extension);
-
extension->frames_map = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, NULL);
}
diff --git a/embed/web-process-extension/ephy-web-process-extension.h
b/embed/web-process-extension/ephy-web-process-extension.h
index 7fc9fa9da..f9916c3a9 100644
--- a/embed/web-process-extension/ephy-web-process-extension.h
+++ b/embed/web-process-extension/ephy-web-process-extension.h
@@ -33,7 +33,6 @@ EphyWebProcessExtension *ephy_web_process_extension_get (void);
void ephy_web_process_extension_initialize (EphyWebProcessExtension *extension,
WebKitWebExtension *wk_extension,
const char *guid,
- const char *server_address,
gboolean is_private_profile,
gboolean is_browser_mode);
diff --git a/embed/web-process-extension/resources/js/ephy.js
b/embed/web-process-extension/resources/js/ephy.js
index 379035e5b..5a4a0616c 100644
--- a/embed/web-process-extension/resources/js/ephy.js
+++ b/embed/web-process-extension/resources/js/ephy.js
@@ -345,10 +345,7 @@ Ephy.PasswordManager = class PasswordManager
{
return new Promise((resolver, reject) => {
let promiseID = this._promiseCounter++;
- window.webkit.messageHandlers.passwordManagerQuery.postMessage({
- origin, targetOrigin, username, usernameField, passwordField, promiseID,
- pageID: this._pageID, frameID: this._frameID
- });
+ Ephy.queryPassword(origin, targetOrigin, username, usernameField, passwordField, promiseID,
this._pageID, this._frameID);
this._pendingPromises.push({promiseID, resolver});
});
}
@@ -381,9 +378,7 @@ Ephy.PasswordManager = class PasswordManager
{
return new Promise((resolver, reject) => {
let promiseID = this._promiseCounter++;
- window.webkit.messageHandlers.passwordManagerQueryUsernames.postMessage({
- origin, promiseID, pageID: this._pageID, frameID: this._frameID
- });
+ Ephy.queryUsernames(origin, promiseID, this._pageID, this._frameID);
this._pendingPromises.push({promiseID, resolver});
});
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]