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

Side by Side Diff: components/autofill/core/browser/autofill_manager.cc

Issue 875183003: Minor changes to RealPanClient to get a bit farther (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_manager.h" 5 #include "components/autofill/core/browser/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 return; 554 return;
555 } 555 }
556 556
557 if (is_credit_card && action == AutofillDriver::FORM_DATA_ACTION_FILL) { 557 if (is_credit_card && action == AutofillDriver::FORM_DATA_ACTION_FILL) {
558 const CreditCard* card = static_cast<const CreditCard*>(data_model); 558 const CreditCard* card = static_cast<const CreditCard*>(data_model);
559 if (card->record_type() == CreditCard::MASKED_SERVER_CARD) { 559 if (card->record_type() == CreditCard::MASKED_SERVER_CARD) {
560 unmasking_card_ = *card; 560 unmasking_card_ = *card;
561 unmasking_query_id_ = query_id; 561 unmasking_query_id_ = query_id;
562 unmasking_form_ = form; 562 unmasking_form_ = form;
563 unmasking_field_ = field; 563 unmasking_field_ = field;
564 // TODO(estade): uncomment this after the demo. 564 real_pan_client_.Prepare();
565 // real_pan_client_.Prepare();
566 client()->ShowUnmaskPrompt(unmasking_card_, 565 client()->ShowUnmaskPrompt(unmasking_card_,
567 weak_ptr_factory_.GetWeakPtr()); 566 weak_ptr_factory_.GetWeakPtr());
568 return; 567 return;
569 } 568 }
570 } 569 }
571 570
572 FillOrPreviewDataModelForm(action, query_id, form, field, data_model, variant, 571 FillOrPreviewDataModelForm(action, query_id, form, field, data_model, variant,
573 is_credit_card); 572 is_credit_card);
574 } 573 }
575 574
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 // account creation forms. 682 // account creation forms.
684 driver_->DetectAccountCreationForms(form_structures_.get()); 683 driver_->DetectAccountCreationForms(form_structures_.get());
685 684
686 // If the corresponding flag is set, annotate forms with the predicted types. 685 // If the corresponding flag is set, annotate forms with the predicted types.
687 driver_->SendAutofillTypePredictionsToRenderer(form_structures_.get()); 686 driver_->SendAutofillTypePredictionsToRenderer(form_structures_.get());
688 } 687 }
689 688
690 void AutofillManager::OnUnmaskResponse(const base::string16& cvc, 689 void AutofillManager::OnUnmaskResponse(const base::string16& cvc,
691 const base::string16& exp_month, 690 const base::string16& exp_month,
692 const base::string16& exp_year) { 691 const base::string16& exp_year) {
693 // Most of this function is demo code. The real code should look something
694 // like:
695 // real_pan_client_.UnmaskCard(unmasking_card_, cvc, exp_month, exp_year);
696
697 unmasking_cvc_ = cvc; 692 unmasking_cvc_ = cvc;
698 // TODO(estade): fake verification: assume 123/1234 is the correct cvc. 693 // TODO(estade): use month/year.
699 if (StartsWithASCII(base::UTF16ToASCII(cvc), "123", true)) { 694 real_pan_client_.UnmaskCard(unmasking_card_, base::UTF16ToASCII(cvc));
700 base::MessageLoop::current()->PostDelayedTask(
701 FROM_HERE, base::Bind(&AutofillManager::OnUnmaskVerificationResult,
702 base::Unretained(this), true),
703 base::TimeDelta::FromSeconds(2));
704 } else {
705 base::MessageLoop::current()->PostDelayedTask(
706 FROM_HERE, base::Bind(&AutofillManager::OnUnmaskVerificationResult,
707 base::Unretained(this), false),
708 base::TimeDelta::FromSeconds(2));
709 }
710 } 695 }
711 696
712 void AutofillManager::OnUnmaskPromptClosed() { 697 void AutofillManager::OnUnmaskPromptClosed() {
713 real_pan_client_.CancelRequest(); 698 real_pan_client_.CancelRequest();
714 driver_->RendererShouldClearPreviewedForm(); 699 driver_->RendererShouldClearPreviewedForm();
715 unmasking_card_ = CreditCard(); 700 unmasking_card_ = CreditCard();
716 unmasking_cvc_.clear(); 701 unmasking_cvc_.clear();
717 } 702 }
718 703
719 IdentityProvider* AutofillManager::GetIdentityProvider() { 704 IdentityProvider* AutofillManager::GetIdentityProvider() {
720 return client()->GetIdentityProvider(); 705 return client()->GetIdentityProvider();
721 } 706 }
722 707
723 void AutofillManager::OnDidGetRealPan(const std::string& real_pan) { 708 void AutofillManager::OnDidGetRealPan(const std::string& real_pan) {
724 NOTIMPLEMENTED(); 709 if (!real_pan.empty()) {
725 }
726
727 void AutofillManager::OnUnmaskVerificationResult(bool success) {
728 if (success) {
729 unmasking_card_.set_record_type(CreditCard::FULL_SERVER_CARD); 710 unmasking_card_.set_record_type(CreditCard::FULL_SERVER_CARD);
730 if (unmasking_card_.type() == kAmericanExpressCard) { 711 unmasking_card_.SetNumber(base::UTF8ToUTF16(real_pan));
731 unmasking_card_.SetNumber(base::ASCIIToUTF16("371449635398431"));
732 } else if (unmasking_card_.type() == kVisaCard) {
733 unmasking_card_.SetNumber(base::ASCIIToUTF16("4012888888881881"));
734 } else {
735 DCHECK_EQ(kDiscoverCard, unmasking_card_.type());
736 unmasking_card_.SetNumber(base::ASCIIToUTF16("6011000990139424"));
737 }
738 personal_data_->UpdateServerCreditCard(unmasking_card_); 712 personal_data_->UpdateServerCreditCard(unmasking_card_);
739 FillCreditCardForm(unmasking_query_id_, unmasking_form_, unmasking_field_, 713 FillCreditCardForm(unmasking_query_id_, unmasking_form_, unmasking_field_,
740 unmasking_card_); 714 unmasking_card_);
741 } 715 }
742 client()->OnUnmaskVerificationResult(success); 716
717 client()->OnUnmaskVerificationResult(!real_pan.empty());
743 } 718 }
744 719
745 void AutofillManager::OnDidEndTextFieldEditing() { 720 void AutofillManager::OnDidEndTextFieldEditing() {
746 external_delegate_->DidEndTextFieldEditing(); 721 external_delegate_->DidEndTextFieldEditing();
747 } 722 }
748 723
749 bool AutofillManager::IsAutofillEnabled() const { 724 bool AutofillManager::IsAutofillEnabled() const {
750 return client_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); 725 return client_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled);
751 } 726 }
752 727
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 return false; 1325 return false;
1351 1326
1352 // Disregard forms that we wouldn't ever autofill in the first place. 1327 // Disregard forms that we wouldn't ever autofill in the first place.
1353 if (!form.ShouldBeParsed()) 1328 if (!form.ShouldBeParsed())
1354 return false; 1329 return false;
1355 1330
1356 return true; 1331 return true;
1357 } 1332 }
1358 1333
1359 } // namespace autofill 1334 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | components/autofill/core/browser/wallet/real_pan_wallet_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698