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

Side by Side Diff: chrome/browser/sync/test/integration/passwords_helper.cc

Issue 335893002: Support to remove passwords by date_synced timestamp. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: vabr's comments Created 6 years, 6 months 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 | Annotate | Revision Log
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/sync/test/integration/passwords_helper.h" 5 #include "chrome/browser/sync/test/integration/passwords_helper.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // Quit the message loop to wake up passwords_helper::GetLogins. 57 // Quit the message loop to wake up passwords_helper::GetLogins.
58 base::MessageLoopForUI::current()->Quit(); 58 base::MessageLoopForUI::current()->Quit();
59 } 59 }
60 60
61 private: 61 private:
62 std::vector<PasswordForm>* result_; 62 std::vector<PasswordForm>* result_;
63 63
64 DISALLOW_COPY_AND_ASSIGN(PasswordStoreConsumerHelper); 64 DISALLOW_COPY_AND_ASSIGN(PasswordStoreConsumerHelper);
65 }; 65 };
66 66
67 // PasswordForm::date_synced is a local field. Therefore it may be different
68 // across clients.
69 void ClearSyncDateField(std::vector<PasswordForm>* forms) {
70 for (std::vector<PasswordForm>::iterator it = forms->begin();
71 it != forms->end();
72 ++it) {
73 it->date_synced = base::Time();
74 }
75 }
76
67 } // namespace 77 } // namespace
68 78
69 namespace passwords_helper { 79 namespace passwords_helper {
70 80
71 void AddLogin(PasswordStore* store, const PasswordForm& form) { 81 void AddLogin(PasswordStore* store, const PasswordForm& form) {
72 ASSERT_TRUE(store); 82 ASSERT_TRUE(store);
73 base::WaitableEvent wait_event(true, false); 83 base::WaitableEvent wait_event(true, false);
74 store->AddLogin(form); 84 store->AddLogin(form);
75 store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event)); 85 store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event));
76 wait_event.Wait(); 86 wait_event.Wait();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 PasswordStore* GetVerifierPasswordStore() { 140 PasswordStore* GetVerifierPasswordStore() {
131 return PasswordStoreFactory::GetForProfile(test()->verifier(), 141 return PasswordStoreFactory::GetForProfile(test()->verifier(),
132 Profile::IMPLICIT_ACCESS).get(); 142 Profile::IMPLICIT_ACCESS).get();
133 } 143 }
134 144
135 bool ProfileContainsSamePasswordFormsAsVerifier(int index) { 145 bool ProfileContainsSamePasswordFormsAsVerifier(int index) {
136 std::vector<PasswordForm> verifier_forms; 146 std::vector<PasswordForm> verifier_forms;
137 std::vector<PasswordForm> forms; 147 std::vector<PasswordForm> forms;
138 GetLogins(GetVerifierPasswordStore(), verifier_forms); 148 GetLogins(GetVerifierPasswordStore(), verifier_forms);
139 GetLogins(GetPasswordStore(index), forms); 149 GetLogins(GetPasswordStore(index), forms);
150 ClearSyncDateField(&forms);
140 bool result = 151 bool result =
141 password_manager::ContainsSamePasswordForms(verifier_forms, forms); 152 password_manager::ContainsSamePasswordForms(verifier_forms, forms);
Nicolas Zea 2014/06/17 21:41:11 Does it make sense to modify this method instead t
vasilii 2014/06/18 10:00:57 ContainsSamePasswordForms() resides in components/
142 if (!result) { 153 if (!result) {
143 LOG(ERROR) << "Password forms in Verifier Profile:"; 154 LOG(ERROR) << "Password forms in Verifier Profile:";
144 for (std::vector<PasswordForm>::iterator it = verifier_forms.begin(); 155 for (std::vector<PasswordForm>::iterator it = verifier_forms.begin();
145 it != verifier_forms.end(); ++it) { 156 it != verifier_forms.end(); ++it) {
146 LOG(ERROR) << *it << std::endl; 157 LOG(ERROR) << *it << std::endl;
147 } 158 }
148 LOG(ERROR) << "Password forms in Profile" << index << ":"; 159 LOG(ERROR) << "Password forms in Profile" << index << ":";
149 for (std::vector<PasswordForm>::iterator it = forms.begin(); 160 for (std::vector<PasswordForm>::iterator it = forms.begin();
150 it != forms.end(); ++it) { 161 it != forms.end(); ++it) {
151 LOG(ERROR) << *it << std::endl; 162 LOG(ERROR) << *it << std::endl;
152 } 163 }
153 } 164 }
154 return result; 165 return result;
155 } 166 }
156 167
157 bool ProfilesContainSamePasswordForms(int index_a, int index_b) { 168 bool ProfilesContainSamePasswordForms(int index_a, int index_b) {
158 std::vector<PasswordForm> forms_a; 169 std::vector<PasswordForm> forms_a;
159 std::vector<PasswordForm> forms_b; 170 std::vector<PasswordForm> forms_b;
160 GetLogins(GetPasswordStore(index_a), forms_a); 171 GetLogins(GetPasswordStore(index_a), forms_a);
161 GetLogins(GetPasswordStore(index_b), forms_b); 172 GetLogins(GetPasswordStore(index_b), forms_b);
173 ClearSyncDateField(&forms_a);
174 ClearSyncDateField(&forms_b);
162 bool result = password_manager::ContainsSamePasswordForms(forms_a, forms_b); 175 bool result = password_manager::ContainsSamePasswordForms(forms_a, forms_b);
163 if (!result) { 176 if (!result) {
164 LOG(ERROR) << "Password forms in Profile" << index_a << ":"; 177 LOG(ERROR) << "Password forms in Profile" << index_a << ":";
165 for (std::vector<PasswordForm>::iterator it = forms_a.begin(); 178 for (std::vector<PasswordForm>::iterator it = forms_a.begin();
166 it != forms_a.end(); ++it) { 179 it != forms_a.end(); ++it) {
167 LOG(ERROR) << *it << std::endl; 180 LOG(ERROR) << *it << std::endl;
168 } 181 }
169 LOG(ERROR) << "Password forms in Profile" << index_b << ":"; 182 LOG(ERROR) << "Password forms in Profile" << index_b << ":";
170 for (std::vector<PasswordForm>::iterator it = forms_b.begin(); 183 for (std::vector<PasswordForm>::iterator it = forms_b.begin();
171 it != forms_b.end(); ++it) { 184 it != forms_b.end(); ++it) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 form.origin = GURL(base::StringPrintf(kIndexedFakeOrigin, index)); 360 form.origin = GURL(base::StringPrintf(kIndexedFakeOrigin, index));
348 form.username_value = 361 form.username_value =
349 base::ASCIIToUTF16(base::StringPrintf("username%d", index)); 362 base::ASCIIToUTF16(base::StringPrintf("username%d", index));
350 form.password_value = 363 form.password_value =
351 base::ASCIIToUTF16(base::StringPrintf("password%d", index)); 364 base::ASCIIToUTF16(base::StringPrintf("password%d", index));
352 form.date_created = base::Time::Now(); 365 form.date_created = base::Time::Now();
353 return form; 366 return form;
354 } 367 }
355 368
356 } // namespace passwords_helper 369 } // namespace passwords_helper
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698