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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 } // namespace | 139 } // namespace |
140 | 140 |
141 AutofillManager::AutofillManager( | 141 AutofillManager::AutofillManager( |
142 AutofillDriver* driver, | 142 AutofillDriver* driver, |
143 AutofillClient* client, | 143 AutofillClient* client, |
144 const std::string& app_locale, | 144 const std::string& app_locale, |
145 AutofillDownloadManagerState enable_download_manager) | 145 AutofillDownloadManagerState enable_download_manager) |
146 : driver_(driver), | 146 : driver_(driver), |
147 client_(client), | 147 client_(client), |
| 148 real_pan_client_(driver->GetURLRequestContext(), this), |
148 app_locale_(app_locale), | 149 app_locale_(app_locale), |
149 personal_data_(client->GetPersonalDataManager()), | 150 personal_data_(client->GetPersonalDataManager()), |
150 autocomplete_history_manager_( | 151 autocomplete_history_manager_( |
151 new AutocompleteHistoryManager(driver, client)), | 152 new AutocompleteHistoryManager(driver, client)), |
152 has_logged_autofill_enabled_(false), | 153 has_logged_autofill_enabled_(false), |
153 has_logged_address_suggestions_count_(false), | 154 has_logged_address_suggestions_count_(false), |
154 did_show_suggestions_(false), | 155 did_show_suggestions_(false), |
155 user_did_type_(false), | 156 user_did_type_(false), |
156 user_did_autofill_(false), | 157 user_did_autofill_(false), |
157 user_did_edit_autofilled_field_(false), | 158 user_did_edit_autofilled_field_(false), |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 | 675 |
675 // Forward form structures to the password generation manager to detect | 676 // Forward form structures to the password generation manager to detect |
676 // account creation forms. | 677 // account creation forms. |
677 driver_->DetectAccountCreationForms(form_structures_.get()); | 678 driver_->DetectAccountCreationForms(form_structures_.get()); |
678 | 679 |
679 // 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. |
680 driver_->SendAutofillTypePredictionsToRenderer(form_structures_.get()); | 681 driver_->SendAutofillTypePredictionsToRenderer(form_structures_.get()); |
681 } | 682 } |
682 | 683 |
683 void AutofillManager::OnUnmaskResponse(const base::string16& cvc) { | 684 void AutofillManager::OnUnmaskResponse(const base::string16& cvc) { |
| 685 // Most of this function is demo code. The real code should look something |
| 686 // like: |
| 687 // real_pan_client_.UnmaskCard(unmasking_card_, cvc); |
| 688 |
684 unmasking_cvc_ = cvc; | 689 unmasking_cvc_ = cvc; |
685 // TODO(estade): fake verification: assume 123/1234 is the correct cvc. | 690 // TODO(estade): fake verification: assume 123/1234 is the correct cvc. |
686 if (StartsWithASCII(base::UTF16ToASCII(cvc), "123", true)) { | 691 if (StartsWithASCII(base::UTF16ToASCII(cvc), "123", true)) { |
687 base::MessageLoop::current()->PostDelayedTask( | 692 base::MessageLoop::current()->PostDelayedTask( |
688 FROM_HERE, base::Bind(&AutofillManager::OnUnmaskVerificationResult, | 693 FROM_HERE, base::Bind(&AutofillManager::OnUnmaskVerificationResult, |
689 base::Unretained(this), true), | 694 base::Unretained(this), true), |
690 base::TimeDelta::FromSeconds(2)); | 695 base::TimeDelta::FromSeconds(2)); |
691 } else { | 696 } else { |
692 base::MessageLoop::current()->PostDelayedTask( | 697 base::MessageLoop::current()->PostDelayedTask( |
693 FROM_HERE, base::Bind(&AutofillManager::OnUnmaskVerificationResult, | 698 FROM_HERE, base::Bind(&AutofillManager::OnUnmaskVerificationResult, |
694 base::Unretained(this), false), | 699 base::Unretained(this), false), |
695 base::TimeDelta::FromSeconds(2)); | 700 base::TimeDelta::FromSeconds(2)); |
696 } | 701 } |
697 } | 702 } |
698 | 703 |
699 void AutofillManager::OnUnmaskPromptClosed() { | 704 void AutofillManager::OnUnmaskPromptClosed() { |
| 705 real_pan_client_.CancelRequest(); |
700 driver_->RendererShouldClearPreviewedForm(); | 706 driver_->RendererShouldClearPreviewedForm(); |
701 unmasking_card_ = CreditCard(); | 707 unmasking_card_ = CreditCard(); |
702 unmasking_cvc_.clear(); | 708 unmasking_cvc_.clear(); |
703 } | 709 } |
704 | 710 |
| 711 void AutofillManager::OnDidGetRealPan(const std::string& real_pan) { |
| 712 NOTIMPLEMENTED(); |
| 713 } |
| 714 |
| 715 std::string AutofillManager::GetOAuth2Token() { |
| 716 NOTIMPLEMENTED(); |
| 717 return "would_I_lie_to_you?"; |
| 718 } |
| 719 |
705 void AutofillManager::OnUnmaskVerificationResult(bool success) { | 720 void AutofillManager::OnUnmaskVerificationResult(bool success) { |
706 if (success) { | 721 if (success) { |
707 unmasking_card_.set_record_type(CreditCard::FULL_SERVER_CARD); | 722 unmasking_card_.set_record_type(CreditCard::FULL_SERVER_CARD); |
708 if (unmasking_card_.type() == kAmericanExpressCard) { | 723 if (unmasking_card_.type() == kAmericanExpressCard) { |
709 unmasking_card_.SetNumber(base::ASCIIToUTF16("371449635398431")); | 724 unmasking_card_.SetNumber(base::ASCIIToUTF16("371449635398431")); |
710 } else { | 725 } else { |
711 DCHECK_EQ(kDiscoverCard, unmasking_card_.type()); | 726 DCHECK_EQ(kDiscoverCard, unmasking_card_.type()); |
712 unmasking_card_.SetNumber(base::ASCIIToUTF16("6011000990139424")); | 727 unmasking_card_.SetNumber(base::ASCIIToUTF16("6011000990139424")); |
713 } | 728 } |
714 personal_data_->UpdateServerCreditCard(unmasking_card_); | 729 personal_data_->UpdateServerCreditCard(unmasking_card_); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 forms_loaded_timestamps_.clear(); | 855 forms_loaded_timestamps_.clear(); |
841 initial_interaction_timestamp_ = TimeTicks(); | 856 initial_interaction_timestamp_ = TimeTicks(); |
842 external_delegate_->Reset(); | 857 external_delegate_->Reset(); |
843 } | 858 } |
844 | 859 |
845 AutofillManager::AutofillManager(AutofillDriver* driver, | 860 AutofillManager::AutofillManager(AutofillDriver* driver, |
846 AutofillClient* client, | 861 AutofillClient* client, |
847 PersonalDataManager* personal_data) | 862 PersonalDataManager* personal_data) |
848 : driver_(driver), | 863 : driver_(driver), |
849 client_(client), | 864 client_(client), |
| 865 real_pan_client_(driver->GetURLRequestContext(), this), |
850 app_locale_("en-US"), | 866 app_locale_("en-US"), |
851 personal_data_(personal_data), | 867 personal_data_(personal_data), |
852 autocomplete_history_manager_( | 868 autocomplete_history_manager_( |
853 new AutocompleteHistoryManager(driver, client)), | 869 new AutocompleteHistoryManager(driver, client)), |
854 has_logged_autofill_enabled_(false), | 870 has_logged_autofill_enabled_(false), |
855 has_logged_address_suggestions_count_(false), | 871 has_logged_address_suggestions_count_(false), |
856 did_show_suggestions_(false), | 872 did_show_suggestions_(false), |
857 user_did_type_(false), | 873 user_did_type_(false), |
858 user_did_autofill_(false), | 874 user_did_autofill_(false), |
859 user_did_edit_autofilled_field_(false), | 875 user_did_edit_autofilled_field_(false), |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 return false; | 1341 return false; |
1326 | 1342 |
1327 // Disregard forms that we wouldn't ever autofill in the first place. | 1343 // Disregard forms that we wouldn't ever autofill in the first place. |
1328 if (!form.ShouldBeParsed()) | 1344 if (!form.ShouldBeParsed()) |
1329 return false; | 1345 return false; |
1330 | 1346 |
1331 return true; | 1347 return true; |
1332 } | 1348 } |
1333 | 1349 |
1334 } // namespace autofill | 1350 } // namespace autofill |
OLD | NEW |