[epiphany] ephy-web-view: Always update the internal address when WebKitWebView:uri changes



commit 9da559f8065d4aefb64973b863c0ff67ef0dab74
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Sat Dec 3 13:08:26 2016 +0100

    ephy-web-view: Always update the internal address when WebKitWebView:uri changes
    
    We are currently changing it manually, and only when WebKitWebView:uri
    changes if the page is loaded. This was needed with older versions of
    WebKit that didn't emit notify::uri for the pending API request URL.
    With current WebKit, as soon as you call webkit_view_load_*() you get a
    notify::uri with the pending API request URL. So, we can now update our
    address everytime WebKitWebView:uri changes to ensure out address is
    updated as soon as possible even before the provisional load event. This
    allows us to do things like
    
    ephy_web_view_load_url();
    ephy_web_view_get_is_blank();
    
    When the load is committed the URI is considered final, and it never
    changes except for navigation to the same document. So, this patch also
    renames ephy_web_view_location_changed() as
    ephy_web_view_set_committed_location(), which is more accurate name, to
    properly update our internal address when we know is final.

 embed/ephy-web-view.c |   29 +++++------------------------
 1 files changed, 5 insertions(+), 24 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 713be07..5d73a4c 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -954,26 +954,8 @@ uri_changed_cb (WebKitWebView *web_view,
                 GParamSpec    *spec,
                 gpointer       data)
 {
-  char *uri;
-  const char *current_address;
-
-  /* We already update the URI manually while loading, so only
-   * update the URI when it changes after the page has been loaded
-   * which is usually the result of navigation within the same page action.
-   */
-  if (webkit_web_view_is_loading (web_view))
-    return;
-
-  /* We need to check if we get URI notifications without going
-     through the usual load process, as this can happen when changing
-     location within a page */
-  current_address = ephy_web_view_get_address (EPHY_WEB_VIEW (web_view));
-  g_object_get (web_view, "uri", &uri, NULL);
-
-  if (g_str_equal (uri, current_address) == FALSE)
-    ephy_web_view_set_address (EPHY_WEB_VIEW (web_view), uri);
-
-  g_free (uri);
+  ephy_web_view_set_address (EPHY_WEB_VIEW (web_view),
+                             webkit_web_view_get_uri (web_view));
 }
 
 static void
@@ -1563,8 +1545,8 @@ ephy_web_view_set_loading_message (EphyWebView *view,
 }
 
 static void
-ephy_web_view_location_changed (EphyWebView *view,
-                                const char  *location)
+ephy_web_view_set_committed_location (EphyWebView *view,
+                                      const char  *location)
 {
   GObject *object = G_OBJECT (view);
 
@@ -1683,7 +1665,6 @@ load_changed_cb (WebKitWebView  *web_view,
       break;
     }
     case WEBKIT_LOAD_REDIRECTED:
-      /* TODO: Update the loading uri */
       break;
     case WEBKIT_LOAD_COMMITTED: {
       const char *uri;
@@ -1691,7 +1672,7 @@ load_changed_cb (WebKitWebView  *web_view,
 
       /* Title and location. */
       uri = webkit_web_view_get_uri (web_view);
-      ephy_web_view_location_changed (view, uri);
+      ephy_web_view_set_committed_location (view, uri);
       update_security_status_for_committed_load (view, uri);
 
       /* History. */


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