diff options
author | Michael Catanzaro <mcatanzaro@igalia.com> | 2015-07-25 17:02:35 -0500 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@igalia.com> | 2015-07-27 20:06:32 -0500 |
commit | a3317ec824d80d99537918f168db0a1f70bd268e (patch) | |
tree | ff72a2143503ed9235de811ca90d8d3d77c549b6 | |
parent | dbee788e39394de6c0536d95dbef95528dbc7e3a (diff) | |
download | epiphany-a3317ec824d80d99537918f168db0a1f70bd268e.tar.gz |
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
-rw-r--r-- | embed/ephy-web-view.c | 29 | ||||
-rw-r--r-- | 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 17d7496a6..a35bee0f4 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 8211d6cdb..cefafe624 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); |