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 package org.chromium.chrome.browser.payments; | 5 package org.chromium.chrome.browser.payments; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
9 import android.os.Handler; | 9 import android.os.Handler; |
10 import android.text.TextUtils; | 10 import android.text.TextUtils; |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 } | 448 } |
449 | 449 |
450 @Override | 450 @Override |
451 public void onSectionOptionChanged( | 451 public void onSectionOptionChanged( |
452 @PaymentRequestUI.DataType int optionType, PaymentOption option) { | 452 @PaymentRequestUI.DataType int optionType, PaymentOption option) { |
453 if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) { | 453 if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) { |
454 // This may update the line items and/or the shipping options. | 454 // This may update the line items and/or the shipping options. |
455 assert option instanceof AutofillAddress; | 455 assert option instanceof AutofillAddress; |
456 mShippingAddressesSection.setSelectedItem(option); | 456 mShippingAddressesSection.setSelectedItem(option); |
457 if (mMerchantNeedsShippingAddress) { | 457 if (mMerchantNeedsShippingAddress) { |
458 mClient.onShippingAddressChange(((AutofillAddress) option).toShi
ppingAddress()); | 458 mClient.onShippingAddressChange(((AutofillAddress) option).toPay
mentAddress()); |
459 } | 459 } |
460 } else if (optionType == PaymentRequestUI.TYPE_SHIPPING_OPTIONS) { | 460 } else if (optionType == PaymentRequestUI.TYPE_SHIPPING_OPTIONS) { |
461 // This may update the line items. | 461 // This may update the line items. |
462 mShippingOptionsSection.setSelectedItem(option); | 462 mShippingOptionsSection.setSelectedItem(option); |
463 mClient.onShippingOptionChange(option.getIdentifier()); | 463 mClient.onShippingOptionChange(option.getIdentifier()); |
464 } else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { | 464 } else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { |
465 assert option instanceof PaymentInstrument; | 465 assert option instanceof PaymentInstrument; |
466 mPaymentMethodsSection.setSelectedItem(option); | 466 mPaymentMethodsSection.setSelectedItem(option); |
467 } | 467 } |
468 } | 468 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 PaymentResponse response = new PaymentResponse(); | 564 PaymentResponse response = new PaymentResponse(); |
565 response.methodName = methodName; | 565 response.methodName = methodName; |
566 response.stringifiedDetails = stringifiedDetails; | 566 response.stringifiedDetails = stringifiedDetails; |
567 | 567 |
568 PaymentOption selectedShippingAddress = mShippingAddressesSection.getSel
ectedItem(); | 568 PaymentOption selectedShippingAddress = mShippingAddressesSection.getSel
ectedItem(); |
569 if (selectedShippingAddress != null) { | 569 if (selectedShippingAddress != null) { |
570 // Shipping addresses are created in show(). The should all be insta
nces of | 570 // Shipping addresses are created in show(). The should all be insta
nces of |
571 // AutofillAddress. | 571 // AutofillAddress. |
572 assert selectedShippingAddress instanceof AutofillAddress; | 572 assert selectedShippingAddress instanceof AutofillAddress; |
573 response.shippingAddress = | 573 response.shippingAddress = |
574 ((AutofillAddress) selectedShippingAddress).toShippingAddres
s(); | 574 ((AutofillAddress) selectedShippingAddress).toPaymentAddress
(); |
575 } | 575 } |
576 | 576 |
577 PaymentOption selectedShippingOption = mShippingOptionsSection.getSelect
edItem(); | 577 PaymentOption selectedShippingOption = mShippingOptionsSection.getSelect
edItem(); |
578 if (selectedShippingOption != null && selectedShippingOption.getIdentifi
er() != null) { | 578 if (selectedShippingOption != null && selectedShippingOption.getIdentifi
er() != null) { |
579 response.shippingOptionId = selectedShippingOption.getIdentifier(); | 579 response.shippingOptionId = selectedShippingOption.getIdentifier(); |
580 } | 580 } |
581 | 581 |
582 mClient.onPaymentResponse(response); | 582 mClient.onPaymentResponse(response); |
583 } | 583 } |
584 | 584 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 } | 620 } |
621 mPaymentMethodsSection = null; | 621 mPaymentMethodsSection = null; |
622 } | 622 } |
623 } | 623 } |
624 | 624 |
625 private void closeClient() { | 625 private void closeClient() { |
626 if (mClient != null) mClient.close(); | 626 if (mClient != null) mClient.close(); |
627 mClient = null; | 627 mClient = null; |
628 } | 628 } |
629 } | 629 } |
OLD | NEW |