| OLD | NEW |
| 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 "components/payments/content/payment_request_state.h" | 5 #include "components/payments/content/payment_request_state.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 void OnShippingAddressSelected(mojom::PaymentAddressPtr address) override { | 48 void OnShippingAddressSelected(mojom::PaymentAddressPtr address) override { |
| 49 selected_shipping_address_ = std::move(address); | 49 selected_shipping_address_ = std::move(address); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void RecreateStateWithOptionsAndDetails( | 52 void RecreateStateWithOptionsAndDetails( |
| 53 mojom::PaymentOptionsPtr options, | 53 mojom::PaymentOptionsPtr options, |
| 54 mojom::PaymentDetailsPtr details, | 54 mojom::PaymentDetailsPtr details, |
| 55 std::vector<mojom::PaymentMethodDataPtr> method_data) { | 55 std::vector<mojom::PaymentMethodDataPtr> method_data) { |
| 56 // The spec will be based on the |options| and |details| passed in. | 56 // The spec will be based on the |options| and |details| passed in. |
| 57 spec_ = base::MakeUnique<PaymentRequestSpec>( | 57 spec_ = base::MakeUnique<PaymentRequestSpec>( |
| 58 std::move(options), std::move(details), std::move(method_data), nullptr, | 58 std::move(options), std::move(details), std::move(method_data), |
| 59 "en-US"); | 59 /*observer=*/nullptr, "en-US"); |
| 60 state_ = base::MakeUnique<PaymentRequestState>( | 60 state_ = base::MakeUnique<PaymentRequestState>( |
| 61 spec_.get(), this, "en-US", &test_personal_data_manager_, | 61 spec_.get(), this, "en-US", &test_personal_data_manager_, |
| 62 &test_payment_request_delegate_); | 62 &test_payment_request_delegate_); |
| 63 state_->AddObserver(this); | 63 state_->AddObserver(this); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Convenience method to create a PaymentRequestState with default details | 66 // Convenience method to create a PaymentRequestState with default details |
| 67 // (one shipping option) and method data (only supports visa). | 67 // (one shipping option) and method data (only supports visa). |
| 68 void RecreateStateWithOptions(mojom::PaymentOptionsPtr options) { | 68 void RecreateStateWithOptions(mojom::PaymentOptionsPtr options) { |
| 69 RecreateStateWithOptionsAndDetails( | 69 RecreateStateWithOptionsAndDetails( |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 EXPECT_EQ("", selected_shipping_address()->dependent_locality); | 307 EXPECT_EQ("", selected_shipping_address()->dependent_locality); |
| 308 EXPECT_EQ("91111", selected_shipping_address()->postal_code); | 308 EXPECT_EQ("91111", selected_shipping_address()->postal_code); |
| 309 EXPECT_EQ("", selected_shipping_address()->sorting_code); | 309 EXPECT_EQ("", selected_shipping_address()->sorting_code); |
| 310 EXPECT_EQ("", selected_shipping_address()->language_code); | 310 EXPECT_EQ("", selected_shipping_address()->language_code); |
| 311 EXPECT_EQ("Underworld", selected_shipping_address()->organization); | 311 EXPECT_EQ("Underworld", selected_shipping_address()->organization); |
| 312 EXPECT_EQ("John H. Doe", selected_shipping_address()->recipient); | 312 EXPECT_EQ("John H. Doe", selected_shipping_address()->recipient); |
| 313 EXPECT_EQ("16502111111", selected_shipping_address()->phone); | 313 EXPECT_EQ("16502111111", selected_shipping_address()->phone); |
| 314 } | 314 } |
| 315 | 315 |
| 316 } // namespace payments | 316 } // namespace payments |
| OLD | NEW |