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 bool AutofillDialogControllerImpl::IsSignedIn() const { | |
274 return !HasRequiredAction(wallet::GAIA_AUTH) && | |
275 !HasRequiredAction(wallet::PASSIVE_GAIA_AUTH); | |
276 } | |
277 | |
278 bool AutofillDialogControllerImpl::HasReceivedWalletResponse() const { | |
279 return wallet_items_.get() != NULL; | |
280 } | |
281 | |
273 string16 AutofillDialogControllerImpl::SaveLocallyText() const { | 282 string16 AutofillDialogControllerImpl::SaveLocallyText() const { |
274 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); | 283 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); |
275 } | 284 } |
276 | 285 |
277 const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( | 286 const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( |
278 DialogSection section) const { | 287 DialogSection section) const { |
279 switch (section) { | 288 switch (section) { |
280 case SECTION_EMAIL: | 289 case SECTION_EMAIL: |
281 return requested_email_fields_; | 290 return requested_email_fields_; |
282 case SECTION_CC: | 291 case SECTION_CC: |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
506 } | 515 } |
507 callback_.Run(&form_structure_); | 516 callback_.Run(&form_structure_); |
508 } else { | 517 } else { |
509 callback_.Run(NULL); | 518 callback_.Run(NULL); |
510 } | 519 } |
511 | 520 |
512 delete this; | 521 delete this; |
513 } | 522 } |
514 | 523 |
515 DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { | 524 DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { |
516 if (wallet_items_ && !wallet_items_->required_actions().empty()) { | 525 if (HasRequiredAction(wallet::VERIFY_CVV)) { |
517 switch (wallet_items_->required_actions()[0]) { | 526 // TODO(dbeam): da real i18nz. |
518 case wallet::UNKNOWN_TYPE: | 527 return DialogNotification(DialogNotification::REQUIRED_ACTION, |
519 NOTREACHED(); | 528 ASCIIToUTF16("Verify da CVVz")); |
520 break; | |
521 // TODO(dbeam): da real i18nz. | |
522 case wallet::SETUP_WALLET: | |
523 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
524 ASCIIToUTF16("Set up da walletz")); | |
525 case wallet::ACCEPT_TOS: | |
526 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
527 ASCIIToUTF16("Accept da ToS")); | |
528 case wallet::GAIA_AUTH: | |
529 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
530 ASCIIToUTF16("Sign in to da Googlez")); | |
531 case wallet::UPDATE_EXPIRATION_DATE: | |
532 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
533 ASCIIToUTF16("Update da expiration datez")); | |
534 case wallet::UPGRADE_MIN_ADDRESS: | |
535 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
536 ASCIIToUTF16("Upgrade da min addrezz")); | |
537 case wallet::INVALID_FORM_FIELD: | |
538 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
539 ASCIIToUTF16("Da form field is invalid")); | |
540 case wallet::VERIFY_CVV: | |
541 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
542 ASCIIToUTF16("Verify da CVVz")); | |
543 case wallet::PASSIVE_GAIA_AUTH: | |
544 return DialogNotification(DialogNotification::REQUIRED_ACTION, | |
545 ASCIIToUTF16("Passively sign in to Googlez")); | |
546 } | |
547 } | 529 } |
548 | 530 |
549 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { | 531 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { |
550 return DialogNotification( | 532 return DialogNotification( |
551 DialogNotification::SECURITY_WARNING, | 533 DialogNotification::SECURITY_WARNING, |
552 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING)); | 534 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING)); |
553 } | 535 } |
554 | 536 |
555 if (!invoked_from_same_origin_) { | 537 if (!invoked_from_same_origin_) { |
556 return DialogNotification( | 538 return DialogNotification( |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
629 //////////////////////////////////////////////////////////////////////////////// | 611 //////////////////////////////////////////////////////////////////////////////// |
630 // content::NotificationObserver | 612 // content::NotificationObserver |
631 | 613 |
632 void AutofillDialogControllerImpl::Observe( | 614 void AutofillDialogControllerImpl::Observe( |
633 int type, | 615 int type, |
634 const content::NotificationSource& source, | 616 const content::NotificationSource& source, |
635 const content::NotificationDetails& details) { | 617 const content::NotificationDetails& details) { |
636 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); | 618 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); |
637 content::LoadCommittedDetails* load_details = | 619 content::LoadCommittedDetails* load_details = |
638 content::Details<content::LoadCommittedDetails>(details).ptr(); | 620 content::Details<content::LoadCommittedDetails>(details).ptr(); |
639 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) | 621 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) { |
640 EndSignInFlow(); | 622 EndSignInFlow(); |
623 // TODO(dbeam): the fetcher can't handle being called multiple times. | |
624 // Address this soon as we will be re-fetching wallet items after every | |
625 // required action is resolved. | |
626 wallet_client_.GetWalletItems(this); | |
627 } | |
641 } | 628 } |
642 | 629 |
643 //////////////////////////////////////////////////////////////////////////////// | 630 //////////////////////////////////////////////////////////////////////////////// |
644 // SuggestionsMenuModelDelegate | 631 // SuggestionsMenuModelDelegate |
645 | 632 |
646 void AutofillDialogControllerImpl::SuggestionItemSelected( | 633 void AutofillDialogControllerImpl::SuggestionItemSelected( |
647 const SuggestionsMenuModel& model) { | 634 const SuggestionsMenuModel& model) { |
648 DialogSection section = SectionForSuggestionsMenuModel(model); | 635 DialogSection section = SectionForSuggestionsMenuModel(model); |
649 section_editing_state_[section] = false; | 636 section_editing_state_[section] = false; |
650 view_->UpdateSection(section); | 637 view_->UpdateSection(section); |
(...skipping 18 matching lines...) Expand all Loading... | |
669 } | 656 } |
670 | 657 |
671 void AutofillDialogControllerImpl::OnDidGetFullWallet( | 658 void AutofillDialogControllerImpl::OnDidGetFullWallet( |
672 scoped_ptr<wallet::FullWallet> full_wallet) { | 659 scoped_ptr<wallet::FullWallet> full_wallet) { |
673 NOTIMPLEMENTED(); | 660 NOTIMPLEMENTED(); |
674 } | 661 } |
675 | 662 |
676 void AutofillDialogControllerImpl::OnDidGetWalletItems( | 663 void AutofillDialogControllerImpl::OnDidGetWalletItems( |
677 scoped_ptr<wallet::WalletItems> wallet_items) { | 664 scoped_ptr<wallet::WalletItems> wallet_items) { |
678 wallet_items_ = wallet_items.Pass(); | 665 wallet_items_ = wallet_items.Pass(); |
666 view_->UpdateAccountChooser(); | |
679 view_->UpdateNotificationArea(); | 667 view_->UpdateNotificationArea(); |
680 } | 668 } |
681 | 669 |
682 void AutofillDialogControllerImpl::OnDidSaveAddress( | 670 void AutofillDialogControllerImpl::OnDidSaveAddress( |
683 const std::string& address_id) { | 671 const std::string& address_id) { |
684 NOTIMPLEMENTED() << " address_id=" << address_id; | 672 NOTIMPLEMENTED() << " address_id=" << address_id; |
685 } | 673 } |
686 | 674 |
687 void AutofillDialogControllerImpl::OnDidSaveInstrument( | 675 void AutofillDialogControllerImpl::OnDidSaveInstrument( |
688 const std::string& instrument_id) { | 676 const std::string& instrument_id) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 | 724 |
737 return false; | 725 return false; |
738 } | 726 } |
739 | 727 |
740 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const { | 728 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const { |
741 return source_url_.SchemeIs(chrome::kHttpsScheme) && | 729 return source_url_.SchemeIs(chrome::kHttpsScheme) && |
742 !net::IsCertStatusError(ssl_status_.cert_status) && | 730 !net::IsCertStatusError(ssl_status_.cert_status) && |
743 !net::IsCertStatusMinorError(ssl_status_.cert_status); | 731 !net::IsCertStatusMinorError(ssl_status_.cert_status); |
744 } | 732 } |
745 | 733 |
734 bool AutofillDialogControllerImpl::HasRequiredAction( | |
735 wallet::RequiredAction action) const { | |
736 if (!wallet_items_) | |
737 return false; | |
738 | |
739 const std::vector<wallet::RequiredAction>& required = | |
Ilya Sherman
2013/01/31 04:35:44
Optional nit: IMO "actions" is a slightly better s
Dan Beam
2013/01/31 21:04:26
Yeah, thought that actions + action was a little u
| |
740 wallet_items_->required_actions(); | |
741 return std::find(required.begin(), required.end(), action) != required.end(); | |
742 } | |
743 | |
746 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { | 744 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { |
747 PersonalDataManager* manager = GetManager(); | 745 PersonalDataManager* manager = GetManager(); |
748 const std::vector<CreditCard*>& cards = manager->credit_cards(); | 746 const std::vector<CreditCard*>& cards = manager->credit_cards(); |
749 for (size_t i = 0; i < cards.size(); ++i) { | 747 for (size_t i = 0; i < cards.size(); ++i) { |
750 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label()); | 748 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label()); |
751 } | 749 } |
752 // TODO(estade): real strings and i18n. | 750 // TODO(estade): real strings and i18n. |
753 suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card")); | 751 suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card")); |
754 | 752 |
755 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); | 753 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
922 } | 920 } |
923 | 921 |
924 void AutofillDialogControllerImpl::HidePopup() { | 922 void AutofillDialogControllerImpl::HidePopup() { |
925 if (popup_controller_) { | 923 if (popup_controller_) { |
926 popup_controller_->Hide(); | 924 popup_controller_->Hide(); |
927 ControllerDestroyed(); | 925 ControllerDestroyed(); |
928 } | 926 } |
929 } | 927 } |
930 | 928 |
931 } // namespace autofill | 929 } // namespace autofill |
OLD | NEW |