aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-12-12 17:58:06 +0800
committerXan Lopez <xan@igalia.com>2012-12-12 19:22:39 +0800
commit5660617413c37eb397a50361b6ca5bdd250b5be5 (patch)
treed03508164c93e4e212587f33bf0a6dc1af703a4c /lib
parent8b97d6e32fbe2e56a7012d731b5e864a86720504 (diff)
downloadgsoc2013-epiphany-5660617413c37eb397a50361b6ca5bdd250b5be5.tar
gsoc2013-epiphany-5660617413c37eb397a50361b6ca5bdd250b5be5.tar.gz
gsoc2013-epiphany-5660617413c37eb397a50361b6ca5bdd250b5be5.tar.bz2
gsoc2013-epiphany-5660617413c37eb397a50361b6ca5bdd250b5be5.tar.lz
gsoc2013-epiphany-5660617413c37eb397a50361b6ca5bdd250b5be5.tar.xz
gsoc2013-epiphany-5660617413c37eb397a50361b6ca5bdd250b5be5.tar.zst
gsoc2013-epiphany-5660617413c37eb397a50361b6ca5bdd250b5be5.zip
First iteration for 'Incognito mode'
For now this is just a private mode but with the following two twists: - We use the dark theme. - We steal our history and bookmarks from the main profile. This is done in 'read-only' mode though, so any changes made in this session will be lost. Add command line options and a UI item to launch the browser in this mode. https://bugzilla.gnome.org/show_bug.cgi?id=676914
Diffstat (limited to 'lib')
-rw-r--r--lib/ephy-file-helpers.c49
-rw-r--r--lib/ephy-file-helpers.h1
2 files changed, 46 insertions, 4 deletions
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 92adcce1b..898e218bd 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -3,6 +3,7 @@
* Copyright © 2002 Jorn Baayen
* Copyright © 2003, 2004 Marco Pesenti Gritti
* Copyright © 2004, 2005, 2006 Christian Persch
+ * Copyright © 2012 Igalia S.L.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -303,7 +304,9 @@ ephy_file_helpers_init (const char *profile_dir,
EphyFileHelpersFlags flags,
GError **error)
{
+ gboolean ret = TRUE;
gboolean private_profile;
+ gboolean steal_data_from_profile;
ephy_file_helpers_error_quark = g_quark_from_static_string ("ephy-file-helpers-error");
@@ -314,8 +317,9 @@ ephy_file_helpers_init (const char *profile_dir,
keep_directory = flags & EPHY_FILE_HELPERS_KEEP_DIR;
private_profile = flags & EPHY_FILE_HELPERS_PRIVATE_PROFILE;
+ steal_data_from_profile = flags & EPHY_FILE_HELPERS_STEAL_DATA;
- if (private_profile && profile_dir != NULL)
+ if (private_profile && profile_dir != NULL && !steal_data_from_profile)
{
dot_dir = g_strdup (profile_dir);
}
@@ -344,9 +348,46 @@ ephy_file_helpers_init (const char *profile_dir,
}
if (flags & EPHY_FILE_HELPERS_ENSURE_EXISTS)
- return ephy_ensure_dir_exists (ephy_dot_dir (), error);
- else
- return TRUE;
+ ret = ephy_ensure_dir_exists (ephy_dot_dir (), error);
+
+ if (steal_data_from_profile && profile_dir)
+ {
+ int i;
+ char *files_to_copy[] = { "ephy-history.db", "ephy-bookmarks.xml" };
+
+ for (i = 0; i < G_N_ELEMENTS (files_to_copy); i++)
+ {
+ char *filename;
+ GError *error = NULL;
+ GFile *source, *destination;
+
+ filename = g_build_filename (profile_dir,
+ files_to_copy[i],
+ NULL);
+ source = g_file_new_for_path (filename);
+ g_free (filename);
+
+ filename = g_build_filename (dot_dir,
+ files_to_copy[i],
+ NULL);
+ destination = g_file_new_for_path (filename);
+ g_free (filename);
+
+ g_file_copy (source, destination,
+ G_FILE_COPY_OVERWRITE,
+ NULL, NULL, NULL, &error);
+ if (error)
+ {
+ printf("Error stealing file %s from profile: %s\n", files_to_copy[i], error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref (source);
+ g_object_unref (destination);
+ }
+ }
+
+ return ret;
}
static void
diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h
index 8ed792fee..5eed9edf7 100644
--- a/lib/ephy-file-helpers.h
+++ b/lib/ephy-file-helpers.h
@@ -48,6 +48,7 @@ typedef enum
EPHY_FILE_HELPERS_KEEP_DIR = 1 << 1,
EPHY_FILE_HELPERS_PRIVATE_PROFILE = 1 << 2,
EPHY_FILE_HELPERS_ENSURE_EXISTS = 1 << 3,
+ EPHY_FILE_HELPERS_STEAL_DATA = 1 << 4
} EphyFileHelpersFlags;
gboolean ephy_file_helpers_init (const char *profile_dir,