Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER _H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER _H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/macros.h" | |
| 13 #include "chrome/browser/ui/views/payments/editor_view_controller.h" | |
| 14 #include "chrome/browser/ui/views/payments/validating_textfield.h" | |
| 15 | |
| 16 namespace payments { | |
| 17 | |
| 18 class PaymentRequestSpec; | |
| 19 class PaymentRequestState; | |
| 20 class PaymentRequestDialogView; | |
| 21 | |
| 22 // Shipping Address editor screen of the Payment Request flow. | |
| 23 class ShippingAddressEditorViewController : public EditorViewController { | |
| 24 public: | |
| 25 // Does not take ownership of the arguments, which should outlive this object. | |
| 26 ShippingAddressEditorViewController(PaymentRequestSpec* spec, | |
| 27 PaymentRequestState* state, | |
| 28 PaymentRequestDialogView* dialog); | |
| 29 ~ShippingAddressEditorViewController() override; | |
| 30 | |
| 31 // EditorViewController: | |
| 32 std::unique_ptr<views::View> CreateHeaderView() override; | |
| 33 int GetViewHeaderTitleId() const override; | |
| 34 std::vector<EditorField> GetFieldDefinitions() override; | |
| 35 bool ValidateModelAndSave() override; | |
| 36 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( | |
| 37 const EditorField& field) override; | |
| 38 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( | |
| 39 const autofill::ServerFieldType& type) override; | |
| 40 void OnPerformAction(views::Combobox* combobox) override; | |
| 41 void UpdateEditorView() override; | |
| 42 | |
| 43 private: | |
| 44 class ShippingAddressValidationDelegate : public ValidationDelegate { | |
| 45 public: | |
| 46 explicit ShippingAddressValidationDelegate( | |
| 47 ShippingAddressEditorViewController* parent, | |
| 48 const EditorField& field); | |
| 49 ~ShippingAddressValidationDelegate() override; | |
| 50 | |
| 51 // ValidationDelegate: | |
| 52 bool ValidateTextfield(views::Textfield* textfield) override; | |
| 53 bool ValidateCombobox(views::Combobox* combobox) override; | |
| 54 | |
| 55 private: | |
| 56 // Validates a specific |value|. | |
| 57 bool ValidateValue(const base::string16& value); | |
| 58 | |
| 59 EditorField field_; | |
| 60 // TODO(mad): Bring back when needed. | |
| 61 // ShippingAddressEditorViewController* parent_{nullptr}; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate); | |
| 64 }; | |
| 65 friend class ShippingAddressValidationDelegate; | |
| 66 | |
| 67 // List of fields, reset everytime the current country changes. | |
| 68 std::vector<EditorField> editor_fields_; | |
| 69 | |
| 70 // The currently chosen country. | |
| 71 int chosen_country_index_{0}; | |
|
Mathieu
2017/03/21 17:08:35
let's have this be size_t?
MAD
2017/03/21 19:28:34
Yeah, I changed it to int because the combobox API
| |
| 72 | |
| 73 // The list of country codes as ordered in the country combo box model. | |
| 74 std::vector<std::string> country_codes_; | |
| 75 | |
| 76 // Updates |editor_fields_| based on the current country. | |
| 77 void UpdateEditorFields(); | |
| 78 | |
| 79 // Called by the validation delegate when the country combo box changed. | |
| 80 void OnCountryChanged(views::Combobox* combobox); | |
| 81 | |
| 82 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController); | |
| 83 }; | |
| 84 | |
| 85 } // namespace payments | |
| 86 | |
| 87 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL LER_H_ | |
| OLD | NEW |