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

Side by Side Diff: ios/chrome/browser/payments/payment_request.mm

Issue 2847503002: [WebPayments] Show labels on incomplete profiles (Closed)
Patch Set: ios namespace Created 3 years, 7 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "ios/chrome/browser/payments/payment_request.h" 5 #include "ios/chrome/browser/payments/payment_request.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "components/autofill/core/browser/autofill_data_util.h" 8 #include "components/autofill/core/browser/autofill_data_util.h"
9 #include "components/autofill/core/browser/autofill_profile.h" 9 #include "components/autofill/core/browser/autofill_profile.h"
10 #include "components/autofill/core/browser/credit_card.h" 10 #include "components/autofill/core/browser/credit_card.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 void PaymentRequest::PopulateProfileCache() { 91 void PaymentRequest::PopulateProfileCache() {
92 const std::vector<autofill::AutofillProfile*>& profiles_to_suggest = 92 const std::vector<autofill::AutofillProfile*>& profiles_to_suggest =
93 personal_data_manager_->GetProfilesToSuggest(); 93 personal_data_manager_->GetProfilesToSuggest();
94 profile_cache_.reserve(profiles_to_suggest.size()); 94 profile_cache_.reserve(profiles_to_suggest.size());
95 for (const auto* profile : profiles_to_suggest) { 95 for (const auto* profile : profiles_to_suggest) {
96 profile_cache_.push_back(*profile); 96 profile_cache_.push_back(*profile);
97 shipping_profiles_.push_back(&profile_cache_.back()); 97 shipping_profiles_.push_back(&profile_cache_.back());
98 contact_profiles_.push_back(&profile_cache_.back()); 98 contact_profiles_.push_back(&profile_cache_.back());
99 } 99 }
100 100
101 payments::PaymentsProfileComparator comparator(
102 GetApplicationContext()->GetApplicationLocale(), *this);
103
101 // TODO(crbug.com/602666): Implement deduplication and prioritization rules 104 // TODO(crbug.com/602666): Implement deduplication and prioritization rules
Mathieu 2017/04/27 18:34:01 is this resolved then?
tmartino 2017/04/28 17:10:06 Nope. We'll want to write a shipping method that's
102 // for shipping profiles. 105 // for shipping profiles.
103 106
104 contact_profiles_ = payments::profile_util::FilterProfilesForContact( 107 contact_profiles_ = comparator.FilterProfilesForContact(contact_profiles_);
105 contact_profiles_, GetApplicationContext()->GetApplicationLocale(),
106 *this);
107 108
108 if (!shipping_profiles_.empty()) 109 if (!shipping_profiles_.empty())
109 selected_shipping_profile_ = shipping_profiles_[0]; 110 selected_shipping_profile_ = shipping_profiles_[0];
110 if (!contact_profiles_.empty()) 111 if (!contact_profiles_.empty() &&
112 comparator.IsContactInfoComplete(contact_profiles_[0])) {
111 selected_contact_profile_ = contact_profiles_[0]; 113 selected_contact_profile_ = contact_profiles_[0];
114 }
112 } 115 }
113 116
114 void PaymentRequest::PopulateCreditCardCache() { 117 void PaymentRequest::PopulateCreditCardCache() {
115 // TODO(crbug.com/709036): Validate method data. 118 // TODO(crbug.com/709036): Validate method data.
116 payments::data_util::ParseBasicCardSupportedNetworks( 119 payments::data_util::ParseBasicCardSupportedNetworks(
117 web_payment_request_.method_data, &supported_card_networks_, 120 web_payment_request_.method_data, &supported_card_networks_,
118 &basic_card_specified_networks_); 121 &basic_card_specified_networks_);
119 122
120 const std::vector<autofill::CreditCard*>& credit_cards_to_suggest = 123 const std::vector<autofill::CreditCard*>& credit_cards_to_suggest =
121 personal_data_manager_->GetCreditCardsToSuggest(); 124 personal_data_manager_->GetCreditCardsToSuggest();
(...skipping 28 matching lines...) Expand all
150 153
151 selected_shipping_option_ = nullptr; 154 selected_shipping_option_ = nullptr;
152 for (auto* shipping_option : shipping_options_) { 155 for (auto* shipping_option : shipping_options_) {
153 if (shipping_option->selected) { 156 if (shipping_option->selected) {
154 // If more than one option has |selected| set, the last one in the 157 // If more than one option has |selected| set, the last one in the
155 // sequence should be treated as the selected item. 158 // sequence should be treated as the selected item.
156 selected_shipping_option_ = shipping_option; 159 selected_shipping_option_ = shipping_option;
157 } 160 }
158 } 161 }
159 } 162 }
OLDNEW
« components/payments/core/profile_util.cc ('K') | « components/payments/core/profile_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698