From 277c1550f516b59ffd14cdbd102ca559c1e145e6 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 22 Feb 2020 16:24:36 +0000 Subject: browser_window: Inform GUI about redirects and final URL To correctly have the GUI know about all url bar updates, we should inform it during the processing of redirects and we should ensure that when we're in the ready-but-not-done phase we do not use the fetch parameters but instead the content's known URL Signed-off-by: Daniel Silverstone --- desktop/browser_window.c | 55 ++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/desktop/browser_window.c b/desktop/browser_window.c index 2a3948f4c..dba3d31eb 100644 --- a/desktop/browser_window.c +++ b/desktop/browser_window.c @@ -1319,6 +1319,27 @@ browser_window__handle_error(struct browser_window *bw, } +/** + * Update URL bar for a given browser window to given URL + * + * \param bw Browser window to update URL bar for. + * \param url URL for content displayed by bw including any fragment. + */ +static inline nserror +browser_window_refresh_url_bar_internal(struct browser_window *bw, nsurl *url) +{ + assert(bw); + assert(url); + + if ((bw->parent != NULL) || (bw->window == NULL)) { + /* Not root window or no gui window so do not set a URL */ + return NSERROR_OK; + } + + return guit->window->set_url(bw->window, url); +} + + /** * Browser window content event callback handler. */ @@ -1393,6 +1414,7 @@ browser_window_callback(hlcache_handle *c, const hlcache_event *event, void *pw) if (urldb_add_url(event->data.redirect.from)) { urldb_update_url_visit_data(event->data.redirect.from); } + browser_window_refresh_url_bar_internal(bw, event->data.redirect.to); break; case CONTENT_MSG_STATUS: @@ -1773,27 +1795,6 @@ static void browser_window_destroy_internal(struct browser_window *bw) } -/** - * Update URL bar for a given browser window to given URL - * - * \param bw Browser window to update URL bar for. - * \param url URL for content displayed by bw including any fragment. - */ -static inline nserror -browser_window_refresh_url_bar_internal(struct browser_window *bw, nsurl *url) -{ - assert(bw); - assert(url); - - if ((bw->parent != NULL) || (bw->window == NULL)) { - /* Not root window or no gui window so do not set a URL */ - return NSERROR_OK; - } - - return guit->window->set_url(bw->window, url); -} - - /** * scroll to a fragment if present * @@ -3165,15 +3166,9 @@ nserror browser_window_refresh_url_bar(struct browser_window *bw) /* no content so return about:blank */ ret = browser_window_refresh_url_bar_internal(bw, corestring_nsurl_about_blank); - } else if (bw->throbbing) { - /* We're throbbing, so show the loading parameters url, - * or if there isn't one, the current parameters url - */ - if (bw->loading_parameters.url != NULL) { - url = bw->loading_parameters.url; - } else { - url = bw->current_parameters.url; - } + } else if (bw->throbbing && bw->loading_parameters.url != NULL) { + /* Throbbing and we have loading parameters, use those */ + url = bw->loading_parameters.url; ret = browser_window_refresh_url_bar_internal(bw, url); } else if (bw->frag_id == NULL) { if (bw->internal_nav) { -- cgit v1.2.3