| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/glue/autofill_model_associator.h" | 5 #include "chrome/browser/sync/glue/autofill_model_associator.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/guid.h" |
| 9 #include "base/task.h" | 10 #include "base/task.h" |
| 10 #include "base/time.h" | 11 #include "base/time.h" |
| 11 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/autofill/autofill_profile.h" | 14 #include "chrome/browser/autofill/autofill_profile.h" |
| 14 #include "chrome/browser/browser_thread.h" | 15 #include "chrome/browser/browser_thread.h" |
| 15 #include "chrome/browser/guid.h" | |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/sync/engine/syncapi.h" | 17 #include "chrome/browser/sync/engine/syncapi.h" |
| 18 #include "chrome/browser/sync/glue/autofill_change_processor.h" | 18 #include "chrome/browser/sync/glue/autofill_change_processor.h" |
| 19 #include "chrome/browser/sync/profile_sync_service.h" | 19 #include "chrome/browser/sync/profile_sync_service.h" |
| 20 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" | 20 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" |
| 21 #include "chrome/browser/webdata/web_database.h" | 21 #include "chrome/browser/webdata/web_database.h" |
| 22 #include "net/base/escape.h" | 22 #include "net/base/escape.h" |
| 23 | 23 |
| 24 using base::TimeTicks; | 24 using base::TimeTicks; |
| 25 | 25 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 if (p1->Compare(*p2) == 0) | 279 if (p1->Compare(*p2) == 0) |
| 280 return true; | 280 return true; |
| 281 else | 281 else |
| 282 return false; | 282 return false; |
| 283 } | 283 } |
| 284 }; | 284 }; |
| 285 | 285 |
| 286 AutoFillProfile* AutofillModelAssociator::FindCorrespondingNodeFromWebDB( | 286 AutoFillProfile* AutofillModelAssociator::FindCorrespondingNodeFromWebDB( |
| 287 const sync_pb::AutofillProfileSpecifics& profile, | 287 const sync_pb::AutofillProfileSpecifics& profile, |
| 288 const std::vector<AutoFillProfile*>& all_profiles_from_db) { | 288 const std::vector<AutoFillProfile*>& all_profiles_from_db) { |
| 289 static std::string guid(guid::GenerateGUID()); | 289 static std::string guid(base::GenerateGUID()); |
| 290 AutoFillProfile p; | 290 AutoFillProfile p; |
| 291 p.set_guid(guid); | 291 p.set_guid(guid); |
| 292 if (!FillProfileWithServerData(&p, profile)) { | 292 if (!FillProfileWithServerData(&p, profile)) { |
| 293 // Not a big deal. We encountered an error. Just say this profile does not | 293 // Not a big deal. We encountered an error. Just say this profile does not |
| 294 // exist. | 294 // exist. |
| 295 LOG(ERROR) << " Profile could not be associated"; | 295 LOG(ERROR) << " Profile could not be associated"; |
| 296 return NULL; | 296 return NULL; |
| 297 } | 297 } |
| 298 | 298 |
| 299 // Now instantiate the functor and call find_if. | 299 // Now instantiate the functor and call find_if. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 scoped_ptr<AutoFillProfile> profile_in_web_db(FindCorrespondingNodeFromWebDB( | 335 scoped_ptr<AutoFillProfile> profile_in_web_db(FindCorrespondingNodeFromWebDB( |
| 336 profile, all_profiles_from_db)); | 336 profile, all_profiles_from_db)); |
| 337 | 337 |
| 338 if (profile_in_web_db.get() != NULL) { | 338 if (profile_in_web_db.get() != NULL) { |
| 339 int64 sync_id = node.GetId(); | 339 int64 sync_id = node.GetId(); |
| 340 std::string guid = profile_in_web_db->guid(); | 340 std::string guid = profile_in_web_db->guid(); |
| 341 Associate(&guid, sync_id); | 341 Associate(&guid, sync_id); |
| 342 return; | 342 return; |
| 343 } else { // Create a new node. | 343 } else { // Create a new node. |
| 344 std::string guid = guid::GenerateGUID(); | 344 std::string guid = base::GenerateGUID(); |
| 345 Associate(&guid, node.GetId()); | 345 Associate(&guid, node.GetId()); |
| 346 AutoFillProfile* p = new AutoFillProfile(guid); | 346 AutoFillProfile* p = new AutoFillProfile(guid); |
| 347 FillProfileWithServerData(p, profile); | 347 FillProfileWithServerData(p, profile); |
| 348 bundle->new_profiles.push_back(p); | 348 bundle->new_profiles.push_back(p); |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 | 351 |
| 352 bool AutofillModelAssociator::DisassociateModels() { | 352 bool AutofillModelAssociator::DisassociateModels() { |
| 353 id_map_.clear(); | 353 id_map_.clear(); |
| 354 id_map_inverse_.clear(); | 354 id_map_inverse_.clear(); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 diff = MergeField(p, PHONE_HOME_WHOLE_NUMBER, s.phone_home_whole_number()) | 507 diff = MergeField(p, PHONE_HOME_WHOLE_NUMBER, s.phone_home_whole_number()) |
| 508 || diff; | 508 || diff; |
| 509 return diff; | 509 return diff; |
| 510 } | 510 } |
| 511 | 511 |
| 512 bool AutofillModelAssociator::HasNotMigratedYet() { | 512 bool AutofillModelAssociator::HasNotMigratedYet() { |
| 513 return true; | 513 return true; |
| 514 } | 514 } |
| 515 | 515 |
| 516 } // namespace browser_sync | 516 } // namespace browser_sync |
| OLD | NEW |