| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/ui/views/payments/payment_request_sheet_controller.h" | 5 #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" | 7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" |
| 8 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" | 8 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" |
| 9 #include "components/payments/content/payment_request.h" | 9 #include "components/payments/content/payment_request.h" |
| 10 #include "components/strings/grit/components_strings.h" | 10 #include "components/strings/grit/components_strings.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "ui/views/background.h" | 12 #include "ui/views/background.h" |
| 13 #include "ui/views/controls/button/md_text_button.h" | 13 #include "ui/views/controls/button/md_text_button.h" |
| 14 #include "ui/views/controls/scroll_view.h" |
| 14 #include "ui/views/layout/box_layout.h" | 15 #include "ui/views/layout/box_layout.h" |
| 15 #include "ui/views/layout/grid_layout.h" | 16 #include "ui/views/layout/grid_layout.h" |
| 16 | 17 |
| 17 namespace payments { | 18 namespace payments { |
| 18 | 19 |
| 19 PaymentRequestSheetController::PaymentRequestSheetController( | 20 PaymentRequestSheetController::PaymentRequestSheetController( |
| 20 PaymentRequest* request, PaymentRequestDialogView* dialog) | 21 PaymentRequest* request, PaymentRequestDialogView* dialog) |
| 21 : request_(request), dialog_(dialog) { | 22 : request_(request), dialog_(dialog) { |
| 22 } | 23 } |
| 23 | 24 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 58 |
| 58 // Paint the sheets to layers, otherwise the MD buttons (which do paint to a | 59 // Paint the sheets to layers, otherwise the MD buttons (which do paint to a |
| 59 // layer) won't do proper clipping. | 60 // layer) won't do proper clipping. |
| 60 view->SetPaintToLayer(); | 61 view->SetPaintToLayer(); |
| 61 | 62 |
| 62 views::GridLayout* layout = new views::GridLayout(view.get()); | 63 views::GridLayout* layout = new views::GridLayout(view.get()); |
| 63 view->SetLayoutManager(layout); | 64 view->SetLayoutManager(layout); |
| 64 | 65 |
| 65 // Note: each view is responsible for its own padding (insets). | 66 // Note: each view is responsible for its own padding (insets). |
| 66 views::ColumnSet* columns = layout->AddColumnSet(0); | 67 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 67 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, | 68 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
| 68 1, views::GridLayout::USE_PREF, 0, 0); | 69 views::GridLayout::USE_PREF, 0, 0); |
| 69 | 70 |
| 70 layout->StartRow(0, 0); | 71 layout->StartRow(0, 0); |
| 71 // |header_view| will be deleted when |view| is. | 72 // |header_view| will be deleted when |view| is. |
| 72 layout->AddView(header_view.release()); | 73 layout->AddView(header_view.release()); |
| 73 | 74 |
| 74 layout->StartRow(0, 0); | 75 layout->StartRow(1, 0); |
| 75 // |content_view| will be deleted when |view| is. | 76 // |content_view| will go into a views::ScrollView so it needs to be sized now |
| 76 layout->AddView(content_view.release()); | 77 // otherwise it'll be sized to the ScrollView's viewport height, preventing |
| 78 // the scroll bar from ever being shown. |
| 79 content_view->SizeToPreferredSize(); |
| 77 | 80 |
| 78 layout->AddPaddingRow(1, 0); | 81 std::unique_ptr<views::ScrollView> scroll = |
| 82 base::MakeUnique<views::ScrollView>(); |
| 83 scroll->EnableViewPortLayer(); |
| 84 scroll->set_hide_horizontal_scrollbar(true); |
| 85 scroll->SetContents(content_view.release()); |
| 86 layout->AddView(scroll.release()); |
| 87 |
| 79 layout->StartRow(0, 0); | 88 layout->StartRow(0, 0); |
| 80 layout->AddView(CreateFooterView().release()); | 89 layout->AddView(CreateFooterView().release()); |
| 81 | 90 |
| 82 return view; | 91 return view; |
| 83 } | 92 } |
| 84 | 93 |
| 85 std::unique_ptr<views::View> PaymentRequestSheetController::CreateFooterView() { | 94 std::unique_ptr<views::View> PaymentRequestSheetController::CreateFooterView() { |
| 86 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); | 95 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); |
| 87 | 96 |
| 88 views::GridLayout* layout = new views::GridLayout(container.get()); | 97 views::GridLayout* layout = new views::GridLayout(container.get()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 this, l10n_util::GetStringUTF16(IDS_CANCEL)); | 134 this, l10n_util::GetStringUTF16(IDS_CANCEL)); |
| 126 button->set_tag(static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG)); | 135 button->set_tag(static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG)); |
| 127 trailing_buttons_container->AddChildView(button); | 136 trailing_buttons_container->AddChildView(button); |
| 128 | 137 |
| 129 layout->AddView(trailing_buttons_container.release()); | 138 layout->AddView(trailing_buttons_container.release()); |
| 130 | 139 |
| 131 return container; | 140 return container; |
| 132 } | 141 } |
| 133 | 142 |
| 134 } // namespace payments | 143 } // namespace payments |
| OLD | NEW |