mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-25 13:37:02 +03:00
use the default resource:favicon.ico when a site has no icon of its own
svn path=/trunk/netsurf/; revision=12992
This commit is contained in:
parent
62111d36be
commit
2f60ecea61
@ -912,11 +912,7 @@ static nserror browser_window_favicon_callback(hlcache_handle *c,
|
||||
/* content_get_bitmap on the hlcache_handle should give
|
||||
* us the favicon bitmap at this point
|
||||
*/
|
||||
if (bw->window != NULL) {
|
||||
gui_window_set_icon(bw->window, c);
|
||||
} else {
|
||||
LOG(("null browser window on favicon!"));
|
||||
}
|
||||
gui_window_set_icon(bw->window, c);
|
||||
break;
|
||||
|
||||
case CONTENT_MSG_ERROR:
|
||||
@ -930,9 +926,32 @@ static nserror browser_window_favicon_callback(hlcache_handle *c,
|
||||
|
||||
hlcache_handle_release(c);
|
||||
|
||||
/** @todo if this was not the default
|
||||
* resource:favicon.png start a fetch for it.
|
||||
*/
|
||||
if (bw->failed_favicon == false) {
|
||||
nsurl *nsref = NULL;
|
||||
nsurl *nsurl;
|
||||
nserror error;
|
||||
|
||||
bw->failed_favicon = true;
|
||||
|
||||
error = nsurl_create("resource:favicon.ico", &nsurl);
|
||||
if (error != NSERROR_OK) {
|
||||
LOG(("Unable to create default location url"));
|
||||
} else {
|
||||
|
||||
hlcache_handle_retrieve(nsurl,
|
||||
HLCACHE_RETRIEVE_SNIFF_TYPE,
|
||||
nsref,
|
||||
NULL,
|
||||
browser_window_favicon_callback,
|
||||
bw,
|
||||
NULL,
|
||||
CONTENT_IMAGE,
|
||||
&bw->loading_favicon);
|
||||
|
||||
nsurl_unref(nsurl);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -962,6 +981,8 @@ static void browser_window_update_favicon(hlcache_handle *c,
|
||||
if (bw->loading_favicon != NULL)
|
||||
return;
|
||||
|
||||
bw->failed_favicon = false;
|
||||
|
||||
if (link == NULL) {
|
||||
/* look for favicon metadata link */
|
||||
lwc_intern_string("icon", SLEN("icon"), &icon_str);
|
||||
@ -1001,6 +1022,7 @@ static void browser_window_update_favicon(hlcache_handle *c,
|
||||
/* no favicon via link, try for the default location */
|
||||
error = nsurl_join(nsurl, "/favicon.ico", &nsurl);
|
||||
} else {
|
||||
bw->failed_favicon = true;
|
||||
error = nsurl_create("resource:favicon.ico", &nsurl);
|
||||
}
|
||||
if (error != NSERROR_OK) {
|
||||
|
@ -79,6 +79,8 @@ struct browser_window {
|
||||
struct hlcache_handle *current_favicon;
|
||||
/** handle for favicon which we started loading early */
|
||||
struct hlcache_handle *loading_favicon;
|
||||
/** favicon fetch already failed - prevents infinite error looping */
|
||||
bool failed_favicon;
|
||||
|
||||
/** Window history structure. */
|
||||
struct history *history;
|
||||
|
Loading…
Reference in New Issue
Block a user