Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
|
please use gerrit instead
2017/01/06 21:49:10
2017
Mathieu
2017/01/07 05:03:08
Done.
| |
| 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_PAYMENT_REQUEST_WEB_CONTENTS_MANAGER_H_ | |
| 6 #define COMPONENTS_PAYMENTS_PAYMENT_REQUEST_WEB_CONTENTS_MANAGER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <set> | |
| 10 | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "components/payments/payment_request.mojom.h" | |
| 13 #include "components/payments/payment_request_impl.h" | |
| 14 #include "content/public/browser/web_contents_user_data.h" | |
| 15 #include "mojo/public/cpp/bindings/binding.h" | |
| 16 | |
| 17 namespace payments { | |
| 18 | |
| 19 class PaymentRequestDelegate; | |
| 20 | |
| 21 // This class owns the PaymentRequestImpl associated with a given WebContents. | |
| 22 // | |
| 23 // Responsible for creating PaymentRequestImpl's and retaining ownership. No | |
| 24 // request pointers are currently available because the request manages its | |
| 25 // interactions with UI and renderer. The PaymentRequestImpl may call | |
| 26 // DestroyRequest() to signal it is ready to die. Otherwise it gets destroyed | |
| 27 // when the WebContents (thus this class) goes away. | |
| 28 class PaymentRequestWebContentsManager | |
| 29 : public content::WebContentsUserData<PaymentRequestWebContentsManager> { | |
| 30 public: | |
| 31 ~PaymentRequestWebContentsManager() override; | |
| 32 | |
| 33 // Retrieves the instance of PaymentRequestWebContentsManager that was | |
| 34 // attached to the specified WebContents. If no instance was attached, | |
| 35 // creates one, and attaches it to the specified WebContents. | |
| 36 static PaymentRequestWebContentsManager* GetOrCreateForWebContents( | |
| 37 content::WebContents* web_contents); | |
| 38 | |
| 39 // Creates the PaymentRequestImpl that will interact with this |web_contents|. | |
| 40 void CreatePaymentRequestImpl( | |
| 41 content::WebContents* web_contents, | |
| 42 std::unique_ptr<PaymentRequestDelegate> delegate, | |
| 43 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request); | |
| 44 | |
| 45 // Destroys the given |request|. | |
| 46 void DestroyRequest(PaymentRequestImpl* request); | |
| 47 | |
| 48 private: | |
| 49 explicit PaymentRequestWebContentsManager(content::WebContents* web_contents); | |
| 50 friend class content::WebContentsUserData<PaymentRequestWebContentsManager>; | |
| 51 friend class SitePerProcessPaymentsBrowserTest; | |
| 52 | |
| 53 // Owns all the PaymentRequestImpl for this WebContents. Since the | |
| 54 // PaymentRequestWebContentsManager's lifetime is tied to the WebContents, | |
| 55 // these requests only get destroyed when the WebContents goes away, or when | |
| 56 // the requests themselves call DestroyRequest(). | |
| 57 std::unordered_map<PaymentRequestImpl*, std::unique_ptr<PaymentRequestImpl>> | |
| 58 payment_requests_; | |
| 59 }; | |
|
please use gerrit instead
2017/01/06 21:49:10
DISALLOW_COPY_AND_ASSIGN(PaymentRequestWebContents
| |
| 60 | |
| 61 } // namespace payments | |
| 62 | |
| 63 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_IMPL_H_ | |
| OLD | NEW |