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

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

Issue 1942653002: Provide shipping address only to merchants that need it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@integration-tests
Patch Set: Rebase Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
index 066456948a1365b725a66e75fa0f24455e2984fd..d6387942a952d36a7ce039d655cb0ffe060e185c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java
@@ -75,6 +75,7 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
private PaymentRequestUI mUI;
private Callback<PaymentInformation> mPaymentInformationCallback;
private Pattern mRegionCodePattern;
+ private boolean mMerchantNeedsShippingAddress;
/**
* Builds the dialog.
@@ -167,6 +168,11 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
return;
}
+ // If the merchant requests shipping and does not provide shipping options here, then the
+ // merchant needs the shipping address to calculate shipping price and availability.
+ boolean requestShipping = options != null && options.requestShipping;
+ mMerchantNeedsShippingAddress = requestShipping && mShippingOptions.isEmpty();
+
mData = getValidatedData(mSupportedMethods, stringifiedData);
if (mData == null) {
disconnectFromClientWithDebugMessage("Invalid payment method specific data");
@@ -211,7 +217,6 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
if (!isGettingInstruments) mPaymentMethods = new SectionInformation();
- boolean requestShipping = options != null && options.requestShipping;
mUI = new PaymentRequestUI(mContext, this, requestShipping, mMerchantName, mOrigin);
if (mFavicon != null) mUI.setTitleBitmap(mFavicon);
mFavicon = null;
@@ -394,8 +399,10 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
public void onShippingAddressChanged(PaymentOption selectedShippingAddress) {
assert selectedShippingAddress instanceof AutofillAddress;
mShippingAddresses.setSelectedItem(selectedShippingAddress);
- mClient.onShippingAddressChange(
- ((AutofillAddress) selectedShippingAddress).toShippingAddress());
+ if (mMerchantNeedsShippingAddress) {
+ mClient.onShippingAddressChange(
+ ((AutofillAddress) selectedShippingAddress).toShippingAddress());
+ }
}
@Override
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698