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 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 bool ValidateValue(const base::string16& value); | |
| 57 | |
| 58 EditorField field_; | |
| 59 // TODO(mad): Bring back when needed. | |
| 60 // ShippingAddressEditorViewController* parent_{nullptr}; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate); | |
| 63 }; | |
| 64 friend class ShippingAddressValidationDelegate; | |
| 65 | |
| 66 // List of fields, reset everytime the current country changes. | |
| 67 std::vector<EditorField> editor_fields_; | |
| 68 | |
| 69 // The currently chosen country. Defaults to 0 as the first entry in the | |
| 70 // combobox, which is the generated default value received from | |
| 71 // autofill::CountryComboboxModel::SetCountries. | |
| 72 size_t chosen_country_index_{0}; | |
|
Mathieu
2017/03/21 21:09:25
Is this the user's country? If not, we should TODO
MAD
2017/03/22 20:15:42
Done.
| |
| 73 | |
| 74 // The list of country codes as ordered in the country combobox model. | |
| 75 std::vector<std::string> country_codes_; | |
| 76 | |
| 77 // Updates |editor_fields_| based on the current country. | |
| 78 void UpdateEditorFields(); | |
| 79 | |
| 80 // Called by the validation delegate when the country combobox changed. | |
| 81 void OnCountryChanged(views::Combobox* combobox); | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController); | |
| 84 }; | |
| 85 | |
| 86 } // namespace payments | |
| 87 | |
| 88 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL LER_H_ | |
| OLD | NEW |