| 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 to validate |field| (the data will be copied to the delegate). |
| 43 CreditCardValidationDelegate( |
| 44 const EditorField& field, |
| 45 EditorViewController* controller, |
| 46 const std::vector<std::string>& supported_card_networks); |
| 40 ~CreditCardValidationDelegate() override; | 47 ~CreditCardValidationDelegate() override; |
| 41 | 48 |
| 42 // ValidationDelegate: | 49 // ValidationDelegate: |
| 43 bool ValidateTextfield(views::Textfield* textfield) override; | 50 bool ValidateTextfield(views::Textfield* textfield) override; |
| 44 bool ValidateCombobox(views::Combobox* combobox) override; | 51 bool ValidateCombobox(views::Combobox* combobox) override; |
| 45 | 52 |
| 46 private: | 53 private: |
| 47 // Validates a specific |value|. | 54 // Validates a specific |value|. |
| 48 bool ValidateValue(const base::string16& value); | 55 bool ValidateValue(const base::string16& value); |
| 49 | 56 |
| 50 EditorField field_; | 57 EditorField field_; |
| 51 // Outlives this class. | 58 // Outlives this class. |
| 52 EditorViewController* controller_; | 59 EditorViewController* controller_; |
| 60 // The list of supported basic card networks. |
| 61 std::set<std::string> supported_card_networks_; |
| 53 | 62 |
| 54 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate); | 63 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate); |
| 55 }; | 64 }; |
| 56 | 65 |
| 57 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController); | 66 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController); |
| 58 }; | 67 }; |
| 59 | 68 |
| 60 } // namespace payments | 69 } // namespace payments |
| 61 | 70 |
| 62 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H
_ | 71 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H
_ |
| OLD | NEW |