| 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 94b23bce9d0ec82646bd231ead9807c8a99eb64f..e4389adf3a118fc78618b13cae875af5cc5b1585 100644
|
| --- a/chrome/browser/ui/views/payments/editor_view_controller.cc
|
| +++ b/chrome/browser/ui/views/payments/editor_view_controller.cc
|
| @@ -46,10 +46,13 @@ constexpr int kNumCharactersInLongField = 20;
|
|
|
| } // namespace
|
|
|
| -EditorViewController::EditorViewController(PaymentRequestSpec* spec,
|
| - PaymentRequestState* state,
|
| - PaymentRequestDialogView* dialog)
|
| - : PaymentRequestSheetController(spec, state, dialog) {}
|
| +EditorViewController::EditorViewController(
|
| + PaymentRequestSpec* spec,
|
| + PaymentRequestState* state,
|
| + PaymentRequestDialogView* dialog,
|
| + BackNavigationType back_navigation_type)
|
| + : PaymentRequestSheetController(spec, state, dialog),
|
| + back_navigation_type_(back_navigation_type) {}
|
|
|
| EditorViewController::~EditorViewController() {}
|
|
|
| @@ -86,6 +89,9 @@ void EditorViewController::FillContentView(views::View* content_view) {
|
|
|
| // The heart of the editor dialog: all the input fields with their labels.
|
| content_view->AddChildView(CreateEditorView().release());
|
| +
|
| + // Room for custom fields that can't be expressed with a field definition.
|
| + content_view->AddChildView(CreateCustomFieldsView().release());
|
| }
|
|
|
| // Adds the "required fields" label in disabled text, to obtain this result.
|
| @@ -123,8 +129,16 @@ void EditorViewController::ButtonPressed(views::Button* sender,
|
| const ui::Event& event) {
|
| switch (sender->tag()) {
|
| case static_cast<int>(EditorViewControllerTags::SAVE_BUTTON):
|
| - if (ValidateModelAndSave())
|
| - dialog()->GoBackToPaymentSheet();
|
| + if (ValidateModelAndSave()) {
|
| + switch (back_navigation_type_) {
|
| + case BackNavigationType::kOneStep:
|
| + dialog()->GoBack();
|
| + break;
|
| + case BackNavigationType::kPaymentSheet:
|
| + dialog()->GoBackToPaymentSheet();
|
| + break;
|
| + }
|
| + }
|
| break;
|
| default:
|
| PaymentRequestSheetController::ButtonPressed(sender, event);
|
| @@ -168,13 +182,12 @@ std::unique_ptr<views::View> EditorViewController::CreateEditorView() {
|
| columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0,
|
| views::GridLayout::USE_PREF, 0, 0);
|
|
|
| - // The LayoutManager needs to be set before input fields are created, so we
|
| - // keep a handle to it before we release it to the view.
|
| - views::GridLayout* layout_handle = editor_layout.get();
|
| editor_view->SetLayoutManager(editor_layout.release());
|
| std::vector<EditorField> fields = GetFieldDefinitions();
|
| for (const auto& field : fields) {
|
| - CreateInputField(layout_handle, field);
|
| + CreateInputField(
|
| + static_cast<views::GridLayout*>(editor_view->GetLayoutManager()),
|
| + field);
|
| }
|
|
|
| return editor_view;
|
| @@ -189,14 +202,12 @@ std::unique_ptr<views::View> EditorViewController::CreateEditorView() {
|
| void EditorViewController::CreateInputField(views::GridLayout* layout,
|
| const EditorField& field) {
|
| // This is the top padding for every row.
|
| - constexpr int kInputRowSpacing = 6;
|
| layout->StartRowWithPadding(0, 0, 0, kInputRowSpacing);
|
|
|
| std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>(
|
| field.required ? field.label + base::ASCIIToUTF16("*") : field.label);
|
| - // A very long label will wrap. Value picked so that left + right label
|
| - // padding bring the label to half-way in the dialog (~225).
|
| - constexpr int kMaximumLabelWidth = 192;
|
| +
|
| + // A very long label will wrap.
|
| label->SetMultiLine(true);
|
| label->SetMaximumWidth(kMaximumLabelWidth);
|
| layout->AddView(label.release());
|
|
|