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

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: Moved label creation back to base class 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..267fe2377df128db42275844471ce73990c4227d 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() {}
@@ -124,8 +127,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 +186,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,6 +211,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;
@@ -244,7 +255,8 @@ 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|.
+ 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