[epiphany/webkit2: 12/17] Port geolocation permission request to WebKit2
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/webkit2: 12/17] Port geolocation permission request to WebKit2
- Date: Thu, 21 Jun 2012 10:04:21 +0000 (UTC)
commit 57745b9670c09b9230b0e64bd9e975f198fb29c4
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Wed Jun 6 18:03:57 2012 +0200
Port geolocation permission request to WebKit2
embed/ephy-web-view.c | 47 ++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 40 insertions(+), 7 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 80f6fa9..8326d3f 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -1849,7 +1849,25 @@ mime_type_policy_decision_requested_cb (WebKitWebView *web_view,
#endif
#ifdef HAVE_WEBKIT2
-/* TODO: Geolocation */
+static void
+decide_on_geolocation_policy_request (GtkWidget *info_bar,
+ int response,
+ WebKitPermissionRequest *request)
+{
+ gtk_widget_destroy (info_bar);
+
+ switch (response) {
+ case GTK_RESPONSE_YES:
+ webkit_permission_request_allow (request);
+ break;
+ default:
+ webkit_permission_request_deny (request);
+ break;
+ }
+
+ gtk_widget_destroy (info_bar);
+ g_object_unref (request);
+}
#else
static void
decide_on_geolocation_policy_request (GtkWidget *info_bar,
@@ -1868,12 +1886,19 @@ decide_on_geolocation_policy_request (GtkWidget *info_bar,
webkit_geolocation_policy_deny (decision);
g_object_unref (decision);
}
+#endif
+#ifdef HAVE_WEBKIT2
+static gboolean
+permission_request_cb (WebKitWebView *web_view,
+ WebKitPermissionRequest *decision)
+#else
static gboolean
geolocation_policy_decision_requested_cb (WebKitWebView *web_view,
WebKitWebFrame *web_frame,
WebKitGeolocationPolicyDecision *decision,
gpointer data)
+#endif
{
GtkWidget *info_bar;
GtkWidget *action_area;
@@ -1884,6 +1909,11 @@ geolocation_policy_decision_requested_cb (WebKitWebView *web_view,
char *message;
char *host;
+#ifdef HAVE_WEBKIT2
+ if (!WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST (decision))
+ return FALSE;
+#endif
+
info_bar = gtk_info_bar_new ();
/* Buttons */
@@ -1905,7 +1935,11 @@ geolocation_policy_decision_requested_cb (WebKitWebView *web_view,
G_CALLBACK (send_yes_response_cb), info_bar);
/* Label */
+#ifdef HAVE_WEBKIT2
+ host = ephy_string_get_host_name (webkit_web_view_get_uri (web_view));
+#else
host = ephy_string_get_host_name (webkit_web_frame_get_uri (web_frame));
+#endif
message = g_markup_printf_escaped (_("The page at <b>%s</b> wants to know your location."),
host);
g_free (host);
@@ -1920,19 +1954,16 @@ geolocation_policy_decision_requested_cb (WebKitWebView *web_view,
gtk_widget_show_all (info_bar);
+ /* Ref the decision, to keep it alive while we decide */
g_signal_connect (info_bar, "response",
G_CALLBACK (decide_on_geolocation_policy_request),
- decision);
+ g_object_ref (decision));
ephy_embed_add_top_widget (EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view),
info_bar, TRUE);
- /* Ref the decision, to keep it alive while we decide */
- g_object_ref (decision);
-
return TRUE;
}
-#endif
#ifdef HAVE_WEBKIT2
/* TODO: DOM Bindings */
@@ -2664,7 +2695,9 @@ ephy_web_view_init (EphyWebView *web_view)
#endif
#ifdef HAVE_WEBKIT2
- /* TODO: Geolocation */
+ g_signal_connect (web_view, "permission-request",
+ G_CALLBACK (permission_request_cb),
+ NULL);
#else
g_signal_connect (web_view, "geolocation-policy-decision-requested",
G_CALLBACK (geolocation_policy_decision_requested_cb),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]