Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / components / password_manager / core / browser / test_password_store.cc
index f2cc235..555eb70 100644 (file)
@@ -6,6 +6,8 @@
 
 #include "components/autofill/core/common/password_form.h"
 
+namespace password_manager {
+
 TestPasswordStore::TestPasswordStore()
     : PasswordStore(base::MessageLoopProxy::current(),
                     base::MessageLoopProxy::current()) {
@@ -13,7 +15,8 @@ TestPasswordStore::TestPasswordStore()
 
 TestPasswordStore::~TestPasswordStore() {}
 
-TestPasswordStore::PasswordMap TestPasswordStore::stored_passwords() {
+const TestPasswordStore::PasswordMap& TestPasswordStore::stored_passwords()
+    const {
   return stored_passwords_;
 }
 
@@ -21,6 +24,18 @@ void TestPasswordStore::Clear() {
   stored_passwords_.clear();
 }
 
+bool TestPasswordStore::IsEmpty() const {
+  // The store is empty, if the sum of all stored passwords across all entries
+  // in |stored_passwords_| is 0.
+  size_t number_of_passwords = 0u;
+  for (PasswordMap::const_iterator it = stored_passwords_.begin();
+       !number_of_passwords && it != stored_passwords_.end();
+       ++it) {
+    number_of_passwords += it->second.size();
+  }
+  return number_of_passwords == 0u;
+}
+
 bool TestPasswordStore::FormsAreEquivalent(const autofill::PasswordForm& lhs,
                                            const autofill::PasswordForm& rhs) {
   return lhs.origin == rhs.origin &&
@@ -105,3 +120,5 @@ bool TestPasswordStore::FillBlacklistLogins(
     std::vector<autofill::PasswordForm*>* forms) {
   return true;
 }
+
+}  // namespace password_manager