| Index: chrome/browser/ui/views/autofill/autofill_dialog_views.cc
|
| diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
|
| index 6db9e0b173f39db433faea5dd362ae5fa62ac15b..962ecf376e113b8d8bf73d83d7d94811b48d8ea3 100644
|
| --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
|
| +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
|
| @@ -775,10 +775,9 @@ void AutofillDialogViews::UpdateSection(DialogSection section) {
|
| }
|
|
|
| void AutofillDialogViews::FillSection(DialogSection section,
|
| - const DetailInput& originating_input) {
|
| + AutofillFieldType type) {
|
| DetailsGroup* group = GroupForSection(section);
|
| - TextfieldMap::iterator text_mapping =
|
| - group->textfields.find(&originating_input);
|
| + TextfieldMap::iterator text_mapping = group->textfields.find(type);
|
| if (text_mapping != group->textfields.end())
|
| text_mapping->second->textfield()->SetText(string16());
|
|
|
| @@ -860,12 +859,13 @@ void AutofillDialogViews::CancelForTesting() {
|
| Hide();
|
| }
|
|
|
| -string16 AutofillDialogViews::GetTextContentsOfInput(const DetailInput& input) {
|
| - views::Textfield* textfield = TextfieldForInput(input);
|
| +string16 AutofillDialogViews::GetTextContentsOfInput(DialogSection section,
|
| + AutofillFieldType type) {
|
| + views::Textfield* textfield = TextfieldForInput(section, type);
|
| if (textfield)
|
| return textfield->text();
|
|
|
| - views::Combobox* combobox = ComboboxForInput(input);
|
| + views::Combobox* combobox = ComboboxForInput(section, type);
|
| if (combobox)
|
| return combobox->model()->GetItemAt(combobox->selected_index());
|
|
|
| @@ -873,15 +873,16 @@ string16 AutofillDialogViews::GetTextContentsOfInput(const DetailInput& input) {
|
| return string16();
|
| }
|
|
|
| -void AutofillDialogViews::SetTextContentsOfInput(const DetailInput& input,
|
| +void AutofillDialogViews::SetTextContentsOfInput(DialogSection section,
|
| + AutofillFieldType type,
|
| const string16& contents) {
|
| - views::Textfield* textfield = TextfieldForInput(input);
|
| + views::Textfield* textfield = TextfieldForInput(section, type);
|
| if (textfield) {
|
| - TextfieldForInput(input)->SetText(contents);
|
| + textfield->SetText(contents);
|
| return;
|
| }
|
|
|
| - views::Combobox* combobox = ComboboxForInput(input);
|
| + views::Combobox* combobox = ComboboxForInput(section, type);
|
| if (combobox) {
|
| for (int i = 0; i < combobox->model()->GetItemCount(); ++i) {
|
| if (contents == combobox->model()->GetItemAt(i)) {
|
| @@ -897,8 +898,9 @@ void AutofillDialogViews::SetTextContentsOfInput(const DetailInput& input,
|
| NOTREACHED();
|
| }
|
|
|
| -void AutofillDialogViews::ActivateInput(const DetailInput& input) {
|
| - TextfieldEditedOrActivated(TextfieldForInput(input), false);
|
| +void AutofillDialogViews::ActivateInput(DialogSection section,
|
| + AutofillFieldType type) {
|
| + TextfieldEditedOrActivated(TextfieldForInput(section, type), false);
|
| }
|
|
|
| string16 AutofillDialogViews::GetWindowTitle() const {
|
| @@ -1287,7 +1289,7 @@ views::View* AutofillDialogViews::InitInputsView(DialogSection section) {
|
| if (input_model) {
|
| views::Combobox* combobox = new views::Combobox(input_model);
|
| combobox->set_listener(this);
|
| - comboboxes->insert(std::make_pair(&input, combobox));
|
| + comboboxes->insert(std::make_pair(input.type, combobox));
|
| layout->AddView(combobox);
|
|
|
| for (int i = 0; i < input_model->GetItemCount(); ++i) {
|
| @@ -1306,7 +1308,7 @@ views::View* AutofillDialogViews::InitInputsView(DialogSection section) {
|
| controller_->IconForField(input.type, input.initial_value);
|
| field->textfield()->SetIcon(icon.AsImageSkia());
|
|
|
| - textfields->insert(std::make_pair(&input, field));
|
| + textfields->insert(std::make_pair(input.type, field));
|
| layout->AddView(field);
|
| }
|
| }
|
| @@ -1323,23 +1325,23 @@ void AutofillDialogViews::UpdateSectionImpl(
|
|
|
| for (DetailInputs::const_iterator iter = updated_inputs.begin();
|
| iter != updated_inputs.end(); ++iter) {
|
| - const DetailInput& input = *iter;
|
| - TextfieldMap::iterator text_mapping = group->textfields.find(&input);
|
| + AutofillFieldType type = iter->type;
|
| + TextfieldMap::iterator text_mapping = group->textfields.find(type);
|
|
|
| if (text_mapping != group->textfields.end()) {
|
| views::Textfield* textfield = text_mapping->second->textfield();
|
| if (textfield->text().empty() || clobber_inputs) {
|
| textfield->SetText(iter->initial_value);
|
| - textfield->SetIcon(controller_->IconForField(
|
| - input.type, textfield->text()).AsImageSkia());
|
| + textfield->SetIcon(controller_->IconForField(type, textfield->text())
|
| + .AsImageSkia());
|
| }
|
| }
|
|
|
| - ComboboxMap::iterator combo_mapping = group->comboboxes.find(&input);
|
| + ComboboxMap::iterator combo_mapping = group->comboboxes.find(type);
|
| if (combo_mapping != group->comboboxes.end()) {
|
| views::Combobox* combobox = combo_mapping->second;
|
| for (int i = 0; i < combobox->model()->GetItemCount(); ++i) {
|
| - if (input.initial_value == combobox->model()->GetItemAt(i)) {
|
| + if (iter->initial_value == combobox->model()->GetItemAt(i)) {
|
| combobox->SetSelectedIndex(i);
|
| break;
|
| }
|
| @@ -1394,7 +1396,6 @@ bool AutofillDialogViews::ValidateGroup(
|
| AutofillDialogController::ValidationType validation_type) {
|
| DCHECK(group->container->visible());
|
|
|
| - scoped_ptr<DetailInput> cvc_input;
|
| DetailOutputMap detail_outputs;
|
| std::map<AutofillFieldType, base::Callback<void(bool)> > field_map;
|
|
|
| @@ -1402,9 +1403,8 @@ bool AutofillDialogViews::ValidateGroup(
|
| for (TextfieldMap::iterator iter = group->textfields.begin();
|
| iter != group->textfields.end(); ++iter) {
|
| detail_outputs[iter->first] = iter->second->textfield()->text();
|
| - field_map[iter->first->type] =
|
| - base::Bind(&DecoratedTextfield::SetInvalid,
|
| - base::Unretained(iter->second));
|
| + field_map[iter->first] = base::Bind(&DecoratedTextfield::SetInvalid,
|
| + base::Unretained(iter->second));
|
| }
|
| for (ComboboxMap::iterator iter = group->comboboxes.begin();
|
| iter != group->comboboxes.end(); ++iter) {
|
| @@ -1412,19 +1412,16 @@ bool AutofillDialogViews::ValidateGroup(
|
| string16 item =
|
| combobox->model()->GetItemAt(combobox->selected_index());
|
| detail_outputs[iter->first] = item;
|
| - field_map[iter->first->type] =
|
| - base::Bind(&views::Combobox::SetInvalid,
|
| - base::Unretained(iter->second));
|
| + field_map[iter->first] = base::Bind(&views::Combobox::SetInvalid,
|
| + base::Unretained(iter->second));
|
| }
|
| } else if (group->section == SECTION_CC) {
|
| DecoratedTextfield* decorated_cvc =
|
| group->suggested_info->decorated_textfield();
|
| - cvc_input.reset(new DetailInput);
|
| - cvc_input->type = CREDIT_CARD_VERIFICATION_CODE;
|
| - detail_outputs[cvc_input.get()] = decorated_cvc->textfield()->text();
|
| - field_map[cvc_input->type] =
|
| - base::Bind(&DecoratedTextfield::SetInvalid,
|
| - base::Unretained(decorated_cvc));
|
| + detail_outputs[CREDIT_CARD_VERIFICATION_CODE] =
|
| + decorated_cvc->textfield()->text();
|
| + field_map[CREDIT_CARD_VERIFICATION_CODE] = base::Bind(
|
| + &DecoratedTextfield::SetInvalid, base::Unretained(decorated_cvc));
|
| }
|
|
|
| std::vector<AutofillFieldType> invalid_inputs;
|
| @@ -1478,12 +1475,13 @@ void AutofillDialogViews::TextfieldEditedOrActivated(
|
| ++iter) {
|
| decorated = iter->second;
|
| if (decorated == ancestor) {
|
| - controller_->UserEditedOrActivatedInput(iter->first,
|
| + controller_->UserEditedOrActivatedInput(group->section,
|
| + iter->first,
|
| GetWidget()->GetNativeView(),
|
| textfield->GetBoundsInScreen(),
|
| textfield->text(),
|
| was_edit);
|
| - type = iter->first->type;
|
| + type = iter->first;
|
| break;
|
| }
|
| }
|
| @@ -1553,25 +1551,24 @@ AutofillDialogViews::DetailsGroup* AutofillDialogViews::GroupForView(
|
| }
|
|
|
| views::Textfield* AutofillDialogViews::TextfieldForInput(
|
| - const DetailInput& input) {
|
| - for (DetailGroupMap::iterator iter = detail_groups_.begin();
|
| - iter != detail_groups_.end(); ++iter) {
|
| - const DetailsGroup& group = iter->second;
|
| - TextfieldMap::const_iterator text_mapping = group.textfields.find(&input);
|
| - if (text_mapping != group.textfields.end())
|
| + DialogSection section,
|
| + AutofillFieldType type) {
|
| + DetailsGroup* group = GroupForSection(section);
|
| + if (group) {
|
| + TextfieldMap::const_iterator text_mapping = group->textfields.find(type);
|
| + if (text_mapping != group->textfields.end())
|
| return text_mapping->second->textfield();
|
| }
|
|
|
| return NULL;
|
| }
|
|
|
| -views::Combobox* AutofillDialogViews::ComboboxForInput(
|
| - const DetailInput& input) {
|
| - for (DetailGroupMap::iterator iter = detail_groups_.begin();
|
| - iter != detail_groups_.end(); ++iter) {
|
| - const DetailsGroup& group = iter->second;
|
| - ComboboxMap::const_iterator combo_mapping = group.comboboxes.find(&input);
|
| - if (combo_mapping != group.comboboxes.end())
|
| +views::Combobox* AutofillDialogViews::ComboboxForInput(DialogSection section,
|
| + AutofillFieldType type) {
|
| + DetailsGroup* group = GroupForSection(section);
|
| + if (group) {
|
| + ComboboxMap::const_iterator combo_mapping = group->comboboxes.find(type);
|
| + if (combo_mapping != group->comboboxes.end())
|
| return combo_mapping->second;
|
| }
|
|
|
|
|