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

Side by Side Diff: components/payments/payment_request.cc

Issue 2625183002: [WebPayments] Adding Shipping Address and Contact Info display to order summary (Closed)
Patch Set: Rebasing with anthonyvd changes Created 3 years, 11 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 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/payment_request.h" 5 #include "components/payments/payment_request.h"
6 6
7 #include "components/autofill/core/browser/personal_data_manager.h" 7 #include "components/autofill/core/browser/personal_data_manager.h"
8 #include "components/payments/payment_details_validation.h" 8 #include "components/payments/payment_details_validation.h"
9 #include "components/payments/payment_request_delegate.h" 9 #include "components/payments/payment_request_delegate.h"
10 #include "components/payments/payment_request_web_contents_manager.h" 10 #include "components/payments/payment_request_web_contents_manager.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 const base::Optional<std::string> currency_system, 67 const base::Optional<std::string> currency_system,
68 const std::string& locale_name) { 68 const std::string& locale_name) {
69 if (!currency_formatter_) { 69 if (!currency_formatter_) {
70 currency_formatter_.reset( 70 currency_formatter_.reset(
71 new CurrencyFormatter(currency_code, currency_system, locale_name)); 71 new CurrencyFormatter(currency_code, currency_system, locale_name));
72 } 72 }
73 73
74 return currency_formatter_.get(); 74 return currency_formatter_.get();
75 } 75 }
76 76
77 autofill::AutofillProfile* PaymentRequest::GetCurrentlySelectedProfile() {
78 // TODO(tmartino): Implement more sophisticated algorithm for populating
79 // this when it starts empty.
80 if (!profile_) {
81 autofill::PersonalDataManager* data_manager =
82 delegate_->GetPersonalDataManager();
83 auto profiles = data_manager->GetProfiles();
please use gerrit instead 2017/01/18 18:50:48 By the way, GetPersonalDataManager() and GetProfil
84 if (!profiles.empty())
85 profile_ = profiles[0];
86 }
87 return profile_ ? profile_.value() : nullptr;
88 }
89
77 autofill::CreditCard* PaymentRequest::GetCurrentlySelectedCreditCard() { 90 autofill::CreditCard* PaymentRequest::GetCurrentlySelectedCreditCard() {
78 // TODO(anthonyvd): Change this code to prioritize server cards and implement 91 // TODO(anthonyvd): Change this code to prioritize server cards and implement
79 // a way to modify this function's return value. 92 // a way to modify this function's return value.
80 autofill::PersonalDataManager* data_manager = 93 autofill::PersonalDataManager* data_manager =
81 delegate_->GetPersonalDataManager(); 94 delegate_->GetPersonalDataManager();
82 95
83 const std::vector<autofill::CreditCard*> cards = 96 const std::vector<autofill::CreditCard*> cards =
84 data_manager->GetCreditCardsToSuggest(); 97 data_manager->GetCreditCardsToSuggest();
85 98
86 auto first_complete_card = std::find_if( 99 auto first_complete_card = std::find_if(
87 cards.begin(), 100 cards.begin(),
88 cards.end(), 101 cards.end(),
89 [] (autofill::CreditCard* card) { 102 [] (autofill::CreditCard* card) {
90 return card->IsValid(); 103 return card->IsValid();
91 }); 104 });
92 105
93 return first_complete_card == cards.end() ? nullptr : *first_complete_card; 106 return first_complete_card == cards.end() ? nullptr : *first_complete_card;
94 } 107 }
95 108
96 } // namespace payments 109 } // namespace payments
OLDNEW
« components/payments/payment_request.h ('K') | « components/payments/payment_request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698