[epiphany] EphyWebView: add get_display_address()



commit a3317ec824d80d99537918f168db0a1f70bd268e
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sat Jul 25 17:02:35 2015 -0500

    EphyWebView: add get_display_address()
    
    This returns a decoded URI. It is the only URI that is appropriate for
    display to the user.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710004

 embed/ephy-web-view.c |   29 +++++++++++++++++++++++++++--
 embed/ephy-web-view.h |    2 +-
 2 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 17d7496..a35bee0 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -78,6 +78,7 @@ struct _EphyWebViewPrivate {
   guint ever_committed : 1;
 
   char *address;
+  char *display_address;
   char *typed_address;
   char *loading_message;
   char *link_message;
@@ -791,6 +792,7 @@ ephy_web_view_finalize (GObject *object)
   ephy_web_view_popups_manager_reset (EPHY_WEB_VIEW (object));
 
   g_free (priv->address);
+  g_free (priv->display_address);
   g_free (priv->typed_address);
   g_free (priv->link_message);
   g_free (priv->loading_message);
@@ -854,6 +856,9 @@ ephy_web_view_set_address (EphyWebView *view,
   g_free (priv->address);
   priv->address = g_strdup (address);
 
+  g_free (priv->display_address);
+  priv->display_address = g_uri_unescape_string (priv->address, NULL);
+
   is_blank = address == NULL ||
              strcmp (address, "about:blank") == 0;
   _ephy_web_view_set_is_blank (view, is_blank);
@@ -961,7 +966,7 @@ ephy_web_view_class_init (EphyWebViewClass *klass)
 /**
  * EphyWebView:address:
  *
- * View's current address.
+ * View's current address. This is a percent-encoded URI.
  **/
   g_object_class_install_property (gobject_class,
                                    PROP_ADDRESS,
@@ -2350,7 +2355,9 @@ ephy_web_view_is_overview (EphyWebView *view)
  * ephy_web_view_get_address:
  * @view: an #EphyWebView
  *
- * Returns the address of the currently loaded page.
+ * Returns the address of the currently-loaded page, percent-encoded.
+ * This URI should not be displayed to the user; to do that, use
+ * ephy_web_view_get_display_address().
  *
  * Return value: @view's address. Will never be %NULL.
  **/
@@ -2362,6 +2369,24 @@ ephy_web_view_get_address (EphyWebView *view)
 }
 
 /**
+ * ephy_web_view_get_display_address:
+ * @view: an #EphyWebView
+ *
+ * Returns the display address of the currently-loaded page. This is a
+ * decoded URI suitable for display to the user. To get a URI suitable
+ * for sending to a server, e.g. for storage in the bookmarks or history
+ * database, use ephy_web_view_get_address().
+ *
+ * Return value: @view's address. Will never be %NULL.
+ */
+const char *
+ephy_web_view_get_display_address (EphyWebView *view)
+{
+  EphyWebViewPrivate *priv = view->priv;
+  return priv->display_address ? priv->display_address : "about:blank";
+}
+
+/**
  * ephy_web_view_is_loading:
  * @view: an #EphyWebView
  *
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index 8211d6c..cefafe6 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -141,7 +141,7 @@ void                       ephy_web_view_get_security_level       (EphyWebView
                                                                    GTlsCertificateFlags      *errors);
 void                       ephy_web_view_print                    (EphyWebView               *view);
 const char *               ephy_web_view_get_address              (EphyWebView               *view);
-
+const char *               ephy_web_view_get_display_address      (EphyWebView               *view);
 void                       ephy_web_view_set_placeholder          (EphyWebView               *view,
                                                                    const char                *uri,
                                                                    const char                *title);


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