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

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

Issue 2815763002: Prevent usage of web payments API over insecure HTTPS. (Closed)
Patch Set: Fix typo Created 3 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 | chrome/android/java/src/org/chromium/chrome/browser/payments/SslValidityChecker.java » ('j') | 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 74ee260af37fa790402224a4ed0aaae940573255..8ba065f0731b9fba0948c03490ba0cd92ca75fea 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
@@ -46,6 +46,7 @@ import org.chromium.chrome.browser.tabmodel.TabModelObserver;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
import org.chromium.components.payments.CurrencyFormatter;
+import org.chromium.components.payments.OriginSecurityChecker;
import org.chromium.components.payments.PaymentValidator;
import org.chromium.components.url_formatter.UrlFormatter;
import org.chromium.content_public.browser.RenderFrameHost;
@@ -406,6 +407,31 @@ public class PaymentRequestImpl
if (mClient != null || client == null) return;
mClient = client;
+ if (!OriginSecurityChecker.isOriginSecure(mWebContents.getLastCommittedUrl())) {
+ recordAbortReasonHistogram(
+ PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER);
+ disconnectFromClientWithDebugMessage("Not in a secure context");
+ return;
+ }
+
+ mRequestShipping = options != null && options.requestShipping;
+ mRequestPayerName = options != null && options.requestPayerName;
+ mRequestPayerPhone = options != null && options.requestPayerPhone;
+ mRequestPayerEmail = options != null && options.requestPayerEmail;
+ mShippingType = options == null ? PaymentShippingType.SHIPPING : options.shippingType;
+
+ PaymentRequestMetrics.recordRequestedInformationHistogram(
+ mRequestPayerEmail, mRequestPayerPhone, mRequestShipping, mRequestPayerName);
+
+ if (OriginSecurityChecker.isSchemeCryptographic(mWebContents.getLastCommittedUrl())
+ && !SslValidityChecker.isSslCertificateValid(mWebContents)) {
+ Log.d(TAG, "SSL certificate is not valid");
+ // Don't show any UI. Resolve .canMakePayment() with "false". Reject .show() with
+ // "NotSupportedError".
+ onAllPaymentAppsCreated();
+ return;
+ }
+
if (mMethodData != null) {
disconnectFromClientWithDebugMessage("PaymentRequest.show() called more than once.");
recordAbortReasonHistogram(
@@ -433,12 +459,6 @@ public class PaymentRequestImpl
PaymentAppFactory.getInstance().create(mWebContents,
Collections.unmodifiableSet(mMethodData.keySet()), this /* callback */);
- mRequestShipping = options != null && options.requestShipping;
- mRequestPayerName = options != null && options.requestPayerName;
- mRequestPayerPhone = options != null && options.requestPayerPhone;
- mRequestPayerEmail = options != null && options.requestPayerEmail;
- mShippingType = options == null ? PaymentShippingType.SHIPPING : options.shippingType;
-
// If there is a single payment method and the merchant has not requested any other
// information, we can safely go directly to the payment app instead of showing
// Payment Request UI.
@@ -451,9 +471,6 @@ public class PaymentRequestImpl
// the payment request UI, thus can't be skipped.
&& mMethodData.keySet().iterator().next() != null
&& mMethodData.keySet().iterator().next().startsWith(UrlConstants.HTTPS_URL_PREFIX);
-
- PaymentRequestMetrics.recordRequestedInformationHistogram(mRequestPayerEmail,
- mRequestPayerPhone, mRequestShipping, mRequestPayerName);
}
private void buildUI(Activity activity) {
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/SslValidityChecker.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698