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

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

Issue 7967024: Profile shouldn't own PersonalDataManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addresses isherman #11 Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/autofill_helper.h" 5 #include "chrome/browser/sync/test/integration/autofill_helper.h"
6 6
7 #include "chrome/browser/autofill/autofill_common_test.h" 7 #include "chrome/browser/autofill/autofill_common_test.h"
8 #include "chrome/browser/autofill/autofill_profile.h" 8 #include "chrome/browser/autofill/autofill_profile.h"
9 #include "chrome/browser/autofill/autofill_type.h" 9 #include "chrome/browser/autofill/autofill_type.h"
10 #include "chrome/browser/autofill/personal_data_manager.h" 10 #include "chrome/browser/autofill/personal_data_manager.h"
11 #include "chrome/browser/autofill/personal_data_manager_factory.h"
11 #include "chrome/browser/autofill/personal_data_manager_observer.h" 12 #include "chrome/browser/autofill/personal_data_manager_observer.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/sync/profile_sync_service.h" 14 #include "chrome/browser/sync/profile_sync_service.h"
14 #include "chrome/browser/sync/profile_sync_test_util.h" 15 #include "chrome/browser/sync/profile_sync_test_util.h"
15 #include "chrome/browser/sync/test/integration/sync_test.h" 16 #include "chrome/browser/sync/test/integration/sync_test.h"
16 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 17 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
17 #include "chrome/browser/webdata/autofill_entry.h" 18 #include "chrome/browser/webdata/autofill_entry.h"
18 #include "chrome/browser/webdata/autofill_table.h" 19 #include "chrome/browser/webdata/autofill_table.h"
19 #include "chrome/browser/webdata/web_database.h" 20 #include "chrome/browser/webdata/web_database.h"
20 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 break; 121 break;
121 } 122 }
122 return profile; 123 return profile;
123 } 124 }
124 125
125 WebDataService* GetWebDataService(int index) { 126 WebDataService* GetWebDataService(int index) {
126 return test()->GetProfile(index)->GetWebDataService(Profile::EXPLICIT_ACCESS); 127 return test()->GetProfile(index)->GetWebDataService(Profile::EXPLICIT_ACCESS);
127 } 128 }
128 129
129 PersonalDataManager* GetPersonalDataManager(int index) { 130 PersonalDataManager* GetPersonalDataManager(int index) {
130 return test()->GetProfile(index)->GetPersonalDataManager(); 131 return PersonalDataManagerFactory::GetForProfile(test()->GetProfile(index));
131 } 132 }
132 133
133 void AddKeys(int profile, const std::set<AutofillKey>& keys) { 134 void AddKeys(int profile, const std::set<AutofillKey>& keys) {
134 std::vector<webkit_glue::FormField> form_fields; 135 std::vector<webkit_glue::FormField> form_fields;
135 for (std::set<AutofillKey>::const_iterator i = keys.begin(); 136 for (std::set<AutofillKey>::const_iterator i = keys.begin();
136 i != keys.end(); 137 i != keys.end();
137 ++i) { 138 ++i) {
138 webkit_glue::FormField field; 139 webkit_glue::FormField field;
139 field.name = i->name(); 140 field.name = i->name();
140 field.value = i->value(); 141 field.value = i->value();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile); 209 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
209 std::vector<AutofillProfile> autofill_profiles; 210 std::vector<AutofillProfile> autofill_profiles;
210 for (size_t i = 0; i < all_profiles.size(); ++i) { 211 for (size_t i = 0; i < all_profiles.size(); ++i) {
211 if (all_profiles[i]->guid() != guid) 212 if (all_profiles[i]->guid() != guid)
212 autofill_profiles.push_back(*all_profiles[i]); 213 autofill_profiles.push_back(*all_profiles[i]);
213 } 214 }
214 autofill_helper::SetProfiles(profile, &autofill_profiles); 215 autofill_helper::SetProfiles(profile, &autofill_profiles);
215 } 216 }
216 217
217 void UpdateProfile(int profile, 218 void UpdateProfile(int profile,
218 const std::string& guid, 219 const std::string& guid,
219 const AutofillType& type, 220 const AutofillType& type,
220 const string16& value) { 221 const string16& value) {
221 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile); 222 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
222 std::vector<AutofillProfile> profiles; 223 std::vector<AutofillProfile> profiles;
223 for (size_t i = 0; i < all_profiles.size(); ++i) { 224 for (size_t i = 0; i < all_profiles.size(); ++i) {
224 profiles.push_back(*all_profiles[i]); 225 profiles.push_back(*all_profiles[i]);
225 if (all_profiles[i]->guid() == guid) 226 if (all_profiles[i]->guid() == guid)
226 profiles.back().SetInfo(type.field_type(), value); 227 profiles.back().SetInfo(type.field_type(), value);
227 } 228 }
228 autofill_helper::SetProfiles(profile, &profiles); 229 autofill_helper::SetProfiles(profile, &profiles);
229 } 230 }
230 231
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if (!ProfilesMatch(0, i)) { 290 if (!ProfilesMatch(0, i)) {
290 LOG(ERROR) << "Profile " << i << "does not contain the same autofill " 291 LOG(ERROR) << "Profile " << i << "does not contain the same autofill "
291 "profiles as profile 0."; 292 "profiles as profile 0.";
292 return false; 293 return false;
293 } 294 }
294 } 295 }
295 return true; 296 return true;
296 } 297 }
297 298
298 } // namespace autofill_helper 299 } // namespace autofill_helper
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_autofill_unittest.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698