OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/strings/utf_string_conversions.h" | |
6 #include "chrome/browser/payments/ui/payment_request_dialog.h" | |
7 #include "content/public/browser/browser_thread.h" | |
8 #include "ui/views/layout/fill_layout.h" | |
9 | |
10 namespace payments { | |
11 | |
12 PaymentRequestDialog::PaymentRequestDialog( | |
13 payments::mojom::PaymentRequestClientPtr client) | |
14 : client_(std::move(client)), | |
15 label_(new views::Label(base::ASCIIToUTF16("Payments dialog"))) { | |
16 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
17 SetLayoutManager(new views::FillLayout()); | |
18 AddChildView(label_.get()); | |
19 } | |
20 | |
21 PaymentRequestDialog::~PaymentRequestDialog() {} | |
22 | |
23 ui::ModalType PaymentRequestDialog::GetModalType() const { | |
24 return ui::MODAL_TYPE_CHILD; | |
25 } | |
26 | |
27 gfx::Size PaymentRequestDialog::GetPreferredSize() const { | |
28 gfx::Size ps = label_->GetPreferredSize(); | |
29 ps.Enlarge(200, 200); | |
30 return ps; | |
31 } | |
32 | |
33 bool PaymentRequestDialog::Cancel() { | |
34 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
35 client_->OnError(payments::mojom::PaymentErrorReason::USER_CANCEL); | |
36 return true; | |
37 } | |
38 | |
39 } // namespace payments | |
OLD | NEW |