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 <dsilvers@digital-scurf.org>
This commit is contained in:
Daniel Silverstone 2020-02-22 16:24:36 +00:00
parent c9e5fa9bc1
commit 277c1550f5
No known key found for this signature in database
GPG Key ID: C30DF439F2987D74
1 changed files with 25 additions and 30 deletions

View File

@ -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) {