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

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

Issue 2840013002: [Web Payments] Layout sheets after the width of their parent is known (Closed)
Patch Set: Address comment. 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_dialog_view_ids.h" 8 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
9 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 9 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
10 #include "components/payments/content/payment_request.h" 10 #include "components/payments/content/payment_request.h"
(...skipping 10 matching lines...) Expand all
21 21
22 PaymentRequestSheetController::PaymentRequestSheetController( 22 PaymentRequestSheetController::PaymentRequestSheetController(
23 PaymentRequestSpec* spec, 23 PaymentRequestSpec* spec,
24 PaymentRequestState* state, 24 PaymentRequestState* state,
25 PaymentRequestDialogView* dialog) 25 PaymentRequestDialogView* dialog)
26 : spec_(spec), state_(state), dialog_(dialog) {} 26 : spec_(spec), state_(state), dialog_(dialog) {}
27 27
28 PaymentRequestSheetController::~PaymentRequestSheetController() {} 28 PaymentRequestSheetController::~PaymentRequestSheetController() {}
29 29
30 std::unique_ptr<views::View> PaymentRequestSheetController::CreateView() { 30 std::unique_ptr<views::View> PaymentRequestSheetController::CreateView() {
31 // This is owned by its parent. 31 std::unique_ptr<views::View> view = CreatePaymentView();
32 content_view_ = new views::View; 32 UpdateContentView();
33 33 return view;
34 FillContentView(content_view_);
35
36 return CreatePaymentView();
37 } 34 }
38 35
39 void PaymentRequestSheetController::UpdateContentView() { 36 void PaymentRequestSheetController::UpdateContentView() {
40 content_view_->RemoveAllChildViews(true); 37 content_view_->RemoveAllChildViews(true);
41 FillContentView(content_view_); 38 FillContentView(content_view_);
42 content_view_->Layout(); 39 content_view_->Layout();
43 pane_->SizeToPreferredSize(); 40 pane_->SizeToPreferredSize();
44 } 41 }
45 42
46 std::unique_ptr<views::Button> 43 std::unique_ptr<views::Button>
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // otherwise it'll be sized to the ScrollView's viewport height, preventing 104 // otherwise it'll be sized to the ScrollView's viewport height, preventing
108 // the scroll bar from ever being shown. 105 // the scroll bar from ever being shown.
109 pane_ = new views::View; 106 pane_ = new views::View;
110 views::GridLayout* pane_layout = new views::GridLayout(pane_); 107 views::GridLayout* pane_layout = new views::GridLayout(pane_);
111 views::ColumnSet* pane_columns = pane_layout->AddColumnSet(0); 108 views::ColumnSet* pane_columns = pane_layout->AddColumnSet(0);
112 pane_columns->AddColumn( 109 pane_columns->AddColumn(
113 views::GridLayout::Alignment::FILL, views::GridLayout::Alignment::LEADING, 110 views::GridLayout::Alignment::FILL, views::GridLayout::Alignment::LEADING,
114 0, views::GridLayout::SizeType::FIXED, kDialogWidth, kDialogWidth); 111 0, views::GridLayout::SizeType::FIXED, kDialogWidth, kDialogWidth);
115 pane_->SetLayoutManager(pane_layout); 112 pane_->SetLayoutManager(pane_layout);
116 pane_layout->StartRow(0, 0); 113 pane_layout->StartRow(0, 0);
114 // This is owned by its parent. It's the container passed to FillContentView.
115 content_view_ = new views::View;
117 pane_layout->AddView(content_view_); 116 pane_layout->AddView(content_view_);
118 pane_->SizeToPreferredSize(); 117 pane_->SizeToPreferredSize();
119 118
120 std::unique_ptr<views::ScrollView> scroll = 119 std::unique_ptr<views::ScrollView> scroll =
121 base::MakeUnique<views::ScrollView>(); 120 base::MakeUnique<views::ScrollView>();
122 scroll->EnableViewPortLayer(); 121 scroll->EnableViewPortLayer();
123 scroll->set_hide_horizontal_scrollbar(true); 122 scroll->set_hide_horizontal_scrollbar(true);
124 scroll->SetContents(pane_); 123 scroll->SetContents(pane_);
125 layout->AddView(scroll.release()); 124 layout->AddView(scroll.release());
126 125
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 button->set_tag(static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG)); 172 button->set_tag(static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG));
174 button->set_id(static_cast<int>(DialogViewID::CANCEL_BUTTON)); 173 button->set_id(static_cast<int>(DialogViewID::CANCEL_BUTTON));
175 trailing_buttons_container->AddChildView(button); 174 trailing_buttons_container->AddChildView(button);
176 175
177 layout->AddView(trailing_buttons_container.release()); 176 layout->AddView(trailing_buttons_container.release());
178 177
179 return container; 178 return container;
180 } 179 }
181 180
182 } // namespace payments 181 } // namespace payments
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698