mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 12:12:35 +03:00
browser_window: Ensure that back works like 'back to safety'
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
parent
6bce06b91f
commit
b67bbe3280
@ -37,6 +37,7 @@
|
|||||||
#include "content/hlcache.h"
|
#include "content/hlcache.h"
|
||||||
#include "content/urldb.h"
|
#include "content/urldb.h"
|
||||||
#include "netsurf/bitmap.h"
|
#include "netsurf/bitmap.h"
|
||||||
|
#include "utils/corestrings.h"
|
||||||
|
|
||||||
#include "desktop/gui_internal.h"
|
#include "desktop/gui_internal.h"
|
||||||
#include "desktop/browser_private.h"
|
#include "desktop/browser_private.h"
|
||||||
@ -519,6 +520,24 @@ void browser_window_history_destroy(struct browser_window *bw)
|
|||||||
/* exported interface documented in desktop/browser_history.h */
|
/* exported interface documented in desktop/browser_history.h */
|
||||||
nserror browser_window_history_back(struct browser_window *bw, bool new_window)
|
nserror browser_window_history_back(struct browser_window *bw, bool new_window)
|
||||||
{
|
{
|
||||||
|
if (bw != NULL && bw->internal_nav) {
|
||||||
|
/* All internal nav back operations ignore new_window */
|
||||||
|
if (bw->current_parameters.url != NULL) {
|
||||||
|
/* There are some internal parameters, restart from there */
|
||||||
|
return browser_window__reload_current_parameters(bw);
|
||||||
|
} else {
|
||||||
|
/* No internal parameters, just navigate to about:blank */
|
||||||
|
return browser_window_navigate(
|
||||||
|
bw,
|
||||||
|
corestring_nsurl_about_blank,
|
||||||
|
NULL, /* Referer */
|
||||||
|
BW_NAVIGATE_HISTORY,
|
||||||
|
NULL, /* Post */
|
||||||
|
NULL, /* Post */
|
||||||
|
NULL /* parent fetch */);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!bw || !bw->history || !bw->history->current ||
|
if (!bw || !bw->history || !bw->history->current ||
|
||||||
!bw->history->current->back) {
|
!bw->history->current->back) {
|
||||||
return NSERROR_BAD_PARAMETER;
|
return NSERROR_BAD_PARAMETER;
|
||||||
|
@ -408,4 +408,11 @@ void browser_window_history_destroy(struct browser_window *bw);
|
|||||||
*/
|
*/
|
||||||
typedef nserror (*browser_window_query_callback)(bool proceed, void *pw);
|
typedef nserror (*browser_window_query_callback)(bool proceed, void *pw);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Navigate a browser window to the current parameters
|
||||||
|
*
|
||||||
|
* \param bw The browser window to cause to navigate
|
||||||
|
*/
|
||||||
|
nserror browser_window__reload_current_parameters(struct browser_window *bw);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -864,23 +864,7 @@ browser_window__handle_ssl_query_response(bool proceed, void *pw)
|
|||||||
* nav to the old 'current' parameters, with any post data
|
* nav to the old 'current' parameters, with any post data
|
||||||
* stripped away
|
* stripped away
|
||||||
*/
|
*/
|
||||||
if (bw->current_parameters.post_urlenc != NULL) {
|
return browser_window__reload_current_parameters(bw);
|
||||||
free(bw->current_parameters.post_urlenc);
|
|
||||||
bw->current_parameters.post_urlenc = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bw->current_parameters.post_multipart != NULL) {
|
|
||||||
fetch_multipart_data_destroy(bw->current_parameters.post_multipart);
|
|
||||||
bw->current_parameters.post_multipart = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bw->current_parameters.flags &= ~BW_NAVIGATE_HISTORY;
|
|
||||||
bw->internal_nav = false;
|
|
||||||
|
|
||||||
browser_window__free_fetch_parameters(&bw->loading_parameters);
|
|
||||||
memcpy(&bw->loading_parameters, &bw->current_parameters, sizeof(bw->loading_parameters));
|
|
||||||
memset(&bw->current_parameters, 0, sizeof(bw->current_parameters));
|
|
||||||
return browser_window__navigate_internal(bw, &bw->loading_parameters);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We're processing a "proceed" attempt from the form */
|
/* We're processing a "proceed" attempt from the form */
|
||||||
@ -1694,7 +1678,9 @@ browser_window_refresh_url_bar_internal(struct browser_window *bw, nsurl *url)
|
|||||||
/* Not root window or no gui window so do not set a URL */
|
/* Not root window or no gui window so do not set a URL */
|
||||||
return NSERROR_OK;
|
return NSERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSLOG(netsurf, CRITICAL, "Updating the URL to %s", nsurl_access(url));
|
||||||
|
|
||||||
return guit->window->set_url(bw->window, url);
|
return guit->window->set_url(bw->window, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4275,6 +4261,10 @@ void browser_window_page_drag_start(struct browser_window *bw, int x, int y)
|
|||||||
/* exported interface documented in netsurf/browser_window.h */
|
/* exported interface documented in netsurf/browser_window.h */
|
||||||
bool browser_window_back_available(struct browser_window *bw)
|
bool browser_window_back_available(struct browser_window *bw)
|
||||||
{
|
{
|
||||||
|
if (bw != NULL && bw->internal_nav) {
|
||||||
|
/* Internal nav, back is possible */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return (bw && bw->history && browser_window_history_back_available(bw));
|
return (bw && bw->history && browser_window_history_back_available(bw));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4375,3 +4365,28 @@ browser_window_console_log(struct browser_window *bw,
|
|||||||
|
|
||||||
return NSERROR_OK;
|
return NSERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Exported interface, documented in browser_private.h */
|
||||||
|
nserror
|
||||||
|
browser_window__reload_current_parameters(struct browser_window *bw)
|
||||||
|
{
|
||||||
|
assert(bw != NULL);
|
||||||
|
|
||||||
|
if (bw->current_parameters.post_urlenc != NULL) {
|
||||||
|
free(bw->current_parameters.post_urlenc);
|
||||||
|
bw->current_parameters.post_urlenc = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bw->current_parameters.post_multipart != NULL) {
|
||||||
|
fetch_multipart_data_destroy(bw->current_parameters.post_multipart);
|
||||||
|
bw->current_parameters.post_multipart = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bw->current_parameters.flags &= ~BW_NAVIGATE_HISTORY;
|
||||||
|
bw->internal_nav = false;
|
||||||
|
|
||||||
|
browser_window__free_fetch_parameters(&bw->loading_parameters);
|
||||||
|
memcpy(&bw->loading_parameters, &bw->current_parameters, sizeof(bw->loading_parameters));
|
||||||
|
memset(&bw->current_parameters, 0, sizeof(bw->current_parameters));
|
||||||
|
return browser_window__navigate_internal(bw, &bw->loading_parameters);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user