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

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

Issue 2768133002: [Web Payments] Refactor sheet display to allow updating view content (Closed)
Patch Set: Add comments. Created 3 years, 9 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 #include "chrome/browser/ui/views/payments/shipping_address_editor_view_controll er.h" 5 #include "chrome/browser/ui/views/payments/shipping_address_editor_view_controll er.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 UpdateEditorFields(); 80 UpdateEditorFields();
81 } 81 }
82 82
83 ShippingAddressEditorViewController::~ShippingAddressEditorViewController() {} 83 ShippingAddressEditorViewController::~ShippingAddressEditorViewController() {}
84 84
85 std::unique_ptr<views::View> 85 std::unique_ptr<views::View>
86 ShippingAddressEditorViewController::CreateHeaderView() { 86 ShippingAddressEditorViewController::CreateHeaderView() {
87 return base::MakeUnique<views::View>(); 87 return base::MakeUnique<views::View>();
88 } 88 }
89 89
90 int ShippingAddressEditorViewController::GetViewHeaderTitleId() const {
91 return IDS_PAYMENT_REQUEST_ADDRESS_EDITOR_ADD_TITLE;
92 }
93
94 std::vector<EditorField> 90 std::vector<EditorField>
95 ShippingAddressEditorViewController::GetFieldDefinitions() { 91 ShippingAddressEditorViewController::GetFieldDefinitions() {
96 return editor_fields_; 92 return editor_fields_;
97 } 93 }
98 94
99 bool ShippingAddressEditorViewController::ValidateModelAndSave() { 95 bool ShippingAddressEditorViewController::ValidateModelAndSave() {
100 autofill::AutofillProfile profile; 96 autofill::AutofillProfile profile;
101 profile.set_origin(autofill::kSettingsOrigin); 97 profile.set_origin(autofill::kSettingsOrigin);
102 for (const auto& field : text_fields()) { 98 for (const auto& field : text_fields()) {
103 // Force a blur in case the value was left untouched. 99 // Force a blur in case the value was left untouched.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 void ShippingAddressEditorViewController::UpdateEditorView() { 185 void ShippingAddressEditorViewController::UpdateEditorView() {
190 EditorViewController::UpdateEditorView(); 186 EditorViewController::UpdateEditorView();
191 if (chosen_country_index_ > 0UL) { 187 if (chosen_country_index_ > 0UL) {
192 views::Combobox* country_combo_box = static_cast<views::Combobox*>( 188 views::Combobox* country_combo_box = static_cast<views::Combobox*>(
193 dialog()->GetViewByID(autofill::ADDRESS_HOME_COUNTRY)); 189 dialog()->GetViewByID(autofill::ADDRESS_HOME_COUNTRY));
194 DCHECK(country_combo_box); 190 DCHECK(country_combo_box);
195 country_combo_box->SetSelectedIndex(chosen_country_index_); 191 country_combo_box->SetSelectedIndex(chosen_country_index_);
196 } 192 }
197 } 193 }
198 194
195 base::string16 ShippingAddressEditorViewController::GetSheetTitle() {
196 return l10n_util::GetStringUTF16(
197 IDS_PAYMENT_REQUEST_ADDRESS_EDITOR_ADD_TITLE);
198 }
199
199 void ShippingAddressEditorViewController::UpdateEditorFields() { 200 void ShippingAddressEditorViewController::UpdateEditorFields() {
200 editor_fields_.clear(); 201 editor_fields_.clear();
201 std::string chosen_country_code; 202 std::string chosen_country_code;
202 if (chosen_country_index_ < country_codes_.size()) 203 if (chosen_country_index_ < country_codes_.size())
203 chosen_country_code = country_codes_[chosen_country_index_]; 204 chosen_country_code = country_codes_[chosen_country_index_];
204 205
205 std::unique_ptr<base::ListValue> components(new base::ListValue); 206 std::unique_ptr<base::ListValue> components(new base::ListValue);
206 std::string unused; 207 std::string unused;
207 autofill::GetAddressComponents(chosen_country_code, 208 autofill::GetAddressComponents(chosen_country_code,
208 state()->GetApplicationLocale(), 209 state()->GetApplicationLocale(),
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } 308 }
308 309
309 bool ShippingAddressEditorViewController::ShippingAddressValidationDelegate:: 310 bool ShippingAddressEditorViewController::ShippingAddressValidationDelegate::
310 ValidateValue(const base::string16& value) { 311 ValidateValue(const base::string16& value) {
311 // TODO(crbug.com/703754) add phone validation. 312 // TODO(crbug.com/703754) add phone validation.
312 // TODO(crbug.com/703756): Display "required" error if applicable. 313 // TODO(crbug.com/703756): Display "required" error if applicable.
313 return !field_.required || !value.empty(); 314 return !field_.required || !value.empty();
314 } 315 }
315 316
316 } // namespace payments 317 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698