| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/password_manager/password_store_factory.h" | 9 #include "chrome/browser/password_manager/password_store_factory.h" |
| 10 #include "chrome/browser/profiles/profile_info_cache.h" | 10 #include "chrome/browser/profiles/profile_info_cache.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 // The class serves to retrieve passwords from PasswordStore asynchronously. It | 91 // The class serves to retrieve passwords from PasswordStore asynchronously. It |
| 92 // used by ProfileManagerBrowserTest.DeletePasswords on some platforms. | 92 // used by ProfileManagerBrowserTest.DeletePasswords on some platforms. |
| 93 class PasswordStoreConsumerVerifier : | 93 class PasswordStoreConsumerVerifier : |
| 94 public password_manager::PasswordStoreConsumer { | 94 public password_manager::PasswordStoreConsumer { |
| 95 public: | 95 public: |
| 96 PasswordStoreConsumerVerifier() : called_(false) {} | 96 PasswordStoreConsumerVerifier() : called_(false) {} |
| 97 | 97 |
| 98 void OnGetPasswordStoreResults( | 98 void OnGetPasswordStoreResults( |
| 99 const std::vector<autofill::PasswordForm*>& results) override { | 99 ScopedVector<autofill::PasswordForm> results) override { |
| 100 EXPECT_FALSE(called_); | 100 EXPECT_FALSE(called_); |
| 101 called_ = true; | 101 called_ = true; |
| 102 password_entries_.clear(); | 102 password_entries_.swap(results); |
| 103 password_entries_.assign(results.begin(), results.end()); | |
| 104 } | 103 } |
| 105 | 104 |
| 106 bool IsCalled() const { return called_; } | 105 bool IsCalled() const { return called_; } |
| 107 | 106 |
| 108 const std::vector<autofill::PasswordForm*>& GetPasswords() const { | 107 const std::vector<autofill::PasswordForm*>& GetPasswords() const { |
| 109 return password_entries_.get(); | 108 return password_entries_.get(); |
| 110 } | 109 } |
| 111 private: | 110 private: |
| 112 ScopedVector<autofill::PasswordForm> password_entries_; | 111 ScopedVector<autofill::PasswordForm> password_entries_; |
| 113 bool called_; | 112 bool called_; |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 run_loop.QuitClosure()); | 443 run_loop.QuitClosure()); |
| 445 EXPECT_TRUE(password_store->ScheduleTask(task)); | 444 EXPECT_TRUE(password_store->ScheduleTask(task)); |
| 446 run_loop.Run(); | 445 run_loop.Run(); |
| 447 | 446 |
| 448 EXPECT_TRUE(verify_add.IsCalled()); | 447 EXPECT_TRUE(verify_add.IsCalled()); |
| 449 EXPECT_EQ(1u, verify_add.GetPasswords().size()); | 448 EXPECT_EQ(1u, verify_add.GetPasswords().size()); |
| 450 EXPECT_TRUE(verify_delete.IsCalled()); | 449 EXPECT_TRUE(verify_delete.IsCalled()); |
| 451 EXPECT_EQ(0u, verify_delete.GetPasswords().size()); | 450 EXPECT_EQ(0u, verify_delete.GetPasswords().size()); |
| 452 } | 451 } |
| 453 #endif // !defined(OS_WIN) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 452 #endif // !defined(OS_WIN) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
| OLD | NEW |