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

Side by Side Diff: components/payments/core/can_make_payment_query.h

Issue 2866623003: PaymentRequest.canMakePayment() query quota on desktop. (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_PAYMENTS_CORE_CAN_MAKE_PAYMENT_QUERY_H_
6 #define COMPONENTS_PAYMENTS_CORE_CAN_MAKE_PAYMENT_QUERY_H_
7
8 #include <map>
9 #include <memory>
10 #include <set>
11 #include <string>
12
13 #include "base/macros.h"
14 #include "base/timer/timer.h"
15 #include "components/keyed_service/core/keyed_service.h"
16 #include "url/gurl.h"
17
18 namespace payments {
19
20 // Keeps track of canMakePayment() queries per browser context.
21 class CanMakePaymentQuery : public KeyedService {
22 public:
23 CanMakePaymentQuery();
24 ~CanMakePaymentQuery() override;
25
26 // Returns whether |iframe_origin| can call canMakePayment() with |query|,
27 // which is a mapping of payment method names to the corresponding
28 // JSON-stringified payment method data. Remembers the iframe-to-query mapping
Mathieu 2017/05/08 15:28:11 see other comment, name this *frame instead of ifr
please use gerrit instead 2017/05/08 17:28:47 Done.
29 // for 30 minutes to enforce the quota.
30 bool CanQuery(const GURL& iframe_origin,
31 const std::map<std::string, std::set<std::string>>& query);
32
33 private:
34 void ExpireQuotaForIframeOrigin(const GURL& iframe_origin);
35
36 // A mapping of iframe origin to the timer that, when fired, allows the iframe
37 // to invoke canMakePayment() with a different query.
38 std::map<GURL, std::unique_ptr<base::OneShotTimer>> timers_;
39
40 // A mapping of iframe origin to its last query. Each query is a mapping of
41 // payment method names to the corresponding JSON-stringified payment method
42 // data.
43 std::map<GURL, std::map<std::string, std::set<std::string>>> queries_;
44
45 DISALLOW_COPY_AND_ASSIGN(CanMakePaymentQuery);
46 };
47
48 } // namespace payments
49
50 #endif // COMPONENTS_PAYMENTS_CORE_CAN_MAKE_PAYMENT_QUERY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698