| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 ShippingAddressEditorViewController* controller_; | 71 ShippingAddressEditorViewController* controller_; |
| 72 | 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate); | 73 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate); |
| 74 }; | 74 }; |
| 75 friend class ShippingAddressValidationDelegate; | 75 friend class ShippingAddressValidationDelegate; |
| 76 | 76 |
| 77 // 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 |
| 78 // this controller. | 78 // this controller. |
| 79 autofill::AutofillProfile* profile_to_edit_; | 79 autofill::AutofillProfile* profile_to_edit_; |
| 80 | 80 |
| 81 // A temporary profile to keep unsaved data in between relayout (e.g., when |
| 82 // the country is changed and fields set may be different). |
| 83 std::unique_ptr<autofill::AutofillProfile> temporary_profile_; |
| 84 |
| 81 // List of fields, reset everytime the current country changes. | 85 // List of fields, reset everytime the current country changes. |
| 82 std::vector<EditorField> editor_fields_; | 86 std::vector<EditorField> editor_fields_; |
| 83 | 87 |
| 84 // The currently chosen country. Defaults to 0 as the first entry in the | 88 // The currently chosen country. Defaults to 0 as the first entry in the |
| 85 // combobox, which is the generated default value received from | 89 // combobox, which is the generated default value received from |
| 86 // autofill::CountryComboboxModel::countries() which is documented to always | 90 // autofill::CountryComboboxModel::countries() which is documented to always |
| 87 // have the default country at the top as well as within the sorted list. | 91 // have the default country at the top as well as within the sorted list. |
| 88 size_t chosen_country_index_; | 92 size_t chosen_country_index_; |
| 89 | 93 |
| 90 // The list of country codes as ordered in the country combobox model. | 94 // The list of country codes as ordered in the country combobox model. |
| 91 std::vector<std::string> country_codes_; | 95 std::vector<std::string> country_codes_; |
| 92 | 96 |
| 93 // Identifies whether we tried and failed to load region data. | 97 // Identifies whether we tried and failed to load region data. |
| 94 bool failed_to_load_region_data_; | 98 bool failed_to_load_region_data_; |
| 95 | 99 |
| 96 // Updates |editor_fields_| based on the current country. | 100 // Updates |editor_fields_| based on the current country. |
| 97 void UpdateEditorFields(); | 101 void UpdateEditorFields(); |
| 98 | 102 |
| 99 // Called when data changes need to force a view update. | 103 // Called when data changes need to force a view update. |
| 100 void OnDataChanged(); | 104 void OnDataChanged(); |
| 101 | 105 |
| 106 // Saves the current state of the |editor_fields_| in |profile| and ignore |
| 107 // errors if |ignore_errors| is true. Return false on errors, ignored or not. |
| 108 bool SaveFieldsToProfile(autofill::AutofillProfile* profile, |
| 109 bool ignore_errors); |
| 110 |
| 102 // When a combobox model has changed, a view update might be needed, e.g., if | 111 // 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. | 112 // there is no data in the combobox and it must be converted to a text field. |
| 104 void OnComboboxModelChanged(views::Combobox* combobox); | 113 void OnComboboxModelChanged(views::Combobox* combobox); |
| 105 | 114 |
| 106 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController); | 115 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController); |
| 107 }; | 116 }; |
| 108 | 117 |
| 109 } // namespace payments | 118 } // namespace payments |
| 110 | 119 |
| 111 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL
LER_H_ | 120 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL
LER_H_ |
| OLD | NEW |