Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "components/autofill/core/browser/autofill_data_util.h" | 9 #include "components/autofill/core/browser/autofill_data_util.h" |
| 10 #include "components/autofill/core/browser/autofill_profile.h" | 10 #include "components/autofill/core/browser/autofill_profile.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 personal_data_manager_(personal_data_manager), | 27 personal_data_manager_(personal_data_manager), |
| 28 selected_shipping_profile_(nullptr), | 28 selected_shipping_profile_(nullptr), |
| 29 selected_contact_profile_(nullptr), | 29 selected_contact_profile_(nullptr), |
| 30 selected_instrument_(nullptr), | 30 selected_instrument_(nullptr), |
| 31 selected_shipping_option_(nullptr) { | 31 selected_shipping_option_(nullptr) { |
| 32 PopulateProfileCache(); | 32 PopulateProfileCache(); |
| 33 UpdateSelectedShippingOption(); | 33 UpdateSelectedShippingOption(); |
| 34 SetDefaultProfileSelections(); | 34 SetDefaultProfileSelections(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool PaymentRequestState::CanMakePayment() { | |
| 38 // TODO(crbug.com/704675): Handle incognito mode when replying to this method. | |
| 39 for (const std::unique_ptr<PaymentInstrument>& instrument : | |
| 40 available_instruments_) { | |
|
please use gerrit instead
2017/03/24 14:47:25
Need to filter by valid instruments (instrument->I
Mathieu
2017/03/24 15:38:40
Whoops, thanks.
| |
| 41 if (spec_->supported_card_networks_set().count( | |
| 42 instrument.get()->method_name())) | |
| 43 return true; | |
| 44 } | |
| 45 return false; | |
| 46 } | |
| 47 | |
| 37 void PaymentRequestState::AddObserver(Observer* observer) { | 48 void PaymentRequestState::AddObserver(Observer* observer) { |
| 38 CHECK(observer); | 49 CHECK(observer); |
| 39 observers_.AddObserver(observer); | 50 observers_.AddObserver(observer); |
| 40 } | 51 } |
| 41 PaymentRequestState::~PaymentRequestState() {} | 52 PaymentRequestState::~PaymentRequestState() {} |
| 42 | 53 |
| 43 void PaymentRequestState::RemoveObserver(Observer* observer) { | 54 void PaymentRequestState::RemoveObserver(Observer* observer) { |
| 44 observers_.RemoveObserver(observer); | 55 observers_.RemoveObserver(observer); |
| 45 } | 56 } |
| 46 | 57 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 spec_->details().shipping_options.rend(), | 231 spec_->details().shipping_options.rend(), |
| 221 [](const payments::mojom::PaymentShippingOptionPtr& element) { | 232 [](const payments::mojom::PaymentShippingOptionPtr& element) { |
| 222 return element->selected; | 233 return element->selected; |
| 223 }); | 234 }); |
| 224 if (selected_shipping_option_it != spec_->details().shipping_options.rend()) { | 235 if (selected_shipping_option_it != spec_->details().shipping_options.rend()) { |
| 225 selected_shipping_option_ = selected_shipping_option_it->get(); | 236 selected_shipping_option_ = selected_shipping_option_it->get(); |
| 226 } | 237 } |
| 227 } | 238 } |
| 228 | 239 |
| 229 } // namespace payments | 240 } // namespace payments |
| OLD | NEW |