| OLD | NEW |
| 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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 FormStructure::ParseQueryResponse(response_xml, form_structures_.get()); | 674 FormStructure::ParseQueryResponse(response_xml, form_structures_.get()); |
| 675 | 675 |
| 676 // Forward form structures to the password generation manager to detect | 676 // Forward form structures to the password generation manager to detect |
| 677 // account creation forms. | 677 // account creation forms. |
| 678 driver_->DetectAccountCreationForms(form_structures_.get()); | 678 driver_->DetectAccountCreationForms(form_structures_.get()); |
| 679 | 679 |
| 680 // If the corresponding flag is set, annotate forms with the predicted types. | 680 // If the corresponding flag is set, annotate forms with the predicted types. |
| 681 driver_->SendAutofillTypePredictionsToRenderer(form_structures_.get()); | 681 driver_->SendAutofillTypePredictionsToRenderer(form_structures_.get()); |
| 682 } | 682 } |
| 683 | 683 |
| 684 void AutofillManager::OnUnmaskResponse(const base::string16& cvc) { | 684 void AutofillManager::OnUnmaskResponse(const base::string16& cvc, |
| 685 const base::string16& exp_month, |
| 686 const base::string16& exp_year) { |
| 685 // Most of this function is demo code. The real code should look something | 687 // Most of this function is demo code. The real code should look something |
| 686 // like: | 688 // like: |
| 687 // real_pan_client_.UnmaskCard(unmasking_card_, cvc); | 689 // real_pan_client_.UnmaskCard(unmasking_card_, cvc, exp_month, exp_year); |
| 688 | 690 |
| 689 unmasking_cvc_ = cvc; | 691 unmasking_cvc_ = cvc; |
| 690 // TODO(estade): fake verification: assume 123/1234 is the correct cvc. | 692 // TODO(estade): fake verification: assume 123/1234 is the correct cvc. |
| 691 if (StartsWithASCII(base::UTF16ToASCII(cvc), "123", true)) { | 693 if (StartsWithASCII(base::UTF16ToASCII(cvc), "123", true)) { |
| 692 base::MessageLoop::current()->PostDelayedTask( | 694 base::MessageLoop::current()->PostDelayedTask( |
| 693 FROM_HERE, base::Bind(&AutofillManager::OnUnmaskVerificationResult, | 695 FROM_HERE, base::Bind(&AutofillManager::OnUnmaskVerificationResult, |
| 694 base::Unretained(this), true), | 696 base::Unretained(this), true), |
| 695 base::TimeDelta::FromSeconds(2)); | 697 base::TimeDelta::FromSeconds(2)); |
| 696 } else { | 698 } else { |
| 697 base::MessageLoop::current()->PostDelayedTask( | 699 base::MessageLoop::current()->PostDelayedTask( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 715 std::string AutofillManager::GetOAuth2Token() { | 717 std::string AutofillManager::GetOAuth2Token() { |
| 716 NOTIMPLEMENTED(); | 718 NOTIMPLEMENTED(); |
| 717 return "would_I_lie_to_you?"; | 719 return "would_I_lie_to_you?"; |
| 718 } | 720 } |
| 719 | 721 |
| 720 void AutofillManager::OnUnmaskVerificationResult(bool success) { | 722 void AutofillManager::OnUnmaskVerificationResult(bool success) { |
| 721 if (success) { | 723 if (success) { |
| 722 unmasking_card_.set_record_type(CreditCard::FULL_SERVER_CARD); | 724 unmasking_card_.set_record_type(CreditCard::FULL_SERVER_CARD); |
| 723 if (unmasking_card_.type() == kAmericanExpressCard) { | 725 if (unmasking_card_.type() == kAmericanExpressCard) { |
| 724 unmasking_card_.SetNumber(base::ASCIIToUTF16("371449635398431")); | 726 unmasking_card_.SetNumber(base::ASCIIToUTF16("371449635398431")); |
| 727 } else if (unmasking_card_.type() == kVisaCard) { |
| 728 unmasking_card_.SetNumber(base::ASCIIToUTF16("4012888888881881")); |
| 725 } else { | 729 } else { |
| 726 DCHECK_EQ(kDiscoverCard, unmasking_card_.type()); | 730 DCHECK_EQ(kDiscoverCard, unmasking_card_.type()); |
| 727 unmasking_card_.SetNumber(base::ASCIIToUTF16("6011000990139424")); | 731 unmasking_card_.SetNumber(base::ASCIIToUTF16("6011000990139424")); |
| 728 } | 732 } |
| 729 personal_data_->UpdateServerCreditCard(unmasking_card_); | 733 personal_data_->UpdateServerCreditCard(unmasking_card_); |
| 730 FillCreditCardForm(unmasking_query_id_, unmasking_form_, unmasking_field_, | 734 FillCreditCardForm(unmasking_query_id_, unmasking_form_, unmasking_field_, |
| 731 unmasking_card_); | 735 unmasking_card_); |
| 732 } | 736 } |
| 733 client()->OnUnmaskVerificationResult(success); | 737 client()->OnUnmaskVerificationResult(success); |
| 734 } | 738 } |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 return false; | 1345 return false; |
| 1342 | 1346 |
| 1343 // Disregard forms that we wouldn't ever autofill in the first place. | 1347 // Disregard forms that we wouldn't ever autofill in the first place. |
| 1344 if (!form.ShouldBeParsed()) | 1348 if (!form.ShouldBeParsed()) |
| 1345 return false; | 1349 return false; |
| 1346 | 1350 |
| 1347 return true; | 1351 return true; |
| 1348 } | 1352 } |
| 1349 | 1353 |
| 1350 } // namespace autofill | 1354 } // namespace autofill |
| OLD | NEW |