mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 18:52:39 +03:00
Browser: Add function to get bw URL with any fragment.
This returns a ref to the URL.
This commit is contained in:
parent
09b015bf11
commit
eeb7be1cbf
@ -2267,6 +2267,36 @@ nsurl* browser_window_access_url(struct browser_window *bw)
|
||||
return corestring_nsurl_about_blank;
|
||||
}
|
||||
|
||||
/* Exported interface, documented in include/netsurf/browser_window.h */
|
||||
nserror browser_window_get_url(
|
||||
struct browser_window *bw,
|
||||
bool fragment,
|
||||
nsurl** url_out)
|
||||
{
|
||||
nserror err;
|
||||
nsurl *url;
|
||||
|
||||
assert(bw != NULL);
|
||||
|
||||
if (!fragment || bw->frag_id == NULL || bw->loading_content != NULL) {
|
||||
/* If there's a loading content, then the bw->frag_id will have
|
||||
* been trampled, possibly with a new frag_id, but we will
|
||||
* still be returning the current URL, so in this edge case
|
||||
* we just drop any fragment. */
|
||||
url = nsurl_ref(browser_window_access_url(bw));
|
||||
|
||||
} else {
|
||||
err = nsurl_refragment(browser_window_access_url(bw),
|
||||
bw->frag_id, &url);
|
||||
if (err != NSERROR_OK) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
*url_out = url;
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* Exported interface, documented in browser.h */
|
||||
const char* browser_window_get_title(struct browser_window *bw)
|
||||
{
|
||||
|
@ -209,6 +209,19 @@ nserror browser_window_navigate_up(struct browser_window *bw, bool new_window);
|
||||
*/
|
||||
struct nsurl* browser_window_access_url(struct browser_window *bw);
|
||||
|
||||
/**
|
||||
* Access a browser window's URL.
|
||||
*
|
||||
* \param[in] bw browser window
|
||||
* \param[in] fragment Whether to include any URL fragment.
|
||||
* \param[out] url_out Returns a ref to the URL on success.
|
||||
* \return NSERROR_OK, or appropriate error otherwise.
|
||||
*/
|
||||
nserror browser_window_get_url(
|
||||
struct browser_window *bw,
|
||||
bool fragment,
|
||||
struct nsurl** url_out);
|
||||
|
||||
/**
|
||||
* Get the title of a browser_window.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user