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 /embed/mozilla/mozilla-embed-single.cpp | |
parent | 42ccd4ec827aed6f2145c2a3bf5613d7c521fa77 (diff) | |
download | gsoc2013-epiphany-cce4921f040c9756af1cbc573e1a7efcebe6a02a.tar.gz 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
Diffstat (limited to 'embed/mozilla/mozilla-embed-single.cpp')
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
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; } |