[project @ 2004-10-01 00:06:49 by jmb]

Send HTTP referer header. This is _only_ sent when a link is clicked (theoretically, at least).

svn path=/import/netsurf/; revision=1296
This commit is contained in:
John Mark Bell 2004-10-01 00:06:49 +00:00
parent 1202ad9c44
commit 39ad1632eb
10 changed files with 53 additions and 28 deletions

View File

@ -82,7 +82,8 @@ static void browser_form_submit(struct browser_window *bw, struct form *form,
/**
* Create and open a new browser window with the given page.
*
* \param url URL to start fetching in the new window (copied)
* \param url URL to start fetching in the new window (copied)
* \param clone The browser window to clone
*/
void browser_window_create(const char *url, struct browser_window *clone)
@ -105,22 +106,24 @@ void browser_window_create(const char *url, struct browser_window *clone)
free(bw);
return;
}
browser_window_go(bw, url);
browser_window_go(bw, url, false);
}
/**
* Start fetching a page in a browser window.
*
* \param bw browser window
* \param url URL to start fetching (copied)
* \param bw browser window
* \param url URL to start fetching (copied)
* \param referer whether to send the referer header
*
* Any existing fetches in the window are aborted.
*/
void browser_window_go(struct browser_window *bw, const char *url)
void browser_window_go(struct browser_window *bw, const char *url,
bool referer)
{
browser_window_go_post(bw, url, 0, 0, true);
browser_window_go_post(bw, url, 0, 0, true, referer);
}
@ -144,7 +147,7 @@ void browser_window_go(struct browser_window *bw, const char *url)
void browser_window_go_post(struct browser_window *bw, const char *url,
char *post_urlenc,
struct form_successful_control *post_multipart,
bool history_add)
bool history_add, bool referer)
{
struct content *c;
char *url2;
@ -188,7 +191,8 @@ void browser_window_go_post(struct browser_window *bw, const char *url,
bw->loading_content = c;
browser_window_start_throbber(bw);
fetchcache_go(c, 0, browser_window_callback, bw, 0,
fetchcache_go(c, referer ? gui_window_get_url(bw->window) : 0,
browser_window_callback, bw, 0,
post_urlenc, post_multipart, true);
}
@ -273,7 +277,8 @@ void browser_window_callback(content_msg msg, struct content *c,
bw->loading_content = 0;
browser_window_set_status(bw,
messages_get("Redirecting"));
browser_window_go(bw, data.redirect);
/* hmm, should we do send the referrer here? */
browser_window_go(bw, data.redirect, false);
break;
case CONTENT_MSG_REFORMAT:
@ -469,7 +474,7 @@ void browser_window_reload(struct browser_window *bw, bool all)
}
}
bw->current_content->fresh = false;
browser_window_go_post(bw, bw->current_content->url, 0, 0, false);
browser_window_go_post(bw, bw->current_content->url, 0, 0, false, false);
}
@ -783,7 +788,7 @@ void browser_window_mouse_click_html(struct browser_window *bw,
click == BROWSER_MOUSE_CLICK_2) {
if (fetch_can_fetch(url)) {
if (click == BROWSER_MOUSE_CLICK_1)
browser_window_go(bw, url);
browser_window_go(bw, url, true);
else
browser_window_create(url, bw);
} else {
@ -1721,7 +1726,7 @@ void browser_form_submit(struct browser_window *bw, struct form *form,
res = url_join(url, base, &url1);
if (res != URL_FUNC_OK)
break;
browser_window_go(bw, url1);
browser_window_go(bw, url1, true);
break;
case method_POST_URLENC:
@ -1734,14 +1739,14 @@ void browser_form_submit(struct browser_window *bw, struct form *form,
res = url_join(form->action, base, &url);
if (res != URL_FUNC_OK)
break;
browser_window_go_post(bw, url, data, 0, true);
browser_window_go_post(bw, url, data, 0, true, true);
break;
case method_POST_MULTIPART:
res = url_join(form->action, base, &url);
if (res != URL_FUNC_OK)
break;
browser_window_go_post(bw, url, 0, success, true);
browser_window_go_post(bw, url, 0, success, true, true);
break;
default:

View File

@ -71,11 +71,12 @@ typedef enum {
void browser_window_create(const char *url, struct browser_window *clone);
void browser_window_go(struct browser_window *bw, const char *url);
void browser_window_go(struct browser_window *bw, const char *url,
bool referer);
void browser_window_go_post(struct browser_window *bw, const char *url,
char *post_urlenc,
struct form_successful_control *post_multipart,
bool history_add);
bool history_add, bool referer);
void browser_window_stop(struct browser_window *bw);
void browser_window_reload(struct browser_window *bw, bool all);
void browser_window_destroy(struct browser_window *bw);

View File

@ -45,6 +45,7 @@ void gui_window_set_extent(struct gui_window *g, int width, int height);
void gui_window_set_status(struct gui_window *g, const char *text);
void gui_window_set_pointer(gui_pointer_shape shape);
void gui_window_set_url(struct gui_window *g, const char *url);
char *gui_window_get_url(struct gui_window *g);
void gui_window_start_throbber(struct gui_window *g);
void gui_window_stop_throbber(struct gui_window *g);
void gui_window_place_caret(struct gui_window *g, int x, int y, int height);

View File

@ -188,7 +188,7 @@ gboolean gui_window_url_key_press_event(GtkWidget *widget,
if (event->keyval != GDK_Return)
return FALSE;
browser_window_go(g->bw, gtk_entry_get_text(GTK_ENTRY(g->url_bar)));
browser_window_go(g->bw, gtk_entry_get_text(GTK_ENTRY(g->url_bar)), false);
return TRUE;
}
@ -305,6 +305,10 @@ void gui_window_set_url(struct gui_window *g, const char *url)
gtk_entry_set_text(GTK_ENTRY(g->url_bar), url);
}
char *gui_window_get_url(struct gui_window *g)
{
return gtk_entry_get_text(GTK_ENTRY(g->url_bar));
}
void gui_window_start_throbber(struct gui_window* g)
{

View File

@ -99,7 +99,7 @@ bool ro_gui_401login_keypress(wimp_key *key)
case wimp_KEY_RETURN:
get_unamepwd();
ro_gui_dialog_close(dialog_401li);
browser_window_go(bwin, url);
browser_window_go(bwin, url, false);
return true;
}
@ -118,7 +118,7 @@ void ro_gui_401login_click(wimp_pointer *pointer)
case ICON_401LOGIN_LOGIN:
get_unamepwd();
ro_gui_dialog_close(dialog_401li);
browser_window_go(bwin, url);
browser_window_go(bwin, url, false);
break;
case ICON_401LOGIN_CANCEL:
ro_gui_dialog_close(dialog_401li);

View File

@ -1164,7 +1164,7 @@ void ro_msg_dataload(wimp_message *message)
return;
if (g)
browser_window_go(g->bw, url);
browser_window_go(g->bw, url, false);
else
browser_window_create(url, 0);

View File

@ -663,7 +663,7 @@ void history_go(struct browser_window *bw, struct history_entry *entry)
else
url = entry->url;
browser_window_go_post(bw, url, 0, 0, false);
browser_window_go_post(bw, url, 0, 0, false, false);
if (entry->frag_id)
free(url);

View File

@ -817,12 +817,12 @@ void ro_gui_menu_selection(wimp_selection *selection)
switch (selection->items[1]) {
case 0: /* Home */
if (option_homepage_url && option_homepage_url[0]) {
browser_window_go_post(current_gui->bw, option_homepage_url, 0, 0, true);
browser_window_go_post(current_gui->bw, option_homepage_url, 0, 0, true, false);
} else {
snprintf(url, sizeof url,
"file:/<NetSurf$Dir>/Docs/intro_%s",
option_language);
browser_window_go_post(current_gui->bw, url, 0, 0, true);
browser_window_go_post(current_gui->bw, url, 0, 0, true, false);
}
break;
case 1: /* Back */

View File

@ -730,7 +730,7 @@ void plugin_url_access(wimp_message *message)
strcasecmp(window, "_parent") == 0 ||
strcasecmp(window, "_top") == 0 ||
strcasecmp(window, "") == 0) {
browser_window_go(c->data.plugin.bw, url);
browser_window_go(c->data.plugin.bw, url, false);
}
else if (strcasecmp(window, "_blank") == 0) {
browser_window_create(url, NULL);

View File

@ -762,6 +762,20 @@ void gui_window_set_url(struct gui_window *g, const char *url)
}
}
/**
* Get the contents of a window's address bar.
*
* \param g gui_window to update
* \return The url in the address bar or NULL
*/
char *gui_window_get_url(struct gui_window *g)
{
if (!g->toolbar)
return NULL;
return ro_gui_get_icon_string(g->toolbar->toolbar_handle,
ICON_TOOLBAR_URL);
}
/**
* Forces all windows to be set to the current theme
@ -818,7 +832,7 @@ void ro_gui_window_update_dimensions(struct gui_window *g, int yscroll) {
return;
}
state.yscroll -= yscroll;
g->old_height = -1;
g->old_height = -1;
ro_gui_window_open(g, (wimp_open *)&state);
/* gui_window_redraw_window(g); */
}
@ -1085,7 +1099,7 @@ void ro_gui_toolbar_click(struct gui_window *g, wimp_pointer *pointer)
if (option_homepage_url && option_homepage_url[0]) {
if (pointer->buttons == wimp_CLICK_SELECT) {
browser_window_go_post(g->bw, option_homepage_url,
0, 0, true);
0, 0, true, false);
} else {
browser_window_create(option_homepage_url, NULL);
}
@ -1094,7 +1108,7 @@ void ro_gui_toolbar_click(struct gui_window *g, wimp_pointer *pointer)
"file:/<NetSurf$Dir>/Docs/intro_%s",
option_language);
if (pointer->buttons == wimp_CLICK_SELECT) {
browser_window_go_post(g->bw, url, 0, 0, true);
browser_window_go_post(g->bw, url, 0, 0, true, false);
} else {
browser_window_create(url, NULL);
}
@ -1447,7 +1461,7 @@ bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar)
res = url_normalize(toolbar_url, &url);
if (res == URL_FUNC_OK) {
gui_window_set_url(g, url);
browser_window_go(g->bw, url);
browser_window_go(g->bw, url, false);
free(url);
}
return true;