From 8ec7ad053a9a291ea2619055b1ca1989d4c975b9 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 5 Nov 2014 23:44:31 +0000 Subject: Make the fetching of a contents encoding generic. The frontends previously had to use an html renderer API to get the encoding of a content. This also required the explicit checking of the contents type rather than using the existing content API to abstract this knowledge. --- content/content.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'content/content.c') diff --git a/content/content.c b/content/content.c index ee6ff818f..728147f31 100644 --- a/content/content.c +++ b/content/content.c @@ -1301,6 +1301,30 @@ bool content_get_quirks(hlcache_handle *h) } +/** + * Retrieve the encoding of a content + * + * \param c Content to retrieve bitmap from + * \return Pointer to bitmap, or NULL if none. + */ +const char *content_get_encoding(hlcache_handle *h) +{ + return content__get_encoding(hlcache_handle_get_content(h)); +} + +const char *content__get_encoding(struct content *c) +{ + const char *encoding = NULL; + + if ((c != NULL) && + (c->handler != NULL) && + (c->handler->get_encoding != NULL) ) { + encoding = c->handler->get_encoding(c); + } + + return encoding; +} + /** * Return whether a content is currently locked * -- cgit v1.2.3