| 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 15e9a028867d27f88d00753024ab04bbd2f70fcb..41f97de3d5af898d7a60dcfc4d3b495c9375ce1d 100644
|
| --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
|
| +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
|
| @@ -1533,6 +1533,7 @@ void AutofillDialogViews::Layout() {
|
| int scroll_bottom = content_bounds.bottom();
|
| DCHECK_EQ(scrollable_area_->contents(), details_container_);
|
| details_container_->SizeToPreferredSize();
|
| + details_container_->Layout();
|
| // TODO(estade): remove this hack. See crbug.com/285996
|
| details_container_->set_ignore_layouts(true);
|
| scrollable_area_->SetBounds(x, scroll_y, width, scroll_bottom - scroll_y);
|
| @@ -1740,9 +1741,14 @@ void AutofillDialogViews::OnDidChangeFocus(
|
| }
|
|
|
| void AutofillDialogViews::OnSelectedIndexChanged(views::Combobox* combobox) {
|
| - DetailsGroup* group = GroupForView(combobox);
|
| - ValidateGroup(*group, VALIDATE_EDIT);
|
| - SetEditabilityForSection(group->section);
|
| + DialogSection section = GroupForView(combobox)->section;
|
| +
|
| + int index = combobox->selected_index();
|
| + delegate_->ComboboxItemSelected(TypeForCombobox(combobox), index);
|
| + // NOTE: |combobox| may have been deleted.
|
| +
|
| + ValidateGroup(*GroupForSection(section), VALIDATE_EDIT);
|
| + SetEditabilityForSection(section);
|
| }
|
|
|
| void AutofillDialogViews::StyledLabelLinkClicked(const gfx::Range& range,
|
| @@ -1900,6 +1906,7 @@ views::View* AutofillDialogViews::CreateDetailsContainer() {
|
| details_container_ = new DetailsContainerView(
|
| base::Bind(&AutofillDialogViews::DetailsContainerBoundsChanged,
|
| base::Unretained(this)));
|
| +
|
| // A box layout is used because it respects widget visibility.
|
| details_container_->SetLayoutManager(
|
| new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
|
| @@ -1913,15 +1920,11 @@ views::View* AutofillDialogViews::CreateDetailsContainer() {
|
| }
|
|
|
| void AutofillDialogViews::CreateDetailsSection(DialogSection section) {
|
| - // Inputs container (manual inputs + combobox).
|
| - views::View* inputs_container = CreateInputsContainer(section);
|
| -
|
| DetailsGroup* group = GroupForSection(section);
|
| // Container (holds label + inputs).
|
| - group->container = new SectionContainer(
|
| - delegate_->LabelForSection(section),
|
| - inputs_container,
|
| - group->suggested_button);
|
| + group->container = new SectionContainer(delegate_->LabelForSection(section),
|
| + CreateInputsContainer(section),
|
| + group->suggested_button);
|
| DCHECK(group->suggested_button->parent());
|
| UpdateDetailsGroupState(*group);
|
| }
|
| @@ -1933,35 +1936,42 @@ views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) {
|
| info_view->SetLayoutManager(
|
| new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
|
|
|
| - views::View* manual_inputs = InitInputsView(section);
|
| - info_view->AddChildView(manual_inputs);
|
| - SuggestionView* suggested_info = new SuggestionView(this);
|
| - info_view->AddChildView(suggested_info);
|
| -
|
| DetailsGroup* group = GroupForSection(section);
|
| + group->manual_input = new views::View();
|
| + InitInputsView(section);
|
| + info_view->AddChildView(group->manual_input);
|
| +
|
| + group->suggested_info = new SuggestionView(this);
|
| + info_view->AddChildView(group->suggested_info);
|
| +
|
| // TODO(estade): It might be slightly more OO if this button were created
|
| // and listened to by the section container.
|
| group->suggested_button = new SuggestedButton(this);
|
| - group->manual_input = manual_inputs;
|
| - group->suggested_info = suggested_info;
|
|
|
| return info_view;
|
| }
|
|
|
| // TODO(estade): we should be using Chrome-style constrained window padding
|
| // values.
|
| -views::View* AutofillDialogViews::InitInputsView(DialogSection section) {
|
| - const DetailInputs& inputs = delegate_->RequestedFieldsForSection(section);
|
| - TextfieldMap* textfields = &GroupForSection(section)->textfields;
|
| - ComboboxMap* comboboxes = &GroupForSection(section)->comboboxes;
|
| +void AutofillDialogViews::InitInputsView(DialogSection section) {
|
| + DetailsGroup* group = GroupForSection(section);
|
| + TextfieldMap* textfields = &group->textfields;
|
| + textfields->clear();
|
| +
|
| + ComboboxMap* comboboxes = &group->comboboxes;
|
| + comboboxes->clear();
|
| +
|
| + views::View* view = group->manual_input;
|
| + view->RemoveAllChildViews(true);
|
|
|
| - views::View* view = new views::View();
|
| views::GridLayout* layout = new views::GridLayout(view);
|
| view->SetLayoutManager(layout);
|
|
|
| + const DetailInputs& inputs = delegate_->RequestedFieldsForSection(section);
|
| for (DetailInputs::const_iterator it = inputs.begin();
|
| it != inputs.end(); ++it) {
|
| const DetailInput& input = *it;
|
| +
|
| ui::ComboboxModel* input_model =
|
| delegate_->ComboboxModelForAutofillType(input.type);
|
| scoped_ptr<views::View> view_to_add;
|
| @@ -1972,11 +1982,9 @@ views::View* AutofillDialogViews::InitInputsView(DialogSection section) {
|
| SelectComboboxValueOrSetToDefault(combobox, input.initial_value);
|
| view_to_add.reset(combobox);
|
| } else {
|
| - DecoratedTextfield* field = new DecoratedTextfield(
|
| - input.initial_value,
|
| - l10n_util::GetStringUTF16(input.placeholder_text_rid),
|
| - this);
|
| -
|
| + DecoratedTextfield* field = new DecoratedTextfield(input.initial_value,
|
| + input.placeholder_text,
|
| + this);
|
| textfields->insert(std::make_pair(input.type, field));
|
| view_to_add.reset(field);
|
| }
|
| @@ -2019,8 +2027,6 @@ views::View* AutofillDialogViews::InitInputsView(DialogSection section) {
|
| }
|
|
|
| SetIconsForSection(section);
|
| -
|
| - return view;
|
| }
|
|
|
| void AutofillDialogViews::ShowDialogInMode(DialogMode dialog_mode) {
|
| @@ -2034,19 +2040,21 @@ void AutofillDialogViews::ShowDialogInMode(DialogMode dialog_mode) {
|
| void AutofillDialogViews::UpdateSectionImpl(
|
| DialogSection section,
|
| bool clobber_inputs) {
|
| - // Reset all validity marks for this section.
|
| - if (clobber_inputs)
|
| - MarkInputsInvalid(section, ValidityMessages(), true);
|
| + DetailsGroup* group = GroupForSection(section);
|
| +
|
| + if (clobber_inputs) {
|
| + InitInputsView(section);
|
| + details_container_->Layout();
|
| + }
|
|
|
| const DetailInputs& updated_inputs =
|
| delegate_->RequestedFieldsForSection(section);
|
| - DetailsGroup* group = GroupForSection(section);
|
|
|
| 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.type);
|
|
|
| + TextfieldMap::iterator text_mapping = group->textfields.find(input.type);
|
| if (text_mapping != group->textfields.end()) {
|
| DecoratedTextfield* decorated = text_mapping->second;
|
| if (decorated->text().empty() || clobber_inputs)
|
| @@ -2181,7 +2189,6 @@ void AutofillDialogViews::MarkInputsInvalid(
|
| // Purge invisible views from |validity_map_|.
|
| std::map<views::View*, base::string16>::iterator it;
|
| for (it = validity_map_.begin(); it != validity_map_.end();) {
|
| - DCHECK(GroupForView(it->first));
|
| if (GroupForView(it->first) == group)
|
| validity_map_.erase(it++);
|
| else
|
| @@ -2396,6 +2403,21 @@ views::Combobox* AutofillDialogViews::ComboboxForInput(
|
| return NULL;
|
| }
|
|
|
| +ServerFieldType AutofillDialogViews::TypeForCombobox(
|
| + const views::Combobox* combobox) const {
|
| + for (DetailGroupMap::const_iterator it = detail_groups_.begin();
|
| + it != detail_groups_.end(); ++it) {
|
| + const DetailsGroup& group = it->second;
|
| + for (ComboboxMap::const_iterator combo_it = group.comboboxes.begin();
|
| + combo_it != group.comboboxes.end(); ++combo_it) {
|
| + if (combo_it->second == combobox)
|
| + return combo_it->first;
|
| + }
|
| + }
|
| + NOTREACHED();
|
| + return UNKNOWN_TYPE;
|
| +}
|
| +
|
| void AutofillDialogViews::DetailsContainerBoundsChanged() {
|
| if (error_bubble_)
|
| error_bubble_->UpdatePosition();
|
|
|