Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
|
please use gerrit instead
2017/01/06 21:49:09
2017
Mathieu
2017/01/07 05:03:07
Well it was moved so I'll keep 2016.
| |
| 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_impl.h" | |
| 6 | |
| 7 #include <map> | |
| 8 | |
| 9 #include "base/lazy_instance.h" | |
| 10 #include "components/payments/payment_details_validation.h" | |
| 11 #include "components/payments/payment_request_delegate.h" | |
| 12 #include "components/payments/payment_request_web_contents_manager.h" | |
| 13 #include "content/public/browser/browser_thread.h" | |
| 14 #include "content/public/browser/web_contents.h" | |
| 15 | |
| 16 namespace payments { | |
| 17 | |
| 18 PaymentRequestImpl::PaymentRequestImpl( | |
| 19 content::WebContents* web_contents, | |
| 20 std::unique_ptr<PaymentRequestDelegate> delegate, | |
| 21 PaymentRequestWebContentsManager* manager, | |
| 22 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request) | |
| 23 : web_contents_(web_contents), | |
| 24 delegate_(std::move(delegate)), | |
| 25 manager_(manager), | |
| 26 binding_(this, std::move(request)) { | |
| 27 binding_.set_connection_error_handler( | |
| 28 base::Bind(&PaymentRequestImpl::OnError, base::Unretained(this))); | |
| 29 } | |
| 30 | |
| 31 PaymentRequestImpl::~PaymentRequestImpl() {} | |
| 32 | |
| 33 void PaymentRequestImpl::Init( | |
| 34 payments::mojom::PaymentRequestClientPtr client, | |
| 35 std::vector<payments::mojom::PaymentMethodDataPtr> methodData, | |
| 36 payments::mojom::PaymentDetailsPtr details, | |
| 37 payments::mojom::PaymentOptionsPtr options) { | |
| 38 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 39 std::string error; | |
| 40 if (!payments::validatePaymentDetails(details, &error)) { | |
| 41 LOG(ERROR) << error; | |
| 42 OnError(); | |
| 43 return; | |
| 44 } | |
| 45 client_ = std::move(client); | |
| 46 details_ = std::move(details); | |
| 47 } | |
| 48 | |
| 49 void PaymentRequestImpl::Show() { | |
| 50 delegate_->ShowPaymentRequestDialog(this); | |
| 51 } | |
| 52 | |
| 53 void PaymentRequestImpl::Cancel() { | |
| 54 client_->OnError(payments::mojom::PaymentErrorReason::USER_CANCEL); | |
| 55 } | |
| 56 | |
| 57 void PaymentRequestImpl::OnError() { | |
| 58 binding_.Close(); | |
| 59 // Kill ourselves. | |
|
please use gerrit instead
2017/01/06 21:49:09
DestroyRequest(this) is self-explanatory, IMHO.
Mathieu
2017/01/07 05:03:07
Done.
| |
| 60 manager_->DestroyRequest(this); | |
| 61 } | |
| 62 | |
| 63 } // namespace payments | |
| OLD | NEW |