| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 string16 AutofillDialogControllerImpl::SignInText() const { | 263 string16 AutofillDialogControllerImpl::SignInText() const { |
| 264 // TODO(abodenha): real strings and l10n. | 264 // TODO(abodenha): real strings and l10n. |
| 265 return string16(ASCIIToUTF16("Sign in to use Google Wallet")); | 265 return string16(ASCIIToUTF16("Sign in to use Google Wallet")); |
| 266 } | 266 } |
| 267 | 267 |
| 268 string16 AutofillDialogControllerImpl::CancelSignInText() const { | 268 string16 AutofillDialogControllerImpl::CancelSignInText() const { |
| 269 // TODO(abodenha): real strings and l10n. | 269 // TODO(abodenha): real strings and l10n. |
| 270 return string16(ASCIIToUTF16("Don't sign in.")); | 270 return string16(ASCIIToUTF16("Don't sign in.")); |
| 271 } | 271 } |
| 272 | 272 |
| 273 DialogSignedInState AutofillDialogControllerImpl::SignedInState() const { |
| 274 if (!wallet_items_) |
| 275 return REQUIRES_RESPONSE; |
| 276 |
| 277 if (HasRequiredAction(wallet::GAIA_AUTH)) |
| 278 return REQUIRES_SIGN_IN; |
| 279 |
| 280 if (HasRequiredAction(wallet::PASSIVE_GAIA_AUTH)) |
| 281 return REQUIRES_PASSIVE_SIGN_IN; |
| 282 |
| 283 return SIGNED_IN; |
| 284 } |
| 285 |
| 273 string16 AutofillDialogControllerImpl::SaveLocallyText() const { | 286 string16 AutofillDialogControllerImpl::SaveLocallyText() const { |
| 274 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); | 287 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); |
| 275 } | 288 } |
| 276 | 289 |
| 277 string16 AutofillDialogControllerImpl::ProgressBarText() const { | 290 string16 AutofillDialogControllerImpl::ProgressBarText() const { |
| 278 return l10n_util::GetStringUTF16( | 291 return l10n_util::GetStringUTF16( |
| 279 IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_PROGRESS_BAR); | 292 IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_PROGRESS_BAR); |
| 280 } | 293 } |
| 281 | 294 |
| 282 const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( | 295 const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 } | 528 } |
| 516 | 529 |
| 517 delete this; | 530 delete this; |
| 518 } | 531 } |
| 519 | 532 |
| 520 void AutofillDialogControllerImpl::UpdateProgressBar(double value) { | 533 void AutofillDialogControllerImpl::UpdateProgressBar(double value) { |
| 521 view_->UpdateProgressBar(value); | 534 view_->UpdateProgressBar(value); |
| 522 } | 535 } |
| 523 | 536 |
| 524 DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { | 537 DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { |
| 525 if (wallet_items_ && !wallet_items_->required_actions().empty()) { | 538 if (HasRequiredAction(wallet::VERIFY_CVV)) { |
| 526 switch (wallet_items_->required_actions()[0]) { | 539 return DialogNotification( |
| 527 case wallet::UNKNOWN_TYPE: | 540 DialogNotification::REQUIRED_ACTION, |
| 528 NOTREACHED(); | 541 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV)); |
| 529 break; | |
| 530 // TODO(dbeam): da real i18nz. | |
| 531 case wallet::SETUP_WALLET: | |
| 532 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
| 533 ASCIIToUTF16("Set up da walletz")); | |
| 534 case wallet::ACCEPT_TOS: | |
| 535 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
| 536 ASCIIToUTF16("Accept da ToS")); | |
| 537 case wallet::GAIA_AUTH: | |
| 538 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
| 539 ASCIIToUTF16("Sign in to da Googlez")); | |
| 540 case wallet::UPDATE_EXPIRATION_DATE: | |
| 541 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
| 542 ASCIIToUTF16("Update da expiration datez")); | |
| 543 case wallet::UPGRADE_MIN_ADDRESS: | |
| 544 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
| 545 ASCIIToUTF16("Upgrade da min addrezz")); | |
| 546 case wallet::INVALID_FORM_FIELD: | |
| 547 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
| 548 ASCIIToUTF16("Da form field is invalid")); | |
| 549 case wallet::VERIFY_CVV: | |
| 550 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
| 551 ASCIIToUTF16("Verify da CVVz")); | |
| 552 case wallet::PASSIVE_GAIA_AUTH: | |
| 553 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
| 554 ASCIIToUTF16("Passively sign in to Googlez")); | |
| 555 } | |
| 556 } | 542 } |
| 557 | 543 |
| 558 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { | 544 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { |
| 559 return DialogNotification( | 545 return DialogNotification( |
| 560 DialogNotification::SECURITY_WARNING, | 546 DialogNotification::SECURITY_WARNING, |
| 561 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING)); | 547 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING)); |
| 562 } | 548 } |
| 563 | 549 |
| 564 if (!invoked_from_same_origin_) { | 550 if (!invoked_from_same_origin_) { |
| 565 return DialogNotification( | 551 return DialogNotification( |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 //////////////////////////////////////////////////////////////////////////////// | 624 //////////////////////////////////////////////////////////////////////////////// |
| 639 // content::NotificationObserver | 625 // content::NotificationObserver |
| 640 | 626 |
| 641 void AutofillDialogControllerImpl::Observe( | 627 void AutofillDialogControllerImpl::Observe( |
| 642 int type, | 628 int type, |
| 643 const content::NotificationSource& source, | 629 const content::NotificationSource& source, |
| 644 const content::NotificationDetails& details) { | 630 const content::NotificationDetails& details) { |
| 645 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); | 631 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); |
| 646 content::LoadCommittedDetails* load_details = | 632 content::LoadCommittedDetails* load_details = |
| 647 content::Details<content::LoadCommittedDetails>(details).ptr(); | 633 content::Details<content::LoadCommittedDetails>(details).ptr(); |
| 648 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) | 634 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) { |
| 649 EndSignInFlow(); | 635 EndSignInFlow(); |
| 636 // TODO(dbeam): the fetcher can't handle being called multiple times. |
| 637 // Address this soon as we will be re-fetching wallet items after every |
| 638 // required action is resolved. |
| 639 wallet_client_.GetWalletItems(this); |
| 640 } |
| 650 } | 641 } |
| 651 | 642 |
| 652 //////////////////////////////////////////////////////////////////////////////// | 643 //////////////////////////////////////////////////////////////////////////////// |
| 653 // SuggestionsMenuModelDelegate | 644 // SuggestionsMenuModelDelegate |
| 654 | 645 |
| 655 void AutofillDialogControllerImpl::SuggestionItemSelected( | 646 void AutofillDialogControllerImpl::SuggestionItemSelected( |
| 656 const SuggestionsMenuModel& model) { | 647 const SuggestionsMenuModel& model) { |
| 657 DialogSection section = SectionForSuggestionsMenuModel(model); | 648 DialogSection section = SectionForSuggestionsMenuModel(model); |
| 658 section_editing_state_[section] = false; | 649 section_editing_state_[section] = false; |
| 659 view_->UpdateSection(section); | 650 view_->UpdateSection(section); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 678 } | 669 } |
| 679 | 670 |
| 680 void AutofillDialogControllerImpl::OnDidGetFullWallet( | 671 void AutofillDialogControllerImpl::OnDidGetFullWallet( |
| 681 scoped_ptr<wallet::FullWallet> full_wallet) { | 672 scoped_ptr<wallet::FullWallet> full_wallet) { |
| 682 NOTIMPLEMENTED(); | 673 NOTIMPLEMENTED(); |
| 683 } | 674 } |
| 684 | 675 |
| 685 void AutofillDialogControllerImpl::OnDidGetWalletItems( | 676 void AutofillDialogControllerImpl::OnDidGetWalletItems( |
| 686 scoped_ptr<wallet::WalletItems> wallet_items) { | 677 scoped_ptr<wallet::WalletItems> wallet_items) { |
| 687 wallet_items_ = wallet_items.Pass(); | 678 wallet_items_ = wallet_items.Pass(); |
| 679 view_->UpdateAccountChooser(); |
| 688 view_->UpdateNotificationArea(); | 680 view_->UpdateNotificationArea(); |
| 689 } | 681 } |
| 690 | 682 |
| 691 void AutofillDialogControllerImpl::OnDidSaveAddress( | 683 void AutofillDialogControllerImpl::OnDidSaveAddress( |
| 692 const std::string& address_id) { | 684 const std::string& address_id) { |
| 693 NOTIMPLEMENTED() << " address_id=" << address_id; | 685 NOTIMPLEMENTED() << " address_id=" << address_id; |
| 694 } | 686 } |
| 695 | 687 |
| 696 void AutofillDialogControllerImpl::OnDidSaveInstrument( | 688 void AutofillDialogControllerImpl::OnDidSaveInstrument( |
| 697 const std::string& instrument_id) { | 689 const std::string& instrument_id) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 | 737 |
| 746 return false; | 738 return false; |
| 747 } | 739 } |
| 748 | 740 |
| 749 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const { | 741 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const { |
| 750 return source_url_.SchemeIs(chrome::kHttpsScheme) && | 742 return source_url_.SchemeIs(chrome::kHttpsScheme) && |
| 751 !net::IsCertStatusError(ssl_status_.cert_status) && | 743 !net::IsCertStatusError(ssl_status_.cert_status) && |
| 752 !net::IsCertStatusMinorError(ssl_status_.cert_status); | 744 !net::IsCertStatusMinorError(ssl_status_.cert_status); |
| 753 } | 745 } |
| 754 | 746 |
| 747 bool AutofillDialogControllerImpl::HasRequiredAction( |
| 748 wallet::RequiredAction action) const { |
| 749 if (!wallet_items_) |
| 750 return false; |
| 751 |
| 752 const std::vector<wallet::RequiredAction>& actions = |
| 753 wallet_items_->required_actions(); |
| 754 return std::find(actions.begin(), actions.end(), action) != actions.end(); |
| 755 } |
| 756 |
| 755 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { | 757 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { |
| 756 PersonalDataManager* manager = GetManager(); | 758 PersonalDataManager* manager = GetManager(); |
| 757 const std::vector<CreditCard*>& cards = manager->credit_cards(); | 759 const std::vector<CreditCard*>& cards = manager->credit_cards(); |
| 758 for (size_t i = 0; i < cards.size(); ++i) { | 760 for (size_t i = 0; i < cards.size(); ++i) { |
| 759 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label()); | 761 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label()); |
| 760 } | 762 } |
| 761 // TODO(estade): real strings and i18n. | 763 // TODO(estade): real strings and i18n. |
| 762 suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card")); | 764 suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card")); |
| 763 | 765 |
| 764 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); | 766 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 } | 933 } |
| 932 | 934 |
| 933 void AutofillDialogControllerImpl::HidePopup() { | 935 void AutofillDialogControllerImpl::HidePopup() { |
| 934 if (popup_controller_) { | 936 if (popup_controller_) { |
| 935 popup_controller_->Hide(); | 937 popup_controller_->Hide(); |
| 936 ControllerDestroyed(); | 938 ControllerDestroyed(); |
| 937 } | 939 } |
| 938 } | 940 } |
| 939 | 941 |
| 940 } // namespace autofill | 942 } // namespace autofill |
| OLD | NEW |