From ba9769bc8c22c49fe1be6536d4684661ea2e079b Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 27 May 2013 14:51:00 +0100 Subject: Pass fetch redirect info up to content layer as content_msg. Mark redirect origin URLs as visited in browser window content callback. Note this doesn't mean we track redirects, it just lets us get the :visited link style on links that redirect. --- content/llcache.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'content/llcache.c') diff --git a/content/llcache.c b/content/llcache.c index 938f1e8f6..f2e519f49 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -1224,6 +1224,7 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target bool match; /* Extract HTTP response code from the fetch object */ long http_code = fetch_http_code(object->fetch.fetch); + llcache_event event; /* Abort fetch for this object */ fetch_abort(object->fetch.fetch); @@ -1238,8 +1239,6 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target /* Forcibly stop redirecting if we've followed too many redirects */ #define REDIRECT_LIMIT 10 if (object->fetch.redirect_count > REDIRECT_LIMIT) { - llcache_event event; - LOG(("Too many nested redirects")); event.type = LLCACHE_EVENT_ERROR; @@ -1254,6 +1253,18 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target if (error != NSERROR_OK) return error; + /* Inform users of redirect */ + event.type = LLCACHE_EVENT_REDIRECT; + event.data.redirect.from = object->url; + event.data.redirect.to = url; + + error = llcache_send_event_to_users(object, &event); + + if (error != NSERROR_OK) { + nsurl_unref(url); + return error; + } + /* Reject attempts to redirect from unvalidated to validated schemes * A "validated" scheme is one over which we have some guarantee that * the source is trustworthy. */ -- cgit v1.2.3