| 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_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER
_H_ | 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_ | 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER
_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 class ShippingAddressValidationDelegate : public ValidationDelegate { | 53 class ShippingAddressValidationDelegate : public ValidationDelegate { |
| 54 public: | 54 public: |
| 55 ShippingAddressValidationDelegate( | 55 ShippingAddressValidationDelegate( |
| 56 ShippingAddressEditorViewController* parent, | 56 ShippingAddressEditorViewController* parent, |
| 57 const EditorField& field); | 57 const EditorField& field); |
| 58 ~ShippingAddressValidationDelegate() override; | 58 ~ShippingAddressValidationDelegate() override; |
| 59 | 59 |
| 60 // ValidationDelegate: | 60 // ValidationDelegate: |
| 61 bool ValidateTextfield(views::Textfield* textfield) override; | 61 bool ValidateTextfield(views::Textfield* textfield) override; |
| 62 bool ValidateCombobox(views::Combobox* combobox) override; | 62 bool ValidateCombobox(views::Combobox* combobox) override; |
| 63 void ComboboxModelChanged(views::Combobox* combobox) override; |
| 63 | 64 |
| 64 private: | 65 private: |
| 65 bool ValidateValue(const base::string16& value); | 66 bool ValidateValue(const base::string16& value); |
| 66 | 67 |
| 67 EditorField field_; | 68 EditorField field_; |
| 69 |
| 68 // Raw pointer back to the owner of this class, therefore will not be null. | 70 // Raw pointer back to the owner of this class, therefore will not be null. |
| 69 ShippingAddressEditorViewController* controller_; | 71 ShippingAddressEditorViewController* controller_; |
| 70 | 72 |
| 71 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate); | 73 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate); |
| 72 }; | 74 }; |
| 73 friend class ShippingAddressValidationDelegate; | 75 friend class ShippingAddressValidationDelegate; |
| 74 | 76 |
| 75 // If non-nullptr, a point to an object to be edited, which should outlive | 77 // If non-nullptr, a point to an object to be edited, which should outlive |
| 76 // this controller. | 78 // this controller. |
| 77 autofill::AutofillProfile* profile_to_edit_; | 79 autofill::AutofillProfile* profile_to_edit_; |
| 78 | 80 |
| 79 // List of fields, reset everytime the current country changes. | 81 // List of fields, reset everytime the current country changes. |
| 80 std::vector<EditorField> editor_fields_; | 82 std::vector<EditorField> editor_fields_; |
| 81 | 83 |
| 82 // The currently chosen country. Defaults to 0 as the first entry in the | 84 // The currently chosen country. Defaults to 0 as the first entry in the |
| 83 // combobox, which is the generated default value received from | 85 // combobox, which is the generated default value received from |
| 84 // autofill::CountryComboboxModel::countries() which is documented to always | 86 // autofill::CountryComboboxModel::countries() which is documented to always |
| 85 // have the default country at the top as well as within the sorted list. | 87 // have the default country at the top as well as within the sorted list. |
| 86 size_t chosen_country_index_{0}; | 88 size_t chosen_country_index_; |
| 87 | 89 |
| 88 // The list of country codes as ordered in the country combobox model. | 90 // The list of country codes as ordered in the country combobox model. |
| 89 std::vector<std::string> country_codes_; | 91 std::vector<std::string> country_codes_; |
| 90 | 92 |
| 93 // Identifies whether we tried and failed to load region data. |
| 94 bool failed_to_load_region_data_; |
| 95 |
| 91 // Updates |editor_fields_| based on the current country. | 96 // Updates |editor_fields_| based on the current country. |
| 92 void UpdateEditorFields(); | 97 void UpdateEditorFields(); |
| 93 | 98 |
| 94 // Called by the validation delegate when the country combobox changed. | 99 // Called when data changes need to force a view update. |
| 95 void OnCountryChanged(views::Combobox* combobox); | 100 void OnDataChanged(); |
| 101 |
| 102 // When a combobox model has changed, a view update might be needed, e.g., if |
| 103 // there is no data in the combobox and it must be converted to a text field. |
| 104 void OnComboboxModelChanged(views::Combobox* combobox); |
| 96 | 105 |
| 97 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController); | 106 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController); |
| 98 }; | 107 }; |
| 99 | 108 |
| 100 } // namespace payments | 109 } // namespace payments |
| 101 | 110 |
| 102 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL
LER_H_ | 111 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL
LER_H_ |
| OLD | NEW |