From dc85ddb0a82af725d843ecce7fb0183b7fd05352 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 19 Apr 2008 11:07:42 +0000 Subject: Launch redirects to unsupported URLs in other applications. svn path=/trunk/netsurf/; revision=4098 --- content/content.h | 2 ++ content/fetchcache.c | 59 ++++++++++++++++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 22 deletions(-) (limited to 'content') diff --git a/content/content.h b/content/content.h index 5e130e138..f2f3f4de2 100644 --- a/content/content.h +++ b/content/content.h @@ -89,6 +89,7 @@ typedef enum { CONTENT_MSG_REDRAW, /**< needs redraw (eg. new animation frame) */ CONTENT_MSG_NEWPTR, /**< structure has been replaced */ CONTENT_MSG_REFRESH, /**< wants refresh */ + CONTENT_MSG_LAUNCH, /**< needs url launching in external program */ #ifdef WITH_AUTH CONTENT_MSG_AUTH, /**< authentication required */ #endif @@ -117,6 +118,7 @@ union content_msg_data { } redraw; const char *auth_realm; /**< Realm, for CONTENT_MSG_AUTH. */ int delay; /**< Minimum delay, for CONTENT_MSG_REFRESH */ + const char *launch_url; /**< URL to launch, for CONTENT_MSG_LAUNCH */ struct { /** Certificate chain (certs[0] == server) */ const struct ssl_cert_info *certs; diff --git a/content/fetchcache.c b/content/fetchcache.c index 5d5753af7..d7e180b89 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -814,6 +814,7 @@ void fetchcache_redirect(struct content *c, const void *data, long http_code; const char *ref; const char *parent; + bool can_fetch; union content_msg_data msg_data; url_func_result result; @@ -933,6 +934,9 @@ void fetchcache_redirect(struct content *c, const void *data, /* No longer need url1 */ free(url1); + /* Determine if we've got a fetch handler for this url */ + can_fetch = fetch_can_fetch(url); + /* Process users of this content */ while (c->user_list->next) { intptr_t p1, p2; @@ -946,34 +950,45 @@ void fetchcache_redirect(struct content *c, const void *data, p2 = c->user_list->next->p2; callback = c->user_list->next->callback; + /* If we can't fetch this url, attempt to launch it */ + if (!can_fetch) { + msg_data.launch_url = url; + callback(CONTENT_MSG_LAUNCH, c, p1, p2, msg_data); + } + /* Remove user */ content_remove_user(c, callback, p1, p2); - /* Get replacement content -- HTTP GET request */ - replacement = fetchcache(url, callback, p1, p2, - c->width, c->height, c->no_error_pages, - NULL, NULL, false, c->download); - if (!replacement) { - msg_data.error = messages_get("BadRedirect"); - content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - - free(url); - free(parent_url); - free(referer); - return; - } + if (can_fetch) { + /* Get replacement content -- HTTP GET request */ + replacement = fetchcache(url, callback, p1, p2, + c->width, c->height, c->no_error_pages, + NULL, NULL, false, c->download); + if (!replacement) { + msg_data.error = messages_get("BadRedirect"); + content_broadcast(c, CONTENT_MSG_ERROR, + msg_data); - /* Set replacement's redirect count to 1 greater than ours */ - replacement->redirect_count = c->redirect_count + 1; + free(url); + free(parent_url); + free(referer); + return; + } - /* Notify user that content has changed */ - msg_data.new_url = url; - callback(CONTENT_MSG_NEWPTR, replacement, p1, p2, msg_data); + /* Set replacement's redirect count to 1 greater + * than ours */ + replacement->redirect_count = c->redirect_count + 1; - /* Start fetching the replacement content */ - fetchcache_go(replacement, referer, callback, p1, p2, - c->width, c->height, NULL, NULL, - false, parent_url); + /* Notify user that content has changed */ + msg_data.new_url = url; + callback(CONTENT_MSG_NEWPTR, replacement, + p1, p2, msg_data); + + /* Start fetching the replacement content */ + fetchcache_go(replacement, referer, callback, p1, p2, + c->width, c->height, NULL, NULL, + false, parent_url); + } } /* Clean up */ -- cgit v1.2.3