OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/browser/payments/ui/payment_request_dialog.h" | 6 #include "chrome/browser/payments/payment_request_impl.h" |
| 7 #include "chrome/browser/ui/views/payments/payment_request_dialog.h" |
| 8 #include "components/constrained_window/constrained_window_views.h" |
7 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
8 #include "ui/views/layout/fill_layout.h" | 10 #include "ui/views/layout/fill_layout.h" |
9 | 11 |
| 12 namespace chrome { |
| 13 |
| 14 void ShowPaymentRequestDialog(payments::PaymentRequestImpl* impl) { |
| 15 constrained_window::ShowWebModalDialogViews( |
| 16 new payments::PaymentRequestDialog(impl), impl->web_contents()); |
| 17 } |
| 18 |
| 19 } |
| 20 |
10 namespace payments { | 21 namespace payments { |
11 | 22 |
12 PaymentRequestDialog::PaymentRequestDialog( | 23 PaymentRequestDialog::PaymentRequestDialog(PaymentRequestImpl* impl) |
13 payments::mojom::PaymentRequestClientPtr client) | 24 : impl_(impl), |
14 : client_(std::move(client)), | |
15 label_(new views::Label(base::ASCIIToUTF16("Payments dialog"))) { | 25 label_(new views::Label(base::ASCIIToUTF16("Payments dialog"))) { |
16 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 26 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
17 SetLayoutManager(new views::FillLayout()); | 27 SetLayoutManager(new views::FillLayout()); |
18 AddChildView(label_.get()); | 28 AddChildView(label_.get()); |
19 } | 29 } |
20 | 30 |
21 PaymentRequestDialog::~PaymentRequestDialog() {} | 31 PaymentRequestDialog::~PaymentRequestDialog() {} |
22 | 32 |
23 ui::ModalType PaymentRequestDialog::GetModalType() const { | 33 ui::ModalType PaymentRequestDialog::GetModalType() const { |
24 return ui::MODAL_TYPE_CHILD; | 34 return ui::MODAL_TYPE_CHILD; |
25 } | 35 } |
26 | 36 |
27 gfx::Size PaymentRequestDialog::GetPreferredSize() const { | 37 gfx::Size PaymentRequestDialog::GetPreferredSize() const { |
28 gfx::Size ps = label_->GetPreferredSize(); | 38 gfx::Size ps = label_->GetPreferredSize(); |
29 ps.Enlarge(200, 200); | 39 ps.Enlarge(200, 200); |
30 return ps; | 40 return ps; |
31 } | 41 } |
32 | 42 |
33 bool PaymentRequestDialog::Cancel() { | 43 bool PaymentRequestDialog::Cancel() { |
34 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 44 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
35 client_->OnError(payments::mojom::PaymentErrorReason::USER_CANCEL); | 45 impl_->Cancel(); |
36 return true; | 46 return true; |
37 } | 47 } |
38 | 48 |
39 } // namespace payments | 49 } // namespace payments |
OLD | NEW |