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

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: 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 std::string field_name; 257 std::string field_name;
258 if (!component->GetString(autofill::kFieldNameKey, &field_name)) { 258 if (!component->GetString(autofill::kFieldNameKey, &field_name)) {
259 NOTREACHED(); 259 NOTREACHED();
260 return; 260 return;
261 } 261 }
262 std::string field_length; 262 std::string field_length;
263 if (!component->GetString(autofill::kFieldLengthKey, &field_length)) { 263 if (!component->GetString(autofill::kFieldLengthKey, &field_length)) {
264 NOTREACHED(); 264 NOTREACHED();
265 return; 265 return;
266 } 266 }
267 EditorField::LengthHint length_hint = EditorField::LengthHint::HINT_LONG; 267 EditorField::LengthHint length_hint = EditorField::LengthHint::HINT_SHORT;
268 if (field_length == autofill::kShortField) 268 if (field_length == autofill::kLongField)
269 length_hint = EditorField::LengthHint::HINT_SHORT; 269 length_hint = EditorField::LengthHint::HINT_LONG;
270 else 270 else
271 DCHECK_EQ(autofill::kLongField, field_length); 271 DCHECK_EQ(autofill::kShortField, field_length);
272 autofill::ServerFieldType server_field_type = 272 autofill::ServerFieldType server_field_type =
273 GetFieldTypeFromString(field_type); 273 GetFieldTypeFromString(field_type);
274 EditorField::ControlType control_type = 274 EditorField::ControlType control_type =
275 EditorField::ControlType::TEXTFIELD; 275 EditorField::ControlType::TEXTFIELD;
276 if (server_field_type == autofill::ADDRESS_HOME_COUNTRY || 276 if (server_field_type == autofill::ADDRESS_HOME_COUNTRY ||
277 (server_field_type == autofill::ADDRESS_HOME_STATE && 277 (server_field_type == autofill::ADDRESS_HOME_STATE &&
278 !failed_to_load_region_data_)) { 278 !failed_to_load_region_data_)) {
279 control_type = EditorField::ControlType::COMBOBOX; 279 control_type = EditorField::ControlType::COMBOBOX;
280 } 280 }
281 editor_fields_.emplace_back( 281 editor_fields_.emplace_back(
282 server_field_type, base::UTF8ToUTF16(field_name), length_hint, 282 server_field_type, base::UTF8ToUTF16(field_name), length_hint,
283 /*required=*/server_field_type != autofill::COMPANY_NAME, 283 /*required=*/server_field_type != autofill::COMPANY_NAME,
284 control_type); 284 control_type);
285 // Insert the Country combobox right after NAME_FULL. 285 // Insert the Country combobox right after NAME_FULL.
286 if (server_field_type == autofill::NAME_FULL) { 286 if (server_field_type == autofill::NAME_FULL) {
287 editor_fields_.emplace_back( 287 editor_fields_.emplace_back(
288 autofill::ADDRESS_HOME_COUNTRY, 288 autofill::ADDRESS_HOME_COUNTRY,
289 l10n_util::GetStringUTF16( 289 l10n_util::GetStringUTF16(
290 IDS_LIBADDRESSINPUT_COUNTRY_OR_REGION_LABEL), 290 IDS_LIBADDRESSINPUT_COUNTRY_OR_REGION_LABEL),
291 EditorField::LengthHint::HINT_LONG, /*required=*/true, 291 EditorField::LengthHint::HINT_SHORT, /*required=*/true,
292 EditorField::ControlType::COMBOBOX); 292 EditorField::ControlType::COMBOBOX);
293 } 293 }
294 } 294 }
295 } 295 }
296 // Always add phone number at the end. 296 // Always add phone number at the end.
297 editor_fields_.emplace_back( 297 editor_fields_.emplace_back(
298 autofill::PHONE_HOME_NUMBER, 298 autofill::PHONE_HOME_NUMBER,
299 l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_PHONE), 299 l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_PHONE),
300 EditorField::LengthHint::HINT_LONG, /*required=*/false, 300 EditorField::LengthHint::HINT_SHORT, /*required=*/false,
301 EditorField::ControlType::TEXTFIELD); 301 EditorField::ControlType::TEXTFIELD);
302 } 302 }
303 303
304 void ShippingAddressEditorViewController::OnDataChanged(bool synchronous) { 304 void ShippingAddressEditorViewController::OnDataChanged(bool synchronous) {
305 temporary_profile_.reset(new autofill::AutofillProfile); 305 temporary_profile_.reset(new autofill::AutofillProfile);
306 SaveFieldsToProfile(temporary_profile_.get(), /*ignore_errors*/ true); 306 SaveFieldsToProfile(temporary_profile_.get(), /*ignore_errors*/ true);
307 307
308 UpdateEditorFields(); 308 UpdateEditorFields();
309 if (synchronous) { 309 if (synchronous) {
310 UpdateEditorView(); 310 UpdateEditorView();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 bool is_required_valid = !field_.required; 421 bool is_required_valid = !field_.required;
422 const base::string16 displayed_message = 422 const base::string16 displayed_message =
423 is_required_valid ? base::ASCIIToUTF16("") 423 is_required_valid ? base::ASCIIToUTF16("")
424 : l10n_util::GetStringUTF16( 424 : l10n_util::GetStringUTF16(
425 IDS_PAYMENTS_FIELD_REQUIRED_VALIDATION_MESSAGE); 425 IDS_PAYMENTS_FIELD_REQUIRED_VALIDATION_MESSAGE);
426 controller_->DisplayErrorMessageForField(field_, displayed_message); 426 controller_->DisplayErrorMessageForField(field_, displayed_message);
427 return is_required_valid; 427 return is_required_valid;
428 } 428 }
429 429
430 } // namespace payments 430 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698