| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/autofill_dialog_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 99 } |
| 100 | 100 |
| 101 // Returns true if |input| should be used for a site-requested |field|. | 101 // Returns true if |input| should be used for a site-requested |field|. |
| 102 bool DetailInputMatchesField(const DetailInput& input, | 102 bool DetailInputMatchesField(const DetailInput& input, |
| 103 const AutofillField& field) { | 103 const AutofillField& field) { |
| 104 bool right_section = !input.section_suffix || | 104 bool right_section = !input.section_suffix || |
| 105 EndsWith(field.section(), input.section_suffix, false); | 105 EndsWith(field.section(), input.section_suffix, false); |
| 106 return InputTypeMatchesFieldType(input, field) && right_section; | 106 return InputTypeMatchesFieldType(input, field) && right_section; |
| 107 } | 107 } |
| 108 | 108 |
| 109 bool IsCreditCardType(AutofillFieldType type) { |
| 110 return AutofillType(type).group() == AutofillType::CREDIT_CARD; |
| 111 } |
| 112 |
| 109 // Returns true if |input| should be used to fill a site-requested |field| which | 113 // Returns true if |input| should be used to fill a site-requested |field| which |
| 110 // is notated with a "shipping" tag, for use when the user has decided to use | 114 // is notated with a "shipping" tag, for use when the user has decided to use |
| 111 // the billing address as the shipping address. | 115 // the billing address as the shipping address. |
| 112 bool DetailInputMatchesShippingField(const DetailInput& input, | 116 bool DetailInputMatchesShippingField(const DetailInput& input, |
| 113 const AutofillField& field) { | 117 const AutofillField& field) { |
| 114 if (input.section_suffix && | 118 if (input.section_suffix && |
| 115 std::string(input.section_suffix) == "billing") { | 119 std::string(input.section_suffix) == "billing") { |
| 116 return InputTypeMatchesFieldType(input, field); | 120 return InputTypeMatchesFieldType(input, field); |
| 117 } | 121 } |
| 118 | 122 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 CreditCard* card, | 163 CreditCard* card, |
| 160 string16* cvc, | 164 string16* cvc, |
| 161 AutofillProfile* profile) { | 165 AutofillProfile* profile) { |
| 162 for (DetailOutputMap::const_iterator it = output.begin(); | 166 for (DetailOutputMap::const_iterator it = output.begin(); |
| 163 it != output.end(); ++it) { | 167 it != output.end(); ++it) { |
| 164 string16 trimmed; | 168 string16 trimmed; |
| 165 TrimWhitespace(it->second, TRIM_ALL, &trimmed); | 169 TrimWhitespace(it->second, TRIM_ALL, &trimmed); |
| 166 | 170 |
| 167 // Special case CVC as CreditCard just swallows it. | 171 // Special case CVC as CreditCard just swallows it. |
| 168 if (it->first->type == CREDIT_CARD_VERIFICATION_CODE) { | 172 if (it->first->type == CREDIT_CARD_VERIFICATION_CODE) { |
| 169 *cvc = trimmed; | 173 cvc->assign(trimmed); |
| 170 } else { | 174 } else { |
| 171 // Copy the credit card name to |profile| in addition to |card| as | 175 // Copy the credit card name to |profile| in addition to |card| as |
| 172 // wallet::Instrument requires a recipient name for its billing address. | 176 // wallet::Instrument requires a recipient name for its billing address. |
| 173 if (it->first->type == CREDIT_CARD_NAME) | 177 if (it->first->type == CREDIT_CARD_NAME) |
| 174 profile->SetRawInfo(NAME_FULL, trimmed); | 178 profile->SetRawInfo(NAME_FULL, trimmed); |
| 175 | 179 |
| 176 if (AutofillType(it->first->type).group() == AutofillType::CREDIT_CARD) | 180 if (IsCreditCardType(it->first->type)) |
| 177 card->SetRawInfo(it->first->type, trimmed); | 181 card->SetRawInfo(it->first->type, trimmed); |
| 178 else | 182 else |
| 179 profile->SetRawInfo(it->first->type, trimmed); | 183 profile->SetRawInfo(it->first->type, trimmed); |
| 180 } | 184 } |
| 181 } | 185 } |
| 182 } | 186 } |
| 183 | 187 |
| 184 // Returns the containing window for the given |web_contents|. The containing | 188 // Returns the containing window for the given |web_contents|. The containing |
| 185 // window might be a browser window for a Chrome tab, or it might be a shell | 189 // window might be a browser window for a Chrome tab, or it might be a shell |
| 186 // window for a platform app. | 190 // window for a platform app. |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 | 592 |
| 589 scoped_ptr<DataModelWrapper> AutofillDialogControllerImpl::CreateWrapper( | 593 scoped_ptr<DataModelWrapper> AutofillDialogControllerImpl::CreateWrapper( |
| 590 DialogSection section) { | 594 DialogSection section) { |
| 591 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); | 595 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); |
| 592 std::string item_key = model->GetItemKeyForCheckedItem(); | 596 std::string item_key = model->GetItemKeyForCheckedItem(); |
| 593 scoped_ptr<DataModelWrapper> wrapper; | 597 scoped_ptr<DataModelWrapper> wrapper; |
| 594 if (item_key.empty()) | 598 if (item_key.empty()) |
| 595 return wrapper.Pass(); | 599 return wrapper.Pass(); |
| 596 | 600 |
| 597 if (IsPayingWithWallet()) { | 601 if (IsPayingWithWallet()) { |
| 598 int index; | 602 // Use |full_wallet_| if it exists as it has unmasked data. |
| 599 bool success = base::StringToInt(item_key, &index); | 603 if (full_wallet_.get()) { |
| 600 DCHECK(success); | 604 if (section == SECTION_CC_BILLING) |
| 605 wrapper.reset(new FullWalletBillingWrapper(full_wallet_.get())); |
| 606 else |
| 607 wrapper.reset(new FullWalletShippingWrapper(full_wallet_.get())); |
| 608 } else { |
| 609 int index; |
| 610 bool success = base::StringToInt(item_key, &index); |
| 611 DCHECK(success); |
| 601 | 612 |
| 602 if (section == SECTION_CC_BILLING) { | 613 if (section == SECTION_CC_BILLING) { |
| 603 wrapper.reset( | 614 wrapper.reset( |
| 604 new WalletInstrumentWrapper(wallet_items_->instruments()[index])); | 615 new WalletInstrumentWrapper(wallet_items_->instruments()[index])); |
| 605 } else { | 616 } else { |
| 606 wrapper.reset( | 617 wrapper.reset( |
| 607 new WalletAddressWrapper(wallet_items_->addresses()[index])); | 618 new WalletAddressWrapper(wallet_items_->addresses()[index])); |
| 619 } |
| 608 } | 620 } |
| 609 } else if (section == SECTION_CC) { | 621 } else if (section == SECTION_CC) { |
| 610 CreditCard* card = GetManager()->GetCreditCardByGUID(item_key); | 622 CreditCard* card = GetManager()->GetCreditCardByGUID(item_key); |
| 611 DCHECK(card); | 623 DCHECK(card); |
| 612 wrapper.reset(new AutofillCreditCardWrapper(card)); | 624 wrapper.reset(new AutofillCreditCardWrapper(card)); |
| 613 } else { | 625 } else { |
| 614 // Calculate the variant by looking at how many items come from the same | 626 // Calculate the variant by looking at how many items come from the same |
| 615 // FormGroup. | 627 // FormGroup. |
| 616 size_t variant = 0; | 628 size_t variant = 0; |
| 617 for (int i = model->checked_item() - 1; i >= 0; --i) { | 629 for (int i = model->checked_item() - 1; i >= 0; --i) { |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 GetFullWallet(); | 1075 GetFullWallet(); |
| 1064 else | 1076 else |
| 1065 DisableWallet(); | 1077 DisableWallet(); |
| 1066 } | 1078 } |
| 1067 | 1079 |
| 1068 void AutofillDialogControllerImpl::OnDidGetFullWallet( | 1080 void AutofillDialogControllerImpl::OnDidGetFullWallet( |
| 1069 scoped_ptr<wallet::FullWallet> full_wallet) { | 1081 scoped_ptr<wallet::FullWallet> full_wallet) { |
| 1070 // TODO(dbeam): handle more required actions. | 1082 // TODO(dbeam): handle more required actions. |
| 1071 full_wallet_ = full_wallet.Pass(); | 1083 full_wallet_ = full_wallet.Pass(); |
| 1072 | 1084 |
| 1073 if (!full_wallet_->HasRequiredAction(wallet::VERIFY_CVV)) { | 1085 if (full_wallet_->HasRequiredAction(wallet::VERIFY_CVV)) |
| 1086 DisableWallet(); |
| 1087 else |
| 1074 FinishSubmit(); | 1088 FinishSubmit(); |
| 1075 return; | |
| 1076 } | |
| 1077 | |
| 1078 // TODO(dbeam): pause this flow to ask for a CVC from the user? | |
| 1079 DetailOutputMap output; | |
| 1080 view_->GetUserInput(SECTION_CC_BILLING, &output); | |
| 1081 | |
| 1082 wallet_client_.AuthenticateInstrument( | |
| 1083 active_instrument_id_, | |
| 1084 UTF16ToUTF8(GetValueForType(output, CREDIT_CARD_VERIFICATION_CODE)), | |
| 1085 wallet_items_->obfuscated_gaia_id()); | |
| 1086 } | 1089 } |
| 1087 | 1090 |
| 1088 void AutofillDialogControllerImpl::OnDidGetWalletItems( | 1091 void AutofillDialogControllerImpl::OnDidGetWalletItems( |
| 1089 scoped_ptr<wallet::WalletItems> wallet_items) { | 1092 scoped_ptr<wallet::WalletItems> wallet_items) { |
| 1090 // TODO(dbeam): verify all items support kCartCurrency? | 1093 // TODO(dbeam): verify all items support kCartCurrency? |
| 1091 wallet_items_ = wallet_items.Pass(); | 1094 wallet_items_ = wallet_items.Pass(); |
| 1092 GenerateSuggestionsModels(); | 1095 GenerateSuggestionsModels(); |
| 1093 view_->ModelChanged(); | 1096 view_->ModelChanged(); |
| 1094 view_->UpdateAccountChooser(); | 1097 view_->UpdateAccountChooser(); |
| 1095 view_->UpdateNotificationArea(); | 1098 view_->UpdateNotificationArea(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 if (popup_controller_) | 1179 if (popup_controller_) |
| 1177 return popup_controller_->HandleKeyPressEvent(event); | 1180 return popup_controller_->HandleKeyPressEvent(event); |
| 1178 | 1181 |
| 1179 return false; | 1182 return false; |
| 1180 } | 1183 } |
| 1181 | 1184 |
| 1182 bool AutofillDialogControllerImpl::RequestingCreditCardInfo() const { | 1185 bool AutofillDialogControllerImpl::RequestingCreditCardInfo() const { |
| 1183 DCHECK_GT(form_structure_.field_count(), 0U); | 1186 DCHECK_GT(form_structure_.field_count(), 0U); |
| 1184 | 1187 |
| 1185 for (size_t i = 0; i < form_structure_.field_count(); ++i) { | 1188 for (size_t i = 0; i < form_structure_.field_count(); ++i) { |
| 1186 if (AutofillType(form_structure_.field(i)->type()).group() == | 1189 if (IsCreditCardType(form_structure_.field(i)->type())) |
| 1187 AutofillType::CREDIT_CARD) { | |
| 1188 return true; | 1190 return true; |
| 1189 } | |
| 1190 } | 1191 } |
| 1191 | 1192 |
| 1192 return false; | 1193 return false; |
| 1193 } | 1194 } |
| 1194 | 1195 |
| 1195 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const { | 1196 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const { |
| 1196 return source_url_.SchemeIs(chrome::kHttpsScheme) && | 1197 return source_url_.SchemeIs(chrome::kHttpsScheme) && |
| 1197 !net::IsCertStatusError(ssl_status_.cert_status) && | 1198 !net::IsCertStatusError(ssl_status_.cert_status) && |
| 1198 !net::IsCertStatusMinorError(ssl_status_.cert_status); | 1199 !net::IsCertStatusMinorError(ssl_status_.cert_status); |
| 1199 } | 1200 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 | 1323 |
| 1323 return true; | 1324 return true; |
| 1324 } | 1325 } |
| 1325 | 1326 |
| 1326 void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( | 1327 void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( |
| 1327 DialogSection section, | 1328 DialogSection section, |
| 1328 const InputFieldComparator& compare) { | 1329 const InputFieldComparator& compare) { |
| 1329 if (!SectionIsActive(section)) | 1330 if (!SectionIsActive(section)) |
| 1330 return; | 1331 return; |
| 1331 | 1332 |
| 1332 if (!IsManuallyEditingSection(section)) { | 1333 // Fill the combined credit card and billing section from |full_wallet_| (via |
| 1333 if (section == SECTION_CC_BILLING) { | 1334 // |CreateWrapper()|) as card number and CVC are auto-generated. |
| 1334 // TODO(dbeam): implement. | 1335 if (!IsManuallyEditingSection(section) || section == SECTION_CC_BILLING) { |
| 1335 } else { | 1336 scoped_ptr<DataModelWrapper> model = CreateWrapper(section); |
| 1336 scoped_ptr<DataModelWrapper> model = CreateWrapper(section); | 1337 // Only fill in data that is associated with this section. |
| 1337 // Only fill in data that is associated with this section. | 1338 const DetailInputs& inputs = RequestedFieldsForSection(section); |
| 1338 const DetailInputs& inputs = RequestedFieldsForSection(section); | 1339 model->FillFormStructure(inputs, compare, &form_structure_); |
| 1339 model->FillFormStructure(inputs, compare, &form_structure_); | |
| 1340 | 1340 |
| 1341 // CVC needs special-casing because the CreditCard class doesn't store | 1341 // CVC needs special-casing because the CreditCard class doesn't store or |
| 1342 // or handle them. | 1342 // handle them. This isn't necessary when filling the combined CC and |
| 1343 if (section == SECTION_CC) | 1343 // billing section as CVC comes from |full_wallet_| in this case. |
| 1344 SetCvcResult(view_->GetCvc()); | 1344 if (section == SECTION_CC) |
| 1345 } | 1345 SetCvcResult(view_->GetCvc()); |
| 1346 } else { | 1346 } else { |
| 1347 // The user manually input data. | 1347 // The user manually input data. If using Autofill, save the info as new or |
| 1348 // edited data. Always fill local data into |form_structure_|. |
| 1348 DetailOutputMap output; | 1349 DetailOutputMap output; |
| 1349 view_->GetUserInput(section, &output); | 1350 view_->GetUserInput(section, &output); |
| 1350 | 1351 |
| 1351 if (IsPayingWithWallet()) { | 1352 if (section == SECTION_CC) { |
| 1352 // TODO(dbeam): implement. | 1353 CreditCard card; |
| 1354 FillFormGroupFromOutputs(output, &card); |
| 1355 |
| 1356 if (ShouldSaveDetailsLocally()) |
| 1357 GetManager()->SaveImportedCreditCard(card); |
| 1358 |
| 1359 FillFormStructureForSection(card, 0, section, compare); |
| 1360 |
| 1361 // Again, CVC needs special-casing. Fill it in directly from |output|. |
| 1362 SetCvcResult(GetValueForType(output, CREDIT_CARD_VERIFICATION_CODE)); |
| 1353 } else { | 1363 } else { |
| 1354 // Save the info as new or edited data and fill it into |form_structure_|. | 1364 AutofillProfile profile; |
| 1355 if (section == SECTION_CC) { | 1365 FillFormGroupFromOutputs(output, &profile); |
| 1356 CreditCard card; | |
| 1357 FillFormGroupFromOutputs(output, &card); | |
| 1358 | 1366 |
| 1359 if (view_->SaveDetailsLocally()) | 1367 // TODO(estade): we should probably edit the existing profile in the |
| 1360 GetManager()->SaveImportedCreditCard(card); | 1368 // cases where the input data is based on an existing profile (user |
| 1369 // clicked "Edit" or autofill popup filled in the form). |
| 1370 if (ShouldSaveDetailsLocally()) |
| 1371 GetManager()->SaveImportedProfile(profile); |
| 1361 | 1372 |
| 1362 FillFormStructureForSection(card, 0, section, compare); | 1373 FillFormStructureForSection(profile, 0, section, compare); |
| 1363 | |
| 1364 // Again, CVC needs special-casing. Fill it in directly from |output|. | |
| 1365 SetCvcResult(GetValueForType(output, CREDIT_CARD_VERIFICATION_CODE)); | |
| 1366 } else { | |
| 1367 AutofillProfile profile; | |
| 1368 FillFormGroupFromOutputs(output, &profile); | |
| 1369 | |
| 1370 // TODO(estade): we should probably edit the existing profile in the | |
| 1371 // cases where the input data is based on an existing profile (user | |
| 1372 // clicked "Edit" or autofill popup filled in the form). | |
| 1373 if (view_->SaveDetailsLocally()) | |
| 1374 GetManager()->SaveImportedProfile(profile); | |
| 1375 | |
| 1376 FillFormStructureForSection(profile, 0, section, compare); | |
| 1377 } | |
| 1378 } | 1374 } |
| 1379 } | 1375 } |
| 1380 } | 1376 } |
| 1381 | 1377 |
| 1382 void AutofillDialogControllerImpl::FillOutputForSection(DialogSection section) { | 1378 void AutofillDialogControllerImpl::FillOutputForSection(DialogSection section) { |
| 1383 FillOutputForSectionWithComparator(section, | 1379 FillOutputForSectionWithComparator(section, |
| 1384 base::Bind(DetailInputMatchesField)); | 1380 base::Bind(DetailInputMatchesField)); |
| 1385 } | 1381 } |
| 1386 | 1382 |
| 1387 void AutofillDialogControllerImpl::FillFormStructureForSection( | 1383 void AutofillDialogControllerImpl::FillFormStructureForSection( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 NOTIMPLEMENTED(); | 1487 NOTIMPLEMENTED(); |
| 1492 } | 1488 } |
| 1493 | 1489 |
| 1494 bool AutofillDialogControllerImpl::IsManuallyEditingSection( | 1490 bool AutofillDialogControllerImpl::IsManuallyEditingSection( |
| 1495 DialogSection section) { | 1491 DialogSection section) { |
| 1496 return section_editing_state_[section] || | 1492 return section_editing_state_[section] || |
| 1497 SuggestionsMenuModelForSection(section)-> | 1493 SuggestionsMenuModelForSection(section)-> |
| 1498 GetItemKeyForCheckedItem().empty(); | 1494 GetItemKeyForCheckedItem().empty(); |
| 1499 } | 1495 } |
| 1500 | 1496 |
| 1501 bool AutofillDialogControllerImpl::UseBillingForShipping() { | 1497 bool AutofillDialogControllerImpl::ShouldUseBillingForShipping() { |
| 1502 // If the user is editing or inputting data, ask the view. | 1498 // If the user is editing or inputting data, ask the view. |
| 1503 if (IsManuallyEditingSection(SECTION_SHIPPING)) | 1499 if (IsManuallyEditingSection(SECTION_SHIPPING)) |
| 1504 return view_->UseBillingForShipping(); | 1500 return view_->UseBillingForShipping(); |
| 1505 | 1501 |
| 1506 // Otherwise, the checkbox should be hidden so its state is irrelevant. | 1502 // Otherwise, the checkbox should be hidden so its state is irrelevant. |
| 1507 // Always use the shipping suggestion model. | 1503 // Always use the shipping suggestion model. |
| 1508 return false; | 1504 return false; |
| 1509 } | 1505 } |
| 1510 | 1506 |
| 1507 bool AutofillDialogControllerImpl::ShouldSaveDetailsLocally() { |
| 1508 // It's possible that the user checked [X] Save details locally before |
| 1509 // switching payment methods, so only ask the view whether to save details |
| 1510 // locally if that checkbox is showing (currently if not paying with wallet). |
| 1511 return !IsPayingWithWallet() && view_->SaveDetailsLocally(); |
| 1512 } |
| 1513 |
| 1511 void AutofillDialogControllerImpl::SubmitWithWallet() { | 1514 void AutofillDialogControllerImpl::SubmitWithWallet() { |
| 1512 // TODO(dbeam): disallow interacting with the dialog while submitting. | 1515 // TODO(dbeam): disallow interacting with the dialog while submitting. |
| 1513 | 1516 |
| 1514 active_instrument_id_.clear(); | 1517 active_instrument_id_.clear(); |
| 1515 active_address_id_.clear(); | 1518 active_address_id_.clear(); |
| 1516 | 1519 |
| 1517 if (!section_editing_state_[SECTION_CC_BILLING]) { | 1520 if (!section_editing_state_[SECTION_CC_BILLING]) { |
| 1518 SuggestionsMenuModel* billing = | 1521 SuggestionsMenuModel* billing = |
| 1519 SuggestionsMenuModelForSection(SECTION_CC_BILLING); | 1522 SuggestionsMenuModelForSection(SECTION_CC_BILLING); |
| 1520 if (!billing->GetItemKeyForCheckedItem().empty() && | 1523 if (!billing->GetItemKeyForCheckedItem().empty() && |
| 1521 billing->checked_item() < | 1524 billing->checked_item() < |
| 1522 static_cast<int>(wallet_items_->instruments().size())) { | 1525 static_cast<int>(wallet_items_->instruments().size())) { |
| 1523 const wallet::WalletItems::MaskedInstrument* active_instrument = | 1526 const wallet::WalletItems::MaskedInstrument* active_instrument = |
| 1524 wallet_items_->instruments()[billing->checked_item()]; | 1527 wallet_items_->instruments()[billing->checked_item()]; |
| 1525 active_instrument_id_ = active_instrument->object_id(); | 1528 active_instrument_id_ = active_instrument->object_id(); |
| 1526 | 1529 |
| 1527 // TODO(dbeam): does re-using instrument address IDs work? | 1530 // TODO(dbeam): does re-using instrument address IDs work? |
| 1528 if (UseBillingForShipping()) | 1531 if (ShouldUseBillingForShipping()) |
| 1529 active_address_id_ = active_instrument->address().object_id(); | 1532 active_address_id_ = active_instrument->address().object_id(); |
| 1530 } | 1533 } |
| 1531 } | 1534 } |
| 1532 | 1535 |
| 1533 if (!section_editing_state_[SECTION_SHIPPING] && active_address_id_.empty()) { | 1536 if (!section_editing_state_[SECTION_SHIPPING] && active_address_id_.empty()) { |
| 1534 SuggestionsMenuModel* shipping = | 1537 SuggestionsMenuModel* shipping = |
| 1535 SuggestionsMenuModelForSection(SECTION_SHIPPING); | 1538 SuggestionsMenuModelForSection(SECTION_SHIPPING); |
| 1536 if (!shipping->GetItemKeyForCheckedItem().empty() && | 1539 if (!shipping->GetItemKeyForCheckedItem().empty() && |
| 1537 shipping->checked_item() < | 1540 shipping->checked_item() < |
| 1538 static_cast<int>(wallet_items_->addresses().size())) { | 1541 static_cast<int>(wallet_items_->addresses().size())) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1559 CreditCard card; | 1562 CreditCard card; |
| 1560 AutofillProfile profile; | 1563 AutofillProfile profile; |
| 1561 string16 cvc; | 1564 string16 cvc; |
| 1562 GetBillingInfoFromOutputs(output, &card, &cvc, &profile); | 1565 GetBillingInfoFromOutputs(output, &card, &cvc, &profile); |
| 1563 | 1566 |
| 1564 new_instrument.reset(new wallet::Instrument(card, cvc, profile)); | 1567 new_instrument.reset(new wallet::Instrument(card, cvc, profile)); |
| 1565 } | 1568 } |
| 1566 | 1569 |
| 1567 scoped_ptr<wallet::Address> new_address; | 1570 scoped_ptr<wallet::Address> new_address; |
| 1568 if (active_address_id_.empty()) { | 1571 if (active_address_id_.empty()) { |
| 1569 if (UseBillingForShipping() && new_instrument.get()) { | 1572 if (ShouldUseBillingForShipping() && new_instrument.get()) { |
| 1570 new_address.reset(new wallet::Address(new_instrument->address())); | 1573 new_address.reset(new wallet::Address(new_instrument->address())); |
| 1571 } else { | 1574 } else { |
| 1572 DetailOutputMap output; | 1575 DetailOutputMap output; |
| 1573 view_->GetUserInput(SECTION_SHIPPING, &output); | 1576 view_->GetUserInput(SECTION_SHIPPING, &output); |
| 1574 | 1577 |
| 1575 AutofillProfile profile; | 1578 AutofillProfile profile; |
| 1576 FillFormGroupFromOutputs(output, &profile); | 1579 FillFormGroupFromOutputs(output, &profile); |
| 1577 | 1580 |
| 1578 new_address.reset(new wallet::Address(profile)); | 1581 new_address.reset(new wallet::Address(profile)); |
| 1579 } | 1582 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1610 wallet_items_->google_transaction_id(), | 1613 wallet_items_->google_transaction_id(), |
| 1611 dialog_type_, | 1614 dialog_type_, |
| 1612 std::vector<wallet::WalletClient::RiskCapability>())); | 1615 std::vector<wallet::WalletClient::RiskCapability>())); |
| 1613 } | 1616 } |
| 1614 | 1617 |
| 1615 void AutofillDialogControllerImpl::FinishSubmit() { | 1618 void AutofillDialogControllerImpl::FinishSubmit() { |
| 1616 FillOutputForSection(SECTION_EMAIL); | 1619 FillOutputForSection(SECTION_EMAIL); |
| 1617 FillOutputForSection(SECTION_CC); | 1620 FillOutputForSection(SECTION_CC); |
| 1618 FillOutputForSection(SECTION_BILLING); | 1621 FillOutputForSection(SECTION_BILLING); |
| 1619 FillOutputForSection(SECTION_CC_BILLING); | 1622 FillOutputForSection(SECTION_CC_BILLING); |
| 1620 if (UseBillingForShipping()) { | 1623 if (ShouldUseBillingForShipping()) { |
| 1621 FillOutputForSectionWithComparator( | 1624 FillOutputForSectionWithComparator( |
| 1622 SECTION_BILLING, | 1625 SECTION_BILLING, |
| 1623 base::Bind(DetailInputMatchesShippingField)); | 1626 base::Bind(DetailInputMatchesShippingField)); |
| 1624 FillOutputForSectionWithComparator( | 1627 FillOutputForSectionWithComparator( |
| 1625 SECTION_CC, | 1628 SECTION_CC, |
| 1626 base::Bind(DetailInputMatchesShippingField)); | 1629 base::Bind(DetailInputMatchesShippingField)); |
| 1627 } else { | 1630 } else { |
| 1628 FillOutputForSection(SECTION_SHIPPING); | 1631 FillOutputForSection(SECTION_SHIPPING); |
| 1629 } | 1632 } |
| 1630 callback_.Run(&form_structure_); | 1633 callback_.Run(&form_structure_); |
| 1631 callback_ = base::Callback<void(const FormStructure*)>(); | 1634 callback_ = base::Callback<void(const FormStructure*)>(); |
| 1632 | 1635 |
| 1633 if (dialog_type_ == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) { | 1636 if (dialog_type_ == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) { |
| 1634 // This may delete us. | 1637 // This may delete us. |
| 1635 Hide(); | 1638 Hide(); |
| 1636 } | 1639 } |
| 1637 } | 1640 } |
| 1638 | 1641 |
| 1639 } // namespace autofill | 1642 } // namespace autofill |
| OLD | NEW |