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 "chrome/browser/ui/views/payments/payment_request_views_util.h" |
| 6 |
| 7 #include "base/memory/ptr_util.h" |
| 8 #include "third_party/skia/include/core/SkColor.h" |
| 9 #include "ui/views/background.h" |
| 10 #include "ui/views/controls/label.h" |
| 11 #include "ui/views/layout/grid_layout.h" |
| 12 #include "ui/views/view.h" |
| 13 |
| 14 namespace payments { |
| 15 |
| 16 std::unique_ptr<views::View> CreatePaymentView( |
| 17 const base::string16& title, std::unique_ptr<views::View> content_view) { |
| 18 std::unique_ptr<views::View> view = base::MakeUnique<views::View>(); |
| 19 view->set_background(views::Background::CreateSolidBackground(SK_ColorWHITE)); |
| 20 |
| 21 // Paint the sheets to layers, otherwise the MD buttons (which do paint to a |
| 22 // layer) won't do proper clipping. |
| 23 view->SetPaintToLayer(true); |
| 24 |
| 25 views::GridLayout* layout = new views::GridLayout(view.get()); |
| 26 view->SetLayoutManager(layout); |
| 27 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 28 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, |
| 29 1, views::GridLayout::USE_PREF, 0, 0); |
| 30 |
| 31 layout->StartRow(0, 0); |
| 32 layout->AddView(new views::Label(title)); |
| 33 |
| 34 layout->StartRow(0, 0); |
| 35 // |content_view| will be deleted when |view| is. |
| 36 layout->AddView(content_view.release()); |
| 37 |
| 38 return view; |
| 39 } |
| 40 |
| 41 } // namespace payments |
OLD | NEW |