Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(599)

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 12094069: [autofill] Hook the sign-in button up to required actions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: +snark Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 !RequiredActionApplies(wallet::GAIA_AUTH) &&
275 !RequiredActionApplies(wallet::PASSIVE_GAIA_AUTH);
276 }
277
278 bool AutofillDialogControllerImpl::HasReceivedWalletResponse() const {
279 return wallet_items_;
Ilya Sherman 2013/01/31 02:33:07 nit: Implicitly converting to a boolean is general
Dan Beam 2013/01/31 02:48:51 Done.
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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 FillOutputForSection(SECTION_SHIPPING); 514 FillOutputForSection(SECTION_SHIPPING);
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
524 std::vector<wallet::RequiredAction>
525 AutofillDialogControllerImpl::RequiredActions() const {
526 return wallet_items_ ? wallet_items_->required_actions() :
527 std::vector<wallet::RequiredAction>();
528 }
529
515 DialogNotification AutofillDialogControllerImpl::CurrentNotification() const { 530 DialogNotification AutofillDialogControllerImpl::CurrentNotification() const {
516 if (wallet_items_ && !wallet_items_->required_actions().empty()) { 531 if (RequiredActionApplies(wallet::VERIFY_CVV)) {
517 switch (wallet_items_->required_actions()[0]) { 532 // TODO(dbeam): da real i18nz.
518 case wallet::UNKNOWN_TYPE: 533 return DialogNotification(DialogNotification::REQUIRED_ACTION,
519 NOTREACHED(); 534 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 } 535 }
548 536
549 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { 537 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) {
550 return DialogNotification( 538 return DialogNotification(
551 DialogNotification::SECURITY_WARNING, 539 DialogNotification::SECURITY_WARNING,
552 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING)); 540 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING));
553 } 541 }
554 542
555 if (!invoked_from_same_origin_) { 543 if (!invoked_from_same_origin_) {
556 return DialogNotification( 544 return DialogNotification(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 //////////////////////////////////////////////////////////////////////////////// 617 ////////////////////////////////////////////////////////////////////////////////
630 // content::NotificationObserver 618 // content::NotificationObserver
631 619
632 void AutofillDialogControllerImpl::Observe( 620 void AutofillDialogControllerImpl::Observe(
633 int type, 621 int type,
634 const content::NotificationSource& source, 622 const content::NotificationSource& source,
635 const content::NotificationDetails& details) { 623 const content::NotificationDetails& details) {
636 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); 624 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED);
637 content::LoadCommittedDetails* load_details = 625 content::LoadCommittedDetails* load_details =
638 content::Details<content::LoadCommittedDetails>(details).ptr(); 626 content::Details<content::LoadCommittedDetails>(details).ptr();
639 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) 627 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) {
640 EndSignInFlow(); 628 EndSignInFlow();
629 // TODO(dbeam): the fetcher can't handle being called multiple times.
630 // Address this soon as we will be re-fetching wallet items after every
631 // required action is resolved.
632 wallet_client_.GetWalletItems(this);
633 }
641 } 634 }
642 635
643 //////////////////////////////////////////////////////////////////////////////// 636 ////////////////////////////////////////////////////////////////////////////////
644 // SuggestionsMenuModelDelegate 637 // SuggestionsMenuModelDelegate
645 638
646 void AutofillDialogControllerImpl::SuggestionItemSelected( 639 void AutofillDialogControllerImpl::SuggestionItemSelected(
647 const SuggestionsMenuModel& model) { 640 const SuggestionsMenuModel& model) {
648 DialogSection section = SectionForSuggestionsMenuModel(model); 641 DialogSection section = SectionForSuggestionsMenuModel(model);
649 section_editing_state_[section] = false; 642 section_editing_state_[section] = false;
650 view_->UpdateSection(section); 643 view_->UpdateSection(section);
(...skipping 18 matching lines...) Expand all
669 } 662 }
670 663
671 void AutofillDialogControllerImpl::OnDidGetFullWallet( 664 void AutofillDialogControllerImpl::OnDidGetFullWallet(
672 scoped_ptr<wallet::FullWallet> full_wallet) { 665 scoped_ptr<wallet::FullWallet> full_wallet) {
673 NOTIMPLEMENTED(); 666 NOTIMPLEMENTED();
674 } 667 }
675 668
676 void AutofillDialogControllerImpl::OnDidGetWalletItems( 669 void AutofillDialogControllerImpl::OnDidGetWalletItems(
677 scoped_ptr<wallet::WalletItems> wallet_items) { 670 scoped_ptr<wallet::WalletItems> wallet_items) {
678 wallet_items_ = wallet_items.Pass(); 671 wallet_items_ = wallet_items.Pass();
672 view_->UpdateAccountChooser();
679 view_->UpdateNotificationArea(); 673 view_->UpdateNotificationArea();
680 } 674 }
681 675
682 void AutofillDialogControllerImpl::OnDidSaveAddress( 676 void AutofillDialogControllerImpl::OnDidSaveAddress(
683 const std::string& address_id) { 677 const std::string& address_id) {
684 NOTIMPLEMENTED() << " address_id=" << address_id; 678 NOTIMPLEMENTED() << " address_id=" << address_id;
685 } 679 }
686 680
687 void AutofillDialogControllerImpl::OnDidSaveInstrument( 681 void AutofillDialogControllerImpl::OnDidSaveInstrument(
688 const std::string& instrument_id) { 682 const std::string& instrument_id) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 730
737 return false; 731 return false;
738 } 732 }
739 733
740 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const { 734 bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const {
741 return source_url_.SchemeIs(chrome::kHttpsScheme) && 735 return source_url_.SchemeIs(chrome::kHttpsScheme) &&
742 !net::IsCertStatusError(ssl_status_.cert_status) && 736 !net::IsCertStatusError(ssl_status_.cert_status) &&
743 !net::IsCertStatusMinorError(ssl_status_.cert_status); 737 !net::IsCertStatusMinorError(ssl_status_.cert_status);
744 } 738 }
745 739
740 bool AutofillDialogControllerImpl::RequiredActionApplies(
741 wallet::RequiredAction action) const {
742 const std::vector<wallet::RequiredAction>& required = RequiredActions();
743 return std::find(required.begin(), required.end(), action) != required.end();
744 }
745
746 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { 746 void AutofillDialogControllerImpl::GenerateSuggestionsModels() {
747 PersonalDataManager* manager = GetManager(); 747 PersonalDataManager* manager = GetManager();
748 const std::vector<CreditCard*>& cards = manager->credit_cards(); 748 const std::vector<CreditCard*>& cards = manager->credit_cards();
749 for (size_t i = 0; i < cards.size(); ++i) { 749 for (size_t i = 0; i < cards.size(); ++i) {
750 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label()); 750 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label());
751 } 751 }
752 // TODO(estade): real strings and i18n. 752 // TODO(estade): real strings and i18n.
753 suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card")); 753 suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card"));
754 754
755 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); 755 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles();
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 } 922 }
923 923
924 void AutofillDialogControllerImpl::HidePopup() { 924 void AutofillDialogControllerImpl::HidePopup() {
925 if (popup_controller_) { 925 if (popup_controller_) {
926 popup_controller_->Hide(); 926 popup_controller_->Hide();
927 ControllerDestroyed(); 927 ControllerDestroyed();
928 } 928 }
929 } 929 }
930 930
931 } // namespace autofill 931 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698