Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: chrome/browser/ui/views/autofill/autofill_dialog_views.cc

Issue 63053003: Ask libaddressinput for address components to use in requestAutocomplete(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: let's try this again, android Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..90f5024296e8833918bc8c09095f867dc238b38d 100644
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
@@ -1150,6 +1150,7 @@ AutofillDialogViews::AutofillDialogViews(AutofillDialogViewDelegate* delegate)
: delegate_(delegate),
updates_scope_(0),
needs_update_(false),
+ details_container_needs_layout_(false),
window_(NULL),
notification_area_(NULL),
account_chooser_(NULL),
@@ -1534,9 +1535,10 @@ void AutofillDialogViews::Layout() {
DCHECK_EQ(scrollable_area_->contents(), details_container_);
details_container_->SizeToPreferredSize();
// TODO(estade): remove this hack. See crbug.com/285996
- details_container_->set_ignore_layouts(true);
+ details_container_->set_ignore_layouts(!details_container_needs_layout_);
Evan Stade 2013/12/02 17:57:33 instead of this, explicitly call layout on the con
Dan Beam 2013/12/02 22:37:54 Done.
scrollable_area_->SetBounds(x, scroll_y, width, scroll_bottom - scroll_y);
details_container_->set_ignore_layouts(false);
+ details_container_needs_layout_ = false;
}
if (error_bubble_)
@@ -1740,9 +1742,11 @@ 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(combobox->model(), section, index);
+ ValidateGroup(*GroupForSection(section), VALIDATE_EDIT);
+ SetEditabilityForSection(section);
}
void AutofillDialogViews::StyledLabelLinkClicked(const gfx::Range& range,
@@ -1900,6 +1904,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));
@@ -1915,8 +1920,8 @@ 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),
@@ -1951,14 +1956,17 @@ views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) {
// 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;
+ textfields->clear();
+
ComboboxMap* comboboxes = &GroupForSection(section)->comboboxes;
+ comboboxes->clear();
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;
@@ -1972,11 +1980,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);
}
@@ -2034,19 +2040,25 @@ 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) {
Evan Stade 2013/12/02 17:57:33 will the rest of the address get clobbered if you
Dan Beam 2013/12/02 22:37:54 it's preserved by the same mechanism as changing a
+ views::View* parent = group->manual_input->parent();
+ int add_index = parent->GetIndexOf(group->manual_input);
+ parent->RemoveChildView(group->manual_input);
Evan Stade 2013/12/02 17:57:33 I believe you're leaking group->manual_input. Any
Dan Beam 2013/12/02 22:37:54 you're right, this was hiding a segfault that i've
+ group->manual_input = InitInputsView(section);
+ parent->AddChildViewAt(group->manual_input, add_index);
+ details_container_needs_layout_ = true;
+ }
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 +2193,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

Powered by Google App Engine
This is Rietveld 408576698