| OLD | NEW |
| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 it != group->comboboxes.end(); ++it) { | 1333 it != group->comboboxes.end(); ++it) { |
| 1334 if (AutofillType(it->first->type).group() == CREDIT_CARD) | 1334 if (AutofillType(it->first->type).group() == CREDIT_CARD) |
| 1335 it->second->SetSelectedIndex(it->second->model()->GetDefaultIndex()); | 1335 it->second->SetSelectedIndex(it->second->model()->GetDefaultIndex()); |
| 1336 } | 1336 } |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 UpdateSectionImpl(section, false); | 1339 UpdateSectionImpl(section, false); |
| 1340 } | 1340 } |
| 1341 | 1341 |
| 1342 void AutofillDialogViews::GetUserInput(DialogSection section, | 1342 void AutofillDialogViews::GetUserInput(DialogSection section, |
| 1343 DetailOutputMap* output) { | 1343 FieldValueMap* output) { |
| 1344 DetailsGroup* group = GroupForSection(section); | 1344 DetailsGroup* group = GroupForSection(section); |
| 1345 for (TextfieldMap::const_iterator it = group->textfields.begin(); | 1345 for (TextfieldMap::const_iterator it = group->textfields.begin(); |
| 1346 it != group->textfields.end(); ++it) { | 1346 it != group->textfields.end(); ++it) { |
| 1347 output->insert(std::make_pair(it->first, it->second->text())); | 1347 output->insert(std::make_pair(it->first->type, it->second->text())); |
| 1348 } | 1348 } |
| 1349 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); | 1349 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); |
| 1350 it != group->comboboxes.end(); ++it) { | 1350 it != group->comboboxes.end(); ++it) { |
| 1351 output->insert(std::make_pair(it->first, | 1351 output->insert(std::make_pair(it->first->type, |
| 1352 it->second->model()->GetItemAt(it->second->selected_index()))); | 1352 it->second->model()->GetItemAt(it->second->selected_index()))); |
| 1353 } | 1353 } |
| 1354 } | 1354 } |
| 1355 | 1355 |
| 1356 base::string16 AutofillDialogViews::GetCvc() { | 1356 base::string16 AutofillDialogViews::GetCvc() { |
| 1357 return GroupForSection(GetCreditCardSection())->suggested_info-> | 1357 return GroupForSection(GetCreditCardSection())->suggested_info-> |
| 1358 decorated_textfield()->text(); | 1358 decorated_textfield()->text(); |
| 1359 } | 1359 } |
| 1360 | 1360 |
| 1361 bool AutofillDialogViews::HitTestInput(const DetailInput& input, | 1361 bool AutofillDialogViews::HitTestInput(const DetailInput& input, |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2191 } | 2191 } |
| 2192 } | 2192 } |
| 2193 } | 2193 } |
| 2194 } | 2194 } |
| 2195 | 2195 |
| 2196 bool AutofillDialogViews::ValidateGroup(const DetailsGroup& group, | 2196 bool AutofillDialogViews::ValidateGroup(const DetailsGroup& group, |
| 2197 ValidationType validation_type) { | 2197 ValidationType validation_type) { |
| 2198 DCHECK(group.container->visible()); | 2198 DCHECK(group.container->visible()); |
| 2199 | 2199 |
| 2200 scoped_ptr<DetailInput> cvc_input; | 2200 scoped_ptr<DetailInput> cvc_input; |
| 2201 DetailOutputMap detail_outputs; | 2201 FieldValueMap detail_outputs; |
| 2202 | 2202 |
| 2203 if (group.manual_input->visible()) { | 2203 if (group.manual_input->visible()) { |
| 2204 for (TextfieldMap::const_iterator iter = group.textfields.begin(); | 2204 for (TextfieldMap::const_iterator iter = group.textfields.begin(); |
| 2205 iter != group.textfields.end(); ++iter) { | 2205 iter != group.textfields.end(); ++iter) { |
| 2206 if (!iter->second->editable()) | 2206 if (!iter->second->editable()) |
| 2207 continue; | 2207 continue; |
| 2208 | 2208 |
| 2209 detail_outputs[iter->first] = iter->second->text(); | 2209 detail_outputs[iter->first->type] = iter->second->text(); |
| 2210 } | 2210 } |
| 2211 for (ComboboxMap::const_iterator iter = group.comboboxes.begin(); | 2211 for (ComboboxMap::const_iterator iter = group.comboboxes.begin(); |
| 2212 iter != group.comboboxes.end(); ++iter) { | 2212 iter != group.comboboxes.end(); ++iter) { |
| 2213 if (!iter->second->enabled()) | 2213 if (!iter->second->enabled()) |
| 2214 continue; | 2214 continue; |
| 2215 | 2215 |
| 2216 views::Combobox* combobox = iter->second; | 2216 views::Combobox* combobox = iter->second; |
| 2217 base::string16 item = | 2217 base::string16 item = |
| 2218 combobox->model()->GetItemAt(combobox->selected_index()); | 2218 combobox->model()->GetItemAt(combobox->selected_index()); |
| 2219 detail_outputs[iter->first] = item; | 2219 detail_outputs[iter->first->type] = item; |
| 2220 } | 2220 } |
| 2221 } else if (group.section == GetCreditCardSection()) { | 2221 } else if (group.section == GetCreditCardSection()) { |
| 2222 DecoratedTextfield* decorated_cvc = | 2222 DecoratedTextfield* decorated_cvc = |
| 2223 group.suggested_info->decorated_textfield(); | 2223 group.suggested_info->decorated_textfield(); |
| 2224 if (decorated_cvc->visible()) { | 2224 if (decorated_cvc->visible()) { |
| 2225 cvc_input.reset(new DetailInput); | 2225 cvc_input.reset(new DetailInput); |
| 2226 cvc_input->type = CREDIT_CARD_VERIFICATION_CODE; | 2226 cvc_input->type = CREDIT_CARD_VERIFICATION_CODE; |
| 2227 detail_outputs[cvc_input.get()] = decorated_cvc->text(); | 2227 detail_outputs[cvc_input->type] = decorated_cvc->text(); |
| 2228 } | 2228 } |
| 2229 } | 2229 } |
| 2230 | 2230 |
| 2231 ValidityMessages validity = delegate_->InputsAreValid(group.section, | 2231 ValidityMessages validity = delegate_->InputsAreValid(group.section, |
| 2232 detail_outputs); | 2232 detail_outputs); |
| 2233 MarkInputsInvalid(group.section, validity, validation_type == VALIDATE_FINAL); | 2233 MarkInputsInvalid(group.section, validity, validation_type == VALIDATE_FINAL); |
| 2234 | 2234 |
| 2235 // If there are any validation errors, sure or unsure, the group is invalid. | 2235 // If there are any validation errors, sure or unsure, the group is invalid. |
| 2236 return !validity.HasErrors(); | 2236 return !validity.HasErrors(); |
| 2237 } | 2237 } |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2390 | 2390 |
| 2391 return NULL; | 2391 return NULL; |
| 2392 } | 2392 } |
| 2393 | 2393 |
| 2394 void AutofillDialogViews::DetailsContainerBoundsChanged() { | 2394 void AutofillDialogViews::DetailsContainerBoundsChanged() { |
| 2395 if (error_bubble_) | 2395 if (error_bubble_) |
| 2396 error_bubble_->UpdatePosition(); | 2396 error_bubble_->UpdatePosition(); |
| 2397 } | 2397 } |
| 2398 | 2398 |
| 2399 void AutofillDialogViews::SetIconsForSection(DialogSection section) { | 2399 void AutofillDialogViews::SetIconsForSection(DialogSection section) { |
| 2400 DetailOutputMap user_input; | 2400 FieldValueMap user_input; |
| 2401 GetUserInput(section, &user_input); | 2401 GetUserInput(section, &user_input); |
| 2402 FieldValueMap field_values; | 2402 FieldIconMap field_icons = delegate_->IconsForFields(user_input); |
| 2403 for (DetailOutputMap::const_iterator user_input_it = user_input.begin(); | |
| 2404 user_input_it != user_input.end(); | |
| 2405 ++user_input_it) { | |
| 2406 const DetailInput* field_detail = user_input_it->first; | |
| 2407 const string16& field_value = user_input_it->second; | |
| 2408 field_values[field_detail->type] = field_value; | |
| 2409 } | |
| 2410 FieldIconMap field_icons = delegate_->IconsForFields(field_values); | |
| 2411 TextfieldMap* textfields = &GroupForSection(section)->textfields; | 2403 TextfieldMap* textfields = &GroupForSection(section)->textfields; |
| 2412 for (TextfieldMap::const_iterator textfield_it = textfields->begin(); | 2404 for (TextfieldMap::const_iterator textfield_it = textfields->begin(); |
| 2413 textfield_it != textfields->end(); | 2405 textfield_it != textfields->end(); |
| 2414 ++textfield_it) { | 2406 ++textfield_it) { |
| 2415 ServerFieldType field_type = textfield_it->first->type; | 2407 ServerFieldType field_type = textfield_it->first->type; |
| 2416 FieldIconMap::const_iterator field_icon_it = field_icons.find(field_type); | 2408 FieldIconMap::const_iterator field_icon_it = field_icons.find(field_type); |
| 2417 DecoratedTextfield* textfield = textfield_it->second; | 2409 DecoratedTextfield* textfield = textfield_it->second; |
| 2418 if (field_icon_it != field_icons.end()) | 2410 if (field_icon_it != field_icons.end()) |
| 2419 textfield->SetIcon(field_icon_it->second); | 2411 textfield->SetIcon(field_icon_it->second); |
| 2420 else | 2412 else |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2450 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2442 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
| 2451 : section(section), | 2443 : section(section), |
| 2452 container(NULL), | 2444 container(NULL), |
| 2453 manual_input(NULL), | 2445 manual_input(NULL), |
| 2454 suggested_info(NULL), | 2446 suggested_info(NULL), |
| 2455 suggested_button(NULL) {} | 2447 suggested_button(NULL) {} |
| 2456 | 2448 |
| 2457 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2449 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
| 2458 | 2450 |
| 2459 } // namespace autofill | 2451 } // namespace autofill |
| OLD | NEW |