Chromium Code Reviews| Index: components/payments/payment_request_web_contents_manager.cc |
| diff --git a/components/payments/payment_request_web_contents_manager.cc b/components/payments/payment_request_web_contents_manager.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bc484050b25fd8f77e53c7a0ca00cb2c47efa7c7 |
| --- /dev/null |
| +++ b/components/payments/payment_request_web_contents_manager.cc |
| @@ -0,0 +1,45 @@ |
| +// 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. |
| + |
| +#include "components/payments/payment_request_web_contents_manager.h" |
| + |
| +#include <memory> |
| +#include <utility> |
| + |
| +#include "components/payments/payment_request_delegate.h" |
| + |
| +DEFINE_WEB_CONTENTS_USER_DATA_KEY(payments::PaymentRequestWebContentsManager); |
| + |
| +namespace payments { |
| + |
| +PaymentRequestWebContentsManager::~PaymentRequestWebContentsManager() {} |
| + |
| +PaymentRequestWebContentsManager* |
| +PaymentRequestWebContentsManager::GetOrCreateForWebContents( |
| + content::WebContents* web_contents) { |
| + DCHECK(web_contents); |
|
please use gerrit instead
2017/01/06 21:49:10
#include "base/logging.h"
Mathieu
2017/01/07 05:03:07
Done.
|
| + // CreateForWebContents does nothing if the delegate instance already exists. |
| + PaymentRequestWebContentsManager::CreateForWebContents(web_contents); |
| + return PaymentRequestWebContentsManager::FromWebContents(web_contents); |
| +} |
| + |
| +void PaymentRequestWebContentsManager::CreatePaymentRequestImpl( |
| + content::WebContents* web_contents, |
| + std::unique_ptr<PaymentRequestDelegate> delegate, |
| + mojo::InterfaceRequest<payments::mojom::PaymentRequest> request) { |
| + std::unique_ptr<PaymentRequestImpl> new_request(new PaymentRequestImpl( |
| + web_contents, std::move(delegate), this, std::move(request))); |
| + payment_requests_.insert( |
| + std::make_pair(new_request.get(), std::move(new_request))); |
|
please use gerrit instead
2017/01/06 21:49:10
Different compilers evaluate the order of paramete
Mathieu
2017/01/07 05:03:07
Oh wow, OK. I'm caching the raw pointer now, that
|
| +} |
| + |
| +void PaymentRequestWebContentsManager::DestroyRequest( |
| + PaymentRequestImpl* request) { |
| + payment_requests_.erase(request); |
| +} |
| + |
| +PaymentRequestWebContentsManager::PaymentRequestWebContentsManager( |
| + content::WebContents* web_contents) {} |
| + |
| +} // namespace payments |