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

Unified Diff: chrome/browser/ui/views/payments/editor_view_controller.cc

Issue 2849523003: Add billing address as a mandatory field of Payments credit cards. (Closed)
Patch Set: Components Unittests fix 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 side-by-side diff with in-line comments
Download patch
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());

Powered by Google App Engine
This is Rietveld 408576698