Add core function to navigate to URL parent.

This commit is contained in:
Michael Drake 2014-10-17 09:51:10 +01:00
parent 7a6faf4199
commit 7519993fd7
2 changed files with 43 additions and 0 deletions

View File

@ -1973,6 +1973,41 @@ nserror browser_window_navigate(struct browser_window *bw,
}
/* Exported interface, documented in browser.h */
nserror browser_window_navigate_up(struct browser_window *bw, bool new_window)
{
nsurl *current, *parent;
nserror err;
if (bw == NULL)
return NSERROR_BAD_PARAMETER;
current = browser_window_get_url(bw);
err = nsurl_parent(current, &parent);
if (err != NSERROR_OK) {
return err;
}
if (nsurl_compare(current, parent, NSURL_COMPLETE) == true) {
/* Can't go up to parent from here */
nsurl_unref(parent);
return NSERROR_OK;
}
if (new_window) {
err = browser_window_create(BW_CREATE_CLONE,
parent, NULL, bw, NULL);
} else {
err = browser_window_navigate(bw, parent, NULL,
BW_NAVIGATE_HISTORY, NULL, NULL, NULL);
}
nsurl_unref(parent);
return err;
}
/* Exported interface, documented in browser.h */
nsurl* browser_window_get_url(struct browser_window *bw)
{

View File

@ -151,6 +151,14 @@ nserror browser_window_navigate(struct browser_window *bw,
struct fetch_multipart_data *post_multipart,
struct hlcache_handle *parent);
/**
* Navigate to a browser_window's parent URL.
*
* \param bw browser window
* \param new_window whether to open parent in a new window, or existing
*/
nserror browser_window_navigate_up(struct browser_window *bw, bool new_window);
/**
* Get a browser window's URL.
*