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

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

Issue 2803443003: [Payments] Added region load failure tolerance and tests to PR editor. (Closed)
Patch Set: Sign bot error fixes Created 3 years, 8 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
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 <vector> 10 #include <vector>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 class ShippingAddressValidationDelegate : public ValidationDelegate { 46 class ShippingAddressValidationDelegate : public ValidationDelegate {
47 public: 47 public:
48 ShippingAddressValidationDelegate( 48 ShippingAddressValidationDelegate(
49 ShippingAddressEditorViewController* parent, 49 ShippingAddressEditorViewController* parent,
50 const EditorField& field); 50 const EditorField& field);
51 ~ShippingAddressValidationDelegate() override; 51 ~ShippingAddressValidationDelegate() override;
52 52
53 // ValidationDelegate: 53 // ValidationDelegate:
54 bool ValidateTextfield(views::Textfield* textfield) override; 54 bool ValidateTextfield(views::Textfield* textfield) override;
55 bool ValidateCombobox(views::Combobox* combobox) override; 55 bool ValidateCombobox(views::Combobox* combobox) override;
56 void ComboboxModelChanged(views::Combobox* combobox) override;
56 57
57 private: 58 private:
58 bool ValidateValue(const base::string16& value); 59 bool ValidateValue(const base::string16& value);
59 60
60 EditorField field_; 61 EditorField field_;
62
61 // Raw pointer back to the owner of this class, therefore will not be null. 63 // Raw pointer back to the owner of this class, therefore will not be null.
62 ShippingAddressEditorViewController* controller_; 64 ShippingAddressEditorViewController* controller_;
63 65
64 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate); 66 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate);
65 }; 67 };
66 friend class ShippingAddressValidationDelegate; 68 friend class ShippingAddressValidationDelegate;
67 69
68 // List of fields, reset everytime the current country changes. 70 // List of fields, reset everytime the current country changes.
69 std::vector<EditorField> editor_fields_; 71 std::vector<EditorField> editor_fields_;
70 72
71 // The currently chosen country. Defaults to 0 as the first entry in the 73 // The currently chosen country. Defaults to 0 as the first entry in the
72 // combobox, which is the generated default value received from 74 // combobox, which is the generated default value received from
73 // autofill::CountryComboboxModel::countries() which is documented to always 75 // autofill::CountryComboboxModel::countries() which is documented to always
74 // have the default country at the top as well as within the sorted list. 76 // have the default country at the top as well as within the sorted list.
75 size_t chosen_country_index_{0}; 77 size_t chosen_country_index_{0};
76 78
77 // The list of country codes as ordered in the country combobox model. 79 // The list of country codes as ordered in the country combobox model.
78 std::vector<std::string> country_codes_; 80 std::vector<std::string> country_codes_;
79 81
82 // Identifies whether we tried and failed to load region data.
83 bool failed_to_load_region_data_{false};
84
80 // Updates |editor_fields_| based on the current country. 85 // Updates |editor_fields_| based on the current country.
81 void UpdateEditorFields(); 86 void UpdateEditorFields();
82 87
83 // Called by the validation delegate when the country combobox changed. 88 // Called when data changes need to force a view update.
84 void OnCountryChanged(views::Combobox* combobox); 89 void OnDataChanged();
90
91 // When a combobox model has changed, a view update might be needed, e.g., if
92 // there is no data in the combox and it must be converted to a text field.
Mathieu 2017/04/05 00:25:14 nit: combobox
MAD 2017/04/07 18:50:40 Done.
93 void OnComboboxModelChanged(views::Combobox* combobox);
85 94
86 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController); 95 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController);
87 }; 96 };
88 97
89 } // namespace payments 98 } // namespace payments
90 99
91 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL LER_H_ 100 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL LER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698