Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: chrome/browser/ui/views/payments/shipping_address_editor_view_controller.h

Issue 2883333003: Payment request shipping address editor now properly handles countries (Closed)
Patch Set: Final nits Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/shipping_address_editor_view_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
14 #include "chrome/browser/ui/views/payments/editor_view_controller.h" 15 #include "chrome/browser/ui/views/payments/editor_view_controller.h"
15 #include "chrome/browser/ui/views/payments/validating_textfield.h" 16 #include "chrome/browser/ui/views/payments/validating_textfield.h"
16 17
17 namespace autofill { 18 namespace autofill {
18 class AutofillProfile; 19 class AutofillProfile;
20 class CountryComboboxModel;
19 } // namespace autofill 21 } // namespace autofill
20 22
21 namespace payments { 23 namespace payments {
22 24
23 class PaymentRequestSpec; 25 class PaymentRequestSpec;
24 class PaymentRequestState; 26 class PaymentRequestState;
25 class PaymentRequestDialogView; 27 class PaymentRequestDialogView;
26 28
27 // Shipping Address editor screen of the Payment Request flow. 29 // Shipping Address editor screen of the Payment Request flow.
28 class ShippingAddressEditorViewController : public EditorViewController { 30 class ShippingAddressEditorViewController : public EditorViewController {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // this controller. 97 // this controller.
96 autofill::AutofillProfile* profile_to_edit_; 98 autofill::AutofillProfile* profile_to_edit_;
97 99
98 // A temporary profile to keep unsaved data in between relayout (e.g., when 100 // A temporary profile to keep unsaved data in between relayout (e.g., when
99 // the country is changed and fields set may be different). 101 // the country is changed and fields set may be different).
100 std::unique_ptr<autofill::AutofillProfile> temporary_profile_; 102 std::unique_ptr<autofill::AutofillProfile> temporary_profile_;
101 103
102 // List of fields, reset everytime the current country changes. 104 // List of fields, reset everytime the current country changes.
103 std::vector<EditorField> editor_fields_; 105 std::vector<EditorField> editor_fields_;
104 106
105 // The currently chosen country. Defaults to 0 as the first entry in the 107 // The currently chosen country. Defaults to an invalid constant until
106 // combobox, which is the generated default value received from 108 // |countries_| is properly initialized and then 0 as the first entry in
109 // |countries_|, which is the generated default value received from
107 // autofill::CountryComboboxModel::countries() which is documented to always 110 // autofill::CountryComboboxModel::countries() which is documented to always
108 // have the default country at the top as well as within the sorted list. 111 // have the default country at the top as well as within the sorted list. If
112 // |profile_to_edit_| is not null, then use the country from there to set
113 // |chosen_country_index_|.
109 size_t chosen_country_index_; 114 size_t chosen_country_index_;
110 115
111 // The list of country codes as ordered in the country combobox model. 116 // The list of country codes and names as ordered in the country combobox
112 std::vector<std::string> country_codes_; 117 // model.
118 std::vector<std::pair<std::string, base::string16>> countries_;
113 119
114 // Identifies whether we tried and failed to load region data. 120 // Identifies whether we tried and failed to load region data.
115 bool failed_to_load_region_data_; 121 bool failed_to_load_region_data_;
116 122
123 // Updates |countries_| with the content of |model| if it's not null,
124 // otherwise use a local model.
125 void UpdateCountries(autofill::CountryComboboxModel* model);
126
117 // Updates |editor_fields_| based on the current country. 127 // Updates |editor_fields_| based on the current country.
118 void UpdateEditorFields(); 128 void UpdateEditorFields();
119 129
120 // Called when data changes need to force a view update. |synchronous| 130 // Called when data changes need to force a view update. |synchronous|
121 // specifies whether the view update can be done synchronously. 131 // specifies whether the view update can be done synchronously.
122 void OnDataChanged(bool synchronous); 132 void OnDataChanged(bool synchronous);
123 133
124 // Saves the current state of the |editor_fields_| in |profile| and ignore 134 // Saves the current state of the |editor_fields_| in |profile| and ignore
125 // errors if |ignore_errors| is true. Return false on errors, ignored or not. 135 // errors if |ignore_errors| is true. Return false on errors, ignored or not.
126 bool SaveFieldsToProfile(autofill::AutofillProfile* profile, 136 bool SaveFieldsToProfile(autofill::AutofillProfile* profile,
127 bool ignore_errors); 137 bool ignore_errors);
128 138
129 // When a combobox model has changed, a view update might be needed, e.g., if 139 // When a combobox model has changed, a view update might be needed, e.g., if
130 // there is no data in the combobox and it must be converted to a text field. 140 // there is no data in the combobox and it must be converted to a text field.
131 void OnComboboxModelChanged(views::Combobox* combobox); 141 void OnComboboxModelChanged(views::Combobox* combobox);
132 142
133 // Failed to fetch the region data in time. 143 // Failed to fetch the region data in time.
134 void RegionDataLoadTimedOut(); 144 void RegionDataLoadTimedOut();
135 145
136 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController); 146 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController);
137 }; 147 };
138 148
139 } // namespace payments 149 } // namespace payments
140 150
141 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL LER_H_ 151 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL LER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/shipping_address_editor_view_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698