| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_PAYMENTS_PAYMENT_REQUEST_WEB_CONTENTS_MANAGER_H_ | 5 #ifndef COMPONENTS_PAYMENTS_PAYMENT_REQUEST_WEB_CONTENTS_MANAGER_H_ |
| 6 #define COMPONENTS_PAYMENTS_PAYMENT_REQUEST_WEB_CONTENTS_MANAGER_H_ | 6 #define COMPONENTS_PAYMENTS_PAYMENT_REQUEST_WEB_CONTENTS_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <unordered_map> | 9 #include <unordered_map> |
| 9 | 10 |
| 10 #include "components/payments/payment_request.h" | 11 #include "base/macros.h" |
| 11 #include "components/payments/payment_request.mojom.h" | 12 #include "components/payments/content/payment_request.mojom.h" |
| 12 #include "content/public/browser/web_contents_user_data.h" | 13 #include "content/public/browser/web_contents_user_data.h" |
| 13 #include "mojo/public/cpp/bindings/binding.h" | 14 #include "mojo/public/cpp/bindings/binding.h" |
| 14 | 15 |
| 16 namespace content { |
| 17 class WebContents; |
| 18 } |
| 19 |
| 15 namespace payments { | 20 namespace payments { |
| 16 | 21 |
| 22 class PaymentRequest; |
| 17 class PaymentRequestDelegate; | 23 class PaymentRequestDelegate; |
| 18 | 24 |
| 19 // This class owns the PaymentRequest associated with a given WebContents. | 25 // This class owns the PaymentRequest associated with a given WebContents. |
| 20 // | 26 // |
| 21 // Responsible for creating PaymentRequest's and retaining ownership. No request | 27 // Responsible for creating PaymentRequest's and retaining ownership. No request |
| 22 // pointers are currently available because the request manages its interactions | 28 // pointers are currently available because the request manages its interactions |
| 23 // with UI and renderer. The PaymentRequest may call DestroyRequest() to signal | 29 // with UI and renderer. The PaymentRequest may call DestroyRequest() to signal |
| 24 // it is ready to die. Otherwise it gets destroyed when the WebContents (thus | 30 // it is ready to die. Otherwise it gets destroyed when the WebContents (thus |
| 25 // this class) goes away. | 31 // this class) goes away. |
| 26 class PaymentRequestWebContentsManager | 32 class PaymentRequestWebContentsManager |
| (...skipping 20 matching lines...) Expand all Loading... |
| 47 explicit PaymentRequestWebContentsManager(content::WebContents* web_contents); | 53 explicit PaymentRequestWebContentsManager(content::WebContents* web_contents); |
| 48 friend class content::WebContentsUserData<PaymentRequestWebContentsManager>; | 54 friend class content::WebContentsUserData<PaymentRequestWebContentsManager>; |
| 49 friend class PaymentRequestInteractiveTestBase; | 55 friend class PaymentRequestInteractiveTestBase; |
| 50 | 56 |
| 51 // Owns all the PaymentRequest for this WebContents. Since the | 57 // Owns all the PaymentRequest for this WebContents. Since the |
| 52 // PaymentRequestWebContentsManager's lifetime is tied to the WebContents, | 58 // PaymentRequestWebContentsManager's lifetime is tied to the WebContents, |
| 53 // these requests only get destroyed when the WebContents goes away, or when | 59 // these requests only get destroyed when the WebContents goes away, or when |
| 54 // the requests themselves call DestroyRequest(). | 60 // the requests themselves call DestroyRequest(). |
| 55 std::unordered_map<PaymentRequest*, std::unique_ptr<PaymentRequest>> | 61 std::unordered_map<PaymentRequest*, std::unique_ptr<PaymentRequest>> |
| 56 payment_requests_; | 62 payment_requests_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(PaymentRequestWebContentsManager); |
| 57 }; | 65 }; |
| 58 | 66 |
| 59 } // namespace payments | 67 } // namespace payments |
| 60 | 68 |
| 61 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_WEB_CONTENTS_MANAGER_H_ | 69 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_WEB_CONTENTS_MANAGER_H_ |
| OLD | NEW |