Commit 79fc7765 authored by rouslan's avatar rouslan Committed by Commit bot

Limit canMakePayment per iframe

BUG=702464

Review-Url: https://codereview.chromium.org/2753773008
Cr-Commit-Position: refs/heads/master@{#457808}
parent e309da24
...@@ -224,10 +224,10 @@ public class PaymentRequestImpl ...@@ -224,10 +224,10 @@ public class PaymentRequestImpl
private static boolean sIsAnyPaymentRequestShowing; private static boolean sIsAnyPaymentRequestShowing;
/** /**
* In-memory mapping of the origins of websites that have recently called canMakePayment() * In-memory mapping of the origins of iframes that have recently called canMakePayment() to the
* to the list of the payment methods that were being queried. Used for throttling the usage of * list of the payment methods that were being queried. Used for throttling the usage of this
* this call. The mapping is shared among all instances of PaymentRequestImpl in the browser * call. The mapping is shared among all instances of PaymentRequestImpl in the browser process
* process on UI thread. The user can reset the throttling mechanism by restarting the browser. * on UI thread. The user can reset the throttling mechanism by restarting the browser.
*/ */
private static Map<String, CanMakePaymentQuery> sCanMakePaymentQueries; private static Map<String, CanMakePaymentQuery> sCanMakePaymentQueries;
...@@ -649,7 +649,8 @@ public class PaymentRequestImpl ...@@ -649,7 +649,8 @@ public class PaymentRequestImpl
} }
if (queryApps.isEmpty()) { if (queryApps.isEmpty()) {
CanMakePaymentQuery query = sCanMakePaymentQueries.get(mSchemelessOriginForPaymentApp); CanMakePaymentQuery query =
sCanMakePaymentQueries.get(mSchemelessIFrameOriginForPaymentApp);
if (query != null && query.matchesPaymentMethods(mMethodData)) { if (query != null && query.matchesPaymentMethods(mMethodData)) {
query.notifyObserversOfResponse(mCanMakePayment); query.notifyObserversOfResponse(mCanMakePayment);
} }
...@@ -1272,14 +1273,15 @@ public class PaymentRequestImpl ...@@ -1272,14 +1273,15 @@ public class PaymentRequestImpl
public void canMakePayment() { public void canMakePayment() {
if (mClient == null) return; if (mClient == null) return;
CanMakePaymentQuery query = sCanMakePaymentQueries.get(mSchemelessOriginForPaymentApp); CanMakePaymentQuery query =
sCanMakePaymentQueries.get(mSchemelessIFrameOriginForPaymentApp);
if (query == null) { if (query == null) {
query = new CanMakePaymentQuery(Collections.unmodifiableMap(mMethodData)); query = new CanMakePaymentQuery(Collections.unmodifiableMap(mMethodData));
sCanMakePaymentQueries.put(mSchemelessOriginForPaymentApp, query); sCanMakePaymentQueries.put(mSchemelessIFrameOriginForPaymentApp, query);
mHandler.postDelayed(new Runnable() { mHandler.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
sCanMakePaymentQueries.remove(mSchemelessOriginForPaymentApp); sCanMakePaymentQueries.remove(mSchemelessIFrameOriginForPaymentApp);
} }
}, CAN_MAKE_PAYMENT_QUERY_PERIOD_MS); }, CAN_MAKE_PAYMENT_QUERY_PERIOD_MS);
} else if (!query.matchesPaymentMethods(Collections.unmodifiableMap(mMethodData))) { } else if (!query.matchesPaymentMethods(Collections.unmodifiableMap(mMethodData))) {
...@@ -1412,7 +1414,8 @@ public class PaymentRequestImpl ...@@ -1412,7 +1414,8 @@ public class PaymentRequestImpl
} }
} }
CanMakePaymentQuery query = sCanMakePaymentQueries.get(mSchemelessOriginForPaymentApp); CanMakePaymentQuery query =
sCanMakePaymentQueries.get(mSchemelessIFrameOriginForPaymentApp);
if (query != null && query.matchesPaymentMethods(mMethodData)) { if (query != null && query.matchesPaymentMethods(mMethodData)) {
query.notifyObserversOfResponse(mCanMakePayment); query.notifyObserversOfResponse(mCanMakePayment);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment