Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: chrome/browser/password_manager/password_store_x_unittest.cc

Issue 2565173002: Remove ScopedVector from PasswordStoreX (Closed)
Patch Set: back_inserter, no =nullptr, drop autofill:: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 86
87 bool DisableAutoSignInForOrigins( 87 bool DisableAutoSignInForOrigins(
88 const base::Callback<bool(const GURL&)>& origin_filter, 88 const base::Callback<bool(const GURL&)>& origin_filter,
89 password_manager::PasswordStoreChangeList* changes) override { 89 password_manager::PasswordStoreChangeList* changes) override {
90 return false; 90 return false;
91 } 91 }
92 92
93 // 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
94 // get ignored. 94 // get ignored.
95 static ScopedVector<autofill::PasswordForm> CreateTrashForms() { 95 static std::vector<std::unique_ptr<PasswordForm>> CreateTrashForms() {
96 ScopedVector<autofill::PasswordForm> forms; 96 std::vector<std::unique_ptr<PasswordForm>> forms;
97 PasswordForm trash; 97 PasswordForm trash;
98 trash.username_element = base::ASCIIToUTF16("trash u. element"); 98 trash.username_element = base::ASCIIToUTF16("trash u. element");
99 trash.username_value = base::ASCIIToUTF16("trash u. value"); 99 trash.username_value = base::ASCIIToUTF16("trash u. value");
100 trash.password_element = base::ASCIIToUTF16("trash p. element"); 100 trash.password_element = base::ASCIIToUTF16("trash p. element");
101 trash.password_value = base::ASCIIToUTF16("trash p. value"); 101 trash.password_value = base::ASCIIToUTF16("trash p. value");
102 for (size_t i = 0; i < 3; ++i) { 102 for (size_t i = 0; i < 3; ++i) {
103 trash.origin = GURL(base::StringPrintf("http://trash%zu.com", i)); 103 trash.origin = GURL(base::StringPrintf("http://trash%zu.com", i));
104 forms.push_back(new PasswordForm(trash)); 104 forms.push_back(base::MakeUnique<PasswordForm>(trash));
105 } 105 }
106 return forms; 106 return forms;
107 } 107 }
108 108
109 bool GetLogins(const PasswordStore::FormDigest& form, 109 bool GetLogins(const PasswordStore::FormDigest& form,
110 ScopedVector<autofill::PasswordForm>* forms) override { 110 std::vector<std::unique_ptr<PasswordForm>>* forms) override {
111 *forms = CreateTrashForms(); 111 *forms = CreateTrashForms();
112 return false; 112 return false;
113 } 113 }
114 114
115 bool GetAutofillableLogins( 115 bool GetAutofillableLogins(
116 ScopedVector<autofill::PasswordForm>* forms) override { 116 std::vector<std::unique_ptr<PasswordForm>>* forms) override {
117 *forms = CreateTrashForms(); 117 *forms = CreateTrashForms();
118 return false; 118 return false;
119 } 119 }
120 120
121 bool GetBlacklistLogins( 121 bool GetBlacklistLogins(
122 ScopedVector<autofill::PasswordForm>* forms) override { 122 std::vector<std::unique_ptr<PasswordForm>>* forms) override {
123 *forms = CreateTrashForms(); 123 *forms = CreateTrashForms();
124 return false; 124 return false;
125 } 125 }
126 126
127 bool GetAllLogins(ScopedVector<autofill::PasswordForm>* forms) override { 127 bool GetAllLogins(
128 std::vector<std::unique_ptr<PasswordForm>>* forms) override {
128 *forms = CreateTrashForms(); 129 *forms = CreateTrashForms();
129 return false; 130 return false;
130 } 131 }
131 }; 132 };
132 133
133 class MockBackend : public PasswordStoreX::NativeBackend { 134 class MockBackend : public PasswordStoreX::NativeBackend {
134 public: 135 public:
135 bool Init() override { return true; } 136 bool Init() override { return true; }
136 137
137 PasswordStoreChangeList AddLogin(const PasswordForm& form) override { 138 PasswordStoreChangeList AddLogin(const PasswordForm& form) override {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 return true; 193 return true;
193 } 194 }
194 195
195 bool DisableAutoSignInForOrigins( 196 bool DisableAutoSignInForOrigins(
196 const base::Callback<bool(const GURL&)>& origin_filter, 197 const base::Callback<bool(const GURL&)>& origin_filter,
197 password_manager::PasswordStoreChangeList* changes) override { 198 password_manager::PasswordStoreChangeList* changes) override {
198 return true; 199 return true;
199 } 200 }
200 201
201 bool GetLogins(const PasswordStore::FormDigest& form, 202 bool GetLogins(const PasswordStore::FormDigest& form,
202 ScopedVector<autofill::PasswordForm>* forms) override { 203 std::vector<std::unique_ptr<PasswordForm>>* forms) override {
203 for (size_t i = 0; i < all_forms_.size(); ++i) 204 for (size_t i = 0; i < all_forms_.size(); ++i)
204 if (all_forms_[i].signon_realm == form.signon_realm) 205 if (all_forms_[i].signon_realm == form.signon_realm)
205 forms->push_back(new PasswordForm(all_forms_[i])); 206 forms->push_back(base::MakeUnique<PasswordForm>(all_forms_[i]));
206 return true; 207 return true;
207 } 208 }
208 209
209 bool GetAutofillableLogins( 210 bool GetAutofillableLogins(
210 ScopedVector<autofill::PasswordForm>* forms) override { 211 std::vector<std::unique_ptr<PasswordForm>>* forms) override {
211 for (size_t i = 0; i < all_forms_.size(); ++i) 212 for (size_t i = 0; i < all_forms_.size(); ++i)
212 if (!all_forms_[i].blacklisted_by_user) 213 if (!all_forms_[i].blacklisted_by_user)
213 forms->push_back(new PasswordForm(all_forms_[i])); 214 forms->push_back(base::MakeUnique<PasswordForm>(all_forms_[i]));
214 return true; 215 return true;
215 } 216 }
216 217
217 bool GetBlacklistLogins( 218 bool GetBlacklistLogins(
218 ScopedVector<autofill::PasswordForm>* forms) override { 219 std::vector<std::unique_ptr<PasswordForm>>* forms) override {
219 for (size_t i = 0; i < all_forms_.size(); ++i) 220 for (size_t i = 0; i < all_forms_.size(); ++i)
220 if (all_forms_[i].blacklisted_by_user) 221 if (all_forms_[i].blacklisted_by_user)
221 forms->push_back(new PasswordForm(all_forms_[i])); 222 forms->push_back(base::MakeUnique<PasswordForm>(all_forms_[i]));
222 return true; 223 return true;
223 } 224 }
224 225
225 bool GetAllLogins(ScopedVector<autofill::PasswordForm>* forms) override { 226 bool GetAllLogins(
227 std::vector<std::unique_ptr<PasswordForm>>* forms) override {
226 for (size_t i = 0; i < all_forms_.size(); ++i) 228 for (size_t i = 0; i < all_forms_.size(); ++i)
227 forms->push_back(new PasswordForm(all_forms_[i])); 229 forms->push_back(base::MakeUnique<PasswordForm>(all_forms_[i]));
228 return true; 230 return true;
229 } 231 }
230 232
231 private: 233 private:
232 void erase(size_t index) { 234 void erase(size_t index) {
233 if (index < all_forms_.size() - 1) 235 if (index < all_forms_.size() - 1)
234 all_forms_[index] = all_forms_.back(); 236 all_forms_[index] = all_forms_.back();
235 all_forms_.pop_back(); 237 all_forms_.pop_back();
236 } 238 }
237 239
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
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));
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_x.cc ('k') | components/autofill/core/common/password_form.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698