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

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

Issue 2905283002: [Payments] Allow international phone from different country in shipping editor. (Closed)
Patch Set: Created 3 years, 6 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 GetInputFieldViewId(autofill::ADDRESS_HOME_COUNTRY))); 372 GetInputFieldViewId(autofill::ADDRESS_HOME_COUNTRY)));
373 // The combobox can be null when saving to temporary profile while updating 373 // The combobox can be null when saving to temporary profile while updating
374 // the view. 374 // the view.
375 if (combobox) { 375 if (combobox) {
376 base::string16 country(combobox->GetTextForRow(combobox->selected_index())); 376 base::string16 country(combobox->GetTextForRow(combobox->selected_index()));
377 bool success = 377 bool success =
378 profile->SetInfo(autofill::AutofillType(autofill::ADDRESS_HOME_COUNTRY), 378 profile->SetInfo(autofill::AutofillType(autofill::ADDRESS_HOME_COUNTRY),
379 country, locale); 379 country, locale);
380 LOG_IF(ERROR, !success && !ignore_errors) 380 LOG_IF(ERROR, !success && !ignore_errors)
381 << "Can't set profile country to: " << country; 381 << "Can't set profile country to: " << country;
382 if (!success && !ignore_errors) 382 if (!success && !ignore_errors) {
383 dialog()->OnEditorValidationError();
383 return false; 384 return false;
385 }
384 } else { 386 } else {
385 DCHECK_EQ(temporary_profile_.get(), profile); 387 DCHECK_EQ(temporary_profile_.get(), profile);
386 } 388 }
387 389
388 bool success = true; 390 bool success = true;
389 for (const auto& field : text_fields()) { 391 for (const auto& field : text_fields()) {
390 // ValidatingTextfield* is the key, EditorField is the value. 392 // ValidatingTextfield* is the key, EditorField is the value.
391 if (field.first->IsValid()) { 393 if (field.first->IsValid()) {
392 success = profile->SetInfo(autofill::AutofillType(field.second.type), 394 success = profile->SetInfo(autofill::AutofillType(field.second.type),
393 field.first->text(), locale); 395 field.first->text(), locale);
394 } else { 396 } else {
395 success = false; 397 success = false;
396 } 398 }
397 LOG_IF(ERROR, !success && !ignore_errors) 399 LOG_IF(ERROR, !success && !ignore_errors)
398 << "Can't setinfo(" << field.second.type << ", " << field.first->text(); 400 << "Can't setinfo(" << field.second.type << ", " << field.first->text();
399 if (!success && !ignore_errors) 401 if (!success && !ignore_errors) {
402 dialog()->OnEditorValidationError();
400 return false; 403 return false;
404 }
401 } 405 }
402 for (const auto& field : comboboxes()) { 406 for (const auto& field : comboboxes()) {
403 // ValidatingCombobox* is the key, EditorField is the value. 407 // ValidatingCombobox* is the key, EditorField is the value.
404 ValidatingCombobox* combobox = field.first; 408 ValidatingCombobox* combobox = field.first;
405 // The country has already been dealt with. 409 // The country has already been dealt with.
406 if (combobox->id() == GetInputFieldViewId(autofill::ADDRESS_HOME_COUNTRY)) 410 if (combobox->id() == GetInputFieldViewId(autofill::ADDRESS_HOME_COUNTRY))
407 continue; 411 continue;
408 if (combobox->IsValid()) { 412 if (combobox->IsValid()) {
409 success = profile->SetInfo( 413 success = profile->SetInfo(
410 autofill::AutofillType(field.second.type), 414 autofill::AutofillType(field.second.type),
411 combobox->GetTextForRow(combobox->selected_index()), locale); 415 combobox->GetTextForRow(combobox->selected_index()), locale);
412 } else { 416 } else {
413 success = false; 417 success = false;
414 } 418 }
415 LOG_IF(ERROR, !success && !ignore_errors) 419 LOG_IF(ERROR, !success && !ignore_errors)
416 << "Can't setinfo(" << field.second.type << ", " 420 << "Can't setinfo(" << field.second.type << ", "
417 << combobox->GetTextForRow(combobox->selected_index()); 421 << combobox->GetTextForRow(combobox->selected_index());
418 if (!success && !ignore_errors) 422 if (!success && !ignore_errors) {
423 dialog()->OnEditorValidationError();
419 return false; 424 return false;
425 }
420 } 426 }
421 return success; 427 return success;
422 } 428 }
423 429
424 void ShippingAddressEditorViewController::OnComboboxModelChanged( 430 void ShippingAddressEditorViewController::OnComboboxModelChanged(
425 views::Combobox* combobox) { 431 views::Combobox* combobox) {
426 if (combobox->id() != GetInputFieldViewId(autofill::ADDRESS_HOME_STATE)) 432 if (combobox->id() != GetInputFieldViewId(autofill::ADDRESS_HOME_STATE))
427 return; 433 return;
428 autofill::RegionComboboxModel* model = 434 autofill::RegionComboboxModel* model =
429 static_cast<autofill::RegionComboboxModel*>(combobox->model()); 435 static_cast<autofill::RegionComboboxModel*>(combobox->model());
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 return true; 528 return true;
523 } 529 }
524 if (error_message && field_.required) { 530 if (error_message && field_.required) {
525 *error_message = l10n_util::GetStringUTF16( 531 *error_message = l10n_util::GetStringUTF16(
526 IDS_PAYMENTS_FIELD_REQUIRED_VALIDATION_MESSAGE); 532 IDS_PAYMENTS_FIELD_REQUIRED_VALIDATION_MESSAGE);
527 } 533 }
528 return !field_.required; 534 return !field_.required;
529 } 535 }
530 536
531 } // namespace payments 537 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698