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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 response.payerEmail = ((AutofillContact) selectedContact).getPay
erEmail(); | 797 response.payerEmail = ((AutofillContact) selectedContact).getPay
erEmail(); |
798 } | 798 } |
799 } | 799 } |
800 | 800 |
801 if (mShippingAddressesSection != null) { | 801 if (mShippingAddressesSection != null) { |
802 PaymentOption selectedShippingAddress = mShippingAddressesSection.ge
tSelectedItem(); | 802 PaymentOption selectedShippingAddress = mShippingAddressesSection.ge
tSelectedItem(); |
803 if (selectedShippingAddress != null) { | 803 if (selectedShippingAddress != null) { |
804 // Shipping addresses are created in show(). These should all be
instances of | 804 // Shipping addresses are created in show(). These should all be
instances of |
805 // AutofillAddress. | 805 // AutofillAddress. |
806 assert selectedShippingAddress instanceof AutofillAddress; | 806 assert selectedShippingAddress instanceof AutofillAddress; |
807 response.shippingAddress = | 807 AutofillAddress selectedAutofillAddress = (AutofillAddress) sele
ctedShippingAddress; |
808 ((AutofillAddress) selectedShippingAddress).toPaymentAdd
ress(); | 808 |
| 809 // Record the use of the profile. |
| 810 PersonalDataManager.getInstance().recordAndLogProfileUse( |
| 811 selectedAutofillAddress.getProfile().getGUID()); |
| 812 |
| 813 response.shippingAddress = selectedAutofillAddress.toPaymentAddr
ess(); |
809 } | 814 } |
810 } | 815 } |
811 | 816 |
812 if (mUiShippingOptions != null) { | 817 if (mUiShippingOptions != null) { |
813 PaymentOption selectedShippingOption = mUiShippingOptions.getSelecte
dItem(); | 818 PaymentOption selectedShippingOption = mUiShippingOptions.getSelecte
dItem(); |
814 if (selectedShippingOption != null && selectedShippingOption.getIden
tifier() != null) { | 819 if (selectedShippingOption != null && selectedShippingOption.getIden
tifier() != null) { |
815 response.shippingOption = selectedShippingOption.getIdentifier()
; | 820 response.shippingOption = selectedShippingOption.getIdentifier()
; |
816 } | 821 } |
817 } | 822 } |
818 | 823 |
| 824 // If the payment method was an Autofill credit card, record its use. |
| 825 if (mPaymentMethodsSection.getSelectedItem() instanceof AutofillPaymentI
nstrument) { |
| 826 PersonalDataManager.getInstance().recordAndLogCreditCardUse( |
| 827 mPaymentMethodsSection.getSelectedItem().getIdentifier()); |
| 828 } |
| 829 |
819 mClient.onPaymentResponse(response); | 830 mClient.onPaymentResponse(response); |
820 } | 831 } |
821 | 832 |
822 /** | 833 /** |
823 * Called if unable to retrieve instrument details. | 834 * Called if unable to retrieve instrument details. |
824 */ | 835 */ |
825 @Override | 836 @Override |
826 public void onInstrumentDetailsError() { | 837 public void onInstrumentDetailsError() { |
827 disconnectFromClientWithDebugMessage("Failed to retrieve payment instrum
ent details"); | 838 disconnectFromClientWithDebugMessage("Failed to retrieve payment instrum
ent details"); |
828 closeUI(false); | 839 closeUI(false); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 private void closeClient() { | 873 private void closeClient() { |
863 if (mClient != null) mClient.close(); | 874 if (mClient != null) mClient.close(); |
864 mClient = null; | 875 mClient = null; |
865 } | 876 } |
866 | 877 |
867 @VisibleForTesting | 878 @VisibleForTesting |
868 public static void setObserverForTest(PaymentRequestServiceObserverForTest o
bserverForTest) { | 879 public static void setObserverForTest(PaymentRequestServiceObserverForTest o
bserverForTest) { |
869 sObserverForTest = observerForTest; | 880 sObserverForTest = observerForTest; |
870 } | 881 } |
871 } | 882 } |
OLD | NEW |