summaryrefslogtreecommitdiff
path: root/desktop/browser.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-10-17 09:51:10 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2014-10-17 09:51:10 +0100
commit7519993fd7ae4e23d1d03a2b2264c9dc86b34db7 (patch)
tree46c0307744dae130533b891272a45a5f0b803cf3 /desktop/browser.c
parent7a6faf41994e1bd9a31112e7349221331e3fdc05 (diff)
downloadnetsurf-7519993fd7ae4e23d1d03a2b2264c9dc86b34db7.tar.gz
netsurf-7519993fd7ae4e23d1d03a2b2264c9dc86b34db7.tar.bz2
Add core function to navigate to URL parent.
Diffstat (limited to 'desktop/browser.c')
-rw-r--r--desktop/browser.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index 42c8edaff..d9ad417ac 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1974,6 +1974,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)
{
assert(bw != NULL);