[epiphany] Add an option to never remember passwords
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Add an option to never remember passwords
- Date: Sat, 8 Oct 2016 00:14:52 +0000 (UTC)
commit 8846eb13942a62f36262ad61c40d11e62c46f441
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Thu Oct 6 14:17:38 2016 -0500
Add an option to never remember passwords
Some users want to never remember passwords on particular websites. Add
an option to the info bar to ensure it never appears in the future for a
given website.
Note there is an existing option to disable password saving on all
sites in the preferences dialog.
Also note that this requires moving EphyHostsManager to lib/ to allow it
to be used from the web extension.
Currently there is no UI to undo the decision if the user accidentally
clicks Never. It's possible to fix by editing hosts.ini, but ideally we
would add UI for this somewhere. (The same UI is needed to manage
notification permissions.)
https://bugzilla.gnome.org/show_bug.cgi?id=612988
data/org.gnome.epiphany.host.gschema.xml | 5 ++++
embed/ephy-web-view.c | 12 ++++++++++-
embed/web-extension/ephy-web-extension.c | 33 ++++++++++++++++++++++++++++++
lib/Makefile.am | 2 +
{embed => lib}/ephy-hosts-manager.c | 18 +++++++++++++++-
{embed => lib}/ephy-hosts-manager.h | 6 +++++
6 files changed, 74 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.epiphany.host.gschema.xml b/data/org.gnome.epiphany.host.gschema.xml
index a85c28e..9b5e3f5 100644
--- a/data/org.gnome.epiphany.host.gschema.xml
+++ b/data/org.gnome.epiphany.host.gschema.xml
@@ -11,5 +11,10 @@
<summary>Decision to apply when notification permission is requested for this host</summary>
<description>This option is used to save whether a given host has been given permission to show
notifications. The 'undecided' default means the browser needs to ask the user for permission, while 'allow'
and 'deny' tell it to automatically make the decision upon request.</description>
</key>
+ <key name="save-password-permission" enum="org.gnome.Epiphany.host.permissions">
+ <default>"undecided"</default>
+ <summary>Decision to apply when save password permission is requested for this host</summary>
+ <description>This option is used to save whether a given host has been given permission to save
passwords. The 'undecided' default means the browser needs to ask the user for permission, while 'allow' and
'deny' tell it to automatically make the decision upon request.</description>
+ </key>
</schema>
</schemalist>
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 708d229..91fb6c4 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -514,7 +514,8 @@ ephy_web_view_create_form_auth_save_confirmation_info_bar (EphyWebView *web_view
LOG ("Going to show infobar about %s", webkit_web_view_get_uri (WEBKIT_WEB_VIEW (web_view)));
- info_bar = gtk_info_bar_new_with_buttons (_("_Don’t Save"), GTK_RESPONSE_CLOSE,
+ info_bar = gtk_info_bar_new_with_buttons (_("Not No_w"), GTK_RESPONSE_CLOSE,
+ _("_Never Save"), GTK_RESPONSE_REJECT,
_("_Save"), GTK_RESPONSE_YES,
NULL);
@@ -686,6 +687,15 @@ form_auth_data_save_confirmation_response (GtkInfoBar *info_bar,
response_id == GTK_RESPONSE_YES);
}
+ if (response_id == GTK_RESPONSE_REJECT) {
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ EphyHostsManager *manager = ephy_embed_shell_get_hosts_manager (shell);
+
+ ephy_hosts_manager_set_save_password_permission_for_address (manager,
+ ephy_web_view_get_address (data->web_view),
+ EPHY_HOST_PERMISSION_DENY);
+ }
+
g_slice_free (FormAuthRequestData, data);
}
diff --git a/embed/web-extension/ephy-web-extension.c b/embed/web-extension/ephy-web-extension.c
index 3dcd94e..a5c351f 100644
--- a/embed/web-extension/ephy-web-extension.c
+++ b/embed/web-extension/ephy-web-extension.c
@@ -24,6 +24,7 @@
#include "ephy-embed-form-auth.h"
#include "ephy-file-helpers.h"
#include "ephy-form-auth-data.h"
+#include "ephy-hosts-manager.h"
#include "ephy-prefs.h"
#include "ephy-settings.h"
#include "ephy-web-dom-utils.h"
@@ -55,6 +56,7 @@ struct _EphyWebExtension {
EphyFormAuthDataCache *form_auth_data_cache;
GHashTable *form_auth_data_save_requests;
EphyWebOverviewModel *overview_model;
+ EphyHostsManager *hosts_manager;
};
static const char introspection_xml[] =
@@ -276,6 +278,24 @@ should_store_cb (const char *username,
gpointer user_data)
{
EphyEmbedFormAuth *form_auth = EPHY_EMBED_FORM_AUTH (user_data);
+ EphyWebExtension *web_extension;
+ EphyHostPermission permission;
+ SoupURI *uri;
+ char *uri_string;
+
+ uri = ephy_embed_form_auth_get_uri (form_auth);
+ uri_string = soup_uri_to_string (uri, FALSE);
+ if (!uri_string)
+ return;
+
+ web_extension = ephy_web_extension_get ();
+ permission = ephy_hosts_manager_get_save_password_permission_for_address (web_extension->hosts_manager,
+ uri_string);
+
+ if (permission == EPHY_HOST_PERMISSION_DENY) {
+ LOG ("User/password storage permission previously denied. Not asking about storing.");
+ goto out;
+ }
if (password) {
WebKitDOMNode *username_node;
@@ -293,6 +313,9 @@ should_store_cb (const char *username,
if (g_strcmp0 (username, username_field_value) == 0 &&
g_str_equal (password, password_field_value)) {
LOG ("User/password already stored. Not asking about storing.");
+ } else if (permission == EPHY_HOST_PERMISSION_ALLOW) {
+ LOG ("User/password not yet stored. Storing.");
+ store_password (form_auth);
} else {
LOG ("User/password not yet stored. Asking about storing.");
request_decision_on_storing (g_object_ref (form_auth));
@@ -300,10 +323,16 @@ should_store_cb (const char *username,
g_free (username_field_value);
g_free (password_field_value);
+ } else if (permission == EPHY_HOST_PERMISSION_ALLOW) {
+ LOG ("No result on query; storing.");
+ store_password (form_auth);
} else {
LOG ("No result on query; asking whether we should store.");
request_decision_on_storing (g_object_ref (form_auth));
}
+
+out:
+ g_free (uri_string);
}
static gboolean
@@ -1285,6 +1314,8 @@ ephy_web_extension_dispose (GObject *object)
g_clear_object (&extension->uri_tester);
g_clear_object (&extension->overview_model);
+ g_clear_object (&extension->hosts_manager);
+
g_clear_pointer (&extension->form_auth_data_cache,
ephy_form_auth_data_cache_free);
@@ -1402,6 +1433,8 @@ ephy_web_extension_initialize (EphyWebExtension *extension,
if (!is_private_profile)
extension->form_auth_data_cache = ephy_form_auth_data_cache_new ();
+ extension->hosts_manager = ephy_hosts_manager_new ();
+
g_signal_connect_swapped (extension->extension, "page-created",
G_CALLBACK (ephy_web_extension_page_created_cb),
extension);
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 72bfed9..5693129 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -22,6 +22,8 @@ libephymisc_la_SOURCES = \
ephy-form-auth-data.h \
ephy-gui.c \
ephy-gui.h \
+ ephy-hosts-manager.c \
+ ephy-hosts-manager.h \
ephy-initial-state.c \
ephy-initial-state.h \
ephy-langs.c \
diff --git a/embed/ephy-hosts-manager.c b/lib/ephy-hosts-manager.c
similarity index 86%
rename from embed/ephy-hosts-manager.c
rename to lib/ephy-hosts-manager.c
index 9a9d3df..f54f9d2 100644
--- a/embed/ephy-hosts-manager.c
+++ b/lib/ephy-hosts-manager.c
@@ -19,7 +19,6 @@
#include "config.h"
#include "ephy-hosts-manager.h"
-#include "ephy-embed-shell.h"
#include "ephy-file-helpers.h"
#include "ephy-string.h"
@@ -150,3 +149,20 @@ ephy_hosts_manager_set_notifications_permission_for_address (EphyHostsManager *m
GSettings *settings = ephy_hosts_manager_get_settings_for_address (manager, address);
g_settings_set_enum (settings, "notifications-permission", permission);
}
+
+EphyHostPermission
+ephy_hosts_manager_get_save_password_permission_for_address (EphyHostsManager *manager,
+ const char *address)
+{
+ GSettings *settings = ephy_hosts_manager_get_settings_for_address (manager, address);
+ return g_settings_get_enum (settings, "save-password-permission");
+}
+
+void
+ephy_hosts_manager_set_save_password_permission_for_address (EphyHostsManager *manager,
+ const char *address,
+ EphyHostPermission permission)
+{
+ GSettings *settings = ephy_hosts_manager_get_settings_for_address (manager, address);
+ g_settings_set_enum (settings, "save-password-permission", permission);
+}
diff --git a/embed/ephy-hosts-manager.h b/lib/ephy-hosts-manager.h
similarity index 76%
rename from embed/ephy-hosts-manager.h
rename to lib/ephy-hosts-manager.h
index 482337e..c8d6859 100644
--- a/embed/ephy-hosts-manager.h
+++ b/lib/ephy-hosts-manager.h
@@ -39,6 +39,12 @@ EphyHostPermission ephy_hosts_manager_get_notifications_permission_for_addr
void ephy_hosts_manager_set_notifications_permission_for_address (EphyHostsManager
*manager,
const char
*address,
EphyHostPermission
permission);
+EphyHostPermission ephy_hosts_manager_get_save_password_permission_for_address (EphyHostsManager
*manager,
+ const char
*address);
+void ephy_hosts_manager_set_save_password_permission_for_address (EphyHostsManager
*manager,
+ const char
*address,
+ EphyHostPermission
permission);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]