aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--embed/ephy-password-manager.c13
-rw-r--r--embed/ephy-password-manager.h3
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp40
-rw-r--r--embed/webkit/webkit-embed-single.cpp6
-rw-r--r--embed/xulrunner/embed/mozilla-embed-single.cpp19
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)
{