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 | |
286 string16 AutofillDialogControllerImpl::SaveLocallyText() const { | 273 string16 AutofillDialogControllerImpl::SaveLocallyText() const { |
287 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); | 274 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); |
288 } | 275 } |
289 | 276 |
290 string16 AutofillDialogControllerImpl::ProgressBarText() const { | 277 string16 AutofillDialogControllerImpl::ProgressBarText() const { |
291 return l10n_util::GetStringUTF16( | 278 return l10n_util::GetStringUTF16( |
292 IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_PROGRESS_BAR); | 279 IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_PROGRESS_BAR); |
293 } | 280 } |
294 | 281 |
295 const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( | 282 const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 } | 515 } |
529 | 516 |
530 delete this; | 517 delete this; |
531 } | 518 } |
532 | 519 |
533 void AutofillDialogControllerImpl::UpdateProgressBar(double value) { | 520 void AutofillDialogControllerImpl::UpdateProgressBar(double value) { |
534 view_->UpdateProgressBar(value); | 521 view_->UpdateProgressBar(value); |
535 } | 522 } |
536 | 523 |
537 DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { | 524 DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { |
538 if (HasRequiredAction(wallet::VERIFY_CVV)) { | 525 if (wallet_items_ && !wallet_items_->required_actions().empty()) { |
539 return DialogNotification( | 526 switch (wallet_items_->required_actions()[0]) { |
540 DialogNotification::REQUIRED_ACTION, | 527 case wallet::UNKNOWN_TYPE: |
541 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV)); | 528 NOTREACHED(); |
| 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 } |
542 } | 556 } |
543 | 557 |
544 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { | 558 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { |
545 return DialogNotification( | 559 return DialogNotification( |
546 DialogNotification::SECURITY_WARNING, | 560 DialogNotification::SECURITY_WARNING, |
547 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING)); | 561 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING)); |
548 } | 562 } |
549 | 563 |
550 if (!invoked_from_same_origin_) { | 564 if (!invoked_from_same_origin_) { |
551 return DialogNotification( | 565 return DialogNotification( |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 //////////////////////////////////////////////////////////////////////////////// | 638 //////////////////////////////////////////////////////////////////////////////// |
625 // content::NotificationObserver | 639 // content::NotificationObserver |
626 | 640 |
627 void AutofillDialogControllerImpl::Observe( | 641 void AutofillDialogControllerImpl::Observe( |
628 int type, | 642 int type, |
629 const content::NotificationSource& source, | 643 const content::NotificationSource& source, |
630 const content::NotificationDetails& details) { | 644 const content::NotificationDetails& details) { |
631 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); | 645 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); |
632 content::LoadCommittedDetails* load_details = | 646 content::LoadCommittedDetails* load_details = |
633 content::Details<content::LoadCommittedDetails>(details).ptr(); | 647 content::Details<content::LoadCommittedDetails>(details).ptr(); |
634 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) { | 648 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) |
635 EndSignInFlow(); | 649 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 } | |
641 } | 650 } |
642 | 651 |
643 //////////////////////////////////////////////////////////////////////////////// | 652 //////////////////////////////////////////////////////////////////////////////// |
644 // SuggestionsMenuModelDelegate | 653 // SuggestionsMenuModelDelegate |
645 | 654 |
646 void AutofillDialogControllerImpl::SuggestionItemSelected( | 655 void AutofillDialogControllerImpl::SuggestionItemSelected( |
647 const SuggestionsMenuModel& model) { | 656 const SuggestionsMenuModel& model) { |
648 DialogSection section = SectionForSuggestionsMenuModel(model); | 657 DialogSection section = SectionForSuggestionsMenuModel(model); |
649 section_editing_state_[section] = false; | 658 section_editing_state_[section] = false; |
650 view_->UpdateSection(section); | 659 view_->UpdateSection(section); |
(...skipping 18 matching lines...) Expand all Loading... |
669 } | 678 } |
670 | 679 |
671 void AutofillDialogControllerImpl::OnDidGetFullWallet( | 680 void AutofillDialogControllerImpl::OnDidGetFullWallet( |
672 scoped_ptr<wallet::FullWallet> full_wallet) { | 681 scoped_ptr<wallet::FullWallet> full_wallet) { |
673 NOTIMPLEMENTED(); | 682 NOTIMPLEMENTED(); |
674 } | 683 } |
675 | 684 |
676 void AutofillDialogControllerImpl::OnDidGetWalletItems( | 685 void AutofillDialogControllerImpl::OnDidGetWalletItems( |
677 scoped_ptr<wallet::WalletItems> wallet_items) { | 686 scoped_ptr<wallet::WalletItems> wallet_items) { |
678 wallet_items_ = wallet_items.Pass(); | 687 wallet_items_ = wallet_items.Pass(); |
679 view_->UpdateAccountChooser(); | |
680 view_->UpdateNotificationArea(); | 688 view_->UpdateNotificationArea(); |
681 } | 689 } |
682 | 690 |
683 void AutofillDialogControllerImpl::OnDidSaveAddress( | 691 void AutofillDialogControllerImpl::OnDidSaveAddress( |
684 const std::string& address_id) { | 692 const std::string& address_id) { |
685 NOTIMPLEMENTED() << " address_id=" << address_id; | 693 NOTIMPLEMENTED() << " address_id=" << address_id; |
686 } | 694 } |
687 | 695 |
688 void AutofillDialogControllerImpl::OnDidSaveInstrument( | 696 void AutofillDialogControllerImpl::OnDidSaveInstrument( |
689 const std::string& instrument_id) { | 697 const std::string& instrument_id) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 | 745 |
738 return false; | 746 return false; |
739 } | 747 } |
740 | 748 |
741 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const { | 749 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const { |
742 return source_url_.SchemeIs(chrome::kHttpsScheme) && | 750 return source_url_.SchemeIs(chrome::kHttpsScheme) && |
743 !net::IsCertStatusError(ssl_status_.cert_status) && | 751 !net::IsCertStatusError(ssl_status_.cert_status) && |
744 !net::IsCertStatusMinorError(ssl_status_.cert_status); | 752 !net::IsCertStatusMinorError(ssl_status_.cert_status); |
745 } | 753 } |
746 | 754 |
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 | |
757 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { | 755 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { |
758 PersonalDataManager* manager = GetManager(); | 756 PersonalDataManager* manager = GetManager(); |
759 const std::vector<CreditCard*>& cards = manager->credit_cards(); | 757 const std::vector<CreditCard*>& cards = manager->credit_cards(); |
760 for (size_t i = 0; i < cards.size(); ++i) { | 758 for (size_t i = 0; i < cards.size(); ++i) { |
761 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label()); | 759 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label()); |
762 } | 760 } |
763 // TODO(estade): real strings and i18n. | 761 // TODO(estade): real strings and i18n. |
764 suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card")); | 762 suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card")); |
765 | 763 |
766 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); | 764 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 } | 931 } |
934 | 932 |
935 void AutofillDialogControllerImpl::HidePopup() { | 933 void AutofillDialogControllerImpl::HidePopup() { |
936 if (popup_controller_) { | 934 if (popup_controller_) { |
937 popup_controller_->Hide(); | 935 popup_controller_->Hide(); |
938 ControllerDestroyed(); | 936 ControllerDestroyed(); |
939 } | 937 } |
940 } | 938 } |
941 | 939 |
942 } // namespace autofill | 940 } // namespace autofill |
OLD | NEW |