Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_sheet_controller.cc

Issue 2859193004: Remove GridLayout::SetInsets in favor of an empty border on the host. (Closed)
Patch Set: edits Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 layout->AddView(footer.release()); 225 layout->AddView(footer.release());
225 226
226 view->SetFirstFocusableView(GetFirstFocusedView()); 227 view->SetFirstFocusableView(GetFirstFocusedView());
227 228
228 return std::move(view); 229 return std::move(view);
229 } 230 }
230 231
231 std::unique_ptr<views::View> PaymentRequestSheetController::CreateFooterView() { 232 std::unique_ptr<views::View> PaymentRequestSheetController::CreateFooterView() {
232 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); 233 std::unique_ptr<views::View> container = base::MakeUnique<views::View>();
233 234
235 // The horizontal distance between the right/left edges of the dialog and the
236 // elements.
237 constexpr int kFooterHorizontalInset = 16;
238 // The vertical distance between footer elements and the top/bottom border
239 // (the bottom border is the edge of the dialog).
240 constexpr int kFooterVerticalInset = 16;
sky 2017/05/05 14:36:39 optional: as these values are the same combine and
Bret 2017/05/06 00:36:43 Done.
241 container->SetBorder(
242 views::CreateEmptyBorder(kFooterVerticalInset, kFooterHorizontalInset,
243 kFooterVerticalInset, kFooterHorizontalInset));
244
234 views::GridLayout* layout = new views::GridLayout(container.get()); 245 views::GridLayout* layout = new views::GridLayout(container.get());
235 container->SetLayoutManager(layout); 246 container->SetLayoutManager(layout);
236 247
237 views::ColumnSet* columns = layout->AddColumnSet(0); 248 views::ColumnSet* columns = layout->AddColumnSet(0);
238 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 249 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
239 0, views::GridLayout::USE_PREF, 0, 0); 250 0, views::GridLayout::USE_PREF, 0, 0);
240 columns->AddPaddingColumn(1, 0); 251 columns->AddPaddingColumn(1, 0);
241 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, 252 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
242 0, views::GridLayout::USE_PREF, 0, 0); 253 0, views::GridLayout::USE_PREF, 0, 0);
243 254
244 // The horizontal distance between the right/left edges of the dialog and the
245 // elements.
246 constexpr int kFooterHorizontalInset = 16;
247 // The vertical distance between footer elements and the top/bottom border
248 // (the bottom border is the edge of the dialog).
249 constexpr int kFooterVerticalInset = 16;
250 layout->SetInsets(kFooterVerticalInset, kFooterHorizontalInset,
251 kFooterVerticalInset, kFooterHorizontalInset);
252 layout->StartRow(0, 0); 255 layout->StartRow(0, 0);
253 std::unique_ptr<views::View> extra_view = CreateExtraFooterView(); 256 std::unique_ptr<views::View> extra_view = CreateExtraFooterView();
254 if (extra_view) 257 if (extra_view)
255 layout->AddView(extra_view.release()); 258 layout->AddView(extra_view.release());
256 else 259 else
257 layout->SkipColumns(1); 260 layout->SkipColumns(1);
258 261
259 std::unique_ptr<views::View> trailing_buttons_container = 262 std::unique_ptr<views::View> trailing_buttons_container =
260 base::MakeUnique<views::View>(); 263 base::MakeUnique<views::View>();
261 264
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 300
298 bool PaymentRequestSheetController::PerformPrimaryButtonAction() { 301 bool PaymentRequestSheetController::PerformPrimaryButtonAction() {
299 if (primary_button_ && primary_button_->enabled()) { 302 if (primary_button_ && primary_button_->enabled()) {
300 ButtonPressed(primary_button_.get(), DummyEvent()); 303 ButtonPressed(primary_button_.get(), DummyEvent());
301 return true; 304 return true;
302 } 305 }
303 return false; 306 return false;
304 } 307 }
305 308
306 } // namespace payments 309 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698