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

Side by Side Diff: chrome/browser/ui/views/payments/credit_card_editor_view_controller.h

Issue 2689363004: [Payments] Add combobox support to editors. (Closed)
Patch Set: Initial 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "chrome/browser/ui/views/payments/editor_view_controller.h" 9 #include "chrome/browser/ui/views/payments/editor_view_controller.h"
10 #include "chrome/browser/ui/views/payments/validating_textfield.h" 10 #include "chrome/browser/ui/views/payments/validation_delegate.h"
11 #include "ui/base/models/simple_combobox_model.h"
11 12
12 namespace payments { 13 namespace payments {
13 14
14 class PaymentRequest; 15 class PaymentRequest;
15 class PaymentRequestDialogView; 16 class PaymentRequestDialogView;
16 17
17 // Credit card editor screen of the Payment Request flow. 18 // Credit card editor screen of the Payment Request flow.
18 class CreditCardEditorViewController : public EditorViewController { 19 class CreditCardEditorViewController : public EditorViewController {
19 public: 20 public:
20 // Does not take ownership of the arguments, which should outlive this object. 21 // Does not take ownership of the arguments, which should outlive this object.
21 CreditCardEditorViewController(PaymentRequest* request, 22 CreditCardEditorViewController(PaymentRequest* request,
22 PaymentRequestDialogView* dialog); 23 PaymentRequestDialogView* dialog);
23 ~CreditCardEditorViewController() override; 24 ~CreditCardEditorViewController() override;
24 25
25 // EditorViewController: 26 // EditorViewController:
26 std::vector<EditorField> GetFieldDefinitions() override; 27 std::vector<EditorField> GetFieldDefinitions() override;
27 bool ValidateModelAndSave() override; 28 bool ValidateModelAndSave() override;
28 std::unique_ptr<ValidatingTextfield::Delegate> CreateValidationDelegate( 29 std::unique_ptr<ValidationDelegate> CreateValidationDelegate(
29 const EditorField& field) override; 30 const EditorField& field) override;
31 ui::ComboboxModel* GetComboboxModelForType(
32 const autofill::ServerFieldType& type) override;
30 33
31 private: 34 private:
32 class ValidationDelegate : public ValidatingTextfield::Delegate { 35 class CreditCardValidationDelegate : public ValidationDelegate {
33 public: 36 public:
34 explicit ValidationDelegate(const EditorField& field); 37 explicit CreditCardValidationDelegate(const EditorField& field);
35 ~ValidationDelegate() override; 38 ~CreditCardValidationDelegate() override;
36 39
37 // ValidatingTextfield::Delegate: 40 // ValidationDelegate:
38 bool ValidateTextfield(views::Textfield* textfield) override; 41 bool ValidateTextfield(views::Textfield* textfield) override;
42 bool ValidateCombobox(views::Combobox* combobox) override;
39 43
40 private: 44 private:
45 // Validates a specific |value|.
46 bool ValidateValue(const base::string16& value);
47
41 EditorField field_; 48 EditorField field_;
42 49
43 DISALLOW_COPY_AND_ASSIGN(ValidationDelegate); 50 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate);
44 }; 51 };
45 52
53 std::unique_ptr<ui::SimpleComboboxModel> exp_month_model_;
Mathieu 2017/02/14 21:23:54 Under the current code, it's problematic to have t
sky 2017/02/14 23:19:24 Indeed. You'll have to tie the lifetime of the mod
Mathieu 2017/02/15 03:15:57 I've picked the last option, as I think that for m
54 std::unique_ptr<ui::SimpleComboboxModel> exp_year_model_;
55
46 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController); 56 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController);
47 }; 57 };
48 58
49 } // namespace payments 59 } // namespace payments
50 60
51 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H _ 61 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698