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

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

Issue 2900163002: Add newly created billing address to payment request state. (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
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/credit_card_editor_view_controller.h" 5 #include "chrome/browser/ui/views/payments/credit_card_editor_view_controller.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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 base::Time::Exploded now_exploded; 83 base::Time::Exploded now_exploded;
84 autofill::AutofillClock::Now().LocalExplode(&now_exploded); 84 autofill::AutofillClock::Now().LocalExplode(&now_exploded);
85 for (int i = 0; i < kNumberOfExpirationYears; i++) { 85 for (int i = 0; i < kNumberOfExpirationYears; i++) {
86 years.push_back(base::UTF8ToUTF16(std::to_string(now_exploded.year + i))); 86 years.push_back(base::UTF8ToUTF16(std::to_string(now_exploded.year + i)));
87 } 87 }
88 return years; 88 return years;
89 } 89 }
90 90
91 bool IsCardExpired(const base::string16& month, 91 bool IsCardExpired(const base::string16& month,
92 base::string16& year, 92 const base::string16& year,
93 const std::string& app_locale) { 93 const std::string& app_locale) {
94 autofill::CreditCard card; 94 autofill::CreditCard card;
95 card.SetExpirationMonthFromString(month, app_locale); 95 card.SetExpirationMonthFromString(month, app_locale);
96 card.SetExpirationYearFromString(year); 96 card.SetExpirationYearFromString(year);
97 return card.IsExpired(autofill::AutofillClock::Now()); 97 return card.IsExpired(autofill::AutofillClock::Now());
98 } 98 }
99 99
100 // Validates the two comboboxes used for expiration date. 100 // Validates the two comboboxes used for expiration date.
101 class ExpirationDateValidationDelegate : public ValidationDelegate { 101 class ExpirationDateValidationDelegate : public ValidationDelegate {
102 public: 102 public:
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 &CreditCardEditorViewController::AddAndSelectNewBillingAddress, 495 &CreditCardEditorViewController::AddAndSelectNewBillingAddress,
496 base::Unretained(this)), 496 base::Unretained(this)),
497 /*profile=*/nullptr); 497 /*profile=*/nullptr);
498 } else { 498 } else {
499 EditorViewController::ButtonPressed(sender, event); 499 EditorViewController::ButtonPressed(sender, event);
500 } 500 }
501 } 501 }
502 502
503 void CreditCardEditorViewController::AddAndSelectNewBillingAddress( 503 void CreditCardEditorViewController::AddAndSelectNewBillingAddress(
504 const autofill::AutofillProfile& profile) { 504 const autofill::AutofillProfile& profile) {
505 state()->AddAutofillShippingProfile(false, profile);
505 views::Combobox* address_combobox = static_cast<views::Combobox*>( 506 views::Combobox* address_combobox = static_cast<views::Combobox*>(
506 dialog()->GetViewByID(GetInputFieldViewId(kBillingAddressType))); 507 dialog()->GetViewByID(GetInputFieldViewId(kBillingAddressType)));
507 autofill::AddressComboboxModel* model = 508 autofill::AddressComboboxModel* model =
508 static_cast<autofill::AddressComboboxModel*>(address_combobox->model()); 509 static_cast<autofill::AddressComboboxModel*>(address_combobox->model());
509 int index = model->AddNewProfile(profile); 510 int index = model->AddNewProfile(profile);
510 // SetSelectedIndex doesn't trigger a perform action notification, which is 511 // SetSelectedIndex doesn't trigger a perform action notification, which is
511 // needed to update the valid state. 512 // needed to update the valid state.
512 address_combobox->SetSelectedRow(index); 513 address_combobox->SetSelectedRow(index);
513 // But it needs to be blured at least once. 514 // But it needs to be blured at least once.
514 address_combobox->OnBlur(); 515 address_combobox->OnBlur();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 return ValidateValue(combobox->GetTextForRow(combobox->selected_index()), 596 return ValidateValue(combobox->GetTextForRow(combobox->selected_index()),
596 error_message); 597 error_message);
597 } 598 }
598 599
599 bool CreditCardEditorViewController::GetSheetId(DialogViewID* sheet_id) { 600 bool CreditCardEditorViewController::GetSheetId(DialogViewID* sheet_id) {
600 *sheet_id = DialogViewID::CREDIT_CARD_EDITOR_SHEET; 601 *sheet_id = DialogViewID::CREDIT_CARD_EDITOR_SHEET;
601 return true; 602 return true;
602 } 603 }
603 604
604 } // namespace payments 605 } // namespace payments
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698