OLD | NEW |
---|---|
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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 *state()->GetPersonalDataManager(), state()->GetApplicationLocale(), | 328 *state()->GetPersonalDataManager(), state()->GetApplicationLocale(), |
329 credit_card_to_edit_ ? credit_card_to_edit_->billing_address_id() | 329 credit_card_to_edit_ ? credit_card_to_edit_->billing_address_id() |
330 : ""); | 330 : ""); |
331 default: | 331 default: |
332 NOTREACHED(); | 332 NOTREACHED(); |
333 break; | 333 break; |
334 } | 334 } |
335 return std::unique_ptr<ui::ComboboxModel>(); | 335 return std::unique_ptr<ui::ComboboxModel>(); |
336 } | 336 } |
337 | 337 |
338 void CreditCardEditorViewController::FillContentView( | |
339 views::View* content_view) { | |
340 EditorViewController::FillContentView(content_view); | |
341 views::Combobox* combobox = | |
342 static_cast<views::Combobox*>(dialog()->GetViewByID(kBillingAddressType)); | |
anthonyvd
2017/05/18 15:08:43
I don't think you need to cast, SetEnabled should
MAD
2017/05/18 16:09:14
But I also need to call GetRowCount(). :-)
| |
343 DCHECK(combobox); | |
344 // When the combobox has a single item, it's because it has no addresses | |
345 // (otherwise, it would have the select header, and a separator before the | |
346 // first address to choose from). | |
347 combobox->SetEnabled(combobox->GetRowCount() > 1); | |
348 } | |
349 | |
338 base::string16 CreditCardEditorViewController::GetSheetTitle() { | 350 base::string16 CreditCardEditorViewController::GetSheetTitle() { |
339 if (!credit_card_to_edit_) | 351 if (!credit_card_to_edit_) |
340 return l10n_util::GetStringUTF16(IDS_PAYMENTS_ADD_CARD); | 352 return l10n_util::GetStringUTF16(IDS_PAYMENTS_ADD_CARD); |
341 | 353 |
342 // Gets the completion message, or empty if nothing is missing from the card. | 354 // Gets the completion message, or empty if nothing is missing from the card. |
343 base::string16 title = autofill::GetCompletionMessageForCard( | 355 base::string16 title = autofill::GetCompletionMessageForCard( |
344 autofill::GetCompletionStatusForCard( | 356 autofill::GetCompletionStatusForCard( |
345 *credit_card_to_edit_, state()->GetApplicationLocale(), | 357 *credit_card_to_edit_, state()->GetApplicationLocale(), |
346 state()->GetPersonalDataManager()->GetProfiles())); | 358 state()->GetPersonalDataManager()->GetProfiles())); |
347 return title.empty() ? l10n_util::GetStringUTF16(IDS_PAYMENTS_EDIT_CARD) | 359 return title.empty() ? l10n_util::GetStringUTF16(IDS_PAYMENTS_EDIT_CARD) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 controller_->DisplayErrorMessageForField(field_, displayed_message); | 441 controller_->DisplayErrorMessageForField(field_, displayed_message); |
430 return is_required_valid; | 442 return is_required_valid; |
431 } | 443 } |
432 | 444 |
433 bool CreditCardEditorViewController::GetSheetId(DialogViewID* sheet_id) { | 445 bool CreditCardEditorViewController::GetSheetId(DialogViewID* sheet_id) { |
434 *sheet_id = DialogViewID::CREDIT_CARD_EDITOR_SHEET; | 446 *sheet_id = DialogViewID::CREDIT_CARD_EDITOR_SHEET; |
435 return true; | 447 return true; |
436 } | 448 } |
437 | 449 |
438 } // namespace payments | 450 } // namespace payments |
OLD | NEW |