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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_dialog_views.cc

Issue 11636040: AutofillPopupController clarifications + simplifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ilya review Created 7 years, 12 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" 10 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 AutofillDialogViews::~AutofillDialogViews() { 86 AutofillDialogViews::~AutofillDialogViews() {
87 DCHECK(!window_); 87 DCHECK(!window_);
88 } 88 }
89 89
90 void AutofillDialogViews::Show() { 90 void AutofillDialogViews::Show() {
91 InitChildViews(); 91 InitChildViews();
92 92
93 // Ownership of |contents_| is handed off by this call. The ConstrainedWindow 93 // Ownership of |contents_| is handed off by this call. The ConstrainedWindow
94 // will take care of deleting itself after calling DeleteDelegate(). 94 // will take care of deleting itself after calling DeleteDelegate().
95 window_ = new ConstrainedWindowViews(controller_->web_contents(), this); 95 window_ = new ConstrainedWindowViews(controller_->web_contents(), this);
96 window_->GetFocusManager()->AddFocusChangeListener(this);
Ilya Sherman 2012/12/20 21:57:42 This diff is not part of this CL.
Evan Stade 2012/12/20 23:04:00 please ignore the parts that are part of my previo
97 }
98
99 void AutofillDialogViews::UpdateSection(DialogSection section) {
100 const DetailInputs& updated_inputs =
101 controller_->RequestedFieldsForSection(section);
102 DetailsGroup* group = GroupForSection(section);
103
104 for (DetailInputs::const_iterator iter = updated_inputs.begin();
105 iter != updated_inputs.end(); ++iter) {
106 TextfieldMap::iterator input = group->textfields.find(&(*iter));
107 if (input == group->textfields.end())
108 continue;
109
110 input->second->SetText(iter->autofilled_value);
111 }
96 } 112 }
97 113
98 int AutofillDialogViews::GetSuggestionSelection(DialogSection section) { 114 int AutofillDialogViews::GetSuggestionSelection(DialogSection section) {
99 return GroupForSection(section)->suggested_input->selected_index(); 115 return GroupForSection(section)->suggested_input->selected_index();
100 } 116 }
101 117
102 void AutofillDialogViews::GetUserInput(DialogSection section, 118 void AutofillDialogViews::GetUserInput(DialogSection section,
103 DetailOutputMap* output) { 119 DetailOutputMap* output) {
104 DetailsGroup* group = GroupForSection(section); 120 DetailsGroup* group = GroupForSection(section);
105 for (TextfieldMap::iterator it = group->textfields.begin(); 121 for (TextfieldMap::iterator it = group->textfields.begin();
(...skipping 10 matching lines...) Expand all
116 } 132 }
117 133
118 bool AutofillDialogViews::UseBillingForShipping() { 134 bool AutofillDialogViews::UseBillingForShipping() {
119 return use_billing_for_shipping_->checked(); 135 return use_billing_for_shipping_->checked();
120 } 136 }
121 137
122 string16 AutofillDialogViews::GetWindowTitle() const { 138 string16 AutofillDialogViews::GetWindowTitle() const {
123 return controller_->DialogTitle(); 139 return controller_->DialogTitle();
124 } 140 }
125 141
142 void AutofillDialogViews::WindowClosing() {
143 window_->GetFocusManager()->RemoveFocusChangeListener(this);
144 }
145
126 void AutofillDialogViews::DeleteDelegate() { 146 void AutofillDialogViews::DeleteDelegate() {
127 window_ = NULL; 147 window_ = NULL;
128 // |this| belongs to |controller_|. 148 // |this| belongs to |controller_|.
129 controller_->ViewClosed(did_submit_ ? ACTION_SUBMIT : ACTION_ABORT); 149 controller_->ViewClosed(did_submit_ ? ACTION_SUBMIT : ACTION_ABORT);
130 } 150 }
131 151
132 views::Widget* AutofillDialogViews::GetWidget() { 152 views::Widget* AutofillDialogViews::GetWidget() {
133 return contents_->GetWidget(); 153 return contents_->GetWidget();
134 } 154 }
135 155
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 DetailsGroup* group = 192 DetailsGroup* group =
173 combobox == email_.suggested_input ? &email_ : 193 combobox == email_.suggested_input ? &email_ :
174 combobox == cc_.suggested_input ? &cc_ : 194 combobox == cc_.suggested_input ? &cc_ :
175 combobox == billing_.suggested_input ? &billing_ : 195 combobox == billing_.suggested_input ? &billing_ :
176 combobox == shipping_.suggested_input ? &shipping_ : NULL; 196 combobox == shipping_.suggested_input ? &shipping_ : NULL;
177 DCHECK(group); 197 DCHECK(group);
178 UpdateDetailsGroupState(*group); 198 UpdateDetailsGroupState(*group);
179 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize()); 199 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
180 } 200 }
181 201
202 void AutofillDialogViews::ContentsChanged(views::Textfield* sender,
203 const string16& new_contents) {
204 // TODO(estade): work for not billing.
205 for (TextfieldMap::iterator iter = billing_.textfields.begin();
206 iter != billing_.textfields.end();
207 ++iter) {
208 if (iter->second == sender) {
209 controller_->UserEditedInput(iter->first,
210 GetWidget()->GetNativeView(),
211 sender->GetBoundsInScreen(),
212 new_contents);
213 break;
214 }
215 }
216 }
217
218 bool AutofillDialogViews::HandleKeyEvent(views::Textfield* sender,
219 const ui::KeyEvent& key_event) {
220 // TODO(estade): implement.
221 return false;
222 }
223
224 void AutofillDialogViews::OnWillChangeFocus(
225 views::View* focused_before,
226 views::View* focused_now) {
227 controller_->FocusMoved();
228 }
229
230 void AutofillDialogViews::OnDidChangeFocus(
231 views::View* focused_before,
232 views::View* focused_now) {}
233
182 void AutofillDialogViews::InitChildViews() { 234 void AutofillDialogViews::InitChildViews() {
183 contents_ = new views::View(); 235 contents_ = new views::View();
184 views::GridLayout* layout = new views::GridLayout(contents_); 236 views::GridLayout* layout = new views::GridLayout(contents_);
185 contents_->SetLayoutManager(layout); 237 contents_->SetLayoutManager(layout);
186 238
187 const int single_column_set = 0; 239 const int single_column_set = 0;
188 views::ColumnSet* column_set = layout->AddColumnSet(single_column_set); 240 views::ColumnSet* column_set = layout->AddColumnSet(single_column_set);
189 column_set->AddColumn(views::GridLayout::FILL, 241 column_set->AddColumn(views::GridLayout::FILL,
190 views::GridLayout::FILL, 242 views::GridLayout::FILL,
191 1, 243 1,
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 417
366 ui::ComboboxModel* input_model = 418 ui::ComboboxModel* input_model =
367 controller_->ComboboxModelForAutofillType(input.type); 419 controller_->ComboboxModelForAutofillType(input.type);
368 // TODO(estade): TextFields and Comboboxes need to be the same height. 420 // TODO(estade): TextFields and Comboboxes need to be the same height.
369 if (input_model) { 421 if (input_model) {
370 views::Combobox* combobox = new views::Combobox(input_model); 422 views::Combobox* combobox = new views::Combobox(input_model);
371 comboboxes->insert(std::make_pair(&input, combobox)); 423 comboboxes->insert(std::make_pair(&input, combobox));
372 layout->AddView(combobox); 424 layout->AddView(combobox);
373 425
374 for (int i = 0; i < input_model->GetItemCount(); ++i) { 426 for (int i = 0; i < input_model->GetItemCount(); ++i) {
375 if (input.starting_value == input_model->GetItemAt(i)) { 427 if (input.autofilled_value == input_model->GetItemAt(i)) {
376 combobox->SetSelectedIndex(i); 428 combobox->SetSelectedIndex(i);
377 break; 429 break;
378 } 430 }
379 } 431 }
380 } else { 432 } else {
381 views::Textfield* field = new views::Textfield(); 433 views::Textfield* field = new views::Textfield();
382 field->set_placeholder_text(ASCIIToUTF16(input.placeholder_text)); 434 field->set_placeholder_text(ASCIIToUTF16(input.placeholder_text));
383 field->SetText(input.starting_value); 435 field->SetText(input.autofilled_value);
436 field->SetController(this);
384 textfields->insert(std::make_pair(&input, field)); 437 textfields->insert(std::make_pair(&input, field));
385 layout->AddView(field); 438 layout->AddView(field);
386 } 439 }
387 } 440 }
388 441
389 return view; 442 return view;
390 } 443 }
391 444
392 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { 445 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) {
393 views::Combobox* combobox = group.suggested_input; 446 views::Combobox* combobox = group.suggested_input;
(...skipping 23 matching lines...) Expand all
417 } 470 }
418 471
419 AutofillDialogViews::DetailsGroup::DetailsGroup() 472 AutofillDialogViews::DetailsGroup::DetailsGroup()
420 : container(NULL), 473 : container(NULL),
421 suggested_input(NULL), 474 suggested_input(NULL),
422 manual_input(NULL) {} 475 manual_input(NULL) {}
423 476
424 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 477 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
425 478
426 } // namespace autofill 479 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698