OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/autofill/autofill_dialog_views.h" | 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
948 } | 948 } |
949 | 949 |
950 UpdateSectionImpl(section, false); | 950 UpdateSectionImpl(section, false); |
951 } | 951 } |
952 | 952 |
953 void AutofillDialogViews::GetUserInput(DialogSection section, | 953 void AutofillDialogViews::GetUserInput(DialogSection section, |
954 DetailOutputMap* output) { | 954 DetailOutputMap* output) { |
955 DetailsGroup* group = GroupForSection(section); | 955 DetailsGroup* group = GroupForSection(section); |
956 for (TextfieldMap::const_iterator it = group->textfields.begin(); | 956 for (TextfieldMap::const_iterator it = group->textfields.begin(); |
957 it != group->textfields.end(); ++it) { | 957 it != group->textfields.end(); ++it) { |
958 if (!it->second->textfield()->enabled()) | |
Evan Stade
2013/05/25 00:41:19
This isn't necessary, and I'd just as soon leave i
Dan Beam
2013/05/25 02:36:57
Done.
| |
959 continue; | |
958 output->insert(std::make_pair(it->first, it->second->textfield()->text())); | 960 output->insert(std::make_pair(it->first, it->second->textfield()->text())); |
959 } | 961 } |
960 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); | 962 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); |
961 it != group->comboboxes.end(); ++it) { | 963 it != group->comboboxes.end(); ++it) { |
964 if (!it->second->enabled()) | |
965 continue; | |
962 output->insert(std::make_pair(it->first, | 966 output->insert(std::make_pair(it->first, |
963 it->second->model()->GetItemAt(it->second->selected_index()))); | 967 it->second->model()->GetItemAt(it->second->selected_index()))); |
964 } | 968 } |
965 } | 969 } |
966 | 970 |
967 string16 AutofillDialogViews::GetCvc() { | 971 string16 AutofillDialogViews::GetCvc() { |
968 DialogSection billing_section = controller_->SectionIsActive(SECTION_CC) ? | 972 DialogSection billing_section = controller_->SectionIsActive(SECTION_CC) ? |
969 SECTION_CC : SECTION_CC_BILLING; | 973 SECTION_CC : SECTION_CC_BILLING; |
970 return GroupForSection(billing_section)->suggested_info-> | 974 return GroupForSection(billing_section)->suggested_info-> |
971 decorated_textfield()->textfield()->text(); | 975 decorated_textfield()->textfield()->text(); |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1500 controller_->RequestedFieldsForSection(section); | 1504 controller_->RequestedFieldsForSection(section); |
1501 DetailsGroup* group = GroupForSection(section); | 1505 DetailsGroup* group = GroupForSection(section); |
1502 | 1506 |
1503 for (DetailInputs::const_iterator iter = updated_inputs.begin(); | 1507 for (DetailInputs::const_iterator iter = updated_inputs.begin(); |
1504 iter != updated_inputs.end(); ++iter) { | 1508 iter != updated_inputs.end(); ++iter) { |
1505 const DetailInput& input = *iter; | 1509 const DetailInput& input = *iter; |
1506 TextfieldMap::iterator text_mapping = group->textfields.find(&input); | 1510 TextfieldMap::iterator text_mapping = group->textfields.find(&input); |
1507 | 1511 |
1508 if (text_mapping != group->textfields.end()) { | 1512 if (text_mapping != group->textfields.end()) { |
1509 views::Textfield* textfield = text_mapping->second->textfield(); | 1513 views::Textfield* textfield = text_mapping->second->textfield(); |
1514 textfield->SetEnabled(input.enabled); | |
1510 if (textfield->text().empty() || clobber_inputs) { | 1515 if (textfield->text().empty() || clobber_inputs) { |
1511 textfield->SetText(iter->initial_value); | 1516 textfield->SetText(iter->initial_value); |
1512 textfield->SetIcon(controller_->IconForField( | 1517 textfield->SetIcon(controller_->IconForField( |
1513 input.type, textfield->text()).AsImageSkia()); | 1518 input.type, textfield->text()).AsImageSkia()); |
1514 } | 1519 } |
1515 } | 1520 } |
1516 | 1521 |
1517 ComboboxMap::iterator combo_mapping = group->comboboxes.find(&input); | 1522 ComboboxMap::iterator combo_mapping = group->comboboxes.find(&input); |
1518 if (combo_mapping != group->comboboxes.end()) { | 1523 if (combo_mapping != group->comboboxes.end()) { |
1519 views::Combobox* combobox = combo_mapping->second; | 1524 views::Combobox* combobox = combo_mapping->second; |
1525 combobox->SetEnabled(input.enabled); | |
1520 if (combobox->selected_index() == combobox->model()->GetDefaultIndex() || | 1526 if (combobox->selected_index() == combobox->model()->GetDefaultIndex() || |
1521 clobber_inputs) { | 1527 clobber_inputs) { |
1522 for (int i = 0; i < combobox->model()->GetItemCount(); ++i) { | 1528 for (int i = 0; i < combobox->model()->GetItemCount(); ++i) { |
1523 if (input.initial_value == combobox->model()->GetItemAt(i)) { | 1529 if (input.initial_value == combobox->model()->GetItemAt(i)) { |
1524 combobox->SetSelectedIndex(i); | 1530 combobox->SetSelectedIndex(i); |
1525 break; | 1531 break; |
1526 } | 1532 } |
1527 } | 1533 } |
1528 } | 1534 } |
1529 } | 1535 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1613 | 1619 |
1614 scoped_ptr<DetailInput> cvc_input; | 1620 scoped_ptr<DetailInput> cvc_input; |
1615 DetailOutputMap detail_outputs; | 1621 DetailOutputMap detail_outputs; |
1616 typedef std::map<AutofillFieldType, base::Callback<void(const string16&)> > | 1622 typedef std::map<AutofillFieldType, base::Callback<void(const string16&)> > |
1617 FieldMap; | 1623 FieldMap; |
1618 FieldMap field_map; | 1624 FieldMap field_map; |
1619 | 1625 |
1620 if (group.manual_input->visible()) { | 1626 if (group.manual_input->visible()) { |
1621 for (TextfieldMap::const_iterator iter = group.textfields.begin(); | 1627 for (TextfieldMap::const_iterator iter = group.textfields.begin(); |
1622 iter != group.textfields.end(); ++iter) { | 1628 iter != group.textfields.end(); ++iter) { |
1629 if (!iter->first->enabled) | |
1630 continue; | |
1631 | |
1623 detail_outputs[iter->first] = iter->second->textfield()->text(); | 1632 detail_outputs[iter->first] = iter->second->textfield()->text(); |
1624 field_map[iter->first->type] = base::Bind( | 1633 field_map[iter->first->type] = base::Bind( |
1625 &AutofillDialogViews::SetValidityForInput<DecoratedTextfield>, | 1634 &AutofillDialogViews::SetValidityForInput<DecoratedTextfield>, |
1626 base::Unretained(this), | 1635 base::Unretained(this), |
1627 iter->second); | 1636 iter->second); |
1628 } | 1637 } |
1629 for (ComboboxMap::const_iterator iter = group.comboboxes.begin(); | 1638 for (ComboboxMap::const_iterator iter = group.comboboxes.begin(); |
1630 iter != group.comboboxes.end(); ++iter) { | 1639 iter != group.comboboxes.end(); ++iter) { |
1640 if (!iter->first->enabled) | |
1641 continue; | |
1642 | |
1631 views::Combobox* combobox = iter->second; | 1643 views::Combobox* combobox = iter->second; |
1632 string16 item = | 1644 string16 item = |
1633 combobox->model()->GetItemAt(combobox->selected_index()); | 1645 combobox->model()->GetItemAt(combobox->selected_index()); |
1634 detail_outputs[iter->first] = item; | 1646 detail_outputs[iter->first] = item; |
1635 field_map[iter->first->type] = base::Bind( | 1647 field_map[iter->first->type] = base::Bind( |
1636 &AutofillDialogViews::SetValidityForInput<views::Combobox>, | 1648 &AutofillDialogViews::SetValidityForInput<views::Combobox>, |
1637 base::Unretained(this), | 1649 base::Unretained(this), |
1638 iter->second); | 1650 iter->second); |
1639 } | 1651 } |
1640 } else if (group.section == SECTION_CC) { | 1652 } else if (group.section == SECTION_CC) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1819 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 1831 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
1820 : section(section), | 1832 : section(section), |
1821 container(NULL), | 1833 container(NULL), |
1822 manual_input(NULL), | 1834 manual_input(NULL), |
1823 suggested_info(NULL), | 1835 suggested_info(NULL), |
1824 suggested_button(NULL) {} | 1836 suggested_button(NULL) {} |
1825 | 1837 |
1826 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 1838 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
1827 | 1839 |
1828 } // namespace autofill | 1840 } // namespace autofill |
OLD | NEW |