| Index: chrome/browser/ui/views/payments/editor_view_controller.h
|
| diff --git a/chrome/browser/ui/views/payments/editor_view_controller.h b/chrome/browser/ui/views/payments/editor_view_controller.h
|
| index 512fb272d0c51c9cae72770d68917a8723957e25..5e0c37318e891205ebaea2b12dce000129ad11fa 100644
|
| --- a/chrome/browser/ui/views/payments/editor_view_controller.h
|
| +++ b/chrome/browser/ui/views/payments/editor_view_controller.h
|
| @@ -13,11 +13,16 @@
|
| #include "base/memory/ptr_util.h"
|
| #include "base/strings/string16.h"
|
| #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h"
|
| -#include "chrome/browser/ui/views/payments/validating_textfield.h"
|
| +#include "chrome/browser/ui/views/payments/validation_delegate.h"
|
| #include "components/autofill/core/browser/field_types.h"
|
| #include "ui/views/controls/button/vector_icon_button_delegate.h"
|
| +#include "ui/views/controls/combobox/combobox_listener.h"
|
| #include "ui/views/controls/textfield/textfield_controller.h"
|
|
|
| +namespace ui {
|
| +class ComboboxModel;
|
| +}
|
| +
|
| namespace views {
|
| class Textfield;
|
| class View;
|
| @@ -27,19 +32,23 @@ namespace payments {
|
|
|
| class PaymentRequest;
|
| class PaymentRequestDialogView;
|
| +class ValidatingTextfield;
|
|
|
| // Field definition for an editor field, used to build the UI.
|
| struct EditorField {
|
| enum class LengthHint : int { HINT_LONG, HINT_SHORT };
|
| + enum class ControlType : int { TEXTFIELD, COMBOBOX };
|
|
|
| EditorField(autofill::ServerFieldType type,
|
| const base::string16& label,
|
| LengthHint length_hint,
|
| - bool required)
|
| + bool required,
|
| + ControlType control_type = ControlType::TEXTFIELD)
|
| : type(type),
|
| label(label),
|
| length_hint(length_hint),
|
| - required(required) {}
|
| + required(required),
|
| + control_type(control_type) {}
|
|
|
| // Data type in the field.
|
| const autofill::ServerFieldType type;
|
| @@ -49,12 +58,15 @@ struct EditorField {
|
| LengthHint length_hint;
|
| // Whether the field is required.
|
| bool required;
|
| + // The control type.
|
| + ControlType control_type;
|
| };
|
|
|
| // The PaymentRequestSheetController subtype for the editor screens of the
|
| // Payment Request flow.
|
| class EditorViewController : public PaymentRequestSheetController,
|
| - public views::TextfieldController {
|
| + public views::TextfieldController,
|
| + public views::ComboboxListener {
|
| public:
|
| using TextFieldsMap =
|
| std::unordered_map<ValidatingTextfield*, const EditorField>;
|
| @@ -71,10 +83,12 @@ class EditorViewController : public PaymentRequestSheetController,
|
| virtual std::vector<EditorField> GetFieldDefinitions() = 0;
|
| // Validates the data entered and attempts to save; returns true on success.
|
| virtual bool ValidateModelAndSave() = 0;
|
| - // Creates a ValidatingTextfield::Delegate which knows how to validate for a
|
| - // given |field| definition.
|
| - virtual std::unique_ptr<ValidatingTextfield::Delegate>
|
| - CreateValidationDelegate(const EditorField& field) = 0;
|
| + // Creates a ValidationDelegate which knows how to validate for a given
|
| + // |field| definition.
|
| + virtual std::unique_ptr<ValidationDelegate> CreateValidationDelegate(
|
| + const EditorField& field) = 0;
|
| + virtual ui::ComboboxModel* GetComboboxModelForType(
|
| + const autofill::ServerFieldType& type) = 0;
|
|
|
| const TextFieldsMap& text_fields() const { return text_fields_; }
|
|
|
| @@ -86,10 +100,13 @@ class EditorViewController : public PaymentRequestSheetController,
|
| // PaymentRequestSheetController:
|
| void ButtonPressed(views::Button* sender, const ui::Event& event) override;
|
|
|
| - // views::TextfieldController
|
| + // views::TextfieldController:
|
| void ContentsChanged(views::Textfield* sender,
|
| const base::string16& new_contents) override;
|
|
|
| + // views::ComboboxListener:
|
| + void OnPerformAction(views::Combobox* combobox) override;
|
| +
|
| // Creates a view for an input field to be added in the editor sheet. |field|
|
| // is the field definition, which contains the label and the hint about
|
| // the length of the input field.
|
|
|