Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java

Issue 2054823002: PaymentRequest: complete() method should take PaymentComplete enum value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 assert selectedPaymentMethod instanceof PaymentInstrument; 573 assert selectedPaymentMethod instanceof PaymentInstrument;
573 PaymentInstrument instrument = (PaymentInstrument) selectedPaymentMethod ; 574 PaymentInstrument instrument = (PaymentInstrument) selectedPaymentMethod ;
574 mPaymentAppRunning = true; 575 mPaymentAppRunning = true;
575 instrument.getDetails(mMerchantName, mOrigin, mRawTotal, mRawLineItems, 576 instrument.getDetails(mMerchantName, mOrigin, mRawTotal, mRawLineItems,
576 mMethodData.get(instrument.getMethodName()), this); 577 mMethodData.get(instrument.getMethodName()), this);
577 } 578 }
578 579
579 @Override 580 @Override
580 public void onDismiss() { 581 public void onDismiss() {
581 disconnectFromClientWithDebugMessage("Dialog dismissed"); 582 disconnectFromClientWithDebugMessage("Dialog dismissed");
582 closeUI(false); 583 closeUI(true);
please use gerrit instead 2016/06/16 00:31:45 false
583 } 584 }
584 585
585 @Override 586 @Override
586 public boolean merchantNeedsShippingAddress() { 587 public boolean merchantNeedsShippingAddress() {
587 return mMerchantNeedsShippingAddress; 588 return mMerchantNeedsShippingAddress;
588 } 589 }
589 590
590 /** 591 /**
591 * Called by the merchant website to abort the payment. 592 * Called by the merchant website to abort the payment.
592 */ 593 */
593 @Override 594 @Override
594 public void abort() { 595 public void abort() {
595 mClient.onAbort(!mPaymentAppRunning); 596 mClient.onAbort(!mPaymentAppRunning);
596 if (mPaymentAppRunning) { 597 if (mPaymentAppRunning) {
597 if (sObserverForTest != null) sObserverForTest.onPaymentRequestServi ceUnableToAbort(); 598 if (sObserverForTest != null) sObserverForTest.onPaymentRequestServi ceUnableToAbort();
598 } else { 599 } else {
599 closeClient(); 600 closeClient();
600 closeUI(false); 601 closeUI(true);
please use gerrit instead 2016/06/16 00:31:46 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(true);
please use gerrit instead 2016/06/16 00:31:45 false
619 } 620 }
620 621
621 /** 622 /**
622 * Called when the Mojo connection encounters an error. 623 * Called when the Mojo connection encounters an error.
623 */ 624 */
624 @Override 625 @Override
625 public void onConnectionError(MojoException e) { 626 public void onConnectionError(MojoException e) {
626 closeClient(); 627 closeClient();
627 closeUI(false); 628 closeUI(true);
please use gerrit instead 2016/06/16 00:31:45 false
628 } 629 }
629 630
630 /** 631 /**
631 * Called after retrieving the list of payment instruments in an app. 632 * Called after retrieving the list of payment instruments in an app.
632 */ 633 */
633 @Override 634 @Override
634 public void onInstrumentsReady(PaymentApp app, List<PaymentInstrument> instr uments) { 635 public void onInstrumentsReady(PaymentApp app, List<PaymentInstrument> instr uments) {
635 mPendingApps.remove(app); 636 mPendingApps.remove(app);
636 637
637 if (instruments != null) { 638 if (instruments != null) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 681
681 mClient.onPaymentResponse(response); 682 mClient.onPaymentResponse(response);
682 } 683 }
683 684
684 /** 685 /**
685 * Called if unable to retrieve instrument details. 686 * Called if unable to retrieve instrument details.
686 */ 687 */
687 @Override 688 @Override
688 public void onInstrumentDetailsError() { 689 public void onInstrumentDetailsError() {
689 disconnectFromClientWithDebugMessage("Failed to retrieve payment instrum ent details"); 690 disconnectFromClientWithDebugMessage("Failed to retrieve payment instrum ent details");
690 closeUI(false); 691 closeUI(true);
please use gerrit instead 2016/06/16 00:31:45 false
691 } 692 }
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 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698