OLD | NEW |
---|---|
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 <set> | |
9 | |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "chrome/browser/ui/views/payments/editor_view_controller.h" | 11 #include "chrome/browser/ui/views/payments/editor_view_controller.h" |
10 #include "chrome/browser/ui/views/payments/validation_delegate.h" | 12 #include "chrome/browser/ui/views/payments/validation_delegate.h" |
11 #include "ui/base/models/simple_combobox_model.h" | 13 #include "ui/base/models/simple_combobox_model.h" |
12 | 14 |
13 namespace payments { | 15 namespace payments { |
14 | 16 |
15 class PaymentRequest; | 17 class PaymentRequest; |
16 class PaymentRequestDialogView; | 18 class PaymentRequestDialogView; |
17 | 19 |
(...skipping 10 matching lines...) Expand all Loading... | |
28 std::vector<EditorField> GetFieldDefinitions() override; | 30 std::vector<EditorField> GetFieldDefinitions() override; |
29 bool ValidateModelAndSave() override; | 31 bool ValidateModelAndSave() override; |
30 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( | 32 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( |
31 const EditorField& field) override; | 33 const EditorField& field) override; |
32 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( | 34 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( |
33 const autofill::ServerFieldType& type) override; | 35 const autofill::ServerFieldType& type) override; |
34 | 36 |
35 private: | 37 private: |
36 class CreditCardValidationDelegate : public ValidationDelegate { | 38 class CreditCardValidationDelegate : public ValidationDelegate { |
37 public: | 39 public: |
38 CreditCardValidationDelegate(const EditorField& field, | 40 // Used to validate |field| type. A reference to the |controller| should |
39 EditorViewController* controller); | 41 // outlive this delegate, and a list of |supported_card_networks| can be |
42 // passed in if it's thought to be used to validate |field| (the data will | |
anthonyvd
2017/02/23 16:42:27
nit: not sure what "if it's thought to be used to
Mathieu
2017/02/23 16:48:31
Done.
| |
43 // be copied to the delegate). | |
44 CreditCardValidationDelegate( | |
45 const EditorField& field, | |
46 EditorViewController* controller, | |
47 const std::vector<std::string>& supported_card_networks); | |
40 ~CreditCardValidationDelegate() override; | 48 ~CreditCardValidationDelegate() override; |
41 | 49 |
42 // ValidationDelegate: | 50 // ValidationDelegate: |
43 bool ValidateTextfield(views::Textfield* textfield) override; | 51 bool ValidateTextfield(views::Textfield* textfield) override; |
44 bool ValidateCombobox(views::Combobox* combobox) override; | 52 bool ValidateCombobox(views::Combobox* combobox) override; |
45 | 53 |
46 private: | 54 private: |
47 // Validates a specific |value|. | 55 // Validates a specific |value|. |
48 bool ValidateValue(const base::string16& value); | 56 bool ValidateValue(const base::string16& value); |
49 | 57 |
50 EditorField field_; | 58 EditorField field_; |
51 // Outlives this class. | 59 // Outlives this class. |
52 EditorViewController* controller_; | 60 EditorViewController* controller_; |
61 // The list of supported basic card networks. | |
62 std::set<std::string> supported_card_networks_; | |
53 | 63 |
54 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate); | 64 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate); |
55 }; | 65 }; |
56 | 66 |
57 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController); | 67 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController); |
58 }; | 68 }; |
59 | 69 |
60 } // namespace payments | 70 } // namespace payments |
61 | 71 |
62 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H _ | 72 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H _ |
OLD | NEW |