aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data/org.gnome.epiphany.gschema.xml5
-rw-r--r--lib/ephy-prefs.h1
-rw-r--r--src/ephy-session.c21
-rw-r--r--tests/ephy-session-test.c43
4 files changed, 64 insertions, 6 deletions
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index becb0a23d..b815635cc 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -54,6 +54,11 @@
<summary>Whether to automatically restore the last session</summary>
<description>Defines how the session will be restored during startup. Allowed values are 'always' (the previous state of the application is always restored), 'crashed' (the session is only restored if the application crashes) and 'never' (the homepage is always shown).</description>
</key>
+ <key type="b" name="restore-session-delaying-loads">
+ <default>true</default>
+ <summary>Whether to delay loading of tabs that are not immediately visible on session restore</summary>
+ <description>When this option is set to true, tabs will not start loading until the user switches to them, upon session restore.</description>
+ </key>
</schema>
<schema path="/org/gnome/epiphany/ui/" id="org.gnome.Epiphany.ui">
<key type="b" name="show-toolbars">
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index c390e37a1..7fe2aeebd 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -123,6 +123,7 @@ typedef enum
#define EPHY_PREFS_ENABLE_CARET_BROWSING "enable-caret-browsing"
#define EPHY_PREFS_INTERNAL_VIEW_SOURCE "internal-view-source"
#define EPHY_PREFS_RESTORE_SESSION_POLICY "restore-session-policy"
+#define EPHY_PREFS_RESTORE_SESSION_DELAYING_LOADS "restore-session-delaying-loads"
#define EPHY_PREFS_LOCKDOWN_SCHEMA "org.gnome.Epiphany.lockdown"
#define EPHY_PREFS_LOCKDOWN_FULLSCREEN "disable-fullscreen"
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 82ecf4149..1099cddbb 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -1105,16 +1105,31 @@ session_parse_embed (SessionParserContext *context,
EphyNewTabFlags flags;
EphyEmbed *embed;
EphyWebView *web_view;
+ gboolean delay_loading;
+
+ delay_loading = g_settings_get_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_RESTORE_SESSION_DELAYING_LOADS);
flags = EPHY_NEW_TAB_IN_EXISTING_WINDOW;
flags |= EPHY_NEW_TAB_APPEND_LAST;
- flags |= EPHY_NEW_TAB_DELAYED_OPEN_PAGE;
+
+ if (delay_loading)
+ {
+ flags |= EPHY_NEW_TAB_DELAYED_OPEN_PAGE;
+ }
+ else
+ {
+ flags |= EPHY_NEW_TAB_OPEN_PAGE;
+ }
embed = ephy_shell_new_tab (ephy_shell_get_default (),
context->window, NULL, url, flags);
- web_view = ephy_embed_get_web_view (embed);
- ephy_web_view_set_placeholder (web_view, url, title);
+ if (delay_loading)
+ {
+ web_view = ephy_embed_get_web_view (embed);
+ ephy_web_view_set_placeholder (web_view, url, title);
+ }
}
else if (was_loading && url != NULL)
{
diff --git a/tests/ephy-session-test.c b/tests/ephy-session-test.c
index 01d10aa62..eda9ab497 100644
--- a/tests/ephy-session-test.c
+++ b/tests/ephy-session-test.c
@@ -25,6 +25,7 @@
#include "ephy-embed-private.h"
#include "ephy-file-helpers.h"
#include "ephy-private.h"
+#include "ephy-settings.h"
#include "ephy-shell.h"
#include "ephy-session.h"
@@ -72,6 +73,22 @@ load_session_from_string (EphySession *session,
}
static void
+enable_delayed_loading (void)
+{
+ g_settings_set_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_RESTORE_SESSION_DELAYING_LOADS,
+ TRUE);
+}
+
+static void
+disable_delayed_loading (void)
+{
+ g_settings_set_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_RESTORE_SESSION_DELAYING_LOADS,
+ FALSE);
+}
+
+static void
test_ephy_session_load (void)
{
EphySession *session;
@@ -80,6 +97,8 @@ test_ephy_session_load (void)
EphyEmbed *embed;
EphyWebView *view;
+ disable_delayed_loading ();
+
session = ephy_shell_get_session (ephy_shell_get_default ());
g_assert (session);
@@ -94,9 +113,11 @@ test_ephy_session_load (void)
g_assert (embed);
view = ephy_embed_get_web_view (embed);
g_assert (view);
- g_assert_cmpstr (ephy_web_view_get_address (view), ==, "about:memory");
+ g_assert_cmpstr (ephy_web_view_get_address (view), ==, "ephy-about:memory");
ephy_session_clear (session);
+
+ enable_delayed_loading ();
}
const char *session_data_many_windows =
@@ -116,6 +137,8 @@ test_ephy_session_clear (void)
EphySession *session;
GList *l;
+ disable_delayed_loading ();
+
session = EPHY_SESSION (ephy_shell_get_session (ephy_shell_get_default ()));
load_session_from_string (session, session_data_many_windows);
@@ -140,6 +163,8 @@ test_ephy_session_load_empty_session (void)
EphyEmbed *embed;
EphyWebView *view;
+ disable_delayed_loading ();
+
session = ephy_shell_get_session (ephy_shell_get_default ());
g_assert (session);
@@ -163,6 +188,7 @@ test_ephy_session_load_empty_session (void)
g_assert (view);
g_assert_cmpstr (ephy_web_view_get_address (view), ==, "ephy-about:overview");
+ enable_delayed_loading ();
ephy_session_clear (session);
}
@@ -175,6 +201,8 @@ test_ephy_session_load_many_windows (void)
EphyEmbed *embed;
EphyWebView *view;
+ disable_delayed_loading ();
+
session = ephy_shell_get_session (ephy_shell_get_default ());
g_assert (session);
@@ -190,9 +218,10 @@ test_ephy_session_load_many_windows (void)
g_assert (embed);
view = ephy_embed_get_web_view (embed);
g_assert (view);
- g_assert_cmpstr (ephy_web_view_get_address (view), ==, "about:epiphany");
+ g_assert_cmpstr (ephy_web_view_get_address (view), ==, "ephy-about:epiphany");
}
+ enable_delayed_loading ();
ephy_session_clear (session);
}
@@ -206,6 +235,8 @@ open_uris_after_loading_session (const char** uris, int final_num_windows)
EphyWebView *view;
guint32 user_time;
+ disable_delayed_loading ();
+
session = ephy_shell_get_session (ephy_shell_get_default ());
g_assert (session);
@@ -224,7 +255,7 @@ open_uris_after_loading_session (const char** uris, int final_num_windows)
g_assert (embed);
view = ephy_embed_get_web_view (embed);
g_assert (view);
- g_assert_cmpstr (ephy_web_view_get_address (view), ==, "about:epiphany");
+ g_assert_cmpstr (ephy_web_view_get_address (view), ==, "ephy-about:epiphany");
}
/* Causing a session load here should not create new windows, since we
@@ -258,6 +289,7 @@ open_uris_after_loading_session (const char** uris, int final_num_windows)
g_assert (l);
g_assert_cmpint (g_list_length (l), ==, final_num_windows);
+ enable_delayed_loading ();
ephy_session_clear (session);
}
@@ -289,6 +321,8 @@ test_ephy_session_restore_tabs (void)
int n_windows;
EphyEmbed *embed;
+ disable_delayed_loading ();
+
/* Nothing to restore. */
g_assert (ephy_session_get_can_undo_tab_closed (session) == FALSE);
@@ -340,6 +374,7 @@ test_ephy_session_restore_tabs (void)
/* We have the same amount of windows than before destroying one. */
g_assert_cmpint (n_windows, ==, g_list_length (gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default()))));
+ enable_delayed_loading ();
ephy_session_clear (session);
}
@@ -348,6 +383,8 @@ main (int argc, char *argv[])
{
int ret;
+ setenv ("GSETTINGS_BACKEND", "memory", TRUE);
+
gtk_test_init (&argc, &argv);
ephy_debug_init ();