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

Side by Side Diff: chrome/browser/autofill/autofill_manager.cc

Issue 6213002: Propagate correct data to the Toolbar servers (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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) 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/autofill/autofill_manager.h" 5 #include "chrome/browser/autofill/autofill_manager.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <set> 8 #include <set>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 FillCreditCardFormField(credit_card, autofill_type, &result.fields[j]); 375 FillCreditCardFormField(credit_card, autofill_type, &result.fields[j]);
376 } else if (profile && 376 } else if (profile &&
377 autofill_type.group() != AutoFillType::CREDIT_CARD) { 377 autofill_type.group() != AutoFillType::CREDIT_CARD) {
378 FillFormField(profile, autofill_type, &result.fields[j]); 378 FillFormField(profile, autofill_type, &result.fields[j]);
379 } 379 }
380 380
381 // We found a matching field in the |form_structure| so we 381 // We found a matching field in the |form_structure| so we
382 // proceed to the next |result| field, and the next |form_structure|. 382 // proceed to the next |result| field, and the next |form_structure|.
383 ++i; 383 ++i;
384 } 384 }
385 autofilled_forms_signatures_.push_front(form_structure->FormSignature()); 385 AutofilledFormInfo form_info;
386 form_info.form_signature = form_structure->FormSignature();
387 form_info.profile_guid = profile_guid;
388 form_info.cc_guid = cc_guid;
389 autofilled_forms_signatures_.push_front(form_info);
386 390
387 host->AutoFillFormDataFilled(query_id, result); 391 host->AutoFillFormDataFilled(query_id, result);
388 return true; 392 return true;
389 } 393 }
390 394
391 void AutoFillManager::ShowAutoFillDialog() { 395 void AutoFillManager::ShowAutoFillDialog() {
392 ::ShowAutoFillDialog(tab_contents_->GetContentNativeView(), 396 ::ShowAutoFillDialog(tab_contents_->GetContentNativeView(),
393 personal_data_, 397 personal_data_,
394 tab_contents_->profile()->GetOriginalProfile()); 398 tab_contents_->profile()->GetOriginalProfile());
395 } 399 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 tab_contents_->AddInfoBar(new AutoFillCCInfoBarDelegate(tab_contents_, 497 tab_contents_->AddInfoBar(new AutoFillCCInfoBarDelegate(tab_contents_,
494 this)); 498 this));
495 } 499 }
496 } 500 }
497 501
498 void AutoFillManager::UploadFormData() { 502 void AutoFillManager::UploadFormData() {
499 if (!disable_download_manager_requests_ && upload_form_structure_.get()) { 503 if (!disable_download_manager_requests_ && upload_form_structure_.get()) {
500 bool was_autofilled = false; 504 bool was_autofilled = false;
501 // Check if the form among last 3 forms that were auto-filled. 505 // Check if the form among last 3 forms that were auto-filled.
502 // Clear older signatures. 506 // Clear older signatures.
503 std::list<std::string>::iterator it; 507 std::list<AutofilledFormInfo>::iterator it;
504 int total_form_checked = 0; 508 int total_form_checked = 0;
509 std::string profile_guid, cc_guid;
505 for (it = autofilled_forms_signatures_.begin(); 510 for (it = autofilled_forms_signatures_.begin();
506 it != autofilled_forms_signatures_.end() && total_form_checked < 3; 511 it != autofilled_forms_signatures_.end() && total_form_checked < 3;
507 ++it, ++total_form_checked) { 512 ++it, ++total_form_checked) {
508 if (*it == upload_form_structure_->FormSignature()) 513 if (it->form_signature == upload_form_structure_->FormSignature()) {
509 was_autofilled = true; 514 was_autofilled = true;
515 profile_guid = it->profile_guid;
516 cc_guid = it->cc_guid;
517 }
510 } 518 }
511 // Remove outdated form signatures. 519 // Remove outdated form signatures.
512 if (total_form_checked == 3 && it != autofilled_forms_signatures_.end()) { 520 if (total_form_checked == 3 && it != autofilled_forms_signatures_.end()) {
513 autofilled_forms_signatures_.erase(it, 521 autofilled_forms_signatures_.erase(it,
514 autofilled_forms_signatures_.end()); 522 autofilled_forms_signatures_.end());
515 } 523 }
516 download_manager_.StartUploadRequest(*(upload_form_structure_.get()), 524 download_manager_.StartUploadRequest(*(upload_form_structure_.get()),
Ilya Sherman 2011/01/11 23:17:37 nit: For the sake of matching indentation, please
GeorgeY 2011/01/13 23:22:28 Indentation restored
517 was_autofilled); 525 was_autofilled,
526 personal_data_->PresentData(profile_guid, cc_guid).c_str());
518 } 527 }
519 } 528 }
520 529
521 void AutoFillManager::OnInfoBarClosed(bool should_save) { 530 void AutoFillManager::OnInfoBarClosed(bool should_save) {
522 if (should_save) 531 if (should_save)
523 personal_data_->SaveImportedCreditCard(); 532 personal_data_->SaveImportedCreditCard();
524 UploadFormData(); 533 UploadFormData();
525 } 534 }
526 535
527 AutoFillManager::AutoFillManager() 536 AutoFillManager::AutoFillManager()
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 return std::string(); 819 return std::string();
811 820
812 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id); 821 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id);
813 if (iter == id_guid_map_.end()) { 822 if (iter == id_guid_map_.end()) {
814 NOTREACHED(); 823 NOTREACHED();
815 return std::string(); 824 return std::string();
816 } 825 }
817 826
818 return iter->second; 827 return iter->second;
819 } 828 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698