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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 private ShoppingCart mUiShoppingCart; | 167 private ShoppingCart mUiShoppingCart; |
168 | 168 |
169 /** | 169 /** |
170 * The UI model for the shipping options. Includes the label and sublabel fo
r each shipping | 170 * The UI model for the shipping options. Includes the label and sublabel fo
r each shipping |
171 * option. Also keeps track of the selected shipping option. This data is pa
ssed to the UI. | 171 * option. Also keeps track of the selected shipping option. This data is pa
ssed to the UI. |
172 */ | 172 */ |
173 private SectionInformation mUiShippingOptions; | 173 private SectionInformation mUiShippingOptions; |
174 | 174 |
175 private Map<String, JSONObject> mMethodData; | 175 private Map<String, JSONObject> mMethodData; |
176 private SectionInformation mShippingAddressesSection; | 176 private SectionInformation mShippingAddressesSection; |
177 private SectionInformation mContactSection; | 177 private SectionInformation mPayerInfoSection; |
178 private List<PaymentApp> mPendingApps; | 178 private List<PaymentApp> mPendingApps; |
179 private List<PaymentInstrument> mPendingInstruments; | 179 private List<PaymentInstrument> mPendingInstruments; |
180 private List<PaymentInstrument> mPendingAutofillInstruments; | 180 private List<PaymentInstrument> mPendingAutofillInstruments; |
181 private SectionInformation mPaymentMethodsSection; | 181 private SectionInformation mPaymentMethodsSection; |
182 private PaymentRequestUI mUI; | 182 private PaymentRequestUI mUI; |
183 private Callback<PaymentInformation> mPaymentInformationCallback; | 183 private Callback<PaymentInformation> mPaymentInformationCallback; |
184 private boolean mPaymentAppRunning; | 184 private boolean mPaymentAppRunning; |
185 private boolean mMerchantSupportsAutofillPaymentInstruments; | 185 private boolean mMerchantSupportsAutofillPaymentInstruments; |
186 private ContactEditor mContactEditor; | 186 private PayerInfoEditor mPayerInfoEditor; |
187 private boolean mHasRecordedAbortReason; | 187 private boolean mHasRecordedAbortReason; |
188 | 188 |
189 /** True if any of the requested payment methods are supported. */ | 189 /** True if any of the requested payment methods are supported. */ |
190 private boolean mArePaymentMethodsSupported; | 190 private boolean mArePaymentMethodsSupported; |
191 | 191 |
192 /** True if show() was called. */ | 192 /** True if show() was called. */ |
193 private boolean mIsShowing; | 193 private boolean mIsShowing; |
194 | 194 |
195 private boolean mIsWaitingForNormalization; | 195 private boolean mIsWaitingForNormalization; |
196 private PaymentResponse mPendingPaymentResponse; | 196 private PaymentResponse mPendingPaymentResponse; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 recordAbortReasonHistogram( | 263 recordAbortReasonHistogram( |
264 PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERE
R); | 264 PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERE
R); |
265 return; | 265 return; |
266 } | 266 } |
267 | 267 |
268 if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return; | 268 if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return; |
269 | 269 |
270 getMatchingPaymentInstruments(); | 270 getMatchingPaymentInstruments(); |
271 | 271 |
272 boolean requestShipping = options != null && options.requestShipping; | 272 boolean requestShipping = options != null && options.requestShipping; |
| 273 boolean requestPayerName = options != null && options.requestPayerName; |
273 boolean requestPayerPhone = options != null && options.requestPayerPhone
; | 274 boolean requestPayerPhone = options != null && options.requestPayerPhone
; |
274 boolean requestPayerEmail = options != null && options.requestPayerEmail
; | 275 boolean requestPayerEmail = options != null && options.requestPayerEmail
; |
275 | 276 |
276 List<AutofillProfile> profiles = null; | 277 List<AutofillProfile> profiles = null; |
277 if (requestShipping || requestPayerPhone || requestPayerEmail) { | 278 if (requestShipping || requestPayerName || requestPayerPhone || requestP
ayerEmail) { |
278 profiles = PersonalDataManager.getInstance().getProfilesToSuggest( | 279 profiles = PersonalDataManager.getInstance().getProfilesToSuggest( |
279 false /* includeName */); | 280 false /* includeName */); |
280 } | 281 } |
281 | 282 |
282 if (requestShipping) { | 283 if (requestShipping) { |
283 List<AutofillAddress> addresses = new ArrayList<>(); | 284 List<AutofillAddress> addresses = new ArrayList<>(); |
284 | 285 |
285 for (int i = 0; i < profiles.size(); i++) { | 286 for (int i = 0; i < profiles.size(); i++) { |
286 AutofillProfile profile = profiles.get(i); | 287 AutofillProfile profile = profiles.get(i); |
287 mAddressEditor.addPhoneNumberIfValid(profile.getPhoneNumber()); | 288 mAddressEditor.addPhoneNumberIfValid(profile.getPhoneNumber()); |
(...skipping 24 matching lines...) Expand all Loading... |
312 if (mUiShippingOptions.getSelectedItem() != null && !addresses.isEmp
ty() | 313 if (mUiShippingOptions.getSelectedItem() != null && !addresses.isEmp
ty() |
313 && addresses.get(0).isComplete()) { | 314 && addresses.get(0).isComplete()) { |
314 firstCompleteAddressIndex = 0; | 315 firstCompleteAddressIndex = 0; |
315 } | 316 } |
316 | 317 |
317 mShippingAddressesSection = | 318 mShippingAddressesSection = |
318 new SectionInformation(PaymentRequestUI.TYPE_SHIPPING_ADDRES
SES, | 319 new SectionInformation(PaymentRequestUI.TYPE_SHIPPING_ADDRES
SES, |
319 firstCompleteAddressIndex, addresses); | 320 firstCompleteAddressIndex, addresses); |
320 } | 321 } |
321 | 322 |
322 if (requestPayerPhone || requestPayerEmail) { | 323 if (requestPayerName || requestPayerPhone || requestPayerEmail) { |
323 Set<String> uniqueContactInfos = new HashSet<>(); | 324 Set<String> uniquePayerInfos = new HashSet<>(); |
324 mContactEditor = new ContactEditor(requestPayerPhone, requestPayerEm
ail); | 325 mPayerInfoEditor = |
325 List<AutofillContact> contacts = new ArrayList<>(); | 326 new PayerInfoEditor(requestPayerName, requestPayerPhone, req
uestPayerEmail); |
| 327 List<AutofillPayerInfo> payerInfos = new ArrayList<>(); |
326 | 328 |
327 for (int i = 0; i < profiles.size(); i++) { | 329 for (int i = 0; i < profiles.size(); i++) { |
328 AutofillProfile profile = profiles.get(i); | 330 AutofillProfile profile = profiles.get(i); |
| 331 String name = requestPayerName && !TextUtils.isEmpty(profile.get
FullName()) |
| 332 ? profile.getFullName() : null; |
329 String phone = requestPayerPhone && !TextUtils.isEmpty(profile.g
etPhoneNumber()) | 333 String phone = requestPayerPhone && !TextUtils.isEmpty(profile.g
etPhoneNumber()) |
330 ? profile.getPhoneNumber() : null; | 334 ? profile.getPhoneNumber() : null; |
331 String email = requestPayerEmail && !TextUtils.isEmpty(profile.g
etEmailAddress()) | 335 String email = requestPayerEmail && !TextUtils.isEmpty(profile.g
etEmailAddress()) |
332 ? profile.getEmailAddress() : null; | 336 ? profile.getEmailAddress() : null; |
333 mContactEditor.addPhoneNumberIfValid(phone); | 337 mPayerInfoEditor.addPayerNameIfValid(name); |
334 mContactEditor.addEmailAddressIfValid(email); | 338 mPayerInfoEditor.addPhoneNumberIfValid(phone); |
| 339 mPayerInfoEditor.addEmailAddressIfValid(email); |
335 | 340 |
336 if (phone != null || email != null) { | 341 if (name != null || phone != null || email != null) { |
337 // Different profiles can have identical contact info. Do no
t add the same | 342 // Different profiles can have identical payer info. Do not
add the same |
338 // contact info to the list twice. | 343 // payer info to the list twice. |
339 String uniqueContactInfo = phone + email; | 344 String uniquePayerInfo = name + phone + email; |
340 if (!uniqueContactInfos.contains(uniqueContactInfo)) { | 345 if (!uniquePayerInfos.contains(uniquePayerInfo)) { |
341 uniqueContactInfos.add(uniqueContactInfo); | 346 uniquePayerInfos.add(uniquePayerInfo); |
342 | 347 |
343 boolean isComplete = | 348 boolean isComplete = |
344 mContactEditor.isContactInformationComplete(phon
e, email); | 349 mPayerInfoEditor.isPayerInformationComplete(name
, phone, email); |
345 contacts.add(new AutofillContact(profile, phone, email,
isComplete)); | 350 payerInfos.add( |
| 351 new AutofillPayerInfo(profile, name, phone, emai
l, isComplete)); |
346 } | 352 } |
347 } | 353 } |
348 } | 354 } |
349 | 355 |
350 // Suggest complete contact infos first. | 356 // Suggest complete payer infos first. |
351 Collections.sort(contacts, COMPLETENESS_COMPARATOR); | 357 Collections.sort(payerInfos, COMPLETENESS_COMPARATOR); |
352 | 358 |
353 // Limit the number of suggestions. | 359 // Limit the number of suggestions. |
354 contacts = contacts.subList(0, Math.min(contacts.size(), SUGGESTIONS
_LIMIT)); | 360 payerInfos = payerInfos.subList(0, Math.min(payerInfos.size(), SUGGE
STIONS_LIMIT)); |
355 | 361 |
356 // Automatically select the first address if it is complete. | 362 // Automatically select the first address if it is complete. |
357 int firstCompleteContactIndex = SectionInformation.NO_SELECTION; | 363 int firstCompletePayerInfoIndex = SectionInformation.NO_SELECTION; |
358 if (!contacts.isEmpty() && contacts.get(0).isComplete()) { | 364 if (!payerInfos.isEmpty() && payerInfos.get(0).isComplete()) { |
359 firstCompleteContactIndex = 0; | 365 firstCompletePayerInfoIndex = 0; |
360 } | 366 } |
361 | 367 |
362 mContactSection = new SectionInformation( | 368 mPayerInfoSection = new SectionInformation( |
363 PaymentRequestUI.TYPE_CONTACT_DETAILS, firstCompleteContactI
ndex, contacts); | 369 PaymentRequestUI.TYPE_CONTACT_DETAILS, firstCompletePayerInf
oIndex, payerInfos); |
364 } | 370 } |
365 | 371 |
366 mUI = new PaymentRequestUI(mContext, this, requestShipping, | 372 mUI = new PaymentRequestUI(mContext, this, requestShipping, |
367 requestPayerPhone || requestPayerEmail, mMerchantSupportsAutofil
lPaymentInstruments, | 373 requestPayerName || requestPayerPhone || requestPayerEmail, |
368 mMerchantName, mOrigin); | 374 mMerchantSupportsAutofillPaymentInstruments, mMerchantName, mOri
gin); |
369 | 375 |
370 if (mFavicon != null) mUI.setTitleBitmap(mFavicon); | 376 if (mFavicon != null) mUI.setTitleBitmap(mFavicon); |
371 mFavicon = null; | 377 mFavicon = null; |
372 | 378 |
373 mAddressEditor.setEditorView(mUI.getEditorView()); | 379 mAddressEditor.setEditorView(mUI.getEditorView()); |
374 mCardEditor.setEditorView(mUI.getCardEditorView()); | 380 mCardEditor.setEditorView(mUI.getCardEditorView()); |
375 if (mContactEditor != null) mContactEditor.setEditorView(mUI.getEditorVi
ew()); | 381 if (mPayerInfoEditor != null) mPayerInfoEditor.setEditorView(mUI.getEdit
orView()); |
376 | 382 |
377 PaymentRequestMetrics.recordRequestedInformationHistogram(requestPayerEm
ail, | 383 PaymentRequestMetrics.recordRequestedInformationHistogram(requestPayerEm
ail, |
378 requestPayerPhone, requestShipping); | 384 requestPayerPhone, requestShipping); |
379 } | 385 } |
380 | 386 |
381 /** | 387 /** |
382 * Called by the merchant website to show the payment request to the user. | 388 * Called by the merchant website to show the payment request to the user. |
383 */ | 389 */ |
384 @Override | 390 @Override |
385 public void show() { | 391 public void show() { |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 @Override | 672 @Override |
667 public void run() { | 673 public void run() { |
668 providePaymentInformation(); | 674 providePaymentInformation(); |
669 } | 675 } |
670 }); | 676 }); |
671 } | 677 } |
672 | 678 |
673 private void providePaymentInformation() { | 679 private void providePaymentInformation() { |
674 mPaymentInformationCallback.onResult( | 680 mPaymentInformationCallback.onResult( |
675 new PaymentInformation(mUiShoppingCart, mShippingAddressesSectio
n, | 681 new PaymentInformation(mUiShoppingCart, mShippingAddressesSectio
n, |
676 mUiShippingOptions, mContactSection, mPaymentMethodsSect
ion)); | 682 mUiShippingOptions, mPayerInfoSection, mPaymentMethodsSe
ction)); |
677 mPaymentInformationCallback = null; | 683 mPaymentInformationCallback = null; |
678 } | 684 } |
679 | 685 |
680 @Override | 686 @Override |
681 public void getShoppingCart(final Callback<ShoppingCart> callback) { | 687 public void getShoppingCart(final Callback<ShoppingCart> callback) { |
682 mHandler.post(new Runnable() { | 688 mHandler.post(new Runnable() { |
683 @Override | 689 @Override |
684 public void run() { | 690 public void run() { |
685 callback.onResult(mUiShoppingCart); | 691 callback.onResult(mUiShoppingCart); |
686 } | 692 } |
687 }); | 693 }); |
688 } | 694 } |
689 | 695 |
690 @Override | 696 @Override |
691 public void getSectionInformation(@PaymentRequestUI.DataType final int optio
nType, | 697 public void getSectionInformation(@PaymentRequestUI.DataType final int optio
nType, |
692 final Callback<SectionInformation> callback) { | 698 final Callback<SectionInformation> callback) { |
693 mHandler.post(new Runnable() { | 699 mHandler.post(new Runnable() { |
694 @Override | 700 @Override |
695 public void run() { | 701 public void run() { |
696 if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) { | 702 if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) { |
697 callback.onResult(mShippingAddressesSection); | 703 callback.onResult(mShippingAddressesSection); |
698 } else if (optionType == PaymentRequestUI.TYPE_SHIPPING_OPTIONS)
{ | 704 } else if (optionType == PaymentRequestUI.TYPE_SHIPPING_OPTIONS)
{ |
699 callback.onResult(mUiShippingOptions); | 705 callback.onResult(mUiShippingOptions); |
700 } else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS)
{ | 706 } else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS)
{ |
701 callback.onResult(mContactSection); | 707 callback.onResult(mPayerInfoSection); |
702 } else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS)
{ | 708 } else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS)
{ |
703 assert mPaymentMethodsSection != null; | 709 assert mPaymentMethodsSection != null; |
704 callback.onResult(mPaymentMethodsSection); | 710 callback.onResult(mPaymentMethodsSection); |
705 } | 711 } |
706 } | 712 } |
707 }); | 713 }); |
708 } | 714 } |
709 | 715 |
710 @Override | 716 @Override |
711 @PaymentRequestUI.SelectionResult public int onSectionOptionSelected( | 717 @PaymentRequestUI.SelectionResult public int onSectionOptionSelected( |
(...skipping 11 matching lines...) Expand all Loading... |
723 } | 729 } |
724 mPaymentInformationCallback = callback; | 730 mPaymentInformationCallback = callback; |
725 return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION; | 731 return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION; |
726 } else if (optionType == PaymentRequestUI.TYPE_SHIPPING_OPTIONS) { | 732 } else if (optionType == PaymentRequestUI.TYPE_SHIPPING_OPTIONS) { |
727 // This may update the line items. | 733 // This may update the line items. |
728 mUiShippingOptions.setSelectedItem(option); | 734 mUiShippingOptions.setSelectedItem(option); |
729 mClient.onShippingOptionChange(option.getIdentifier()); | 735 mClient.onShippingOptionChange(option.getIdentifier()); |
730 mPaymentInformationCallback = callback; | 736 mPaymentInformationCallback = callback; |
731 return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION; | 737 return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION; |
732 } else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) { | 738 } else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) { |
733 assert option instanceof AutofillContact; | 739 assert option instanceof AutofillPayerInfo; |
734 AutofillContact contact = (AutofillContact) option; | 740 AutofillPayerInfo payerInfo = (AutofillPayerInfo) option; |
735 | 741 |
736 if (contact.isComplete()) { | 742 if (payerInfo.isComplete()) { |
737 mContactSection.setSelectedItem(option); | 743 mPayerInfoSection.setSelectedItem(option); |
738 } else { | 744 } else { |
739 editContact(contact); | 745 editPayerInfo(payerInfo); |
740 return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH; | 746 return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH; |
741 } | 747 } |
742 } else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { | 748 } else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { |
743 assert option instanceof PaymentInstrument; | 749 assert option instanceof PaymentInstrument; |
744 if (option instanceof AutofillPaymentInstrument) { | 750 if (option instanceof AutofillPaymentInstrument) { |
745 AutofillPaymentInstrument card = (AutofillPaymentInstrument) opt
ion; | 751 AutofillPaymentInstrument card = (AutofillPaymentInstrument) opt
ion; |
746 | 752 |
747 if (!card.isComplete()) { | 753 if (!card.isComplete()) { |
748 editCard(card); | 754 editCard(card); |
749 return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH; | 755 return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH; |
750 } | 756 } |
751 } | 757 } |
752 | 758 |
753 mPaymentMethodsSection.setSelectedItem(option); | 759 mPaymentMethodsSection.setSelectedItem(option); |
754 } | 760 } |
755 | 761 |
756 return PaymentRequestUI.SELECTION_RESULT_NONE; | 762 return PaymentRequestUI.SELECTION_RESULT_NONE; |
757 } | 763 } |
758 | 764 |
759 @Override | 765 @Override |
760 @PaymentRequestUI.SelectionResult public int onSectionAddOption( | 766 @PaymentRequestUI.SelectionResult public int onSectionAddOption( |
761 @PaymentRequestUI.DataType int optionType, Callback<PaymentInformati
on> callback) { | 767 @PaymentRequestUI.DataType int optionType, Callback<PaymentInformati
on> callback) { |
762 if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) { | 768 if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) { |
763 editAddress(null); | 769 editAddress(null); |
764 mPaymentInformationCallback = callback; | 770 mPaymentInformationCallback = callback; |
765 return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION; | 771 return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION; |
766 } else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) { | 772 } else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) { |
767 editContact(null); | 773 editPayerInfo(null); |
768 return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH; | 774 return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH; |
769 } else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { | 775 } else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { |
770 editCard(null); | 776 editCard(null); |
771 return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH; | 777 return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH; |
772 } | 778 } |
773 | 779 |
774 return PaymentRequestUI.SELECTION_RESULT_NONE; | 780 return PaymentRequestUI.SELECTION_RESULT_NONE; |
775 } | 781 } |
776 | 782 |
777 private void editAddress(final AutofillAddress toEdit) { | 783 private void editAddress(final AutofillAddress toEdit) { |
778 mAddressEditor.edit(toEdit, new Callback<AutofillAddress>() { | 784 mAddressEditor.edit(toEdit, new Callback<AutofillAddress>() { |
779 @Override | 785 @Override |
780 public void onResult(AutofillAddress completeAddress) { | 786 public void onResult(AutofillAddress completeAddress) { |
781 if (mUI == null) return; | 787 if (mUI == null) return; |
782 | 788 |
783 if (completeAddress == null) { | 789 if (completeAddress == null) { |
784 mShippingAddressesSection.setSelectedItemIndex(SectionInform
ation.NO_SELECTION); | 790 mShippingAddressesSection.setSelectedItemIndex(SectionInform
ation.NO_SELECTION); |
785 providePaymentInformation(); | 791 providePaymentInformation(); |
786 } else { | 792 } else { |
787 if (toEdit == null) mShippingAddressesSection.addAndSelectIt
em(completeAddress); | 793 if (toEdit == null) mShippingAddressesSection.addAndSelectIt
em(completeAddress); |
788 mCardEditor.updateBillingAddress(completeAddress); | 794 mCardEditor.updateBillingAddress(completeAddress); |
789 mClient.onShippingAddressChange(completeAddress.toPaymentAdd
ress()); | 795 mClient.onShippingAddressChange(completeAddress.toPaymentAdd
ress()); |
790 } | 796 } |
791 } | 797 } |
792 }); | 798 }); |
793 } | 799 } |
794 | 800 |
795 private void editContact(final AutofillContact toEdit) { | 801 private void editPayerInfo(final AutofillPayerInfo toEdit) { |
796 mContactEditor.edit(toEdit, new Callback<AutofillContact>() { | 802 mPayerInfoEditor.edit(toEdit, new Callback<AutofillPayerInfo>() { |
797 @Override | 803 @Override |
798 public void onResult(AutofillContact completeContact) { | 804 public void onResult(AutofillPayerInfo completePayerInfo) { |
799 if (mUI == null) return; | 805 if (mUI == null) return; |
800 | 806 |
801 if (completeContact == null) { | 807 if (completePayerInfo == null) { |
802 mContactSection.setSelectedItemIndex(SectionInformation.NO_S
ELECTION); | 808 mPayerInfoSection.setSelectedItemIndex(SectionInformation.NO
_SELECTION); |
803 } else if (toEdit == null) { | 809 } else if (toEdit == null) { |
804 mContactSection.addAndSelectItem(completeContact); | 810 mPayerInfoSection.addAndSelectItem(completePayerInfo); |
805 } | 811 } |
806 | 812 |
807 mUI.updateSection(PaymentRequestUI.TYPE_CONTACT_DETAILS, mContac
tSection); | 813 mUI.updateSection(PaymentRequestUI.TYPE_CONTACT_DETAILS, mPayerI
nfoSection); |
808 } | 814 } |
809 }); | 815 }); |
810 } | 816 } |
811 | 817 |
812 private void editCard(final AutofillPaymentInstrument toEdit) { | 818 private void editCard(final AutofillPaymentInstrument toEdit) { |
813 mCardEditor.edit(toEdit, new Callback<AutofillPaymentInstrument>() { | 819 mCardEditor.edit(toEdit, new Callback<AutofillPaymentInstrument>() { |
814 @Override | 820 @Override |
815 public void onResult(AutofillPaymentInstrument completeCard) { | 821 public void onResult(AutofillPaymentInstrument completeCard) { |
816 if (mUI == null) return; | 822 if (mUI == null) return; |
817 | 823 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 * Called after retrieving instrument details. | 1020 * Called after retrieving instrument details. |
1015 */ | 1021 */ |
1016 @Override | 1022 @Override |
1017 public void onInstrumentDetailsReady(String methodName, String stringifiedDe
tails) { | 1023 public void onInstrumentDetailsReady(String methodName, String stringifiedDe
tails) { |
1018 if (mClient == null) return; | 1024 if (mClient == null) return; |
1019 | 1025 |
1020 PaymentResponse response = new PaymentResponse(); | 1026 PaymentResponse response = new PaymentResponse(); |
1021 response.methodName = methodName; | 1027 response.methodName = methodName; |
1022 response.stringifiedDetails = stringifiedDetails; | 1028 response.stringifiedDetails = stringifiedDetails; |
1023 | 1029 |
1024 if (mContactSection != null) { | 1030 if (mPayerInfoSection != null) { |
1025 PaymentOption selectedContact = mContactSection.getSelectedItem(); | 1031 PaymentOption selectedPayerInfo = mPayerInfoSection.getSelectedItem(
); |
1026 if (selectedContact != null) { | 1032 if (selectedPayerInfo != null) { |
1027 // Contacts are created in show(). These should all be instances
of AutofillContact. | 1033 // Payer informations are created in show(). These should all be
instances of |
1028 assert selectedContact instanceof AutofillContact; | 1034 // AutofillPayerInfo. |
1029 response.payerPhone = ((AutofillContact) selectedContact).getPay
erPhone(); | 1035 assert selectedPayerInfo instanceof AutofillPayerInfo; |
1030 response.payerEmail = ((AutofillContact) selectedContact).getPay
erEmail(); | 1036 response.payerName = ((AutofillPayerInfo) selectedPayerInfo).get
PayerName(); |
| 1037 response.payerPhone = ((AutofillPayerInfo) selectedPayerInfo).ge
tPayerPhone(); |
| 1038 response.payerEmail = ((AutofillPayerInfo) selectedPayerInfo).ge
tPayerEmail(); |
1031 } | 1039 } |
1032 } | 1040 } |
1033 | 1041 |
1034 if (mUiShippingOptions != null) { | 1042 if (mUiShippingOptions != null) { |
1035 PaymentOption selectedShippingOption = mUiShippingOptions.getSelecte
dItem(); | 1043 PaymentOption selectedShippingOption = mUiShippingOptions.getSelecte
dItem(); |
1036 if (selectedShippingOption != null && selectedShippingOption.getIden
tifier() != null) { | 1044 if (selectedShippingOption != null && selectedShippingOption.getIden
tifier() != null) { |
1037 response.shippingOption = selectedShippingOption.getIdentifier()
; | 1045 response.shippingOption = selectedShippingOption.getIdentifier()
; |
1038 } | 1046 } |
1039 } | 1047 } |
1040 | 1048 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 private void recordAbortReasonHistogram(int abortReason) { | 1215 private void recordAbortReasonHistogram(int abortReason) { |
1208 assert abortReason < PaymentRequestMetrics.ABORT_REASON_MAX; | 1216 assert abortReason < PaymentRequestMetrics.ABORT_REASON_MAX; |
1209 if (mHasRecordedAbortReason) return; | 1217 if (mHasRecordedAbortReason) return; |
1210 | 1218 |
1211 mHasRecordedAbortReason = true; | 1219 mHasRecordedAbortReason = true; |
1212 RecordHistogram.recordEnumeratedHistogram( | 1220 RecordHistogram.recordEnumeratedHistogram( |
1213 "PaymentRequest.CheckoutFunnel.Aborted", abortReason, | 1221 "PaymentRequest.CheckoutFunnel.Aborted", abortReason, |
1214 PaymentRequestMetrics.ABORT_REASON_MAX); | 1222 PaymentRequestMetrics.ABORT_REASON_MAX); |
1215 } | 1223 } |
1216 } | 1224 } |
OLD | NEW |