diff --git a/core/cog-webkit-utils.c b/core/cog-webkit-utils.c index 8b7137d8..b24794f1 100644 --- a/core/cog-webkit-utils.c +++ b/core/cog-webkit-utils.c @@ -9,32 +9,37 @@ #include #include -static const char error_message_template[] = - "%s\n" - "

%s

\n" - "

%s

\n" - "

%s

\n" - "" - ""; +static bool autoRetry = false; + +static const char error_message_template[] = "%s\n" + "\n" + "

%s

\n" + "

%s

\n" + "

%s

\n" + "" + ""; + +void +cog_set_auto_retry_on_failure(bool value) { + autoRetry = value; +} gboolean -load_error_page (WebKitWebView *web_view, - const char *failing_uri, - const char *title, - const char *message) +load_error_page(WebKitWebView *web_view, const char *failing_uri, const char *title, const char *message) { g_warning ("<%s> %s: %s", failing_uri, title, message); - - g_autofree char *html = g_strdup_printf(error_message_template, title, title, failing_uri, message, failing_uri); + + g_autofree char *html = g_strdup_printf(error_message_template, title, autoRetry ? "true" : "false", failing_uri, title, failing_uri, message); webkit_web_view_load_alternate_html (web_view, html, failing_uri, diff --git a/core/cog-webkit-utils.h b/core/cog-webkit-utils.h index 825eed6e..2968733b 100644 --- a/core/cog-webkit-utils.h +++ b/core/cog-webkit-utils.h @@ -19,6 +19,8 @@ G_BEGIN_DECLS +void cog_set_auto_retry_on_failure(bool value); + gboolean cog_handle_web_view_load_failed (WebKitWebView *web_view, WebKitLoadEvent load_event, char *failing_uri, diff --git a/launcher/cog-launcher.c b/launcher/cog-launcher.c index 8e4499b7..d44ec45f 100644 --- a/launcher/cog-launcher.c +++ b/launcher/cog-launcher.c @@ -53,6 +53,7 @@ static struct { gboolean ignore_tls_errors; gboolean enable_sandbox; gboolean automation; + gboolean auto_retry_on_failure; } s_options = { .scale_factor = 1.0, .device_scale_factor = 1.0, @@ -324,6 +325,7 @@ cog_launcher_create_view(CogLauncher *self, CogShell *shell) cog_web_view_connect_default_progress_handlers(web_view); cog_web_view_connect_default_error_handlers(web_view); + cog_set_auto_retry_on_failure(s_options.auto_retry_on_failure); webkit_web_view_load_uri(web_view, s_options.home_uri); g_clear_pointer(&s_options.home_uri, g_free); @@ -1014,7 +1016,9 @@ static GOptionEntry s_cli_options[] = { {"automation", '\0', 0, G_OPTION_ARG_NONE, &s_options.automation, "Enable automation mode (default: disabled).", NULL}, {G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &s_options.arguments, "", "[URL]"}, - {NULL}}; + {NULL}, + {"auto-retry-on-failure", '\0', 0, G_OPTION_ARG_NONE, &s_options.auto_retry_on_failure, + "Automatically retry page load on failure with 5 second interval.", NULL}}; static void cog_launcher_constructed(GObject *object)