diff options
author | Xan Lopez <xan@igalia.com> | 2012-12-12 17:58:06 +0800 |
---|---|---|
committer | Xan Lopez <xan@igalia.com> | 2012-12-12 19:22:39 +0800 |
commit | 5660617413c37eb397a50361b6ca5bdd250b5be5 (patch) | |
tree | d03508164c93e4e212587f33bf0a6dc1af703a4c /src | |
parent | 8b97d6e32fbe2e56a7012d731b5e864a86720504 (diff) | |
download | gsoc2013-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 'src')
-rw-r--r-- | src/ephy-main.c | 33 | ||||
-rw-r--r-- | src/ephy-shell.c | 9 | ||||
-rw-r--r-- | src/ephy-window.c | 3 | ||||
-rw-r--r-- | src/resources/epiphany-application-menu.ui | 5 | ||||
-rw-r--r-- | src/resources/epiphany-ui.xml | 1 | ||||
-rw-r--r-- | src/window-commands.c | 9 | ||||
-rw-r--r-- | src/window-commands.h | 166 |
7 files changed, 138 insertions, 88 deletions
diff --git a/src/ephy-main.c b/src/ephy-main.c index 10450d7ff..04c82b6aa 100644 --- a/src/ephy-main.c +++ b/src/ephy-main.c @@ -56,6 +56,7 @@ static char *application_to_delete = NULL; /* Only set from options in debug builds */ static gboolean private_instance = FALSE; +static gboolean incognito_mode = FALSE; static gboolean application_mode = FALSE; static gboolean keep_temp_directory = FALSE; static char *profile_directory = NULL; @@ -86,6 +87,10 @@ static const GOptionEntry option_entries[] = N_("Add a bookmark"), N_("URL") }, { "private-instance", 'p', 0, G_OPTION_ARG_NONE, &private_instance, N_("Start a private instance"), NULL }, + { "incognito-mode", 'i', 0, G_OPTION_ARG_NONE, &incognito_mode, + N_("Start an instance in incognito mode"), NULL }, + { "netbank-mode", 0, 0, G_OPTION_ARG_NONE, &incognito_mode, + N_("Start an instance in netbank mode"), NULL }, { "application-mode", 'a', 0, G_OPTION_ARG_NONE, &application_mode, N_("Start the browser in application mode"), NULL }, { "profile", 0, 0, G_OPTION_ARG_STRING, &profile_directory, @@ -353,8 +358,8 @@ main (int argc, exit (1); } - if (profile_directory != NULL && private_instance == FALSE && application_mode == FALSE) { - g_print ("--profile can only be used in combination with --private-instance or --application-mode\n"); + if (profile_directory != NULL && private_instance == FALSE && application_mode == FALSE && incognito_mode == FALSE) { + g_print ("--profile can only be used in combination with --private-instance, --incognito-mode or --application-mode\n"); exit (1); } @@ -368,12 +373,18 @@ main (int argc, exit (1); } + if (incognito_mode && profile_directory == NULL) { + g_print ("--incognito-mode needs a --profile parameter to steal the data from\n"); + exit (1); + } + /* Work-around Flash Player crash */ g_setenv ("XLIB_SKIP_ARGB_VISUALS", "1", FALSE); /* Run the migration in all cases, except when running a private - instance without a given profile directory. */ - if (!(private_instance && profile_directory == FALSE)) { + instance without a given profile directory or running in + incognito mode. */ + if (!(private_instance && profile_directory == NULL) && incognito_mode == FALSE) { /* If the migration fails we don't really want to continue. */ if (!ephy_profile_utils_do_migration ((const char *)profile_directory, -1, FALSE)) { g_print ("Failed to run the migrator process, Web will now abort."); @@ -384,8 +395,10 @@ main (int argc, /* Start our services */ flags = EPHY_FILE_HELPERS_ENSURE_EXISTS; - if (private_instance || application_mode) + if (incognito_mode || private_instance || application_mode) flags |= EPHY_FILE_HELPERS_PRIVATE_PROFILE; + if (incognito_mode) + flags |= EPHY_FILE_HELPERS_STEAL_DATA; if (keep_temp_directory || profile_directory) flags |= EPHY_FILE_HELPERS_KEEP_DIR; @@ -433,7 +446,15 @@ main (int argc, /* Now create the shell */ if (private_instance) mode = EPHY_EMBED_SHELL_MODE_PRIVATE; - else if (application_mode) { + else if (incognito_mode) { + /* Internally incognito mode is also a private mode. */ + mode = EPHY_EMBED_SHELL_MODE_PRIVATE; + + /* Use the right theming. */ + g_object_set (gtk_settings_get_default (), + "gtk-application-prefer-dark-theme", TRUE, + NULL); + } else if (application_mode) { char *app_name; char *app_icon; diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 3c4cbfc1b..813eea396 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -165,6 +165,14 @@ new_window (GSimpleAction *action, } static void +new_incognito_window (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + window_cmd_file_new_incognito_window (NULL, NULL); +} + +static void show_bookmarks (GSimpleAction *action, GVariant *parameter, gpointer user_data) @@ -218,6 +226,7 @@ quit_application (GSimpleAction *action, static GActionEntry app_entries[] = { { "new", new_window, NULL, NULL, NULL }, + { "incognito", new_incognito_window, NULL, NULL, NULL }, { "bookmarks", show_bookmarks, NULL, NULL, NULL }, { "history", show_history, NULL, NULL, NULL }, { "preferences", show_preferences, NULL, NULL, NULL }, diff --git a/src/ephy-window.c b/src/ephy-window.c index 6858b47f8..dbabe40c6 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -103,6 +103,8 @@ static const GtkActionEntry ephy_menu_entries [] = { { "FileNewWindow", NULL, N_("_New Window"), "<control>N", NULL, G_CALLBACK (window_cmd_file_new_window) }, + { "FileNewWindowIncognito", NULL, N_("New _Incognito Window"), "<control><shift>N", NULL, + G_CALLBACK (window_cmd_file_new_incognito_window) }, { "FileOpen", NULL, N_("_Open…"), "<control>O", NULL, G_CALLBACK (window_cmd_file_open) }, { "FileSaveAs", NULL, N_("Save _As…"), "<shift><control>S", NULL, @@ -3777,6 +3779,7 @@ _gtk_css_provider_load_from_resource (GtkCssProvider* provider, static const gchar* app_actions[] = { "FileNewWindow", + "FileNewWindowIncognito", "EditPreferences", "EditPersonalData", "EditBookmarks", diff --git a/src/resources/epiphany-application-menu.ui b/src/resources/epiphany-application-menu.ui index ab0202b30..36fa068a4 100644 --- a/src/resources/epiphany-application-menu.ui +++ b/src/resources/epiphany-application-menu.ui @@ -4,6 +4,11 @@ <section> <item> <attribute name="label" translatable="yes">_New Window</attribute> + <attribute name="action">app.new-incognito</attribute> + <attribute name="accel"><Primary>i</attribute> + </item> + <item> + <attribute name="label" translatable="yes">New _Incognito Window</attribute> <attribute name="action">app.new</attribute> <attribute name="accel"><Primary>n</attribute> </item> diff --git a/src/resources/epiphany-ui.xml b/src/resources/epiphany-ui.xml index 493cff2a7..4afa856fe 100644 --- a/src/resources/epiphany-ui.xml +++ b/src/resources/epiphany-ui.xml @@ -69,6 +69,7 @@ <popup name="PagePopup" action="PagePopupAction" accelerators="true"> <menuitem name="FileNewWindowMenu" action="FileNewWindow"/> + <menuitem name="FileNewWindowIncognitoMenu" action="FileNewWindowIncognito"/> <menuitem name="FileNewTabMenu" action="FileNewTab"/> <menuitem name="FileOpenMenu" action="FileOpen"/> <separator name="FileSep1"/> diff --git a/src/window-commands.c b/src/window-commands.c index 17f334a7e..99b8c1abf 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -734,6 +734,15 @@ window_cmd_file_new_window (GtkAction *action, } void +window_cmd_file_new_incognito_window (GtkAction *action, + EphyWindow *window) +{ + char *str = g_strdup_printf ("epiphany --incognito-mode --profile %s", ephy_dot_dir ()); + g_spawn_command_line_async (str, NULL); + g_free (str); +} + +void window_cmd_edit_undo (GtkAction *action, EphyWindow *window) { diff --git a/src/window-commands.h b/src/window-commands.h index b689bb4c0..4d8582f31 100644 --- a/src/window-commands.h +++ b/src/window-commands.h @@ -30,88 +30,90 @@ G_BEGIN_DECLS -void window_cmd_edit_find (GtkAction *action, - EphyWindow *window); -void window_cmd_view_stop (GtkAction *action, - EphyWindow *window); -void window_cmd_go_location (GtkAction *action, - EphyWindow *window); -void window_cmd_view_reload (GtkAction *action, - EphyWindow *window); -void window_cmd_new (GtkAction *action, - EphyWindow *window); -void window_cmd_file_bookmark_page (GtkAction *action, - EphyWindow *window); -void window_cmd_file_open (GtkAction *action, - EphyWindow *window); -void window_cmd_file_save_as (GtkAction *action, - EphyWindow *window); -void window_cmd_file_save_as_application (GtkAction *action, - EphyWindow *window); -void window_cmd_file_print (GtkAction *action, - EphyWindow *window); -void window_cmd_file_send_to (GtkAction *action, - EphyWindow *window); -void window_cmd_file_work_offline (GtkAction *action, - EphyWindow *window); -void window_cmd_file_close_window (GtkAction *action, - EphyWindow *window); -void window_cmd_edit_undo (GtkAction *action, - EphyWindow *window); -void window_cmd_edit_redo (GtkAction *action, - EphyWindow *window); -void window_cmd_edit_cut (GtkAction *action, - EphyWindow *window); -void window_cmd_edit_copy (GtkAction *action, - EphyWindow *window); -void window_cmd_edit_paste (GtkAction *action, - EphyWindow *window); -void window_cmd_edit_delete (GtkAction *action, - EphyWindow *window); -void window_cmd_edit_select_all (GtkAction *action, - EphyWindow *window); -void window_cmd_edit_find_next (GtkAction *action, - EphyWindow *window); -void window_cmd_edit_find_prev (GtkAction *action, - EphyWindow *window); -void window_cmd_view_fullscreen (GtkAction *action, - EphyWindow *window); -void window_cmd_view_zoom_in (GtkAction *action, - EphyWindow *window); -void window_cmd_view_zoom_out (GtkAction *action, - EphyWindow *window); -void window_cmd_view_zoom_normal (GtkAction *action, - EphyWindow *window); -void window_cmd_view_page_source (GtkAction *action, - EphyWindow *window); -void window_cmd_help_about (GtkAction *action, - GtkWidget *window); -void window_cmd_tabs_next (GtkAction *action, - EphyWindow *window); -void window_cmd_tabs_previous (GtkAction *action, - EphyWindow *window); -void window_cmd_tabs_move_left (GtkAction *action, - EphyWindow *window); -void window_cmd_tabs_move_right (GtkAction *action, - EphyWindow *window); -void window_cmd_tabs_detach (GtkAction *action, - EphyWindow *window); -void window_cmd_load_location (GtkAction *action, - EphyWindow *window); -void window_cmd_browse_with_caret (GtkAction *action, - EphyWindow *window); -void window_cmd_file_quit (GtkAction *action, - EphyWindow *window); -void window_cmd_edit_bookmarks (GtkAction *action, - EphyWindow *window); -void window_cmd_edit_history (GtkAction *action, - EphyWindow *window); -void window_cmd_file_new_window (GtkAction *action, - EphyWindow *window); -void window_cmd_edit_preferences (GtkAction *action, - EphyWindow *window); -void window_cmd_edit_personal_data (GtkAction *action, - EphyWindow *window); +void window_cmd_edit_find (GtkAction *action, + EphyWindow *window); +void window_cmd_view_stop (GtkAction *action, + EphyWindow *window); +void window_cmd_go_location (GtkAction *action, + EphyWindow *window); +void window_cmd_view_reload (GtkAction *action, + EphyWindow *window); +void window_cmd_new (GtkAction *action, + EphyWindow *window); +void window_cmd_file_bookmark_page (GtkAction *action, + EphyWindow *window); +void window_cmd_file_open (GtkAction *action, + EphyWindow *window); +void window_cmd_file_save_as (GtkAction *action, + EphyWindow *window); +void window_cmd_file_save_as_application (GtkAction *action, + EphyWindow *window); +void window_cmd_file_print (GtkAction *action, + EphyWindow *window); +void window_cmd_file_send_to (GtkAction *action, + EphyWindow *window); +void window_cmd_file_work_offline (GtkAction *action, + EphyWindow *window); +void window_cmd_file_close_window (GtkAction *action, + EphyWindow *window); +void window_cmd_edit_undo (GtkAction *action, + EphyWindow *window); +void window_cmd_edit_redo (GtkAction *action, + EphyWindow *window); +void window_cmd_edit_cut (GtkAction *action, + EphyWindow *window); +void window_cmd_edit_copy (GtkAction *action, + EphyWindow *window); +void window_cmd_edit_paste (GtkAction *action, + EphyWindow *window); +void window_cmd_edit_delete (GtkAction *action, + EphyWindow *window); +void window_cmd_edit_select_all (GtkAction *action, + EphyWindow *window); +void window_cmd_edit_find_next (GtkAction *action, + EphyWindow *window); +void window_cmd_edit_find_prev (GtkAction *action, + EphyWindow *window); +void window_cmd_view_fullscreen (GtkAction *action, + EphyWindow *window); +void window_cmd_view_zoom_in (GtkAction *action, + EphyWindow *window); +void window_cmd_view_zoom_out (GtkAction *action, + EphyWindow *window); +void window_cmd_view_zoom_normal (GtkAction *action, + EphyWindow *window); +void window_cmd_view_page_source (GtkAction *action, + EphyWindow *window); +void window_cmd_help_about (GtkAction *action, + GtkWidget *window); +void window_cmd_tabs_next (GtkAction *action, + EphyWindow *window); +void window_cmd_tabs_previous (GtkAction *action, + EphyWindow *window); +void window_cmd_tabs_move_left (GtkAction *action, + EphyWindow *window); +void window_cmd_tabs_move_right (GtkAction *action, + EphyWindow *window); +void window_cmd_tabs_detach (GtkAction *action, + EphyWindow *window); +void window_cmd_load_location (GtkAction *action, + EphyWindow *window); +void window_cmd_browse_with_caret (GtkAction *action, + EphyWindow *window); +void window_cmd_file_quit (GtkAction *action, + EphyWindow *window); +void window_cmd_edit_bookmarks (GtkAction *action, + EphyWindow *window); +void window_cmd_edit_history (GtkAction *action, + EphyWindow *window); +void window_cmd_file_new_window (GtkAction *action, + EphyWindow *window); +void window_cmd_file_new_incognito_window (GtkAction *action, + EphyWindow *window); +void window_cmd_edit_preferences (GtkAction *action, + EphyWindow *window); +void window_cmd_edit_personal_data (GtkAction *action, + EphyWindow *window); G_END_DECLS |