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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 14644010: respect default wallet instrument/address (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2cf3af3f1319541e9a65db5a543a72ecf92be3b8..bfdc89f616226c5ea3f539a130658952a9dbbb8f 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -1729,24 +1729,33 @@ void AutofillDialogControllerImpl::SuggestionsUpdated() {
const std::vector<wallet::Address*>& addresses =
wallet_items_->addresses();
for (size_t i = 0; i < addresses.size(); ++i) {
- // TODO(dbeam): respect the default instrument ID. http://crbug.com/232954
+ std::string key = base::IntToString(i);
suggested_shipping_.AddKeyedItemWithSublabel(
- base::IntToString(i),
+ key,
addresses[i]->DisplayName(),
addresses[i]->DisplayNameDetail());
+ if (addresses[i]->object_id() ==
+ wallet_items_->default_address_id()) {
+ suggested_shipping_.SetCheckedItem(key);
+ }
}
if (!IsSubmitPausedOn(wallet::VERIFY_CVV)) {
const std::vector<wallet::WalletItems::MaskedInstrument*>& instruments =
wallet_items_->instruments();
for (size_t i = 0; i < instruments.size(); ++i) {
- // TODO(dbeam): respect the default address ID. http://crbug.com/232954
+ std::string key = base::IntToString(i);
suggested_cc_billing_.AddKeyedItemWithSublabelAndIcon(
- base::IntToString(i),
+ key,
instruments[i]->DisplayName(),
instruments[i]->DisplayNameDetail(),
instruments[i]->CardIcon());
+
+ if (instruments[i]->object_id() ==
+ wallet_items_->default_instrument_id()) {
+ suggested_cc_billing_.SetCheckedItem(key);
+ }
}
// TODO(estade): this should have a URL sublabel.
@@ -1821,13 +1830,14 @@ void AutofillDialogControllerImpl::SuggestionsUpdated() {
suggested_shipping_.AddKeyedItem(
kManageItemsKey,
l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_MANAGE_SHIPPING_ADDRESS));
-
- // Default shipping address is the first suggestion, if one exists. Otherwise
- // it's the "Use shipping for billing" item.
- const std::string& first_real_suggestion_item_key =
- suggested_shipping_.GetItemKeyAt(1);
- if (IsASuggestionItemKey(first_real_suggestion_item_key))
+ if (!IsPayingWithWallet()) {
+ // When using Autofill, the default option is the first suggestion, if
+ // one exists. Otherwise it's the "Use shipping for billing" item.
+ const std::string& first_real_suggestion_item_key =
+ suggested_shipping_.GetItemKeyAt(1);
+ if (IsASuggestionItemKey(first_real_suggestion_item_key))
suggested_shipping_.SetCheckedItem(first_real_suggestion_item_key);
+ }
if (view_)
view_->ModelChanged();
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698