diff options
author | Cosimo Cecchi <cosimoc@src.gnome.org> | 2007-11-05 07:35:28 +0800 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@src.gnome.org> | 2007-11-05 07:35:28 +0800 |
commit | cce4921f040c9756af1cbc573e1a7efcebe6a02a (patch) | |
tree | 04486e048111d8259f00253471e9b952d0850ee5 | |
parent | 42ccd4ec827aed6f2145c2a3bf5613d7c521fa77 (diff) | |
download | gsoc2013-epiphany-cce4921f040c9756af1cbc573e1a7efcebe6a02a.tar gsoc2013-epiphany-cce4921f040c9756af1cbc573e1a7efcebe6a02a.tar.gz gsoc2013-epiphany-cce4921f040c9756af1cbc573e1a7efcebe6a02a.tar.bz2 gsoc2013-epiphany-cce4921f040c9756af1cbc573e1a7efcebe6a02a.tar.lz gsoc2013-epiphany-cce4921f040c9756af1cbc573e1a7efcebe6a02a.tar.xz gsoc2013-epiphany-cce4921f040c9756af1cbc573e1a7efcebe6a02a.tar.zst gsoc2013-epiphany-cce4921f040c9756af1cbc573e1a7efcebe6a02a.zip |
Add remove_all_passwords method to EphyPasswordManager and implement it
in Mozilla and XulRunner backends.
Bug #476411.
svn path=/trunk/; revision=7623
-rw-r--r-- | embed/ephy-password-manager.c | 13 | ||||
-rw-r--r-- | embed/ephy-password-manager.h | 3 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp | 40 | ||||
-rw-r--r-- | embed/webkit/webkit-embed-single.cpp | 6 | ||||
-rw-r--r-- | embed/xulrunner/embed/mozilla-embed-single.cpp | 19 |
5 files changed, 81 insertions, 0 deletions
diff --git a/embed/ephy-password-manager.c b/embed/ephy-password-manager.c index c4fb56143..6f1b49520 100644 --- a/embed/ephy-password-manager.c +++ b/embed/ephy-password-manager.c @@ -187,6 +187,19 @@ ephy_password_manager_remove_password (EphyPasswordManager *manager, } /** + * ephy_password_manager_remove_all_passwords: + * @manager: the #EphyPasswordManager + * + * Removes all the password entries from the password database. + **/ +void +ephy_password_manager_remove_all_passwords (EphyPasswordManager *manager) +{ + EphyPasswordManagerIface *iface = EPHY_PASSWORD_MANAGER_GET_IFACE (manager); + iface->remove_all (manager); +} + +/** * ephy_password_manager_list_passwords: * @manager: the #EphyPasswordManager * diff --git a/embed/ephy-password-manager.h b/embed/ephy-password-manager.h index 7b85a0092..8dd2751af 100644 --- a/embed/ephy-password-manager.h +++ b/embed/ephy-password-manager.h @@ -58,6 +58,7 @@ struct _EphyPasswordManagerIface EphyPasswordInfo *info); void (* remove) (EphyPasswordManager *manager, EphyPasswordInfo *info); + void (* remove_all) (EphyPasswordManager *manager); GList * (* list) (EphyPasswordManager *manager); }; @@ -83,6 +84,8 @@ void ephy_password_manager_add_password (EphyPasswordManager *manager, void ephy_password_manager_remove_password (EphyPasswordManager *manager, EphyPasswordInfo *info); +void ephy_password_manager_remove_all_passwords (EphyPasswordManager *manager); + GList * ephy_password_manager_list_passwords (EphyPasswordManager *manager); G_END_DECLS diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index 77a982007..1d07ab548 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -958,6 +958,45 @@ impl_remove_password (EphyPasswordManager *manager, } static void +impl_remove_all_passwords (EphyPasswordManager *manager) +{ +#ifndef HAVE_GECKO_1_9 + nsresult rv; + nsCOMPtr<nsIPasswordManager> passwordManager = + do_GetService (NS_PASSWORDMANAGER_CONTRACTID); + if (!passwordManager) return; + + nsCOMPtr<nsIIDNService> idnService + (do_GetService ("@mozilla.org/network/idn-service;1")); + NS_ENSURE_TRUE (idnService, ); + + nsCOMPtr<nsISimpleEnumerator> passwordEnumerator; + passwordManager->GetEnumerator (getter_AddRefs(passwordEnumerator)); + NS_ENSURE_TRUE (passwordEnumerator, ); + + PRBool enumResult; + for (passwordEnumerator->HasMoreElements(&enumResult) ; + enumResult == PR_TRUE ; + passwordEnumerator->HasMoreElements(&enumResult)) + { + nsCOMPtr<nsIPassword> nsPassword; + passwordEnumerator->GetNext (getter_AddRefs(nsPassword)); + if (!nsPassword) continue; + + nsCString host; + rv = nsPassword->GetHost (host); + if (NS_FAILED (rv)) continue; + + nsString userName; + rv = nsPassword->GetUser (userName); + if (NS_FAILED (rv)) continue; + + passwordManager->RemoveUser (host, userName); + } +#endif /* !HAVE_GECKO_1_9 */ +} + +static void impl_add_password (EphyPasswordManager *manager, EphyPasswordInfo *info) { @@ -1337,6 +1376,7 @@ ephy_password_manager_iface_init (EphyPasswordManagerIface *iface) { iface->add = impl_add_password; iface->remove = impl_remove_password; + iface->remove_all = impl_remove_all_passwords; iface->list = impl_list_passwords; } diff --git a/embed/webkit/webkit-embed-single.cpp b/embed/webkit/webkit-embed-single.cpp index 0946472d3..cb4174213 100644 --- a/embed/webkit/webkit-embed-single.cpp +++ b/embed/webkit/webkit-embed-single.cpp @@ -169,6 +169,11 @@ impl_remove_password (EphyPasswordManager *manager, } static void +impl_remove_all_passwords (EphyPasswordManager *manager) +{ +} + +static void impl_add_password (EphyPasswordManager *manager, EphyPasswordInfo *info) { @@ -328,6 +333,7 @@ ephy_password_manager_iface_init (EphyPasswordManagerIface *iface) { iface->add = impl_add_password; iface->remove = impl_remove_password; + iface->remove = impl_remove_all_passwords; iface->list = impl_list_passwords; } diff --git a/embed/xulrunner/embed/mozilla-embed-single.cpp b/embed/xulrunner/embed/mozilla-embed-single.cpp index e2236297c..ab0373085 100644 --- a/embed/xulrunner/embed/mozilla-embed-single.cpp +++ b/embed/xulrunner/embed/mozilla-embed-single.cpp @@ -983,6 +983,25 @@ impl_remove_password (EphyPasswordManager *manager, } static void +impl_remove_all_passwords (EphyPasswordManager *manager) +{ + nsresult rv; + nsCOMPtr<nsILoginManager> loginManager = + do_GetService (NS_LOGINMANAGER_CONTRACTID); + g_return_val_if_fail (NS_SUCCEEDED (rv), NULL); + if (!loginManager) + return NULL; + + nsCOMPtr<nsIIDNService> idnService + (do_GetService ("@mozilla.org/network/idn-service;1")); + NS_ENSURE_TRUE (idnService, ); + + rv = loginManager->RemoveAllLogins (); + if (NS_FAILED (rv)) + return; +} + +static void impl_add_password (EphyPasswordManager *manager, EphyPasswordInfo *info) { |