Chromium Code Reviews| Index: components/payments/payment_request_web_contents_manager.h |
| diff --git a/components/payments/payment_request_web_contents_manager.h b/components/payments/payment_request_web_contents_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d16e4f65481025c0730417f12005cde2996ae2ae |
| --- /dev/null |
| +++ b/components/payments/payment_request_web_contents_manager.h |
| @@ -0,0 +1,63 @@ |
| +// 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.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_PAYMENTS_PAYMENT_REQUEST_WEB_CONTENTS_MANAGER_H_ |
| +#define COMPONENTS_PAYMENTS_PAYMENT_REQUEST_WEB_CONTENTS_MANAGER_H_ |
| + |
| +#include <map> |
| +#include <set> |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "components/payments/payment_request.mojom.h" |
| +#include "components/payments/payment_request_impl.h" |
| +#include "content/public/browser/web_contents_user_data.h" |
| +#include "mojo/public/cpp/bindings/binding.h" |
| + |
| +namespace payments { |
| + |
| +class PaymentRequestDelegate; |
| + |
| +// This class owns the PaymentRequestImpl associated with a given WebContents. |
| +// |
| +// Responsible for creating PaymentRequestImpl's and retaining ownership. No |
| +// request pointers are currently available because the request manages its |
| +// interactions with UI and renderer. The PaymentRequestImpl may call |
| +// DestroyRequest() to signal it is ready to die. Otherwise it gets destroyed |
| +// when the WebContents (thus this class) goes away. |
| +class PaymentRequestWebContentsManager |
| + : public content::WebContentsUserData<PaymentRequestWebContentsManager> { |
| + public: |
| + ~PaymentRequestWebContentsManager() override; |
| + |
| + // Retrieves the instance of PaymentRequestWebContentsManager that was |
| + // attached to the specified WebContents. If no instance was attached, |
| + // creates one, and attaches it to the specified WebContents. |
| + static PaymentRequestWebContentsManager* GetOrCreateForWebContents( |
| + content::WebContents* web_contents); |
| + |
| + // Creates the PaymentRequestImpl that will interact with this |web_contents|. |
| + void CreatePaymentRequestImpl( |
| + content::WebContents* web_contents, |
| + std::unique_ptr<PaymentRequestDelegate> delegate, |
| + mojo::InterfaceRequest<payments::mojom::PaymentRequest> request); |
| + |
| + // Destroys the given |request|. |
| + void DestroyRequest(PaymentRequestImpl* request); |
| + |
| + private: |
| + explicit PaymentRequestWebContentsManager(content::WebContents* web_contents); |
| + friend class content::WebContentsUserData<PaymentRequestWebContentsManager>; |
| + friend class SitePerProcessPaymentsBrowserTest; |
| + |
| + // Owns all the PaymentRequestImpl for this WebContents. Since the |
| + // 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<PaymentRequestImpl*, std::unique_ptr<PaymentRequestImpl>> |
| + payment_requests_; |
| +}; |
|
please use gerrit instead
2017/01/06 21:49:10
DISALLOW_COPY_AND_ASSIGN(PaymentRequestWebContents
|
| + |
| +} // namespace payments |
| + |
| +#endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_IMPL_H_ |