Index: chrome/browser/ui/views/payments/editor_view_controller.cc |
diff --git a/chrome/browser/ui/views/payments/editor_view_controller.cc b/chrome/browser/ui/views/payments/editor_view_controller.cc |
index c87e63d4bc6b982567a4837434932968f157d417..2b4f33472c9b6666ec40e4284b653beef113f4d4 100644 |
--- a/chrome/browser/ui/views/payments/editor_view_controller.cc |
+++ b/chrome/browser/ui/views/payments/editor_view_controller.cc |
@@ -68,7 +68,8 @@ std::unique_ptr<views::View> EditorViewController::CreateView() { |
content_view->AddChildView(CreateHeaderView().release()); |
// The heart of the editor dialog: all the input fields with their labels. |
- content_view->AddChildView(CreateEditorView().release()); |
+ CreateEditorView(); |
+ content_view->AddChildView(editor_view_.get()); |
return CreatePaymentView( |
CreateSheetHeaderView( |
@@ -119,32 +120,13 @@ std::unique_ptr<views::View> EditorViewController::CreateExtraFooterView() { |
return content_view; |
} |
-void EditorViewController::ButtonPressed(views::Button* sender, |
- const ui::Event& event) { |
- switch (sender->tag()) { |
- case static_cast<int>(EditorViewControllerTags::SAVE_BUTTON): |
- if (ValidateModelAndSave()) |
- dialog()->GoBack(); |
- break; |
- default: |
- PaymentRequestSheetController::ButtonPressed(sender, event); |
- break; |
- } |
-} |
+void EditorViewController::UpdateEditorView() { |
+ DCHECK_NE(nullptr, editor_view_.get()); |
+ text_fields_.clear(); |
+ comboboxes_.clear(); |
+ editor_view_->RemoveAllChildViews(true); |
-void EditorViewController::ContentsChanged(views::Textfield* sender, |
- const base::string16& new_contents) { |
- static_cast<ValidatingTextfield*>(sender)->OnContentsChanged(); |
-} |
- |
-void EditorViewController::OnPerformAction(views::Combobox* sender) { |
- static_cast<ValidatingCombobox*>(sender)->OnContentsChanged(); |
-} |
- |
-std::unique_ptr<views::View> EditorViewController::CreateEditorView() { |
- std::unique_ptr<views::View> editor_view = base::MakeUnique<views::View>(); |
- |
- views::GridLayout* editor_layout = new views::GridLayout(editor_view.get()); |
+ views::GridLayout* editor_layout = new views::GridLayout(editor_view_.get()); |
anthonyvd
2017/03/21 21:18:24
For consistency, this should be a unique_ptr creat
MAD
2017/03/22 20:15:42
Done.
|
// The editor grid layout is padded vertically from the top and bottom, and |
// horizontally inset like other content views. The top padding needs to be |
@@ -154,7 +136,7 @@ std::unique_ptr<views::View> EditorViewController::CreateEditorView() { |
kEditorVerticalInset, payments::kPaymentRequestRowHorizontalInsets, |
kEditorVerticalInset, payments::kPaymentRequestRowHorizontalInsets); |
- editor_view->SetLayoutManager(editor_layout); |
+ editor_view_->SetLayoutManager(editor_layout); |
views::ColumnSet* columns = editor_layout->AddColumnSet(0); |
columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0, |
views::GridLayout::USE_PREF, 0, 0); |
@@ -170,8 +152,38 @@ std::unique_ptr<views::View> EditorViewController::CreateEditorView() { |
for (const auto& field : fields) { |
CreateInputField(editor_layout, field); |
} |
+ editor_view_->Layout(); |
+ // TODO(mad): Find how to update the view bounds so that the vertical |
+ // scrollbar size gets updated. |
+} |
+ |
+void EditorViewController::ButtonPressed(views::Button* sender, |
+ const ui::Event& event) { |
+ switch (sender->tag()) { |
+ case static_cast<int>(EditorViewControllerTags::SAVE_BUTTON): |
+ if (ValidateModelAndSave()) |
+ dialog()->GoBack(); |
+ break; |
+ default: |
+ PaymentRequestSheetController::ButtonPressed(sender, event); |
+ break; |
+ } |
+} |
+ |
+void EditorViewController::ContentsChanged(views::Textfield* sender, |
+ const base::string16& new_contents) { |
+ static_cast<ValidatingTextfield*>(sender)->OnContentsChanged(); |
+} |
+ |
+void EditorViewController::OnPerformAction(views::Combobox* sender) { |
+ static_cast<ValidatingCombobox*>(sender)->OnContentsChanged(); |
+} |
+ |
+void EditorViewController::CreateEditorView() { |
+ editor_view_ = base::MakeUnique<views::View>(); |
+ editor_view_->set_owned_by_client(); |
- return editor_view; |
+ UpdateEditorView(); |
} |
// Each input field is a 4-quadrant grid. |