Chromium Code Reviews| Index: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| index a7406ad0ff8f434b1e73a0779cdfef9cadd1564d..7fe21d65ed65ac9fcd194c26d8112c9be14ac02a 100644 |
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| @@ -842,13 +842,18 @@ bool AutofillDialogControllerImpl::IsSubmitPausedOn( |
| } |
| void AutofillDialogControllerImpl::GetWalletItems() { |
| - DCHECK(previously_selected_instrument_id_.empty()); |
| - DCHECK(previously_selected_shipping_address_id_.empty()); |
| ScopedViewUpdates updates(view_.get()); |
| + previously_selected_instrument_id_.clear(); |
| + previously_selected_shipping_address_id_.clear(); |
| if (wallet_items_) { |
| - if (ActiveInstrument()) |
| - previously_selected_instrument_id_ = ActiveInstrument()->object_id(); |
| + previous_default_instrument_id_ = wallet_items_->default_instrument_id(); |
| + previous_default_shipping_address_id_ = wallet_items_->default_address_id(); |
| + |
| + const wallet::WalletItems::MaskedInstrument* instrument = |
| + ActiveInstrument(); |
| + if (instrument) |
| + previously_selected_instrument_id_ = instrument->object_id(); |
| const wallet::Address* address = ActiveShippingAddress(); |
| if (address) |
| @@ -2377,6 +2382,14 @@ void AutofillDialogControllerImpl::SuggestionsUpdated() { |
| account_chooser_model_.active_wallet_account_name()); |
| } |
| + // If the default address changed since the last fetch of the Wallet data, |
| + // select it rather than the previously selected address, as the user's |
| + // intention in changing the default address was probably to use it. |
| + if (previous_default_shipping_address_id_ != |
| + wallet_items_->default_address_id()) { |
| + previously_selected_shipping_address_id_.clear(); |
| + } |
| + |
| const std::vector<wallet::Address*>& addresses = |
| wallet_items_->addresses(); |
| for (size_t i = 0; i < addresses.size(); ++i) { |
| @@ -2396,6 +2409,14 @@ void AutofillDialogControllerImpl::SuggestionsUpdated() { |
| previously_selected_shipping_address_id_.clear(); |
| if (!IsSubmitPausedOn(wallet::VERIFY_CVV)) { |
| + // If the default address changed since the last fetch of the Wallet data, |
| + // select it rather than the previously selected address, as the user's |
| + // intention in changing the default address was probably to use it. |
| + if (previous_default_instrument_id_ != |
| + wallet_items_->default_instrument_id()) { |
| + previously_selected_instrument_id_.clear(); |
|
Evan Stade
2013/09/04 19:25:28
can you keep all this default instrument logic in
Ilya Sherman
2013/09/05 01:13:59
Done.
|
| + } |
| + |
| const std::vector<wallet::WalletItems::MaskedInstrument*>& instruments = |
| wallet_items_->instruments(); |
| std::string first_active_instrument_key; |