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

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

Issue 2689363004: [Payments] Add combobox support to editors. (Closed)
Patch Set: fix test Created 3 years, 10 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.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..c5851c872d1e58dc65c66105dcf3408cde4694d6 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,24 @@ namespace payments {
class PaymentRequest;
class PaymentRequestDialogView;
+class ValidatingCombobox;
+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,15 +59,20 @@ 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>;
+ using ComboboxMap =
+ std::unordered_map<ValidatingCombobox*, const EditorField>;
// Does not take ownership of the arguments, which should outlive this object.
EditorViewController(PaymentRequest* request,
@@ -71,11 +86,14 @@ 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 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType(
+ const autofill::ServerFieldType& type) = 0;
+
+ const ComboboxMap& comboboxes() const { return comboboxes_; }
const TextFieldsMap& text_fields() const { return text_fields_; }
protected:
@@ -86,20 +104,24 @@ 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.
std::unique_ptr<views::View> CreateInputField(const EditorField& field);
// Used to remember the association between the input field UI element and the
- // original field definition. The ValidatingTextfield* are owned by their
- // parent view, this only keeps a reference that is good as long as the
- // textfield is visible.
+ // original field definition. The ValidatingTextfield* and ValidatingCombobox*
+ // are owned by their parent view, this only keeps a reference that is good as
+ // long as the input field is visible.
TextFieldsMap text_fields_;
+ ComboboxMap comboboxes_;
DISALLOW_COPY_AND_ASSIGN(EditorViewController);
};

Powered by Google App Engine
This is Rietveld 408576698