15b9c547cSRui Paulo /* 25b9c547cSRui Paulo * Hotspot 2.0 client - Web browser using WebKit 35b9c547cSRui Paulo * Copyright (c) 2013, Qualcomm Atheros, Inc. 45b9c547cSRui Paulo * 55b9c547cSRui Paulo * This software may be distributed under the terms of the BSD license. 65b9c547cSRui Paulo * See README for more details. 75b9c547cSRui Paulo */ 85b9c547cSRui Paulo 95b9c547cSRui Paulo #include "includes.h" 10c1d255d3SCy Schubert #ifdef USE_WEBKIT2 11c1d255d3SCy Schubert #include <webkit2/webkit2.h> 12c1d255d3SCy Schubert #else /* USE_WEBKIT2 */ 135b9c547cSRui Paulo #include <webkit/webkit.h> 14c1d255d3SCy Schubert #endif /* USE_WEBKIT2 */ 155b9c547cSRui Paulo 165b9c547cSRui Paulo #include "common.h" 175b9c547cSRui Paulo #include "browser.h" 185b9c547cSRui Paulo 195b9c547cSRui Paulo 205b9c547cSRui Paulo struct browser_context { 215b9c547cSRui Paulo GtkWidget *win; 22c1d255d3SCy Schubert WebKitWebView *view; 235b9c547cSRui Paulo int success; 245b9c547cSRui Paulo int progress; 255b9c547cSRui Paulo char *hover_link; 265b9c547cSRui Paulo char *title; 27c1d255d3SCy Schubert int gtk_main_started; 28c1d255d3SCy Schubert int quit_gtk_main; 295b9c547cSRui Paulo }; 305b9c547cSRui Paulo 315b9c547cSRui Paulo static void win_cb_destroy(GtkWidget *win, struct browser_context *ctx) 325b9c547cSRui Paulo { 335b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "BROWSER:%s", __func__); 34c1d255d3SCy Schubert if (ctx->gtk_main_started) 355b9c547cSRui Paulo gtk_main_quit(); 365b9c547cSRui Paulo } 375b9c547cSRui Paulo 385b9c547cSRui Paulo 395b9c547cSRui Paulo static void browser_update_title(struct browser_context *ctx) 405b9c547cSRui Paulo { 415b9c547cSRui Paulo char buf[100]; 425b9c547cSRui Paulo 435b9c547cSRui Paulo if (ctx->hover_link) { 445b9c547cSRui Paulo gtk_window_set_title(GTK_WINDOW(ctx->win), ctx->hover_link); 455b9c547cSRui Paulo return; 465b9c547cSRui Paulo } 475b9c547cSRui Paulo 485b9c547cSRui Paulo if (ctx->progress == 100) { 495b9c547cSRui Paulo gtk_window_set_title(GTK_WINDOW(ctx->win), 505b9c547cSRui Paulo ctx->title ? ctx->title : 515b9c547cSRui Paulo "Hotspot 2.0 client"); 525b9c547cSRui Paulo return; 535b9c547cSRui Paulo } 545b9c547cSRui Paulo 555b9c547cSRui Paulo snprintf(buf, sizeof(buf), "[%d%%] %s", ctx->progress, 565b9c547cSRui Paulo ctx->title ? ctx->title : "Hotspot 2.0 client"); 575b9c547cSRui Paulo gtk_window_set_title(GTK_WINDOW(ctx->win), buf); 585b9c547cSRui Paulo } 595b9c547cSRui Paulo 605b9c547cSRui Paulo 61c1d255d3SCy Schubert static void process_request_starting_uri(struct browser_context *ctx, 62c1d255d3SCy Schubert const char *uri) 63c1d255d3SCy Schubert { 64c1d255d3SCy Schubert int quit = 0; 65c1d255d3SCy Schubert 66c1d255d3SCy Schubert if (g_str_has_prefix(uri, "osu://")) { 67c1d255d3SCy Schubert ctx->success = atoi(uri + 6); 68c1d255d3SCy Schubert quit = 1; 69c1d255d3SCy Schubert } else if (g_str_has_prefix(uri, "http://localhost:12345")) { 70c1d255d3SCy Schubert /* 71c1d255d3SCy Schubert * This is used as a special trigger to indicate that the 72c1d255d3SCy Schubert * user exchange has been completed. 73c1d255d3SCy Schubert */ 74c1d255d3SCy Schubert ctx->success = 1; 75c1d255d3SCy Schubert quit = 1; 76c1d255d3SCy Schubert } 77c1d255d3SCy Schubert 78c1d255d3SCy Schubert if (quit) { 79c1d255d3SCy Schubert if (ctx->gtk_main_started) { 80c1d255d3SCy Schubert gtk_main_quit(); 81c1d255d3SCy Schubert ctx->gtk_main_started = 0; 82c1d255d3SCy Schubert } else { 83c1d255d3SCy Schubert ctx->quit_gtk_main = 1; 84c1d255d3SCy Schubert } 85c1d255d3SCy Schubert } 86c1d255d3SCy Schubert } 87c1d255d3SCy Schubert 88c1d255d3SCy Schubert 89c1d255d3SCy Schubert #ifdef USE_WEBKIT2 90c1d255d3SCy Schubert 91c1d255d3SCy Schubert static void view_cb_notify_estimated_load_progress(WebKitWebView *view, 92c1d255d3SCy Schubert GParamSpec *pspec, 93c1d255d3SCy Schubert struct browser_context *ctx) 94c1d255d3SCy Schubert { 95c1d255d3SCy Schubert ctx->progress = 100 * webkit_web_view_get_estimated_load_progress(view); 96c1d255d3SCy Schubert wpa_printf(MSG_DEBUG, "BROWSER:%s progress=%d", __func__, 97c1d255d3SCy Schubert ctx->progress); 98c1d255d3SCy Schubert browser_update_title(ctx); 99c1d255d3SCy Schubert } 100c1d255d3SCy Schubert 101c1d255d3SCy Schubert 102c1d255d3SCy Schubert static void view_cb_resource_load_starting(WebKitWebView *view, 103c1d255d3SCy Schubert WebKitWebResource *res, 104c1d255d3SCy Schubert WebKitURIRequest *req, 105c1d255d3SCy Schubert struct browser_context *ctx) 106c1d255d3SCy Schubert { 107c1d255d3SCy Schubert const gchar *uri = webkit_uri_request_get_uri(req); 108c1d255d3SCy Schubert 109c1d255d3SCy Schubert wpa_printf(MSG_DEBUG, "BROWSER:%s uri=%s", __func__, uri); 110c1d255d3SCy Schubert process_request_starting_uri(ctx, uri); 111c1d255d3SCy Schubert } 112c1d255d3SCy Schubert 113c1d255d3SCy Schubert 114c1d255d3SCy Schubert static gboolean view_cb_decide_policy(WebKitWebView *view, 115c1d255d3SCy Schubert WebKitPolicyDecision *policy, 116c1d255d3SCy Schubert WebKitPolicyDecisionType type, 117c1d255d3SCy Schubert struct browser_context *ctx) 118c1d255d3SCy Schubert { 119c1d255d3SCy Schubert wpa_printf(MSG_DEBUG, "BROWSER:%s type=%d", __func__, type); 120c1d255d3SCy Schubert switch (type) { 121c1d255d3SCy Schubert case WEBKIT_POLICY_DECISION_TYPE_RESPONSE: { 122c1d255d3SCy Schubert /* This function makes webkit send a download signal for all 123c1d255d3SCy Schubert * unknown mime types. */ 124c1d255d3SCy Schubert WebKitResponsePolicyDecision *response; 125c1d255d3SCy Schubert 126c1d255d3SCy Schubert response = WEBKIT_RESPONSE_POLICY_DECISION(policy); 127c1d255d3SCy Schubert if (!webkit_response_policy_decision_is_mime_type_supported( 128c1d255d3SCy Schubert response)) { 129c1d255d3SCy Schubert webkit_policy_decision_download(policy); 130c1d255d3SCy Schubert return TRUE; 131c1d255d3SCy Schubert } 132c1d255d3SCy Schubert break; 133c1d255d3SCy Schubert } 134c1d255d3SCy Schubert case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: { 135c1d255d3SCy Schubert WebKitNavigationPolicyDecision *d; 136c1d255d3SCy Schubert WebKitNavigationAction *a; 137c1d255d3SCy Schubert WebKitURIRequest *req; 138c1d255d3SCy Schubert const gchar *uri; 139c1d255d3SCy Schubert 140c1d255d3SCy Schubert d = WEBKIT_NAVIGATION_POLICY_DECISION(policy); 141c1d255d3SCy Schubert a = webkit_navigation_policy_decision_get_navigation_action(d); 142c1d255d3SCy Schubert req = webkit_navigation_action_get_request(a); 143c1d255d3SCy Schubert uri = webkit_uri_request_get_uri(req); 144c1d255d3SCy Schubert wpa_printf(MSG_DEBUG, "BROWSER:%s navigation action: uri=%s", 145c1d255d3SCy Schubert __func__, uri); 146c1d255d3SCy Schubert process_request_starting_uri(ctx, uri); 147c1d255d3SCy Schubert break; 148c1d255d3SCy Schubert } 149c1d255d3SCy Schubert default: 150c1d255d3SCy Schubert break; 151c1d255d3SCy Schubert } 152c1d255d3SCy Schubert 153c1d255d3SCy Schubert return FALSE; 154c1d255d3SCy Schubert } 155c1d255d3SCy Schubert 156c1d255d3SCy Schubert 157c1d255d3SCy Schubert static void view_cb_mouse_target_changed(WebKitWebView *view, 158c1d255d3SCy Schubert WebKitHitTestResult *h, 159c1d255d3SCy Schubert guint modifiers, 160c1d255d3SCy Schubert struct browser_context *ctx) 161c1d255d3SCy Schubert { 162c1d255d3SCy Schubert WebKitHitTestResultContext hc = webkit_hit_test_result_get_context(h); 163c1d255d3SCy Schubert const char *uri = NULL; 164c1d255d3SCy Schubert 165c1d255d3SCy Schubert if (hc & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) 166c1d255d3SCy Schubert uri = webkit_hit_test_result_get_link_uri(h); 167c1d255d3SCy Schubert else if (hc & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE) 168c1d255d3SCy Schubert uri = webkit_hit_test_result_get_image_uri(h); 169c1d255d3SCy Schubert else if (hc & WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA) 170c1d255d3SCy Schubert uri = webkit_hit_test_result_get_media_uri(h); 171c1d255d3SCy Schubert 172c1d255d3SCy Schubert wpa_printf(MSG_DEBUG, "BROWSER:%s uri=%s", __func__, uri ? uri : "N/A"); 173c1d255d3SCy Schubert os_free(ctx->hover_link); 174c1d255d3SCy Schubert if (uri) 175c1d255d3SCy Schubert ctx->hover_link = os_strdup(uri); 176c1d255d3SCy Schubert else 177c1d255d3SCy Schubert ctx->hover_link = NULL; 178c1d255d3SCy Schubert 179c1d255d3SCy Schubert browser_update_title(ctx); 180c1d255d3SCy Schubert } 181c1d255d3SCy Schubert 182c1d255d3SCy Schubert 183c1d255d3SCy Schubert static void view_cb_notify_title(WebKitWebView *view, GParamSpec *ps, 184c1d255d3SCy Schubert struct browser_context *ctx) 185c1d255d3SCy Schubert { 186c1d255d3SCy Schubert const char *title; 187c1d255d3SCy Schubert 188c1d255d3SCy Schubert title = webkit_web_view_get_title(ctx->view); 189c1d255d3SCy Schubert wpa_printf(MSG_DEBUG, "BROWSER:%s title=%s", __func__, title); 190c1d255d3SCy Schubert os_free(ctx->title); 191c1d255d3SCy Schubert ctx->title = os_strdup(title); 192c1d255d3SCy Schubert browser_update_title(ctx); 193c1d255d3SCy Schubert } 194c1d255d3SCy Schubert 195c1d255d3SCy Schubert #else /* USE_WEBKIT2 */ 196c1d255d3SCy Schubert 1975b9c547cSRui Paulo static void view_cb_notify_progress(WebKitWebView *view, GParamSpec *pspec, 1985b9c547cSRui Paulo struct browser_context *ctx) 1995b9c547cSRui Paulo { 2005b9c547cSRui Paulo ctx->progress = 100 * webkit_web_view_get_progress(view); 2015b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "BROWSER:%s progress=%d", __func__, 2025b9c547cSRui Paulo ctx->progress); 2035b9c547cSRui Paulo browser_update_title(ctx); 2045b9c547cSRui Paulo } 2055b9c547cSRui Paulo 2065b9c547cSRui Paulo 2075b9c547cSRui Paulo static void view_cb_notify_load_status(WebKitWebView *view, GParamSpec *pspec, 2085b9c547cSRui Paulo struct browser_context *ctx) 2095b9c547cSRui Paulo { 2105b9c547cSRui Paulo int status = webkit_web_view_get_load_status(view); 2115b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "BROWSER:%s load-status=%d uri=%s", 2125b9c547cSRui Paulo __func__, status, webkit_web_view_get_uri(view)); 213c1d255d3SCy Schubert if (ctx->quit_gtk_main) { 214c1d255d3SCy Schubert gtk_main_quit(); 215c1d255d3SCy Schubert ctx->gtk_main_started = 0; 216c1d255d3SCy Schubert } 2175b9c547cSRui Paulo } 2185b9c547cSRui Paulo 2195b9c547cSRui Paulo 2205b9c547cSRui Paulo static void view_cb_resource_request_starting(WebKitWebView *view, 2215b9c547cSRui Paulo WebKitWebFrame *frame, 2225b9c547cSRui Paulo WebKitWebResource *res, 2235b9c547cSRui Paulo WebKitNetworkRequest *req, 2245b9c547cSRui Paulo WebKitNetworkResponse *resp, 2255b9c547cSRui Paulo struct browser_context *ctx) 2265b9c547cSRui Paulo { 2275b9c547cSRui Paulo const gchar *uri = webkit_network_request_get_uri(req); 228c1d255d3SCy Schubert 2295b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "BROWSER:%s uri=%s", __func__, uri); 2305b9c547cSRui Paulo if (g_str_has_suffix(uri, "/favicon.ico")) 2315b9c547cSRui Paulo webkit_network_request_set_uri(req, "about:blank"); 232c1d255d3SCy Schubert 233c1d255d3SCy Schubert process_request_starting_uri(ctx, uri); 2345b9c547cSRui Paulo } 2355b9c547cSRui Paulo 2365b9c547cSRui Paulo 2375b9c547cSRui Paulo static gboolean view_cb_mime_type_policy_decision( 2385b9c547cSRui Paulo WebKitWebView *view, WebKitWebFrame *frame, WebKitNetworkRequest *req, 2395b9c547cSRui Paulo gchar *mime, WebKitWebPolicyDecision *policy, 2405b9c547cSRui Paulo struct browser_context *ctx) 2415b9c547cSRui Paulo { 2425b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "BROWSER:%s mime=%s", __func__, mime); 2435b9c547cSRui Paulo 2445b9c547cSRui Paulo if (!webkit_web_view_can_show_mime_type(view, mime)) { 2455b9c547cSRui Paulo webkit_web_policy_decision_download(policy); 2465b9c547cSRui Paulo return TRUE; 2475b9c547cSRui Paulo } 2485b9c547cSRui Paulo 2495b9c547cSRui Paulo return FALSE; 2505b9c547cSRui Paulo } 2515b9c547cSRui Paulo 2525b9c547cSRui Paulo 2535b9c547cSRui Paulo static gboolean view_cb_download_requested(WebKitWebView *view, 2545b9c547cSRui Paulo WebKitDownload *dl, 2555b9c547cSRui Paulo struct browser_context *ctx) 2565b9c547cSRui Paulo { 2575b9c547cSRui Paulo const gchar *uri; 2585b9c547cSRui Paulo uri = webkit_download_get_uri(dl); 2595b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "BROWSER:%s uri=%s", __func__, uri); 2605b9c547cSRui Paulo return FALSE; 2615b9c547cSRui Paulo } 2625b9c547cSRui Paulo 2635b9c547cSRui Paulo 2645b9c547cSRui Paulo static void view_cb_hovering_over_link(WebKitWebView *view, gchar *title, 2655b9c547cSRui Paulo gchar *uri, struct browser_context *ctx) 2665b9c547cSRui Paulo { 2675b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "BROWSER:%s title=%s uri=%s", __func__, title, 2685b9c547cSRui Paulo uri); 2695b9c547cSRui Paulo os_free(ctx->hover_link); 2705b9c547cSRui Paulo if (uri) 2715b9c547cSRui Paulo ctx->hover_link = os_strdup(uri); 2725b9c547cSRui Paulo else 2735b9c547cSRui Paulo ctx->hover_link = NULL; 2745b9c547cSRui Paulo 2755b9c547cSRui Paulo browser_update_title(ctx); 2765b9c547cSRui Paulo } 2775b9c547cSRui Paulo 2785b9c547cSRui Paulo 2795b9c547cSRui Paulo static void view_cb_title_changed(WebKitWebView *view, WebKitWebFrame *frame, 2805b9c547cSRui Paulo const char *title, 2815b9c547cSRui Paulo struct browser_context *ctx) 2825b9c547cSRui Paulo { 2835b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "BROWSER:%s title=%s", __func__, title); 2845b9c547cSRui Paulo os_free(ctx->title); 2855b9c547cSRui Paulo ctx->title = os_strdup(title); 2865b9c547cSRui Paulo browser_update_title(ctx); 2875b9c547cSRui Paulo } 2885b9c547cSRui Paulo 289c1d255d3SCy Schubert #endif /* USE_WEBKIT2 */ 2905b9c547cSRui Paulo 291c1d255d3SCy Schubert 292c1d255d3SCy Schubert int hs20_web_browser(const char *url, int ignore_tls) 2935b9c547cSRui Paulo { 2945b9c547cSRui Paulo GtkWidget *scroll; 2955b9c547cSRui Paulo WebKitWebView *view; 296c1d255d3SCy Schubert #ifdef USE_WEBKIT2 297c1d255d3SCy Schubert WebKitSettings *settings; 298c1d255d3SCy Schubert #else /* USE_WEBKIT2 */ 2995b9c547cSRui Paulo WebKitWebSettings *settings; 300c1d255d3SCy Schubert SoupSession *s; 301c1d255d3SCy Schubert #endif /* USE_WEBKIT2 */ 3025b9c547cSRui Paulo struct browser_context ctx; 3035b9c547cSRui Paulo 3045b9c547cSRui Paulo memset(&ctx, 0, sizeof(ctx)); 3055b9c547cSRui Paulo if (!gtk_init_check(NULL, NULL)) 3065b9c547cSRui Paulo return -1; 3075b9c547cSRui Paulo 308c1d255d3SCy Schubert #ifndef USE_WEBKIT2 3095b9c547cSRui Paulo s = webkit_get_default_session(); 3105b9c547cSRui Paulo g_object_set(G_OBJECT(s), "ssl-ca-file", 3115b9c547cSRui Paulo "/etc/ssl/certs/ca-certificates.crt", NULL); 312c1d255d3SCy Schubert if (ignore_tls) 3135b9c547cSRui Paulo g_object_set(G_OBJECT(s), "ssl-strict", FALSE, NULL); 314c1d255d3SCy Schubert #endif /* USE_WEBKIT2 */ 3155b9c547cSRui Paulo 3165b9c547cSRui Paulo ctx.win = gtk_window_new(GTK_WINDOW_TOPLEVEL); 3174bc52338SCy Schubert gtk_window_set_role(GTK_WINDOW(ctx.win), "Hotspot 2.0 client"); 3185b9c547cSRui Paulo gtk_window_set_default_size(GTK_WINDOW(ctx.win), 800, 600); 3195b9c547cSRui Paulo 3205b9c547cSRui Paulo scroll = gtk_scrolled_window_new(NULL, NULL); 3215b9c547cSRui Paulo gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), 3225b9c547cSRui Paulo GTK_POLICY_NEVER, GTK_POLICY_NEVER); 3235b9c547cSRui Paulo 3245b9c547cSRui Paulo g_signal_connect(G_OBJECT(ctx.win), "destroy", 3255b9c547cSRui Paulo G_CALLBACK(win_cb_destroy), &ctx); 3265b9c547cSRui Paulo 3275b9c547cSRui Paulo view = WEBKIT_WEB_VIEW(webkit_web_view_new()); 328c1d255d3SCy Schubert ctx.view = view; 329c1d255d3SCy Schubert #ifdef USE_WEBKIT2 330c1d255d3SCy Schubert g_signal_connect(G_OBJECT(view), "notify::estimated-load-progress", 331c1d255d3SCy Schubert G_CALLBACK(view_cb_notify_estimated_load_progress), 332c1d255d3SCy Schubert &ctx); 333c1d255d3SCy Schubert g_signal_connect(G_OBJECT(view), "resource-load-started", 334c1d255d3SCy Schubert G_CALLBACK(view_cb_resource_load_starting), &ctx); 335c1d255d3SCy Schubert g_signal_connect(G_OBJECT(view), "decide-policy", 336c1d255d3SCy Schubert G_CALLBACK(view_cb_decide_policy), &ctx); 337c1d255d3SCy Schubert g_signal_connect(G_OBJECT(view), "mouse-target-changed", 338c1d255d3SCy Schubert G_CALLBACK(view_cb_mouse_target_changed), &ctx); 339c1d255d3SCy Schubert g_signal_connect(G_OBJECT(view), "notify::title", 340c1d255d3SCy Schubert G_CALLBACK(view_cb_notify_title), &ctx); 341c1d255d3SCy Schubert #else /* USE_WEBKIT2 */ 3425b9c547cSRui Paulo g_signal_connect(G_OBJECT(view), "notify::load-status", 3435b9c547cSRui Paulo G_CALLBACK(view_cb_notify_load_status), &ctx); 344c1d255d3SCy Schubert g_signal_connect(G_OBJECT(view), "notify::progress", 345c1d255d3SCy Schubert G_CALLBACK(view_cb_notify_progress), &ctx); 3465b9c547cSRui Paulo g_signal_connect(G_OBJECT(view), "resource-request-starting", 3475b9c547cSRui Paulo G_CALLBACK(view_cb_resource_request_starting), &ctx); 3485b9c547cSRui Paulo g_signal_connect(G_OBJECT(view), "mime-type-policy-decision-requested", 3495b9c547cSRui Paulo G_CALLBACK(view_cb_mime_type_policy_decision), &ctx); 3505b9c547cSRui Paulo g_signal_connect(G_OBJECT(view), "download-requested", 3515b9c547cSRui Paulo G_CALLBACK(view_cb_download_requested), &ctx); 3525b9c547cSRui Paulo g_signal_connect(G_OBJECT(view), "hovering-over-link", 3535b9c547cSRui Paulo G_CALLBACK(view_cb_hovering_over_link), &ctx); 3545b9c547cSRui Paulo g_signal_connect(G_OBJECT(view), "title-changed", 3555b9c547cSRui Paulo G_CALLBACK(view_cb_title_changed), &ctx); 356c1d255d3SCy Schubert #endif /* USE_WEBKIT2 */ 3575b9c547cSRui Paulo 3585b9c547cSRui Paulo gtk_container_add(GTK_CONTAINER(scroll), GTK_WIDGET(view)); 3595b9c547cSRui Paulo gtk_container_add(GTK_CONTAINER(ctx.win), GTK_WIDGET(scroll)); 3605b9c547cSRui Paulo 3615b9c547cSRui Paulo gtk_widget_grab_focus(GTK_WIDGET(view)); 3625b9c547cSRui Paulo gtk_widget_show_all(ctx.win); 3635b9c547cSRui Paulo 3645b9c547cSRui Paulo settings = webkit_web_view_get_settings(view); 3655b9c547cSRui Paulo g_object_set(G_OBJECT(settings), "user-agent", 3665b9c547cSRui Paulo "Mozilla/5.0 (X11; U; Unix; en-US) " 3675b9c547cSRui Paulo "AppleWebKit/537.15 (KHTML, like Gecko) " 3685b9c547cSRui Paulo "hs20-client/1.0", NULL); 3695b9c547cSRui Paulo g_object_set(G_OBJECT(settings), "auto-load-images", TRUE, NULL); 3705b9c547cSRui Paulo 371c1d255d3SCy Schubert #ifdef USE_WEBKIT2 372c1d255d3SCy Schubert if (ignore_tls) { 373*a90b9d01SCy Schubert #if WEBKIT_CHECK_VERSION(2, 32, 0) 374*a90b9d01SCy Schubert WebKitWebContext *wkctx; 375*a90b9d01SCy Schubert WebKitWebsiteDataManager *wkmgr; 376*a90b9d01SCy Schubert 377*a90b9d01SCy Schubert wkctx = webkit_web_context_get_default(); 378*a90b9d01SCy Schubert wkmgr = webkit_web_context_get_website_data_manager(wkctx); 379*a90b9d01SCy Schubert webkit_website_data_manager_set_tls_errors_policy( 380*a90b9d01SCy Schubert wkmgr, WEBKIT_TLS_ERRORS_POLICY_IGNORE); 381*a90b9d01SCy Schubert #else 382c1d255d3SCy Schubert WebKitWebContext *wkctx; 383c1d255d3SCy Schubert 384c1d255d3SCy Schubert wkctx = webkit_web_context_get_default(); 385c1d255d3SCy Schubert webkit_web_context_set_tls_errors_policy( 386c1d255d3SCy Schubert wkctx, WEBKIT_TLS_ERRORS_POLICY_IGNORE); 387*a90b9d01SCy Schubert #endif 388c1d255d3SCy Schubert } 389c1d255d3SCy Schubert #endif /* USE_WEBKIT2 */ 390c1d255d3SCy Schubert 3915b9c547cSRui Paulo webkit_web_view_load_uri(view, url); 3925b9c547cSRui Paulo 393c1d255d3SCy Schubert ctx.gtk_main_started = 1; 3945b9c547cSRui Paulo gtk_main(); 3955b9c547cSRui Paulo gtk_widget_destroy(ctx.win); 3965b9c547cSRui Paulo while (gtk_events_pending()) 3975b9c547cSRui Paulo gtk_main_iteration(); 3985b9c547cSRui Paulo 3995b9c547cSRui Paulo free(ctx.hover_link); 4005b9c547cSRui Paulo free(ctx.title); 4015b9c547cSRui Paulo return ctx.success; 4025b9c547cSRui Paulo } 403