static void changed_load_progress(GObject *, GParamSpec *, gpointer);
static void changed_title(GObject *, GParamSpec *, gpointer);
static void changed_uri(GObject *, GParamSpec *, gpointer);
+static gboolean crashed_web_view(WebKitWebView *, gpointer);
+static gboolean crashed_web_view_reload(gpointer);
static gboolean decide_policy(WebKitWebView *, WebKitPolicyDecision *,
WebKitPolicyDecisionType, gpointer);
static gboolean download_handle(WebKitDownload *, gchar *, gpointer);
static gboolean remote_msg(GIOChannel *, GIOCondition, gpointer);
static void search(gpointer, gint);
static Window tabbed_launch(void);
+static void trust_user_certs(WebKitWebContext *);
static void usage(void);
static gboolean cooperative_alone = TRUE;
static gboolean cooperative_instances = TRUE;
static int cooperative_pipe_fp = 0;
+static int crash_autoreload_delay = 2;
static gchar *download_dir = "/tmp";
static Window embed = 0;
static gchar *fifo_suffix = "main";
G_CALLBACK(key_web_view), c);
g_signal_connect(G_OBJECT(c->web_view), "mouse-target-changed",
G_CALLBACK(hover_web_view), c);
+ g_signal_connect(G_OBJECT(c->web_view), "web-process-crashed",
+ G_CALLBACK(crashed_web_view), c);
if (!initial_wc_setup_done)
{
g_signal_connect(G_OBJECT(wc), "download-started",
G_CALLBACK(download_handle_start), NULL);
+ trust_user_certs(wc);
+
initial_wc_setup_done = TRUE;
}
gtk_entry_set_text(GTK_ENTRY(c->location), (t == NULL ? __NAME__ : t));
}
+gboolean
+crashed_web_view(WebKitWebView *web_view, gpointer data)
+{
+ fprintf(stderr, __NAME__": WebView crashed!\n");
+ if (crash_autoreload_delay >= 1)
+ {
+ fprintf(stderr, __NAME__": Reloading WebView in %d seconds.\n",
+ crash_autoreload_delay);
+ g_timeout_add_seconds(crash_autoreload_delay, crashed_web_view_reload,
+ web_view);
+ }
+
+ return TRUE;
+}
+
+gboolean
+crashed_web_view_reload(gpointer data)
+{
+ webkit_web_view_reload_bypass_cache(WEBKIT_WEB_VIEW(data));
+
+ return G_SOURCE_REMOVE;
+}
+
gboolean
decide_policy(WebKitWebView *web_view, WebKitPolicyDecision *decision,
WebKitPolicyDecisionType type, gpointer data)
if (e != NULL)
accepted_language[0] = g_strdup(e);
+ e = g_getenv(__NAME_UPPERCASE__"_CRASH_AUTORELOAD_DELAY");
+ if (e != NULL)
+ crash_autoreload_delay = atoi(e);
+
e = g_getenv(__NAME_UPPERCASE__"_DOWNLOAD_DIR");
if (e != NULL)
download_dir = g_strdup(e);
struct Client *c = (struct Client *)data;
const gchar *t;
gchar *f;
+ WebKitWebContext *wc = webkit_web_view_get_context(WEBKIT_WEB_VIEW(c->web_view));
if (event->type == GDK_KEY_PRESS)
{
gtk_entry_set_text(GTK_ENTRY(c->location), "/");
gtk_editable_set_position(GTK_EDITABLE(c->location), -1);
return TRUE;
+ case GDK_KEY_c: /* reload trusted certs (left hand) */
+ trust_user_certs(wc);
+ return TRUE;
}
}
else
gdouble dx, dy;
gchar *f;
gfloat z;
+ WebKitWebContext *wc = webkit_web_view_get_context(WEBKIT_WEB_VIEW(c->web_view));
if (event->type == GDK_KEY_PRESS)
{
gtk_entry_set_text(GTK_ENTRY(c->location), "/");
gtk_editable_set_position(GTK_EDITABLE(c->location), -1);
return TRUE;
+ case GDK_KEY_c: /* reload trusted certs (left hand) */
+ trust_user_certs(wc);
+ return TRUE;
}
}
else if (((GdkEventKey *)event)->keyval == GDK_KEY_Escape)
return plug_into;
}
+void
+trust_user_certs(WebKitWebContext *wc)
+{
+ GTlsCertificate *cert;
+ const gchar *basedir, *file, *absfile;
+ GDir *dir;
+
+ basedir = g_build_filename(g_get_user_config_dir(), __NAME__, "certs", NULL);
+ dir = g_dir_open(basedir, 0, NULL);
+ if (dir != NULL)
+ {
+ file = g_dir_read_name(dir);
+ while (file != NULL)
+ {
+ absfile = g_build_filename(g_get_user_config_dir(), __NAME__, "certs",
+ file, NULL);
+ cert = g_tls_certificate_new_from_file(absfile, NULL);
+ if (cert == NULL)
+ fprintf(stderr, __NAME__": Could not load trusted cert '%s'\n", file);
+ else
+ webkit_web_context_allow_tls_certificate_for_host(wc, cert, file);
+ file = g_dir_read_name(dir);
+ }
+ g_dir_close(dir);
+ }
+}
+
void
usage(void)
{