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

Unified Diff: components/payments/content/payment_request_web_contents_manager.h

Issue 2864013002: Verify behavior of PaymentRequest.show() method, part 1. (Closed)
Patch Set: Address comments. 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 side-by-side diff with in-line comments
Download patch
Index: components/payments/content/payment_request_web_contents_manager.h
diff --git a/components/payments/content/payment_request_web_contents_manager.h b/components/payments/content/payment_request_web_contents_manager.h
index be08a3da0035226eb91044d9d85b61fd37c81ff8..1c000ec33ed3be157d6b0a498eb3cf24856a95b8 100644
--- a/components/payments/content/payment_request_web_contents_manager.h
+++ b/components/payments/content/payment_request_web_contents_manager.h
@@ -5,8 +5,8 @@
#ifndef COMPONENTS_PAYMENTS_PAYMENT_REQUEST_WEB_CONTENTS_MANAGER_H_
#define COMPONENTS_PAYMENTS_PAYMENT_REQUEST_WEB_CONTENTS_MANAGER_H_
+#include <map>
#include <memory>
-#include <unordered_map>
#include "base/macros.h"
#include "components/payments/content/payment_request.h"
@@ -50,6 +50,12 @@ class PaymentRequestWebContentsManager
// Destroys the given |request|.
void DestroyRequest(PaymentRequest* request);
+ // Called when |request| has received the show() call. If the |request| can be
+ // shown, then returns true and assumes that |request| is now showing until
+ // DestroyRequest(|request|) is called with the same pointer. (Only one
+ // request at a time can be shown per tab.)
+ bool CanShow(PaymentRequest* request);
+
private:
explicit PaymentRequestWebContentsManager(content::WebContents* web_contents);
friend class content::WebContentsUserData<PaymentRequestWebContentsManager>;
@@ -59,8 +65,11 @@ class PaymentRequestWebContentsManager
// PaymentRequestWebContentsManager's lifetime is tied to the WebContents,
// these requests only get destroyed when the WebContents goes away, or when
// the requests themselves call DestroyRequest().
- std::unordered_map<PaymentRequest*, std::unique_ptr<PaymentRequest>>
- payment_requests_;
+ std::map<PaymentRequest*, std::unique_ptr<PaymentRequest>> payment_requests_;
+
+ // The currently displayed instance of PaymentRequest. Points to one of the
+ // elements in |payment_requests_|. Can be null.
+ PaymentRequest* showing_;
DISALLOW_COPY_AND_ASSIGN(PaymentRequestWebContentsManager);
};
« no previous file with comments | « components/payments/content/payment_request.cc ('k') | components/payments/content/payment_request_web_contents_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698