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

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

Issue 2871873003: [Payments] Fix up field widths in desktop editors. (Closed)
Patch Set: addressed comments 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
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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 std::string field_name; 260 std::string field_name;
261 if (!component->GetString(autofill::kFieldNameKey, &field_name)) { 261 if (!component->GetString(autofill::kFieldNameKey, &field_name)) {
262 NOTREACHED(); 262 NOTREACHED();
263 return; 263 return;
264 } 264 }
265 std::string field_length; 265 std::string field_length;
266 if (!component->GetString(autofill::kFieldLengthKey, &field_length)) { 266 if (!component->GetString(autofill::kFieldLengthKey, &field_length)) {
267 NOTREACHED(); 267 NOTREACHED();
268 return; 268 return;
269 } 269 }
270 EditorField::LengthHint length_hint = EditorField::LengthHint::HINT_LONG; 270 EditorField::LengthHint length_hint = EditorField::LengthHint::HINT_SHORT;
271 if (field_length == autofill::kShortField) 271 if (field_length == autofill::kLongField)
272 length_hint = EditorField::LengthHint::HINT_SHORT; 272 length_hint = EditorField::LengthHint::HINT_LONG;
273 else 273 else
274 DCHECK_EQ(autofill::kLongField, field_length); 274 DCHECK_EQ(autofill::kShortField, field_length);
275 autofill::ServerFieldType server_field_type = 275 autofill::ServerFieldType server_field_type =
276 GetFieldTypeFromString(field_type); 276 GetFieldTypeFromString(field_type);
277 EditorField::ControlType control_type = 277 EditorField::ControlType control_type =
278 EditorField::ControlType::TEXTFIELD; 278 EditorField::ControlType::TEXTFIELD;
279 if (server_field_type == autofill::ADDRESS_HOME_COUNTRY || 279 if (server_field_type == autofill::ADDRESS_HOME_COUNTRY ||
280 (server_field_type == autofill::ADDRESS_HOME_STATE && 280 (server_field_type == autofill::ADDRESS_HOME_STATE &&
281 !failed_to_load_region_data_)) { 281 !failed_to_load_region_data_)) {
282 control_type = EditorField::ControlType::COMBOBOX; 282 control_type = EditorField::ControlType::COMBOBOX;
283 } 283 }
284 editor_fields_.emplace_back( 284 editor_fields_.emplace_back(
285 server_field_type, base::UTF8ToUTF16(field_name), length_hint, 285 server_field_type, base::UTF8ToUTF16(field_name), length_hint,
286 /*required=*/server_field_type != autofill::COMPANY_NAME, 286 /*required=*/server_field_type != autofill::COMPANY_NAME,
287 control_type); 287 control_type);
288 // Insert the Country combobox right after NAME_FULL. 288 // Insert the Country combobox right after NAME_FULL.
289 if (server_field_type == autofill::NAME_FULL) { 289 if (server_field_type == autofill::NAME_FULL) {
290 editor_fields_.emplace_back( 290 editor_fields_.emplace_back(
291 autofill::ADDRESS_HOME_COUNTRY, 291 autofill::ADDRESS_HOME_COUNTRY,
292 l10n_util::GetStringUTF16( 292 l10n_util::GetStringUTF16(
293 IDS_LIBADDRESSINPUT_COUNTRY_OR_REGION_LABEL), 293 IDS_LIBADDRESSINPUT_COUNTRY_OR_REGION_LABEL),
294 EditorField::LengthHint::HINT_LONG, /*required=*/true, 294 EditorField::LengthHint::HINT_SHORT, /*required=*/true,
295 EditorField::ControlType::COMBOBOX); 295 EditorField::ControlType::COMBOBOX);
296 } 296 }
297 } 297 }
298 } 298 }
299 // Always add phone number at the end. 299 // Always add phone number at the end.
300 editor_fields_.emplace_back( 300 editor_fields_.emplace_back(
301 autofill::PHONE_HOME_WHOLE_NUMBER, 301 autofill::PHONE_HOME_WHOLE_NUMBER,
302 l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_PHONE), 302 l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_PHONE),
303 EditorField::LengthHint::HINT_LONG, /*required=*/true, 303 EditorField::LengthHint::HINT_SHORT, /*required=*/true,
304 EditorField::ControlType::TEXTFIELD); 304 EditorField::ControlType::TEXTFIELD);
305 } 305 }
306 306
307 void ShippingAddressEditorViewController::OnDataChanged(bool synchronous) { 307 void ShippingAddressEditorViewController::OnDataChanged(bool synchronous) {
308 temporary_profile_.reset(new autofill::AutofillProfile); 308 temporary_profile_.reset(new autofill::AutofillProfile);
309 SaveFieldsToProfile(temporary_profile_.get(), /*ignore_errors*/ true); 309 SaveFieldsToProfile(temporary_profile_.get(), /*ignore_errors*/ true);
310 310
311 UpdateEditorFields(); 311 UpdateEditorFields();
312 if (synchronous) { 312 if (synchronous) {
313 UpdateEditorView(); 313 UpdateEditorView();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 bool is_required_valid = !field_.required; 430 bool is_required_valid = !field_.required;
431 const base::string16 displayed_message = 431 const base::string16 displayed_message =
432 is_required_valid ? base::ASCIIToUTF16("") 432 is_required_valid ? base::ASCIIToUTF16("")
433 : l10n_util::GetStringUTF16( 433 : l10n_util::GetStringUTF16(
434 IDS_PAYMENTS_FIELD_REQUIRED_VALIDATION_MESSAGE); 434 IDS_PAYMENTS_FIELD_REQUIRED_VALIDATION_MESSAGE);
435 controller_->DisplayErrorMessageForField(field_, displayed_message); 435 controller_->DisplayErrorMessageForField(field_, displayed_message);
436 return is_required_valid; 436 return is_required_valid;
437 } 437 }
438 438
439 } // namespace payments 439 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698