| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/autofill/autofill_dialog_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 kShippingInputs, | 214 kShippingInputs, |
| 215 arraysize(kShippingInputs), | 215 arraysize(kShippingInputs), |
| 216 &requested_shipping_fields_); | 216 &requested_shipping_fields_); |
| 217 | 217 |
| 218 GenerateSuggestionsModels(); | 218 GenerateSuggestionsModels(); |
| 219 | 219 |
| 220 // TODO(estade): don't show the dialog if the site didn't specify the right | 220 // TODO(estade): don't show the dialog if the site didn't specify the right |
| 221 // fields. First we must figure out what the "right" fields are. | 221 // fields. First we must figure out what the "right" fields are. |
| 222 view_.reset(AutofillDialogView::Create(this)); | 222 view_.reset(AutofillDialogView::Create(this)); |
| 223 view_->Show(); | 223 view_->Show(); |
| 224 GetManager()->AddObserver(this); |
| 224 | 225 |
| 225 // Request sugar info after the view is showing to simplify code for now. | 226 // Request sugar info after the view is showing to simplify code for now. |
| 226 if (CanPayWithWallet()) | 227 if (CanPayWithWallet()) |
| 227 ScheduleRefreshWalletItems(); | 228 ScheduleRefreshWalletItems(); |
| 228 } | 229 } |
| 229 | 230 |
| 230 void AutofillDialogControllerImpl::Hide() { | 231 void AutofillDialogControllerImpl::Hide() { |
| 231 if (view_) | 232 if (view_) |
| 232 view_->Hide(); | 233 view_->Hide(); |
| 233 } | 234 } |
| 234 | 235 |
| 236 void AutofillDialogControllerImpl::UpdateProgressBar(double value) { |
| 237 view_->UpdateProgressBar(value); |
| 238 } |
| 239 |
| 235 //////////////////////////////////////////////////////////////////////////////// | 240 //////////////////////////////////////////////////////////////////////////////// |
| 236 // AutofillDialogController implementation. | 241 // AutofillDialogController implementation. |
| 237 | 242 |
| 238 string16 AutofillDialogControllerImpl::DialogTitle() const { | 243 string16 AutofillDialogControllerImpl::DialogTitle() const { |
| 239 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_TITLE); | 244 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_TITLE); |
| 240 } | 245 } |
| 241 | 246 |
| 242 string16 AutofillDialogControllerImpl::EditSuggestionText() const { | 247 string16 AutofillDialogControllerImpl::EditSuggestionText() const { |
| 243 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_EDIT); | 248 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_EDIT); |
| 244 } | 249 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); | 378 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); |
| 374 std::string item_key = model->GetItemKeyAt(model->checked_item()); | 379 std::string item_key = model->GetItemKeyAt(model->checked_item()); |
| 375 if (item_key.empty()) | 380 if (item_key.empty()) |
| 376 return string16(); | 381 return string16(); |
| 377 | 382 |
| 378 if (section == SECTION_EMAIL) | 383 if (section == SECTION_EMAIL) |
| 379 return model->GetLabelAt(model->checked_item()); | 384 return model->GetLabelAt(model->checked_item()); |
| 380 | 385 |
| 381 if (section == SECTION_CC) { | 386 if (section == SECTION_CC) { |
| 382 CreditCard* card = GetManager()->GetCreditCardByGUID(item_key); | 387 CreditCard* card = GetManager()->GetCreditCardByGUID(item_key); |
| 383 if (!card) | |
| 384 return string16(); | |
| 385 | |
| 386 return card->TypeAndLastFourDigits(); | 388 return card->TypeAndLastFourDigits(); |
| 387 } | 389 } |
| 388 | 390 |
| 391 const std::string app_locale = AutofillCountry::ApplicationLocale(); |
| 389 AutofillProfile* profile = GetManager()->GetProfileByGUID(item_key); | 392 AutofillProfile* profile = GetManager()->GetProfileByGUID(item_key); |
| 390 if (!profile) | |
| 391 return string16(); | |
| 392 | |
| 393 const std::string app_locale = AutofillCountry::ApplicationLocale(); | |
| 394 string16 comma = ASCIIToUTF16(", "); | 393 string16 comma = ASCIIToUTF16(", "); |
| 395 string16 label = profile->GetInfo(NAME_FULL, app_locale) + | 394 string16 label = profile->GetInfo(NAME_FULL, app_locale) + |
| 396 comma + profile->GetInfo(ADDRESS_HOME_LINE1, app_locale); | 395 comma + profile->GetInfo(ADDRESS_HOME_LINE1, app_locale); |
| 397 string16 address2 = profile->GetInfo(ADDRESS_HOME_LINE2, app_locale); | 396 string16 address2 = profile->GetInfo(ADDRESS_HOME_LINE2, app_locale); |
| 398 if (!address2.empty()) | 397 if (!address2.empty()) |
| 399 label += comma + address2; | 398 label += comma + address2; |
| 400 label += ASCIIToUTF16("\n") + | 399 label += ASCIIToUTF16("\n") + |
| 401 profile->GetInfo(ADDRESS_HOME_CITY, app_locale) + comma + | 400 profile->GetInfo(ADDRESS_HOME_CITY, app_locale) + comma + |
| 402 profile->GetInfo(ADDRESS_HOME_STATE, app_locale) + ASCIIToUTF16(" ") + | 401 profile->GetInfo(ADDRESS_HOME_STATE, app_locale) + ASCIIToUTF16(" ") + |
| 403 profile->GetInfo(ADDRESS_HOME_ZIP, app_locale); | 402 profile->GetInfo(ADDRESS_HOME_ZIP, app_locale); |
| 404 return label; | 403 return label; |
| 405 } | 404 } |
| 406 | 405 |
| 407 gfx::Image AutofillDialogControllerImpl::SuggestionIconForSection( | 406 gfx::Image AutofillDialogControllerImpl::SuggestionIconForSection( |
| 408 DialogSection section) { | 407 DialogSection section) { |
| 409 if (section != SECTION_CC) | 408 if (section != SECTION_CC) |
| 410 return gfx::Image(); | 409 return gfx::Image(); |
| 411 | 410 |
| 412 std::string item_key = | 411 std::string item_key = |
| 413 suggested_cc_.GetItemKeyAt(suggested_cc_.checked_item()); | 412 suggested_cc_.GetItemKeyAt(suggested_cc_.checked_item()); |
| 413 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 414 CreditCard* card = GetManager()->GetCreditCardByGUID(item_key); | 414 CreditCard* card = GetManager()->GetCreditCardByGUID(item_key); |
| 415 if (!card) | |
| 416 return gfx::Image(); | |
| 417 | |
| 418 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 419 return rb.GetImageNamed(card->IconResourceId()); | 415 return rb.GetImageNamed(card->IconResourceId()); |
| 420 } | 416 } |
| 421 | 417 |
| 422 void AutofillDialogControllerImpl::EditClickedForSection( | 418 void AutofillDialogControllerImpl::EditClickedForSection( |
| 423 DialogSection section) { | 419 DialogSection section) { |
| 424 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); | 420 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); |
| 425 DetailInputs* inputs = MutableRequestedFieldsForSection(section); | 421 DetailInputs* inputs = MutableRequestedFieldsForSection(section); |
| 426 | 422 |
| 427 if (section == SECTION_EMAIL) { | 423 if (section == SECTION_EMAIL) { |
| 428 // TODO(estade): shouldn't need to make this check. | 424 // TODO(estade): shouldn't need to make this check. |
| 429 if (inputs->empty()) | 425 if (inputs->empty()) |
| 430 return; | 426 return; |
| 431 | 427 |
| 432 (*inputs)[0].autofilled_value = model->GetLabelAt(model->checked_item()); | 428 (*inputs)[0].autofilled_value = model->GetLabelAt(model->checked_item()); |
| 433 } else { | 429 } else { |
| 434 std::string guid = model->GetItemKeyAt(model->checked_item()); | 430 std::string guid = model->GetItemKeyAt(model->checked_item()); |
| 435 DCHECK(!guid.empty()); | 431 DCHECK(!guid.empty()); |
| 436 | 432 |
| 437 FormGroup* form_group = section == SECTION_CC ? | 433 FormGroup* form_group = section == SECTION_CC ? |
| 438 static_cast<FormGroup*>(GetManager()->GetCreditCardByGUID(guid)) : | 434 static_cast<FormGroup*>(GetManager()->GetCreditCardByGUID(guid)) : |
| 439 static_cast<FormGroup*>(GetManager()->GetProfileByGUID(guid)); | 435 static_cast<FormGroup*>(GetManager()->GetProfileByGUID(guid)); |
| 440 | 436 DCHECK(form_group); |
| 441 // TODO(estade): we shouldn't let this happen. | |
| 442 if (!form_group) | |
| 443 return; | |
| 444 | |
| 445 FillInputFromFormGroup(form_group, inputs); | 437 FillInputFromFormGroup(form_group, inputs); |
| 446 } | 438 } |
| 447 | 439 |
| 448 section_editing_state_[section] = true; | 440 section_editing_state_[section] = true; |
| 449 view_->UpdateSection(section); | 441 view_->UpdateSection(section); |
| 450 } | 442 } |
| 451 | 443 |
| 452 bool AutofillDialogControllerImpl::InputIsValid(AutofillFieldType type, | 444 bool AutofillDialogControllerImpl::InputIsValid(AutofillFieldType type, |
| 453 const string16& value) { | 445 const string16& value) { |
| 454 switch (type) { | 446 switch (type) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 popup_icons, | 540 popup_icons, |
| 549 popup_ids); | 541 popup_ids); |
| 550 section_showing_popup_ = section; | 542 section_showing_popup_ = section; |
| 551 } | 543 } |
| 552 | 544 |
| 553 void AutofillDialogControllerImpl::FocusMoved() { | 545 void AutofillDialogControllerImpl::FocusMoved() { |
| 554 HidePopup(); | 546 HidePopup(); |
| 555 } | 547 } |
| 556 | 548 |
| 557 void AutofillDialogControllerImpl::ViewClosed(DialogAction action) { | 549 void AutofillDialogControllerImpl::ViewClosed(DialogAction action) { |
| 550 GetManager()->RemoveObserver(this); |
| 551 |
| 558 if (action == ACTION_SUBMIT) { | 552 if (action == ACTION_SUBMIT) { |
| 559 FillOutputForSection(SECTION_EMAIL); | 553 FillOutputForSection(SECTION_EMAIL); |
| 560 FillOutputForSection(SECTION_CC); | 554 FillOutputForSection(SECTION_CC); |
| 561 FillOutputForSection(SECTION_BILLING); | 555 FillOutputForSection(SECTION_BILLING); |
| 562 if (view_->UseBillingForShipping()) { | 556 if (view_->UseBillingForShipping()) { |
| 563 FillOutputForSectionWithComparator( | 557 FillOutputForSectionWithComparator( |
| 564 SECTION_BILLING, | 558 SECTION_BILLING, |
| 565 base::Bind(DetailInputMatchesShippingField)); | 559 base::Bind(DetailInputMatchesShippingField)); |
| 566 FillOutputForSectionWithComparator( | 560 FillOutputForSectionWithComparator( |
| 567 SECTION_CC, | 561 SECTION_CC, |
| 568 base::Bind(DetailInputMatchesShippingField)); | 562 base::Bind(DetailInputMatchesShippingField)); |
| 569 } else { | 563 } else { |
| 570 FillOutputForSection(SECTION_SHIPPING); | 564 FillOutputForSection(SECTION_SHIPPING); |
| 571 } | 565 } |
| 572 callback_.Run(&form_structure_); | 566 callback_.Run(&form_structure_); |
| 573 } else { | 567 } else { |
| 574 callback_.Run(NULL); | 568 callback_.Run(NULL); |
| 575 } | 569 } |
| 576 | 570 |
| 577 delete this; | 571 delete this; |
| 578 } | 572 } |
| 579 | 573 |
| 580 void AutofillDialogControllerImpl::UpdateProgressBar(double value) { | |
| 581 view_->UpdateProgressBar(value); | |
| 582 } | |
| 583 | |
| 584 DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { | 574 DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { |
| 585 if (HasRequiredAction(wallet::VERIFY_CVV)) { | 575 if (HasRequiredAction(wallet::VERIFY_CVV)) { |
| 586 return DialogNotification( | 576 return DialogNotification( |
| 587 DialogNotification::REQUIRED_ACTION, | 577 DialogNotification::REQUIRED_ACTION, |
| 588 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV)); | 578 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV)); |
| 589 } | 579 } |
| 590 | 580 |
| 591 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { | 581 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { |
| 592 return DialogNotification( | 582 return DialogNotification( |
| 593 DialogNotification::SECURITY_WARNING, | 583 DialogNotification::SECURITY_WARNING, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 | 618 |
| 629 Profile* AutofillDialogControllerImpl::profile() { | 619 Profile* AutofillDialogControllerImpl::profile() { |
| 630 return profile_; | 620 return profile_; |
| 631 } | 621 } |
| 632 | 622 |
| 633 content::WebContents* AutofillDialogControllerImpl::web_contents() { | 623 content::WebContents* AutofillDialogControllerImpl::web_contents() { |
| 634 return contents_; | 624 return contents_; |
| 635 } | 625 } |
| 636 | 626 |
| 637 //////////////////////////////////////////////////////////////////////////////// | 627 //////////////////////////////////////////////////////////////////////////////// |
| 638 // AutofillPopupDelegate | 628 // AutofillPopupDelegate implementation. |
| 639 | 629 |
| 640 void AutofillDialogControllerImpl::OnPopupShown( | 630 void AutofillDialogControllerImpl::OnPopupShown( |
| 641 content::KeyboardListener* listener) {} | 631 content::KeyboardListener* listener) {} |
| 642 | 632 |
| 643 void AutofillDialogControllerImpl::OnPopupHidden( | 633 void AutofillDialogControllerImpl::OnPopupHidden( |
| 644 content::KeyboardListener* listener) {} | 634 content::KeyboardListener* listener) {} |
| 645 | 635 |
| 646 void AutofillDialogControllerImpl::DidSelectSuggestion(int identifier) { | 636 void AutofillDialogControllerImpl::DidSelectSuggestion(int identifier) { |
| 647 // TODO(estade): implement. | 637 // TODO(estade): implement. |
| 648 } | 638 } |
| 649 | 639 |
| 650 void AutofillDialogControllerImpl::DidAcceptSuggestion(const string16& value, | 640 void AutofillDialogControllerImpl::DidAcceptSuggestion(const string16& value, |
| 651 int identifier) { | 641 int identifier) { |
| 652 const PersonalDataManager::GUIDPair& pair = popup_guids_[identifier]; | 642 const PersonalDataManager::GUIDPair& pair = popup_guids_[identifier]; |
| 653 | 643 |
| 654 FormGroup* form_group = section_showing_popup_ == SECTION_CC ? | 644 FormGroup* form_group = section_showing_popup_ == SECTION_CC ? |
| 655 static_cast<FormGroup*>(GetManager()->GetCreditCardByGUID(pair.first)) : | 645 static_cast<FormGroup*>(GetManager()->GetCreditCardByGUID(pair.first)) : |
| 656 // TODO(estade): need to use the variant, |pair.second|. | 646 // TODO(estade): need to use the variant, |pair.second|. |
| 657 static_cast<FormGroup*>(GetManager()->GetProfileByGUID(pair.first)); | 647 static_cast<FormGroup*>(GetManager()->GetProfileByGUID(pair.first)); |
| 658 | 648 DCHECK(form_group); |
| 659 // TODO(estade): we shouldn't let this happen. | |
| 660 if (!form_group) | |
| 661 return; | |
| 662 | 649 |
| 663 FillInputFromFormGroup( | 650 FillInputFromFormGroup( |
| 664 form_group, | 651 form_group, |
| 665 MutableRequestedFieldsForSection(section_showing_popup_)); | 652 MutableRequestedFieldsForSection(section_showing_popup_)); |
| 666 view_->UpdateSection(section_showing_popup_); | 653 view_->UpdateSection(section_showing_popup_); |
| 667 | 654 |
| 668 // TODO(estade): not sure why it's necessary to do this explicitly. | 655 // TODO(estade): not sure why it's necessary to do this explicitly. |
| 669 HidePopup(); | 656 HidePopup(); |
| 670 } | 657 } |
| 671 | 658 |
| 672 void AutofillDialogControllerImpl::RemoveSuggestion(const string16& value, | 659 void AutofillDialogControllerImpl::RemoveSuggestion(const string16& value, |
| 673 int identifier) { | 660 int identifier) { |
| 674 // TODO(estade): implement. | 661 // TODO(estade): implement. |
| 675 } | 662 } |
| 676 | 663 |
| 677 void AutofillDialogControllerImpl::ClearPreviewedForm() { | 664 void AutofillDialogControllerImpl::ClearPreviewedForm() { |
| 678 // TODO(estade): implement. | 665 // TODO(estade): implement. |
| 679 } | 666 } |
| 680 | 667 |
| 681 //////////////////////////////////////////////////////////////////////////////// | 668 //////////////////////////////////////////////////////////////////////////////// |
| 682 // content::NotificationObserver | 669 // content::NotificationObserver implementation. |
| 683 | 670 |
| 684 void AutofillDialogControllerImpl::Observe( | 671 void AutofillDialogControllerImpl::Observe( |
| 685 int type, | 672 int type, |
| 686 const content::NotificationSource& source, | 673 const content::NotificationSource& source, |
| 687 const content::NotificationDetails& details) { | 674 const content::NotificationDetails& details) { |
| 688 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); | 675 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); |
| 689 content::LoadCommittedDetails* load_details = | 676 content::LoadCommittedDetails* load_details = |
| 690 content::Details<content::LoadCommittedDetails>(details).ptr(); | 677 content::Details<content::LoadCommittedDetails>(details).ptr(); |
| 691 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) { | 678 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) { |
| 692 EndSignInFlow(); | 679 EndSignInFlow(); |
| 693 if (CanPayWithWallet()) | 680 if (CanPayWithWallet()) |
| 694 ScheduleRefreshWalletItems(); | 681 ScheduleRefreshWalletItems(); |
| 695 } | 682 } |
| 696 } | 683 } |
| 697 | 684 |
| 698 //////////////////////////////////////////////////////////////////////////////// | 685 //////////////////////////////////////////////////////////////////////////////// |
| 699 // SuggestionsMenuModelDelegate | 686 // SuggestionsMenuModelDelegate implementation. |
| 700 | 687 |
| 701 void AutofillDialogControllerImpl::SuggestionItemSelected( | 688 void AutofillDialogControllerImpl::SuggestionItemSelected( |
| 702 const SuggestionsMenuModel& model) { | 689 const SuggestionsMenuModel& model) { |
| 703 DialogSection section = SectionForSuggestionsMenuModel(model); | 690 DialogSection section = SectionForSuggestionsMenuModel(model); |
| 704 section_editing_state_[section] = false; | 691 section_editing_state_[section] = false; |
| 705 view_->UpdateSection(section); | 692 view_->UpdateSection(section); |
| 706 } | 693 } |
| 707 | 694 |
| 708 //////////////////////////////////////////////////////////////////////////////// | 695 //////////////////////////////////////////////////////////////////////////////// |
| 709 // wallet::WalletClientObserver | 696 // wallet::WalletClientObserver implementation. |
| 710 | 697 |
| 711 void AutofillDialogControllerImpl::OnDidAcceptLegalDocuments() { | 698 void AutofillDialogControllerImpl::OnDidAcceptLegalDocuments() { |
| 712 NOTIMPLEMENTED(); | 699 NOTIMPLEMENTED(); |
| 713 } | 700 } |
| 714 | 701 |
| 715 void AutofillDialogControllerImpl::OnDidEncryptOtp( | 702 void AutofillDialogControllerImpl::OnDidEncryptOtp( |
| 716 const std::string& encrypted_otp, const std::string& session_material) { | 703 const std::string& encrypted_otp, const std::string& session_material) { |
| 717 NOTIMPLEMENTED() << " encrypted_otp=" << encrypted_otp | 704 NOTIMPLEMENTED() << " encrypted_otp=" << encrypted_otp |
| 718 << ", session_material=" << session_material; | 705 << ", session_material=" << session_material; |
| 719 } | 706 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 | 763 |
| 777 void AutofillDialogControllerImpl::OnMalformedResponse() { | 764 void AutofillDialogControllerImpl::OnMalformedResponse() { |
| 778 WalletRequestCompleted(false); | 765 WalletRequestCompleted(false); |
| 779 } | 766 } |
| 780 | 767 |
| 781 void AutofillDialogControllerImpl::OnNetworkError(int response_code) { | 768 void AutofillDialogControllerImpl::OnNetworkError(int response_code) { |
| 782 WalletRequestCompleted(false); | 769 WalletRequestCompleted(false); |
| 783 } | 770 } |
| 784 | 771 |
| 785 //////////////////////////////////////////////////////////////////////////////// | 772 //////////////////////////////////////////////////////////////////////////////// |
| 773 // PersonalDataManagerObserver implementation. |
| 774 |
| 775 void AutofillDialogControllerImpl::OnPersonalDataChanged() { |
| 776 HidePopup(); |
| 777 GenerateSuggestionsModels(); |
| 778 view_->ModelChanged(); |
| 779 } |
| 780 |
| 781 //////////////////////////////////////////////////////////////////////////////// |
| 786 | 782 |
| 787 bool AutofillDialogControllerImpl::HandleKeyPressEventInInput( | 783 bool AutofillDialogControllerImpl::HandleKeyPressEventInInput( |
| 788 const content::NativeWebKeyboardEvent& event) { | 784 const content::NativeWebKeyboardEvent& event) { |
| 789 if (popup_controller_) | 785 if (popup_controller_) |
| 790 return popup_controller_->HandleKeyPressEvent(event); | 786 return popup_controller_->HandleKeyPressEvent(event); |
| 791 | 787 |
| 792 return false; | 788 return false; |
| 793 } | 789 } |
| 794 | 790 |
| 795 bool AutofillDialogControllerImpl::RequestingCreditCardInfo() const { | 791 bool AutofillDialogControllerImpl::RequestingCreditCardInfo() const { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 view_->UpdateAccountChooser(); | 836 view_->UpdateAccountChooser(); |
| 841 view_->UpdateNotificationArea(); | 837 view_->UpdateNotificationArea(); |
| 842 return; | 838 return; |
| 843 } | 839 } |
| 844 | 840 |
| 845 if (refresh_wallet_items_queued_) | 841 if (refresh_wallet_items_queued_) |
| 846 ScheduleRefreshWalletItems(); | 842 ScheduleRefreshWalletItems(); |
| 847 } | 843 } |
| 848 | 844 |
| 849 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { | 845 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { |
| 846 suggested_cc_.Reset(); |
| 847 suggested_billing_.Reset(); |
| 848 suggested_email_.Reset(); |
| 849 suggested_shipping_.Reset(); |
| 850 |
| 850 PersonalDataManager* manager = GetManager(); | 851 PersonalDataManager* manager = GetManager(); |
| 851 const std::vector<CreditCard*>& cards = manager->credit_cards(); | 852 const std::vector<CreditCard*>& cards = manager->credit_cards(); |
| 852 for (size_t i = 0; i < cards.size(); ++i) { | 853 for (size_t i = 0; i < cards.size(); ++i) { |
| 853 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label()); | 854 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label()); |
| 854 } | 855 } |
| 855 // TODO(estade): real strings and i18n. | 856 // TODO(estade): real strings and i18n. |
| 856 suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card")); | 857 suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card")); |
| 857 | 858 |
| 858 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); | 859 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); |
| 859 const std::string app_locale = AutofillCountry::ApplicationLocale(); | 860 const std::string app_locale = AutofillCountry::ApplicationLocale(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( | 898 void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( |
| 898 DialogSection section, | 899 DialogSection section, |
| 899 const InputFieldComparator& compare) { | 900 const InputFieldComparator& compare) { |
| 900 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); | 901 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); |
| 901 std::string guid = model->GetItemKeyAt(model->checked_item()); | 902 std::string guid = model->GetItemKeyAt(model->checked_item()); |
| 902 PersonalDataManager* manager = GetManager(); | 903 PersonalDataManager* manager = GetManager(); |
| 903 if (!guid.empty() && !section_editing_state_[section]) { | 904 if (!guid.empty() && !section_editing_state_[section]) { |
| 904 FormGroup* form_group = section == SECTION_CC ? | 905 FormGroup* form_group = section == SECTION_CC ? |
| 905 static_cast<FormGroup*>(manager->GetCreditCardByGUID(guid)) : | 906 static_cast<FormGroup*>(manager->GetCreditCardByGUID(guid)) : |
| 906 static_cast<FormGroup*>(manager->GetProfileByGUID(guid)); | 907 static_cast<FormGroup*>(manager->GetProfileByGUID(guid)); |
| 907 // TODO(estade): we shouldn't let this happen. | 908 DCHECK(form_group); |
| 908 if (!form_group) | |
| 909 return; | |
| 910 | 909 |
| 911 // Calculate the variant by looking at how many items come from the same | 910 // Calculate the variant by looking at how many items come from the same |
| 912 // FormGroup. TODO(estade): add a test for this. | 911 // FormGroup. TODO(estade): add a test for this. |
| 913 size_t variant = 0; | 912 size_t variant = 0; |
| 914 for (int i = model->checked_item() - 1; i >= 0; --i) { | 913 for (int i = model->checked_item() - 1; i >= 0; --i) { |
| 915 if (model->GetItemKeyAt(i) == guid) | 914 if (model->GetItemKeyAt(i) == guid) |
| 916 variant++; | 915 variant++; |
| 917 else | 916 else |
| 918 break; | 917 break; |
| 919 } | 918 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 DialogSection section) { | 1030 DialogSection section) { |
| 1032 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); | 1031 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); |
| 1033 } | 1032 } |
| 1034 | 1033 |
| 1035 void AutofillDialogControllerImpl::HidePopup() { | 1034 void AutofillDialogControllerImpl::HidePopup() { |
| 1036 if (popup_controller_) | 1035 if (popup_controller_) |
| 1037 popup_controller_->Hide(); | 1036 popup_controller_->Hide(); |
| 1038 } | 1037 } |
| 1039 | 1038 |
| 1040 } // namespace autofill | 1039 } // namespace autofill |
| OLD | NEW |