Implement a quota policy for canMakePayment, and return QUERY_QUOTA_EXCEEDED accordingly.
Thanks Rouslan for taking this on
:-O
https://codereview.chromium.org/2866623003
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/690997683fffaf201782981ab91701653a0a6a90 commit 690997683fffaf201782981ab91701653a0a6a90 Author: rouslan <rouslan@chromium.org> Date: Tue May 09 18:07:39 2017 PaymentRequest.canMakePayment() query quota on desktop. Before this patch, Chrome on Android would restrict canMakePayment() queries to 1 per 30 minutes per iframe origin. Desktop did not have this restriction. This patch adds a browser-wide service CanMakePaymentQuery that keeps track of canMakePayment() queries in iframes. The first call to canMakePayment() from an iframe saves the query in memory and starts a 30 minute timer that, after ending, forgets the query. During these 30 minutes, the iframe origin is allowed to call canMakePayment() only with its original query. This restriction is lifted for localhost and file:// scheme origins for web developer convenience, but a warning is printed in the developer console. This patch switches PaymentRequest browser tests from https://127.0.0.1 to use https://a.com instead to simulate usage in production. After this patch, Chrome on desktop behaves in the same way as on Android: each iframe origin can call canMakePayment() with 1 query per 30 minutes. TEST=PaymentRequestCanMakePaymentCCQuery.QueryQuota TBR=erg@chromium.org BUG= 704676 Review-Url: https://codereview.chromium.org/2866623003 Cr-Commit-Position: refs/heads/master@{#470382} [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/chrome/browser/chrome_content_browser_client.cc [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/chrome/browser/payments/payment_request_factory.cc [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/chrome/browser/payments/payment_request_factory.h [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/chrome/browser/ui/views/payments/payment_request_browsertest_base.cc [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/chrome/browser/ui/views/payments/payment_request_browsertest_base.h [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/chrome/browser/ui/views/payments/payment_request_can_make_payment_browsertest.cc [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/chrome/test/data/payments/can_make_payment_query_cc.js [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/content/BUILD.gn [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/content/DEPS [add] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/content/can_make_payment_query_factory.cc [add] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/content/can_make_payment_query_factory.h [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/content/payment_request.cc [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/content/payment_request.h [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/content/payment_request_spec.cc [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/content/payment_request_spec.h [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/content/payment_request_web_contents_manager.cc [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/content/payment_request_web_contents_manager.h [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/core/BUILD.gn [modify] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/core/DEPS [add] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/core/can_make_payment_query.cc [add] https://crrev.com/690997683fffaf201782981ab91701653a0a6a90/components/payments/core/can_make_payment_query.h
Comment 1 by ma...@chromium.org
, Mar 23 2017