blob: ca893723f6fd8a1491cd5e13f7324369ff585fef [file] [log] [blame]
mathpf709499d2017-01-09 20:48:361// Copyright 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "components/payments/payment_request_web_contents_manager.h"
6
7#include <memory>
8#include <utility>
9
10#include "base/logging.h"
11#include "components/payments/payment_request_delegate.h"
12
13DEFINE_WEB_CONTENTS_USER_DATA_KEY(payments::PaymentRequestWebContentsManager);
14
15namespace payments {
16
17PaymentRequestWebContentsManager::~PaymentRequestWebContentsManager() {}
18
19PaymentRequestWebContentsManager*
20PaymentRequestWebContentsManager::GetOrCreateForWebContents(
21 content::WebContents* web_contents) {
22 DCHECK(web_contents);
mathpa397e242017-01-19 20:01:1523 // CreateForWebContents does nothing if the manager instance already exists.
mathpf709499d2017-01-09 20:48:3624 PaymentRequestWebContentsManager::CreateForWebContents(web_contents);
25 return PaymentRequestWebContentsManager::FromWebContents(web_contents);
26}
27
28void PaymentRequestWebContentsManager::CreatePaymentRequest(
29 content::WebContents* web_contents,
30 std::unique_ptr<PaymentRequestDelegate> delegate,
31 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request) {
32 std::unique_ptr<PaymentRequest> new_request(new PaymentRequest(
33 web_contents, std::move(delegate), this, std::move(request)));
34 PaymentRequest* request_ptr = new_request.get();
35 payment_requests_.insert(std::make_pair(request_ptr, std::move(new_request)));
36}
37
38void PaymentRequestWebContentsManager::DestroyRequest(PaymentRequest* request) {
39 payment_requests_.erase(request);
40}
41
42PaymentRequestWebContentsManager::PaymentRequestWebContentsManager(
43 content::WebContents* web_contents) {}
44
45} // namespace payments