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

Side by Side Diff: components/payments/content/payment_request_state.cc

Issue 2841643002: When a new Payments address is created from the editor, use it as the chosen address (Closed)
Patch Set: And yet another small goof fix... :-( Created 3 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 unified diff | Download patch
« no previous file with comments | « components/payments/content/payment_request_state.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/payments/content/payment_request_state.h" 5 #include "components/payments/content/payment_request_state.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 std::unique_ptr<PaymentInstrument> instrument = 98 std::unique_ptr<PaymentInstrument> instrument =
99 base::MakeUnique<AutofillPaymentInstrument>( 99 base::MakeUnique<AutofillPaymentInstrument>(
100 basic_card_network, card, shipping_profiles_, app_locale_, 100 basic_card_network, card, shipping_profiles_, app_locale_,
101 payment_request_delegate_); 101 payment_request_delegate_);
102 available_instruments_.push_back(std::move(instrument)); 102 available_instruments_.push_back(std::move(instrument));
103 103
104 if (selected) 104 if (selected)
105 SetSelectedInstrument(available_instruments_.back().get()); 105 SetSelectedInstrument(available_instruments_.back().get());
106 } 106 }
107 107
108 void PaymentRequestState::AddAutofillShippingProfile(
109 bool selected,
110 const autofill::AutofillProfile& profile) {
111 profile_cache_.push_back(
112 base::MakeUnique<autofill::AutofillProfile>(profile));
113 // TODO(tmartino): Implement deduplication rules specific to shipping
114 // profiles.
115 autofill::AutofillProfile* new_cached_profile = profile_cache_.back().get();
116 shipping_profiles_.push_back(new_cached_profile);
117
118 if (selected)
119 SetSelectedShippingProfile(new_cached_profile);
120 }
121
108 void PaymentRequestState::SetSelectedShippingOption( 122 void PaymentRequestState::SetSelectedShippingOption(
109 const std::string& shipping_option_id) { 123 const std::string& shipping_option_id) {
110 spec_->StartWaitingForUpdateWith( 124 spec_->StartWaitingForUpdateWith(
111 PaymentRequestSpec::UpdateReason::SHIPPING_OPTION); 125 PaymentRequestSpec::UpdateReason::SHIPPING_OPTION);
112 // This will inform the merchant and will lead to them calling updateWith with 126 // This will inform the merchant and will lead to them calling updateWith with
113 // new PaymentDetails. 127 // new PaymentDetails.
114 delegate_->OnShippingOptionIdSelected(shipping_option_id); 128 delegate_->OnShippingOptionIdSelected(shipping_option_id);
115 } 129 }
116 130
117 void PaymentRequestState::SetSelectedShippingProfile( 131 void PaymentRequestState::SetSelectedShippingProfile(
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 bool PaymentRequestState::ArePaymentOptionsSatisfied() { 244 bool PaymentRequestState::ArePaymentOptionsSatisfied() {
231 // TODO(mathp): Have a measure of shipping address completeness. 245 // TODO(mathp): Have a measure of shipping address completeness.
232 if (spec_->request_shipping() && selected_shipping_profile_ == nullptr) 246 if (spec_->request_shipping() && selected_shipping_profile_ == nullptr)
233 return false; 247 return false;
234 248
235 profile_util::PaymentsProfileComparator comparator(app_locale_, *spec_); 249 profile_util::PaymentsProfileComparator comparator(app_locale_, *spec_);
236 return comparator.IsContactInfoComplete(selected_contact_profile_); 250 return comparator.IsContactInfoComplete(selected_contact_profile_);
237 } 251 }
238 252
239 } // namespace payments 253 } // namespace payments
OLDNEW
« no previous file with comments | « components/payments/content/payment_request_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698