[epiphany] ephy-embed.c: workaround possibly bogus COMMITTED load-status from WebKit



commit 341b0cdc26e50e1b515074badf8257f6eeb6a3a2
Author: Xan Lopez <xan gnome org>
Date:   Thu Aug 27 13:08:37 2009 +0300

    ephy-embed.c: workaround possibly bogus COMMITTED load-status from WebKit
    
    When WebKitGTK+ fails to load a URI and is allowed to load the default
    error page it will emit a COMMITTED load-status with the original URI
    we failed to load. This was confusing epiphany, since in theory
    COMMITTED should be only emitted with URIs known to be good. As a
    workaround flag pages that fail to load in the callback for
    'load-error' and avoid doing anything with them when they arrive in
    COMMITTED.
    
    Bug #593200

 embed/ephy-embed.c |   43 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index ddbb5dd..80fd0cd 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -60,6 +60,7 @@ struct EphyEmbedPrivate
   WebKitWebView *web_view;
   EphyHistory *history;
   GtkWidget *inspector_window;
+  char *load_failed_uri;
   guint is_setting_zoom : 1;
 };
 
@@ -204,11 +205,22 @@ load_status_changed_cb (WebKitWebView *view,
   if (status == WEBKIT_LOAD_COMMITTED) {
     const gchar* uri;
     EphyWebViewSecurityLevel security_level;
-    
+
     uri = webkit_web_view_get_uri (view);
+
+    /* If the load failed for this URI, do nothing */
+    if (embed->priv->load_failed_uri &&
+        g_str_equal (embed->priv->load_failed_uri, uri)) {
+      g_free (embed->priv->load_failed_uri);
+      embed->priv->load_failed_uri = NULL;
+
+      ephy_web_view_set_security_level (EPHY_WEB_VIEW (view), EPHY_WEB_VIEW_STATE_IS_UNKNOWN);
+
+      return;
+    }
+
     ephy_web_view_location_changed (EPHY_WEB_VIEW (view),
                                     uri);
-
     restore_zoom_level (embed, uri);
     ephy_history_add_page (embed->priv->history,
                            uri,
@@ -311,12 +323,23 @@ ephy_embed_grab_focus (GtkWidget *widget)
 }
 
 static void
+ephy_embed_finalize (GObject *object)
+{
+  EphyEmbed *embed = EPHY_EMBED (object);
+
+  g_free (embed->priv->load_failed_uri);
+
+  G_OBJECT_CLASS (ephy_embed_parent_class)->finalize (object);
+}
+
+static void
 ephy_embed_class_init (EphyEmbedClass *klass)
 {
   GObjectClass *object_class = (GObjectClass *)klass;
   GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
 
   object_class->constructed = ephy_embed_constructed;
+  object_class->finalize = ephy_embed_finalize;
   widget_class->grab_focus = ephy_embed_grab_focus;
 
   g_type_class_add_private (G_OBJECT_CLASS (klass), sizeof(EphyEmbedPrivate));
@@ -690,6 +713,21 @@ download_requested_cb (WebKitWebView *web_view,
   return TRUE;
 }
 
+static gboolean
+load_error_cb (WebKitWebView *web_view,
+               WebKitWebFrame *frame,
+               const char *uri,
+               GError *error,
+               EphyEmbed *embed)
+{
+  /* Flag the page as error. We need the flag to check it when
+     receiving COMMITTED status, since for some reason we are getting
+     that when the load fails too */
+  embed->priv->load_failed_uri = g_strdup (uri);
+
+  return FALSE;
+}
+
 static void
 ephy_embed_constructed (GObject *object)
 {
@@ -712,6 +750,7 @@ ephy_embed_constructed (GObject *object)
                     "signal::notify::zoom-level", G_CALLBACK (zoom_changed_cb), embed,
                     "signal::notify::title", G_CALLBACK (title_changed_cb), embed,
                     "signal::notify::uri", G_CALLBACK (uri_changed_cb), embed,
+                    "signal::load-error", G_CALLBACK (load_error_cb), embed,
                     NULL);
 
   embed->priv->inspector_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]