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 12 matching lines...) Expand all Loading... |
23 import org.chromium.chrome.browser.payments.ui.ShoppingCart; | 23 import org.chromium.chrome.browser.payments.ui.ShoppingCart; |
24 import org.chromium.chrome.browser.preferences.PreferencesLauncher; | 24 import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
25 import org.chromium.chrome.browser.preferences.autofill.AutofillCreditCardEditor
; | 25 import org.chromium.chrome.browser.preferences.autofill.AutofillCreditCardEditor
; |
26 import org.chromium.chrome.browser.preferences.autofill.AutofillProfileEditor; | 26 import org.chromium.chrome.browser.preferences.autofill.AutofillProfileEditor; |
27 import org.chromium.chrome.browser.profiles.Profile; | 27 import org.chromium.chrome.browser.profiles.Profile; |
28 import org.chromium.chrome.browser.util.UrlUtilities; | 28 import org.chromium.chrome.browser.util.UrlUtilities; |
29 import org.chromium.components.safejson.JsonSanitizer; | 29 import org.chromium.components.safejson.JsonSanitizer; |
30 import org.chromium.content.browser.ContentViewCore; | 30 import org.chromium.content.browser.ContentViewCore; |
31 import org.chromium.content_public.browser.WebContents; | 31 import org.chromium.content_public.browser.WebContents; |
32 import org.chromium.mojo.system.MojoException; | 32 import org.chromium.mojo.system.MojoException; |
| 33 import org.chromium.mojom.payments.PaymentComplete; |
33 import org.chromium.mojom.payments.PaymentDetails; | 34 import org.chromium.mojom.payments.PaymentDetails; |
34 import org.chromium.mojom.payments.PaymentItem; | 35 import org.chromium.mojom.payments.PaymentItem; |
35 import org.chromium.mojom.payments.PaymentMethodData; | 36 import org.chromium.mojom.payments.PaymentMethodData; |
36 import org.chromium.mojom.payments.PaymentOptions; | 37 import org.chromium.mojom.payments.PaymentOptions; |
37 import org.chromium.mojom.payments.PaymentRequest; | 38 import org.chromium.mojom.payments.PaymentRequest; |
38 import org.chromium.mojom.payments.PaymentRequestClient; | 39 import org.chromium.mojom.payments.PaymentRequestClient; |
39 import org.chromium.mojom.payments.PaymentResponse; | 40 import org.chromium.mojom.payments.PaymentResponse; |
40 import org.chromium.mojom.payments.ShippingOption; | 41 import org.chromium.mojom.payments.ShippingOption; |
41 import org.chromium.ui.base.WindowAndroid; | 42 import org.chromium.ui.base.WindowAndroid; |
42 import org.json.JSONException; | 43 import org.json.JSONException; |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 } else { | 599 } else { |
599 closeClient(); | 600 closeClient(); |
600 closeUI(false); | 601 closeUI(false); |
601 } | 602 } |
602 } | 603 } |
603 | 604 |
604 /** | 605 /** |
605 * Called when the merchant website has processed the payment. | 606 * Called when the merchant website has processed the payment. |
606 */ | 607 */ |
607 @Override | 608 @Override |
608 public void complete(boolean success) { | 609 public void complete(int result) { |
609 closeUI(success); | 610 closeUI(PaymentComplete.FAIL != result); |
610 } | 611 } |
611 | 612 |
612 /** | 613 /** |
613 * Called when the renderer closes the Mojo connection. | 614 * Called when the renderer closes the Mojo connection. |
614 */ | 615 */ |
615 @Override | 616 @Override |
616 public void close() { | 617 public void close() { |
617 closeClient(); | 618 closeClient(); |
618 closeUI(false); | 619 closeUI(false); |
619 } | 620 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 | 693 |
693 private void disconnectFromClientWithDebugMessage(String debugMessage) { | 694 private void disconnectFromClientWithDebugMessage(String debugMessage) { |
694 Log.d(TAG, debugMessage); | 695 Log.d(TAG, debugMessage); |
695 mClient.onError(); | 696 mClient.onError(); |
696 closeClient(); | 697 closeClient(); |
697 } | 698 } |
698 | 699 |
699 /** | 700 /** |
700 * Closes the UI. If the client is still connected, then it's notified of UI
hiding. | 701 * Closes the UI. If the client is still connected, then it's notified of UI
hiding. |
701 */ | 702 */ |
702 private void closeUI(boolean paymentSuccess) { | 703 private void closeUI(boolean immediateClose) { |
703 if (mUI != null) { | 704 if (mUI != null) { |
704 mUI.close(paymentSuccess, new Runnable() { | 705 mUI.close(immediateClose, new Runnable() { |
705 @Override | 706 @Override |
706 public void run() { | 707 public void run() { |
707 if (mClient != null) mClient.onComplete(); | 708 if (mClient != null) mClient.onComplete(); |
708 closeClient(); | 709 closeClient(); |
709 } | 710 } |
710 }); | 711 }); |
711 mUI = null; | 712 mUI = null; |
712 } | 713 } |
713 | 714 |
714 if (mPaymentMethodsSection != null) { | 715 if (mPaymentMethodsSection != null) { |
715 for (int i = 0; i < mPaymentMethodsSection.getSize(); i++) { | 716 for (int i = 0; i < mPaymentMethodsSection.getSize(); i++) { |
716 PaymentOption option = mPaymentMethodsSection.getItem(i); | 717 PaymentOption option = mPaymentMethodsSection.getItem(i); |
717 assert option instanceof PaymentInstrument; | 718 assert option instanceof PaymentInstrument; |
718 ((PaymentInstrument) option).dismiss(); | 719 ((PaymentInstrument) option).dismiss(); |
719 } | 720 } |
720 mPaymentMethodsSection = null; | 721 mPaymentMethodsSection = null; |
721 } | 722 } |
722 } | 723 } |
723 | 724 |
724 private void closeClient() { | 725 private void closeClient() { |
725 if (mClient != null) mClient.close(); | 726 if (mClient != null) mClient.close(); |
726 mClient = null; | 727 mClient = null; |
727 } | 728 } |
728 | 729 |
729 @VisibleForTesting | 730 @VisibleForTesting |
730 public static void setObserverForTest(PaymentRequestServiceObserverForTest o
bserverForTest) { | 731 public static void setObserverForTest(PaymentRequestServiceObserverForTest o
bserverForTest) { |
731 sObserverForTest = observerForTest; | 732 sObserverForTest = observerForTest; |
732 } | 733 } |
733 } | 734 } |
OLD | NEW |