aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2013-03-21 21:00:18 +0800
committerClaudio Saavedra <csaavedra@igalia.com>2013-08-29 03:25:29 +0800
commitb5754ac85db00de0183dbd13004917d5eb9c06a6 (patch)
tree3358120b3d8181fa906b857add572719e5be5d35 /embed
parent1d9f2c94024756ee68abba6eaff1078a52c6e57b (diff)
downloadgsoc2013-epiphany-b5754ac85db00de0183dbd13004917d5eb9c06a6.tar
gsoc2013-epiphany-b5754ac85db00de0183dbd13004917d5eb9c06a6.tar.gz
gsoc2013-epiphany-b5754ac85db00de0183dbd13004917d5eb9c06a6.tar.bz2
gsoc2013-epiphany-b5754ac85db00de0183dbd13004917d5eb9c06a6.tar.lz
gsoc2013-epiphany-b5754ac85db00de0183dbd13004917d5eb9c06a6.tar.xz
gsoc2013-epiphany-b5754ac85db00de0183dbd13004917d5eb9c06a6.tar.zst
gsoc2013-epiphany-b5754ac85db00de0183dbd13004917d5eb9c06a6.zip
Make ephy_web_view_has_modified_forms() asynchronous
https://bugzilla.gnome.org/show_bug.cgi?id=695642
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-web-view.c73
-rw-r--r--embed/ephy-web-view.h8
2 files changed, 60 insertions, 21 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index f39546b9d..57ceab62f 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -2545,6 +2545,26 @@ ephy_web_view_set_typed_address (EphyWebView *view,
g_object_notify (G_OBJECT (view), "typed-address");
}
+#ifdef HAVE_WEBKIT2
+static void
+has_modified_forms_cb (GDBusProxy *web_extension,
+ GAsyncResult *result,
+ GTask *task)
+{
+ GVariant *return_value;
+ gboolean retval = FALSE;
+
+ return_value = g_dbus_proxy_call_finish (web_extension, result, NULL);
+ if (return_value) {
+ g_variant_get (return_value, "(b)", &retval);
+ g_variant_unref (return_value);
+ }
+
+ g_task_return_boolean (task, retval);
+ g_object_unref (task);
+}
+#endif
+
/**
* ephy_web_view_has_modified_forms:
* @view: an #EphyWebView
@@ -2559,33 +2579,46 @@ ephy_web_view_set_typed_address (EphyWebView *view,
*
* Return value: %TRUE if @view has user-modified forms
**/
-gboolean
-ephy_web_view_has_modified_forms (EphyWebView *view)
+void
+ephy_web_view_has_modified_forms (EphyWebView *view,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
- return FALSE;
-#if 0
+ GTask *task = g_task_new (view, cancellable, callback, user_data);
+#ifdef HAVE_WEBKIT2
GDBusProxy *web_extension;
- GVariant *result;
- gboolean retval = FALSE;
- /* FIXME: This should be async */
web_extension = ephy_embed_shell_get_web_extension_proxy (ephy_embed_shell_get_default ());
- if (!web_extension)
- return FALSE;
- result = g_dbus_proxy_call_sync (web_extension,
- "HasModifiedForms",
- g_variant_new ("(t)", webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- NULL);
+ if (web_extension) {
+ g_dbus_proxy_call (web_extension,
+ "HasModifiedForms",
+ g_variant_new ("(t)", webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ (GAsyncReadyCallback)has_modified_forms_cb,
+ g_object_ref (task));
+ } else {
+ g_task_return_boolean (task, FALSE);
+ }
+#else
+ WebKitDOMDocument *document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
+
+ g_task_return_boolean (task, ephy_web_dom_utils_has_modified_forms (document));
+#endif
+ g_object_unref (task);
+}
- g_variant_get (result, "(b)", &retval);
- g_variant_unref (result);
+gboolean
+ephy_web_view_has_modified_forms_finish (EphyWebView *view,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_return_val_if_fail (g_task_is_valid (result, view), FALSE);
- return retval;
-#endif
+ return g_task_propagate_boolean (G_TASK (result), error);
}
/**
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index a24f96269..2e0b0672c 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -144,7 +144,13 @@ const char * ephy_web_view_get_typed_address (EphyWebView
void ephy_web_view_set_typed_address (EphyWebView *view,
const char *address);
gboolean ephy_web_view_get_is_blank (EphyWebView *view);
-gboolean ephy_web_view_has_modified_forms (EphyWebView *view);
+void ephy_web_view_has_modified_forms (EphyWebView *view,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean ephy_web_view_has_modified_forms_finish (EphyWebView *view,
+ GAsyncResult *result,
+ GError **error);
void ephy_web_view_get_security_level (EphyWebView *view,
EphyWebViewSecurityLevel *level,
GTlsCertificate **certificate,