Chromium Code Reviews| 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 532553a8ebfe9fad3520ffab62cab692ca9c9b59..5cb0c625e788406465544cb02bc9c9097ef9cee2 100644 |
| --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc |
| +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc |
| @@ -1933,10 +1933,6 @@ views::View* AutofillDialogViews::InitInputsView(DialogSection section) { |
| l10n_util::GetStringUTF16(input.placeholder_text_rid), |
| this); |
| - gfx::Image icon = |
| - delegate_->IconForField(input.type, input.initial_value); |
| - field->SetIcon(icon); |
| - |
| textfields->insert(std::make_pair(&input, field)); |
| view_to_add.reset(field); |
| } |
| @@ -1978,6 +1974,8 @@ views::View* AutofillDialogViews::InitInputsView(DialogSection section) { |
| 1, 0); |
| } |
| + SetIconsForSection(section); |
| + |
| return view; |
| } |
| @@ -1996,11 +1994,8 @@ void AutofillDialogViews::UpdateSectionImpl( |
| if (text_mapping != group->textfields.end()) { |
| DecoratedTextfield* decorated = text_mapping->second; |
| decorated->SetEnabled(input.editable); |
| - if (decorated->text().empty() || clobber_inputs) { |
| + if (decorated->text().empty() || clobber_inputs) |
| decorated->SetText(iter->initial_value); |
| - decorated->SetIcon( |
| - delegate_->IconForField(input.type, decorated->text())); |
| - } |
| } |
| ComboboxMap::iterator combo_mapping = group->comboboxes.find(&input); |
| @@ -2019,6 +2014,7 @@ void AutofillDialogViews::UpdateSectionImpl( |
| } |
| } |
| + SetIconsForSection(section); |
| UpdateDetailsGroupState(*group); |
| } |
| @@ -2237,7 +2233,7 @@ void AutofillDialogViews::TextfieldEditedOrActivated( |
| SetValidityForInput<DecoratedTextfield>( |
| decorated, |
| delegate_->InputValidityMessage(group->section, type, |
| - textfield->text())); |
| + textfield->text())); |
| // If the field transitioned from invalid to valid, re-validate the group, |
| // since inter-field checks become meaningful with valid fields. |
| @@ -2245,8 +2241,8 @@ void AutofillDialogViews::TextfieldEditedOrActivated( |
| ValidateGroup(*group, VALIDATE_EDIT); |
| } |
| - gfx::Image icon = delegate_->IconForField(type, textfield->text()); |
| - decorated->SetIcon(icon); |
| + if (delegate_->FieldControlsIcons(type)) |
| + SetIconsForSection(group->section); |
| } |
| void AutofillDialogViews::UpdateButtonStripExtraView() { |
| @@ -2339,6 +2335,30 @@ bool AutofillDialogViews::SignInWebviewDictatesHeight() const { |
| (sign_in_webview_->web_contents() && delegate_->ShouldShowSpinner()); |
| } |
| +void AutofillDialogViews::SetIconsForSection(DialogSection section) { |
| + FieldValueMap field_values; |
| + TextfieldMap* textfields = &GroupForSection(section)->textfields; |
| + for (TextfieldMap::const_iterator textfield_it = textfields->begin(); |
| + textfield_it != textfields->end(); |
| + ++textfield_it) { |
| + ServerFieldType field_type = textfield_it->first->type; |
| + const string16& field_value = textfield_it->second->text(); |
| + field_values[field_type] = field_value; |
|
Evan Stade
2013/09/16 23:36:59
I think you can reuse GetUserInput
please use gerrit instead
2013/09/17 00:38:17
Done.
|
| + } |
| + FieldIconMap field_icons = delegate_->IconsForFields(field_values); |
| + for (TextfieldMap::const_iterator textfield_it = textfields->begin(); |
| + textfield_it != textfields->end(); |
| + ++textfield_it) { |
| + ServerFieldType field_type = textfield_it->first->type; |
| + FieldIconMap::const_iterator field_icon_it = field_icons.find(field_type); |
|
Evan Stade
2013/09/16 23:36:59
since the icon map is smaller than the textfield m
please use gerrit instead
2013/09/17 00:38:17
That wouldn't be efficient because the icon map ha
Evan Stade
2013/09/17 00:52:45
Well, for the numbers we're talking about, it's ac
please use gerrit instead
2013/09/17 17:25:04
I enabled going from an icon to no icon. Now the c
|
| + if (field_icon_it == field_icons.end()) |
| + continue; |
| + const gfx::Image& field_icon = field_icon_it->second; |
| + DecoratedTextfield* textfield = textfield_it->second; |
| + textfield->SetIcon(field_icon); |
| + } |
| +} |
| + |
| AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
| : section(section), |
| container(NULL), |