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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 class MockPasswordStoreObserver | 51 class MockPasswordStoreObserver |
52 : public password_manager::PasswordStore::Observer { | 52 : public password_manager::PasswordStore::Observer { |
53 public: | 53 public: |
54 MOCK_METHOD1(OnLoginsChanged, | 54 MOCK_METHOD1(OnLoginsChanged, |
55 void(const password_manager::PasswordStoreChangeList& changes)); | 55 void(const password_manager::PasswordStoreChangeList& changes)); |
56 }; | 56 }; |
57 | 57 |
58 class FailingBackend : public PasswordStoreX::NativeBackend { | 58 class FailingBackend : public PasswordStoreX::NativeBackend { |
59 public: | 59 public: |
60 virtual bool Init() OVERRIDE { return true; } | 60 virtual bool Init() override { return true; } |
61 | 61 |
62 virtual PasswordStoreChangeList AddLogin(const PasswordForm& form) OVERRIDE { | 62 virtual PasswordStoreChangeList AddLogin(const PasswordForm& form) override { |
63 return PasswordStoreChangeList(); | 63 return PasswordStoreChangeList(); |
64 } | 64 } |
65 virtual bool UpdateLogin(const PasswordForm& form, | 65 virtual bool UpdateLogin(const PasswordForm& form, |
66 PasswordStoreChangeList* changes) OVERRIDE { | 66 PasswordStoreChangeList* changes) override { |
67 return false; | 67 return false; |
68 } | 68 } |
69 virtual bool RemoveLogin(const PasswordForm& form) OVERRIDE { return false; } | 69 virtual bool RemoveLogin(const PasswordForm& form) override { return false; } |
70 | 70 |
71 virtual bool RemoveLoginsCreatedBetween( | 71 virtual bool RemoveLoginsCreatedBetween( |
72 base::Time delete_begin, | 72 base::Time delete_begin, |
73 base::Time delete_end, | 73 base::Time delete_end, |
74 password_manager::PasswordStoreChangeList* changes) OVERRIDE { | 74 password_manager::PasswordStoreChangeList* changes) override { |
75 return false; | 75 return false; |
76 } | 76 } |
77 | 77 |
78 virtual bool RemoveLoginsSyncedBetween( | 78 virtual bool RemoveLoginsSyncedBetween( |
79 base::Time delete_begin, | 79 base::Time delete_begin, |
80 base::Time delete_end, | 80 base::Time delete_end, |
81 password_manager::PasswordStoreChangeList* changes) OVERRIDE { | 81 password_manager::PasswordStoreChangeList* changes) override { |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 virtual bool GetLogins(const PasswordForm& form, | 85 virtual bool GetLogins(const PasswordForm& form, |
86 PasswordFormList* forms) OVERRIDE { | 86 PasswordFormList* forms) override { |
87 return false; | 87 return false; |
88 } | 88 } |
89 | 89 |
90 virtual bool GetAutofillableLogins(PasswordFormList* forms) OVERRIDE { | 90 virtual bool GetAutofillableLogins(PasswordFormList* forms) override { |
91 return false; | 91 return false; |
92 } | 92 } |
93 virtual bool GetBlacklistLogins(PasswordFormList* forms) OVERRIDE { | 93 virtual bool GetBlacklistLogins(PasswordFormList* forms) override { |
94 return false; | 94 return false; |
95 } | 95 } |
96 }; | 96 }; |
97 | 97 |
98 class MockBackend : public PasswordStoreX::NativeBackend { | 98 class MockBackend : public PasswordStoreX::NativeBackend { |
99 public: | 99 public: |
100 virtual bool Init() OVERRIDE { return true; } | 100 virtual bool Init() override { return true; } |
101 | 101 |
102 virtual PasswordStoreChangeList AddLogin(const PasswordForm& form) OVERRIDE { | 102 virtual PasswordStoreChangeList AddLogin(const PasswordForm& form) override { |
103 all_forms_.push_back(form); | 103 all_forms_.push_back(form); |
104 PasswordStoreChange change(PasswordStoreChange::ADD, form); | 104 PasswordStoreChange change(PasswordStoreChange::ADD, form); |
105 return PasswordStoreChangeList(1, change); | 105 return PasswordStoreChangeList(1, change); |
106 } | 106 } |
107 | 107 |
108 virtual bool UpdateLogin(const PasswordForm& form, | 108 virtual bool UpdateLogin(const PasswordForm& form, |
109 PasswordStoreChangeList* changes) OVERRIDE { | 109 PasswordStoreChangeList* changes) override { |
110 for (size_t i = 0; i < all_forms_.size(); ++i) | 110 for (size_t i = 0; i < all_forms_.size(); ++i) |
111 if (CompareForms(all_forms_[i], form, true)) { | 111 if (CompareForms(all_forms_[i], form, true)) { |
112 all_forms_[i] = form; | 112 all_forms_[i] = form; |
113 changes->push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, | 113 changes->push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, |
114 form)); | 114 form)); |
115 } | 115 } |
116 return true; | 116 return true; |
117 } | 117 } |
118 | 118 |
119 virtual bool RemoveLogin(const PasswordForm& form) OVERRIDE { | 119 virtual bool RemoveLogin(const PasswordForm& form) override { |
120 for (size_t i = 0; i < all_forms_.size(); ++i) | 120 for (size_t i = 0; i < all_forms_.size(); ++i) |
121 if (CompareForms(all_forms_[i], form, false)) | 121 if (CompareForms(all_forms_[i], form, false)) |
122 erase(i--); | 122 erase(i--); |
123 return true; | 123 return true; |
124 } | 124 } |
125 | 125 |
126 virtual bool RemoveLoginsCreatedBetween( | 126 virtual bool RemoveLoginsCreatedBetween( |
127 base::Time delete_begin, | 127 base::Time delete_begin, |
128 base::Time delete_end, | 128 base::Time delete_end, |
129 password_manager::PasswordStoreChangeList* changes) OVERRIDE { | 129 password_manager::PasswordStoreChangeList* changes) override { |
130 for (size_t i = 0; i < all_forms_.size(); ++i) { | 130 for (size_t i = 0; i < all_forms_.size(); ++i) { |
131 if (delete_begin <= all_forms_[i].date_created && | 131 if (delete_begin <= all_forms_[i].date_created && |
132 (delete_end.is_null() || all_forms_[i].date_created < delete_end)) | 132 (delete_end.is_null() || all_forms_[i].date_created < delete_end)) |
133 erase(i--); | 133 erase(i--); |
134 } | 134 } |
135 return true; | 135 return true; |
136 } | 136 } |
137 | 137 |
138 virtual bool RemoveLoginsSyncedBetween( | 138 virtual bool RemoveLoginsSyncedBetween( |
139 base::Time delete_begin, | 139 base::Time delete_begin, |
140 base::Time delete_end, | 140 base::Time delete_end, |
141 password_manager::PasswordStoreChangeList* changes) OVERRIDE { | 141 password_manager::PasswordStoreChangeList* changes) override { |
142 DCHECK(changes); | 142 DCHECK(changes); |
143 for (size_t i = 0; i < all_forms_.size(); ++i) { | 143 for (size_t i = 0; i < all_forms_.size(); ++i) { |
144 if (delete_begin <= all_forms_[i].date_synced && | 144 if (delete_begin <= all_forms_[i].date_synced && |
145 (delete_end.is_null() || all_forms_[i].date_synced < delete_end)) { | 145 (delete_end.is_null() || all_forms_[i].date_synced < delete_end)) { |
146 changes->push_back(password_manager::PasswordStoreChange( | 146 changes->push_back(password_manager::PasswordStoreChange( |
147 password_manager::PasswordStoreChange::REMOVE, all_forms_[i])); | 147 password_manager::PasswordStoreChange::REMOVE, all_forms_[i])); |
148 erase(i--); | 148 erase(i--); |
149 } | 149 } |
150 } | 150 } |
151 return true; | 151 return true; |
152 } | 152 } |
153 | 153 |
154 virtual bool GetLogins(const PasswordForm& form, | 154 virtual bool GetLogins(const PasswordForm& form, |
155 PasswordFormList* forms) OVERRIDE { | 155 PasswordFormList* forms) override { |
156 for (size_t i = 0; i < all_forms_.size(); ++i) | 156 for (size_t i = 0; i < all_forms_.size(); ++i) |
157 if (all_forms_[i].signon_realm == form.signon_realm) | 157 if (all_forms_[i].signon_realm == form.signon_realm) |
158 forms->push_back(new PasswordForm(all_forms_[i])); | 158 forms->push_back(new PasswordForm(all_forms_[i])); |
159 return true; | 159 return true; |
160 } | 160 } |
161 | 161 |
162 virtual bool GetAutofillableLogins(PasswordFormList* forms) OVERRIDE { | 162 virtual bool GetAutofillableLogins(PasswordFormList* forms) override { |
163 for (size_t i = 0; i < all_forms_.size(); ++i) | 163 for (size_t i = 0; i < all_forms_.size(); ++i) |
164 if (!all_forms_[i].blacklisted_by_user) | 164 if (!all_forms_[i].blacklisted_by_user) |
165 forms->push_back(new PasswordForm(all_forms_[i])); | 165 forms->push_back(new PasswordForm(all_forms_[i])); |
166 return true; | 166 return true; |
167 } | 167 } |
168 | 168 |
169 virtual bool GetBlacklistLogins(PasswordFormList* forms) OVERRIDE { | 169 virtual bool GetBlacklistLogins(PasswordFormList* forms) override { |
170 for (size_t i = 0; i < all_forms_.size(); ++i) | 170 for (size_t i = 0; i < all_forms_.size(); ++i) |
171 if (all_forms_[i].blacklisted_by_user) | 171 if (all_forms_[i].blacklisted_by_user) |
172 forms->push_back(new PasswordForm(all_forms_[i])); | 172 forms->push_back(new PasswordForm(all_forms_[i])); |
173 return true; | 173 return true; |
174 } | 174 } |
175 | 175 |
176 private: | 176 private: |
177 void erase(size_t index) { | 177 void erase(size_t index) { |
178 if (index < all_forms_.size() - 1) | 178 if (index < all_forms_.size() - 1) |
179 all_forms_[index] = all_forms_[all_forms_.size() - 1]; | 179 all_forms_[index] = all_forms_[all_forms_.size() - 1]; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 463 |
464 INSTANTIATE_TEST_CASE_P(NoBackend, | 464 INSTANTIATE_TEST_CASE_P(NoBackend, |
465 PasswordStoreXTest, | 465 PasswordStoreXTest, |
466 testing::Values(NO_BACKEND)); | 466 testing::Values(NO_BACKEND)); |
467 INSTANTIATE_TEST_CASE_P(FailingBackend, | 467 INSTANTIATE_TEST_CASE_P(FailingBackend, |
468 PasswordStoreXTest, | 468 PasswordStoreXTest, |
469 testing::Values(FAILING_BACKEND)); | 469 testing::Values(FAILING_BACKEND)); |
470 INSTANTIATE_TEST_CASE_P(WorkingBackend, | 470 INSTANTIATE_TEST_CASE_P(WorkingBackend, |
471 PasswordStoreXTest, | 471 PasswordStoreXTest, |
472 testing::Values(WORKING_BACKEND)); | 472 testing::Values(WORKING_BACKEND)); |
OLD | NEW |