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 "chrome/browser/password_manager/password_store_x.h" | 5 #include "chrome/browser/password_manager/password_store_x.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 return false; | 77 return false; |
78 } | 78 } |
79 | 79 |
80 bool RemoveLoginsSyncedBetween( | 80 bool RemoveLoginsSyncedBetween( |
81 base::Time delete_begin, | 81 base::Time delete_begin, |
82 base::Time delete_end, | 82 base::Time delete_end, |
83 password_manager::PasswordStoreChangeList* changes) override { | 83 password_manager::PasswordStoreChangeList* changes) override { |
84 return false; | 84 return false; |
85 } | 85 } |
86 | 86 |
87 bool DisableAutoSignInForAllLogins( | 87 bool DisableAutoSignInForOrigins( |
88 const base::Callback<bool(const GURL&)>& origin_filter, | |
88 password_manager::PasswordStoreChangeList* changes) override { | 89 password_manager::PasswordStoreChangeList* changes) override { |
89 return false; | 90 return false; |
90 } | 91 } |
91 | 92 |
92 // Use this as a landmine to check whether results of failed Get*Logins calls | 93 // Use this as a landmine to check whether results of failed Get*Logins calls |
93 // get ignored. | 94 // get ignored. |
94 static ScopedVector<autofill::PasswordForm> CreateTrashForms() { | 95 static ScopedVector<autofill::PasswordForm> CreateTrashForms() { |
95 ScopedVector<autofill::PasswordForm> forms; | 96 ScopedVector<autofill::PasswordForm> forms; |
96 PasswordForm trash; | 97 PasswordForm trash; |
97 trash.username_element = base::ASCIIToUTF16("trash u. element"); | 98 trash.username_element = base::ASCIIToUTF16("trash u. element"); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 if (delete_begin <= all_forms_[i].date_synced && | 185 if (delete_begin <= all_forms_[i].date_synced && |
185 (delete_end.is_null() || all_forms_[i].date_synced < delete_end)) { | 186 (delete_end.is_null() || all_forms_[i].date_synced < delete_end)) { |
186 changes->push_back(password_manager::PasswordStoreChange( | 187 changes->push_back(password_manager::PasswordStoreChange( |
187 password_manager::PasswordStoreChange::REMOVE, all_forms_[i])); | 188 password_manager::PasswordStoreChange::REMOVE, all_forms_[i])); |
188 erase(i--); | 189 erase(i--); |
189 } | 190 } |
190 } | 191 } |
191 return true; | 192 return true; |
192 } | 193 } |
193 | 194 |
194 bool DisableAutoSignInForAllLogins( | 195 bool DisableAutoSignInForOrigins( |
196 const base::Callback<bool(const GURL&)>& origin_filter, | |
195 password_manager::PasswordStoreChangeList* changes) override { | 197 password_manager::PasswordStoreChangeList* changes) override { |
196 return true; | 198 return true; |
197 } | 199 } |
198 | 200 |
199 bool GetLogins(const PasswordForm& form, | 201 bool GetLogins(const PasswordForm& form, |
200 ScopedVector<autofill::PasswordForm>* forms) override { | 202 ScopedVector<autofill::PasswordForm>* forms) override { |
201 for (size_t i = 0; i < all_forms_.size(); ++i) | 203 for (size_t i = 0; i < all_forms_.size(); ++i) |
202 if (all_forms_[i].signon_realm == form.signon_realm) | 204 if (all_forms_[i].signon_realm == form.signon_realm) |
203 forms->push_back(new PasswordForm(all_forms_[i])); | 205 forms->push_back(new PasswordForm(all_forms_[i])); |
204 return true; | 206 return true; |
(...skipping 17 matching lines...) Expand all Loading... | |
222 | 224 |
223 bool GetAllLogins(ScopedVector<autofill::PasswordForm>* forms) override { | 225 bool GetAllLogins(ScopedVector<autofill::PasswordForm>* forms) override { |
224 for (size_t i = 0; i < all_forms_.size(); ++i) | 226 for (size_t i = 0; i < all_forms_.size(); ++i) |
225 forms->push_back(new PasswordForm(all_forms_[i])); | 227 forms->push_back(new PasswordForm(all_forms_[i])); |
226 return true; | 228 return true; |
227 } | 229 } |
228 | 230 |
229 private: | 231 private: |
230 void erase(size_t index) { | 232 void erase(size_t index) { |
231 if (index < all_forms_.size() - 1) | 233 if (index < all_forms_.size() - 1) |
232 all_forms_[index] = all_forms_.back(); | 234 all_forms_[index] = all_forms_.back(); |
msramek
2016/07/12 13:45:51
This got here from a rebase over https://chromium.
| |
233 all_forms_.pop_back(); | 235 all_forms_.pop_back(); |
234 } | 236 } |
235 | 237 |
236 std::vector<PasswordForm> all_forms_; | 238 std::vector<PasswordForm> all_forms_; |
237 }; | 239 }; |
238 | 240 |
239 class MockLoginDatabaseReturn { | 241 class MockLoginDatabaseReturn { |
240 public: | 242 public: |
241 MOCK_METHOD1(OnLoginDatabaseQueryDone, | 243 MOCK_METHOD1(OnLoginDatabaseQueryDone, |
242 void(const std::vector<PasswordForm*>&)); | 244 void(const std::vector<PasswordForm*>&)); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 | 580 |
579 INSTANTIATE_TEST_CASE_P(NoBackend, | 581 INSTANTIATE_TEST_CASE_P(NoBackend, |
580 PasswordStoreXTest, | 582 PasswordStoreXTest, |
581 testing::Values(NO_BACKEND)); | 583 testing::Values(NO_BACKEND)); |
582 INSTANTIATE_TEST_CASE_P(FailingBackend, | 584 INSTANTIATE_TEST_CASE_P(FailingBackend, |
583 PasswordStoreXTest, | 585 PasswordStoreXTest, |
584 testing::Values(FAILING_BACKEND)); | 586 testing::Values(FAILING_BACKEND)); |
585 INSTANTIATE_TEST_CASE_P(WorkingBackend, | 587 INSTANTIATE_TEST_CASE_P(WorkingBackend, |
586 PasswordStoreXTest, | 588 PasswordStoreXTest, |
587 testing::Values(WORKING_BACKEND)); | 589 testing::Values(WORKING_BACKEND)); |
OLD | NEW |