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 "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/ui/autofill/data_model_wrapper.h" | 23 #include "chrome/browser/ui/autofill/data_model_wrapper.h" |
24 #include "chrome/browser/ui/base_window.h" | 24 #include "chrome/browser/ui/base_window.h" |
25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_finder.h" | 26 #include "chrome/browser/ui/browser_finder.h" |
27 #include "chrome/browser/ui/browser_navigator.h" | 27 #include "chrome/browser/ui/browser_navigator.h" |
28 #include "chrome/browser/ui/browser_window.h" | 28 #include "chrome/browser/ui/browser_window.h" |
29 #include "chrome/browser/ui/extensions/native_app_window.h" | 29 #include "chrome/browser/ui/extensions/native_app_window.h" |
30 #include "chrome/browser/ui/extensions/shell_window.h" | 30 #include "chrome/browser/ui/extensions/shell_window.h" |
31 #include "chrome/common/chrome_version_info.h" | 31 #include "chrome/common/chrome_version_info.h" |
32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 33 #include "components/autofill/browser/autofill_data_model.h" |
33 #include "components/autofill/browser/autofill_manager.h" | 34 #include "components/autofill/browser/autofill_manager.h" |
34 #include "components/autofill/browser/autofill_type.h" | 35 #include "components/autofill/browser/autofill_type.h" |
35 #include "components/autofill/browser/personal_data_manager.h" | 36 #include "components/autofill/browser/personal_data_manager.h" |
36 #include "components/autofill/browser/risk/fingerprint.h" | 37 #include "components/autofill/browser/risk/fingerprint.h" |
37 #include "components/autofill/browser/risk/proto/fingerprint.pb.h" | 38 #include "components/autofill/browser/risk/proto/fingerprint.pb.h" |
38 #include "components/autofill/browser/validation.h" | 39 #include "components/autofill/browser/validation.h" |
39 #include "components/autofill/browser/wallet/cart.h" | 40 #include "components/autofill/browser/wallet/cart.h" |
40 #include "components/autofill/browser/wallet/full_wallet.h" | 41 #include "components/autofill/browser/wallet/full_wallet.h" |
41 #include "components/autofill/browser/wallet/instrument.h" | 42 #include "components/autofill/browser/wallet/instrument.h" |
42 #include "components/autofill/browser/wallet/wallet_address.h" | 43 #include "components/autofill/browser/wallet/wallet_address.h" |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 new WalletAddressWrapper(wallet_items_->addresses()[index])); | 803 new WalletAddressWrapper(wallet_items_->addresses()[index])); |
803 } | 804 } |
804 | 805 |
805 if (section == SECTION_CC) { | 806 if (section == SECTION_CC) { |
806 CreditCard* card = GetManager()->GetCreditCardByGUID(item_key); | 807 CreditCard* card = GetManager()->GetCreditCardByGUID(item_key); |
807 DCHECK(card); | 808 DCHECK(card); |
808 return scoped_ptr<DataModelWrapper>(new AutofillCreditCardWrapper(card)); | 809 return scoped_ptr<DataModelWrapper>(new AutofillCreditCardWrapper(card)); |
809 } | 810 } |
810 | 811 |
811 // Calculate the variant by looking at how many items come from the same | 812 // Calculate the variant by looking at how many items come from the same |
812 // FormGroup. | 813 // data model. |
813 size_t variant = 0; | 814 size_t variant = 0; |
814 for (int i = model->checked_item() - 1; i >= 0; --i) { | 815 for (int i = model->checked_item() - 1; i >= 0; --i) { |
815 if (model->GetItemKeyAt(i) == item_key) | 816 if (model->GetItemKeyAt(i) == item_key) |
816 variant++; | 817 variant++; |
817 else | 818 else |
818 break; | 819 break; |
819 } | 820 } |
820 | 821 |
821 AutofillProfile* profile = GetManager()->GetProfileByGUID(item_key); | 822 AutofillProfile* profile = GetManager()->GetProfileByGUID(item_key); |
822 DCHECK(profile); | 823 DCHECK(profile); |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 } | 1773 } |
1773 } | 1774 } |
1774 } | 1775 } |
1775 | 1776 |
1776 void AutofillDialogControllerImpl::FillOutputForSection(DialogSection section) { | 1777 void AutofillDialogControllerImpl::FillOutputForSection(DialogSection section) { |
1777 FillOutputForSectionWithComparator(section, | 1778 FillOutputForSectionWithComparator(section, |
1778 base::Bind(DetailInputMatchesField)); | 1779 base::Bind(DetailInputMatchesField)); |
1779 } | 1780 } |
1780 | 1781 |
1781 void AutofillDialogControllerImpl::FillFormStructureForSection( | 1782 void AutofillDialogControllerImpl::FillFormStructureForSection( |
1782 const FormGroup& form_group, | 1783 const AutofillDataModel& data_model, |
1783 size_t variant, | 1784 size_t variant, |
1784 DialogSection section, | 1785 DialogSection section, |
1785 const InputFieldComparator& compare) { | 1786 const InputFieldComparator& compare) { |
1786 std::string app_locale = g_browser_process->GetApplicationLocale(); | 1787 std::string app_locale = g_browser_process->GetApplicationLocale(); |
1787 for (size_t i = 0; i < form_structure_.field_count(); ++i) { | 1788 for (size_t i = 0; i < form_structure_.field_count(); ++i) { |
1788 AutofillField* field = form_structure_.field(i); | 1789 AutofillField* field = form_structure_.field(i); |
1789 // Only fill in data that is associated with this section. | 1790 // Only fill in data that is associated with this section. |
1790 const DetailInputs& inputs = RequestedFieldsForSection(section); | 1791 const DetailInputs& inputs = RequestedFieldsForSection(section); |
1791 for (size_t j = 0; j < inputs.size(); ++j) { | 1792 for (size_t j = 0; j < inputs.size(); ++j) { |
1792 if (compare.Run(inputs[j], *field)) { | 1793 if (compare.Run(inputs[j], *field)) { |
1793 form_group.FillFormField(*field, variant, app_locale, field); | 1794 data_model.FillFormField(*field, variant, app_locale, field); |
1794 break; | 1795 break; |
1795 } | 1796 } |
1796 } | 1797 } |
1797 } | 1798 } |
1798 } | 1799 } |
1799 | 1800 |
1800 void AutofillDialogControllerImpl::SetCvcResult(const string16& cvc) { | 1801 void AutofillDialogControllerImpl::SetCvcResult(const string16& cvc) { |
1801 for (size_t i = 0; i < form_structure_.field_count(); ++i) { | 1802 for (size_t i = 0; i < form_structure_.field_count(); ++i) { |
1802 AutofillField* field = form_structure_.field(i); | 1803 AutofillField* field = form_structure_.field(i); |
1803 if (field->type() == CREDIT_CARD_VERIFICATION_CODE) { | 1804 if (field->type() == CREDIT_CARD_VERIFICATION_CODE) { |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2186 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; | 2187 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; |
2187 } | 2188 } |
2188 | 2189 |
2189 // Has Wallet items. | 2190 // Has Wallet items. |
2190 return has_autofill_profiles ? | 2191 return has_autofill_profiles ? |
2191 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : | 2192 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : |
2192 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; | 2193 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; |
2193 } | 2194 } |
2194 | 2195 |
2195 } // namespace autofill | 2196 } // namespace autofill |
OLD | NEW |