summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Michael Brummer <jan.brummer@tabos.org>2021-08-11 21:13:22 +0200
committerJan-Michael Brummer <jan.brummer@tabos.org>2021-08-14 08:21:15 +0200
commit7bc7fc3ecf366fff3b795c5d88f53b44ed236da6 (patch)
treef8ee859accf31e1228ebdf9194e4c56bdc8df87b
parent5031aa63cf26b763ae0b75b3636c5b926211a14a (diff)
downloadepiphany-7bc7fc3ecf366fff3b795c5d88f53b44ed236da6.tar.gz
Ask user whether an unresponsive page should be killed
Fixes: https://gitlab.gnome.org/GNOME/epiphany/-/issues/1561 Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1003>
-rw-r--r--embed/ephy-web-view.c53
1 files changed, 48 insertions, 5 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 8e3b52b47..031316a6f 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -128,6 +128,7 @@ struct _EphyWebView {
EphyWebViewErrorPage error_page;
guint unresponsive_process_timeout_id;
+ GtkWidget *unresponsive_process_dialog;
guint64 uid;
};
@@ -845,11 +846,43 @@ process_terminated_cb (EphyWebView *web_view,
}
static gboolean
+unresponsive_process_timeout_cb (gpointer user_data);
+
+static void
+on_unresponsive_dialog_response (GtkDialog *dialog,
+ int response_id,
+ gpointer user_data)
+{
+ EphyWebView *web_view = EPHY_WEB_VIEW (user_data);
+
+ if (response_id == GTK_RESPONSE_YES)
+ webkit_web_view_terminate_web_process (WEBKIT_WEB_VIEW (web_view));
+ else
+ web_view->unresponsive_process_timeout_id = g_timeout_add_seconds_full (G_PRIORITY_HIGH,
+ 5,
+ (GSourceFunc)unresponsive_process_timeout_cb,
+ web_view,
+ NULL);
+ g_clear_pointer (&web_view->unresponsive_process_dialog, gtk_widget_destroy);
+}
+
+static gboolean
unresponsive_process_timeout_cb (gpointer user_data)
{
EphyWebView *web_view = EPHY_WEB_VIEW (user_data);
- webkit_web_view_terminate_web_process (WEBKIT_WEB_VIEW (web_view));
+ web_view->unresponsive_process_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (web_view))),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("The current page '%s' is unresponsive"),
+ ephy_web_view_get_address (web_view));
+
+ gtk_dialog_add_button (GTK_DIALOG (web_view->unresponsive_process_dialog), _("_Wait"), GTK_RESPONSE_NO);
+ gtk_dialog_add_button (GTK_DIALOG (web_view->unresponsive_process_dialog), _("_Kill"), GTK_RESPONSE_YES);
+
+ g_signal_connect (web_view->unresponsive_process_dialog, "response", G_CALLBACK (on_unresponsive_dialog_response), web_view);
+ gtk_widget_show_all (web_view->unresponsive_process_dialog);
web_view->unresponsive_process_timeout_id = 0;
@@ -861,12 +894,21 @@ is_web_process_responsive_changed_cb (EphyWebView *web_view,
GParamSpec *pspec,
gpointer user_data)
{
+ gboolean responsive = webkit_web_view_get_is_web_process_responsive (WEBKIT_WEB_VIEW (web_view));
+
g_clear_handle_id (&web_view->unresponsive_process_timeout_id, g_source_remove);
- if (!webkit_web_view_get_is_web_process_responsive (WEBKIT_WEB_VIEW (web_view))) {
- web_view->unresponsive_process_timeout_id = g_timeout_add_seconds (10,
- (GSourceFunc)unresponsive_process_timeout_cb,
- web_view);
+ if (web_view->unresponsive_process_dialog && responsive) {
+ g_signal_handlers_disconnect_by_func (web_view->unresponsive_process_dialog, on_unresponsive_dialog_response, web_view);
+ g_clear_pointer (&web_view->unresponsive_process_dialog, gtk_widget_destroy);
+ }
+
+ if (!responsive) {
+ web_view->unresponsive_process_timeout_id = g_timeout_add_seconds_full (G_PRIORITY_HIGH,
+ 10,
+ (GSourceFunc)unresponsive_process_timeout_cb,
+ web_view,
+ NULL);
}
}
@@ -3848,6 +3890,7 @@ ephy_web_view_dispose (GObject *object)
g_clear_object (&view->certificate);
g_clear_object (&view->file_monitor);
g_clear_object (&view->icon);
+ g_clear_pointer (&view->unresponsive_process_dialog, gtk_widget_destroy);
if (view->cancellable) {
g_cancellable_cancel (view->cancellable);