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

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: OWNER comments 2 + fixed new tests 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 a33a40fe82ad3ffb98891f462dd651f8f1f419eb..4da8bd8087d8c75a5635a9d32182dc73d854e2d7 100644
--- a/chrome/browser/ui/views/payments/editor_view_controller.cc
+++ b/chrome/browser/ui/views/payments/editor_view_controller.cc
@@ -46,11 +46,14 @@ constexpr int kNumCharactersInLongField = 20;
} // namespace
-EditorViewController::EditorViewController(PaymentRequestSpec* spec,
- PaymentRequestState* state,
- PaymentRequestDialogView* dialog)
+EditorViewController::EditorViewController(
+ PaymentRequestSpec* spec,
+ PaymentRequestState* state,
+ PaymentRequestDialogView* dialog,
+ BackNavigationType back_navigation_type)
: PaymentRequestSheetController(spec, state, dialog),
- first_field_view_(nullptr) {}
+ first_field_view_(nullptr),
+ back_navigation_type_(back_navigation_type) {}
EditorViewController::~EditorViewController() {}
@@ -64,6 +67,15 @@ void EditorViewController::DisplayErrorMessageForField(
dialog()->Layout();
}
+std::unique_ptr<views::View> EditorViewController::CreateHeaderView() {
+ return nullptr;
+}
+
+std::unique_ptr<views::View> EditorViewController::CreateCustomFieldView(
+ autofill::ServerFieldType type) {
+ return nullptr;
+}
+
std::unique_ptr<views::Button> EditorViewController::CreatePrimaryButton() {
std::unique_ptr<views::Button> button(
views::MdTextButton::CreateSecondaryUiBlueButton(
@@ -83,7 +95,9 @@ void EditorViewController::FillContentView(views::View* content_view) {
// No insets. Child views below are responsible for their padding.
// An editor can optionally have a header view specific to it.
- content_view->AddChildView(CreateHeaderView().release());
+ std::unique_ptr<views::View> header_view = CreateHeaderView();
+ if (header_view.get())
+ content_view->AddChildView(header_view.release());
// The heart of the editor dialog: all the input fields with their labels.
content_view->AddChildView(CreateEditorView().release());
@@ -124,8 +138,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);
@@ -175,13 +197,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;
@@ -201,9 +222,7 @@ void EditorViewController::CreateInputField(views::GridLayout* layout,
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;
+
label->SetMultiLine(true);
label->SetMaximumWidth(kMaximumLabelWidth);
layout->AddView(label.release());
@@ -244,7 +263,9 @@ void EditorViewController::CreateInputField(views::GridLayout* layout,
// |combobox| will now be owned by |row|.
layout->AddView(combobox);
} else {
- NOTREACHED();
+ // Custom field view will now be owned by |row|. And it must be valid since
+ // the derived class specified a custom view for this field.
+ layout->AddView(CreateCustomFieldView(field.type).release());
}
// This is the vertical space between the input field and its error label.

Powered by Google App Engine
This is Rietveld 408576698