In WebKit GTK 2, there is a more official route for this:
WebKitWebContext *context = webkit_web_context_get_default();
webkit_web_context_register_uri_scheme(context, "custom",
(WebKitURISchemeRequestCallback)handle_custom,
NULL, NULL);
/* ... */
static void
handle_custom(WebKitURISchemeRequest *request)
{
/* DO FILE LOCATING MAGIC HERE */
GFile *file = g_file_new_for_path(real_location_of_file);
GFileInputStream *stream = g_file_read(file, NULL, NULL);
g_object_unref(file);
webkit_uri_scheme_request_finish(request, stream, -1, NULL);
g_object_unref(stream);
}