| 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/border.h" |
| 13 #include "ui/views/controls/button/md_text_button.h" | 14 #include "ui/views/controls/button/md_text_button.h" |
| 14 #include "ui/views/controls/scroll_view.h" | 15 #include "ui/views/controls/scroll_view.h" |
| 15 #include "ui/views/focus/focus_search.h" | 16 #include "ui/views/focus/focus_search.h" |
| 16 #include "ui/views/layout/box_layout.h" | 17 #include "ui/views/layout/box_layout.h" |
| 17 #include "ui/views/layout/fill_layout.h" | 18 #include "ui/views/layout/fill_layout.h" |
| 18 #include "ui/views/layout/grid_layout.h" | 19 #include "ui/views/layout/grid_layout.h" |
| 19 | 20 |
| 20 namespace payments { | 21 namespace payments { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 break; | 219 break; |
| 219 case PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX: | 220 case PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX: |
| 220 NOTREACHED(); | 221 NOTREACHED(); |
| 221 break; | 222 break; |
| 222 } | 223 } |
| 223 } | 224 } |
| 224 | 225 |
| 225 std::unique_ptr<views::View> PaymentRequestSheetController::CreateFooterView() { | 226 std::unique_ptr<views::View> PaymentRequestSheetController::CreateFooterView() { |
| 226 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); | 227 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); |
| 227 | 228 |
| 229 // The distance between the elements and the dialog borders. |
| 230 constexpr int kInset = 16; |
| 231 container->SetBorder( |
| 232 views::CreateEmptyBorder(kInset, kInset, kInset, kInset)); |
| 233 |
| 228 views::GridLayout* layout = new views::GridLayout(container.get()); | 234 views::GridLayout* layout = new views::GridLayout(container.get()); |
| 229 container->SetLayoutManager(layout); | 235 container->SetLayoutManager(layout); |
| 230 | 236 |
| 231 views::ColumnSet* columns = layout->AddColumnSet(0); | 237 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 232 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, | 238 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, |
| 233 0, views::GridLayout::USE_PREF, 0, 0); | 239 0, views::GridLayout::USE_PREF, 0, 0); |
| 234 columns->AddPaddingColumn(1, 0); | 240 columns->AddPaddingColumn(1, 0); |
| 235 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, | 241 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, |
| 236 0, views::GridLayout::USE_PREF, 0, 0); | 242 0, views::GridLayout::USE_PREF, 0, 0); |
| 237 | 243 |
| 238 // The horizontal distance between the right/left edges of the dialog and the | |
| 239 // elements. | |
| 240 constexpr int kFooterHorizontalInset = 16; | |
| 241 // The vertical distance between footer elements and the top/bottom border | |
| 242 // (the bottom border is the edge of the dialog). | |
| 243 constexpr int kFooterVerticalInset = 16; | |
| 244 layout->SetInsets(kFooterVerticalInset, kFooterHorizontalInset, | |
| 245 kFooterVerticalInset, kFooterHorizontalInset); | |
| 246 layout->StartRow(0, 0); | 244 layout->StartRow(0, 0); |
| 247 std::unique_ptr<views::View> extra_view = CreateExtraFooterView(); | 245 std::unique_ptr<views::View> extra_view = CreateExtraFooterView(); |
| 248 if (extra_view) | 246 if (extra_view) |
| 249 layout->AddView(extra_view.release()); | 247 layout->AddView(extra_view.release()); |
| 250 else | 248 else |
| 251 layout->SkipColumns(1); | 249 layout->SkipColumns(1); |
| 252 | 250 |
| 253 std::unique_ptr<views::View> trailing_buttons_container = | 251 std::unique_ptr<views::View> trailing_buttons_container = |
| 254 base::MakeUnique<views::View>(); | 252 base::MakeUnique<views::View>(); |
| 255 | 253 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 289 |
| 292 bool PaymentRequestSheetController::PerformPrimaryButtonAction() { | 290 bool PaymentRequestSheetController::PerformPrimaryButtonAction() { |
| 293 if (primary_button_ && primary_button_->enabled()) { | 291 if (primary_button_ && primary_button_->enabled()) { |
| 294 ButtonPressed(primary_button_.get(), DummyEvent()); | 292 ButtonPressed(primary_button_.get(), DummyEvent()); |
| 295 return true; | 293 return true; |
| 296 } | 294 } |
| 297 return false; | 295 return false; |
| 298 } | 296 } |
| 299 | 297 |
| 300 } // namespace payments | 298 } // namespace payments |
| OLD | NEW |