OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 | 457 |
458 return SIGNED_IN; | 458 return SIGNED_IN; |
459 } | 459 } |
460 | 460 |
461 bool AutofillDialogControllerImpl::ShouldShowSpinner() const { | 461 bool AutofillDialogControllerImpl::ShouldShowSpinner() const { |
462 return account_chooser_model_.WalletIsSelected() && | 462 return account_chooser_model_.WalletIsSelected() && |
463 SignedInState() == REQUIRES_RESPONSE; | 463 SignedInState() == REQUIRES_RESPONSE; |
464 } | 464 } |
465 | 465 |
466 string16 AutofillDialogControllerImpl::AccountChooserText() const { | 466 string16 AutofillDialogControllerImpl::AccountChooserText() const { |
467 // TODO(aruslan): this should be l10n "Not using Google Wallet". | |
467 if (!account_chooser_model_.WalletIsSelected()) | 468 if (!account_chooser_model_.WalletIsSelected()) |
468 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PAY_WITHOUT_WALLET); | 469 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PAY_WITHOUT_WALLET); |
469 | 470 |
470 if (SignedInState() == SIGNED_IN) | 471 if (SignedInState() == SIGNED_IN) |
471 return UTF8ToUTF16(current_username_); | 472 return account_chooser_model_.active_wallet_account_name(); |
472 | 473 |
473 // In this case, the account chooser should be showing the signin link. | 474 // In this case, the account chooser should be showing the signin link. |
474 return string16(); | 475 return string16(); |
475 } | 476 } |
476 | 477 |
477 string16 AutofillDialogControllerImpl::SignInLinkText() const { | 478 string16 AutofillDialogControllerImpl::SignInLinkText() const { |
478 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SIGN_IN); | 479 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SIGN_IN); |
479 } | 480 } |
480 | 481 |
481 bool AutofillDialogControllerImpl::ShouldOfferToSaveInChrome() const { | 482 bool AutofillDialogControllerImpl::ShouldOfferToSaveInChrome() const { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 | 527 |
527 bool AutofillDialogControllerImpl::IsSubmitPausedOn( | 528 bool AutofillDialogControllerImpl::IsSubmitPausedOn( |
528 wallet::RequiredAction required_action) const { | 529 wallet::RequiredAction required_action) const { |
529 return full_wallet_ && full_wallet_->HasRequiredAction(required_action); | 530 return full_wallet_ && full_wallet_->HasRequiredAction(required_action); |
530 } | 531 } |
531 | 532 |
532 void AutofillDialogControllerImpl::GetWalletItems() { | 533 void AutofillDialogControllerImpl::GetWalletItems() { |
533 GetWalletClient()->GetWalletItems(source_url_); | 534 GetWalletClient()->GetWalletItems(source_url_); |
534 } | 535 } |
535 | 536 |
536 void AutofillDialogControllerImpl::OnWalletOrSigninUpdate() { | 537 void AutofillDialogControllerImpl::SignedInStateUpdated() { |
538 if (!account_chooser_model_.WalletIsSelected()) | |
539 return; | |
540 | |
537 switch (SignedInState()) { | 541 switch (SignedInState()) { |
538 case SIGNED_IN: | 542 case SIGNED_IN: |
539 // Start fetching the user name if we don't know it yet. | 543 // Start fetching the user name if we don't know it yet. |
540 if (current_username_.empty()) { | 544 if (account_chooser_model_.active_wallet_account_name().empty()) { |
541 signin_helper_.reset(new wallet::WalletSigninHelper( | 545 signin_helper_.reset(new wallet::WalletSigninHelper( |
542 this, profile_->GetRequestContext())); | 546 this, profile_->GetRequestContext())); |
543 signin_helper_->StartUserNameFetch(); | 547 signin_helper_->StartUserNameFetch(); |
544 } | 548 } |
545 break; | 549 break; |
546 | 550 |
547 case REQUIRES_SIGN_IN: | 551 case REQUIRES_SIGN_IN: |
548 // TODO(aruslan): automatic sign-in? | 552 // Switch to the local account and refresh the dialog. |
553 OnWalletSigninError(); | |
549 break; | 554 break; |
550 | 555 |
551 case REQUIRES_PASSIVE_SIGN_IN: | 556 case REQUIRES_PASSIVE_SIGN_IN: |
552 // Attempt to passively sign in the user. | 557 // Attempt to passively sign in the user. |
553 current_username_.clear(); | 558 DCHECK(!signin_helper_); |
559 account_chooser_model_.ClearActiveWalletAccountName(); | |
554 signin_helper_.reset(new wallet::WalletSigninHelper( | 560 signin_helper_.reset(new wallet::WalletSigninHelper( |
555 this, profile_->GetRequestContext())); | 561 this, |
562 profile_->GetRequestContext())); | |
556 signin_helper_->StartPassiveSignin(); | 563 signin_helper_->StartPassiveSignin(); |
557 break; | 564 break; |
558 | 565 |
559 case REQUIRES_RESPONSE: | 566 case REQUIRES_RESPONSE: |
560 break; | 567 break; |
561 } | 568 } |
569 } | |
562 | 570 |
571 void AutofillDialogControllerImpl::OnWalletOrSigninUpdate() { | |
572 SignedInStateUpdated(); | |
563 SuggestionsUpdated(); | 573 SuggestionsUpdated(); |
564 view_->UpdateAccountChooser(); | 574 UpdateAccountChooserView(); |
565 view_->UpdateNotificationArea(); | |
566 | 575 |
567 // On the first successful response, compute the initial user state metric. | 576 // On the first successful response, compute the initial user state metric. |
568 if (initial_user_state_ == AutofillMetrics::DIALOG_USER_STATE_UNKNOWN) | 577 if (initial_user_state_ == AutofillMetrics::DIALOG_USER_STATE_UNKNOWN) |
569 initial_user_state_ = GetInitialUserState(); | 578 initial_user_state_ = GetInitialUserState(); |
570 } | 579 } |
571 | 580 |
572 void AutofillDialogControllerImpl::OnWalletSigninError() { | 581 void AutofillDialogControllerImpl::OnWalletSigninError() { |
573 signin_helper_.reset(); | 582 signin_helper_.reset(); |
574 current_username_.clear(); | |
575 account_chooser_model_.SetHadWalletSigninError(); | 583 account_chooser_model_.SetHadWalletSigninError(); |
576 GetWalletClient()->CancelRequests(); | 584 GetWalletClient()->CancelRequests(); |
577 } | 585 } |
578 | 586 |
579 void AutofillDialogControllerImpl::EnsureLegalDocumentsText() { | 587 void AutofillDialogControllerImpl::EnsureLegalDocumentsText() { |
580 if (!wallet_items_ || wallet_items_->legal_documents().empty()) | 588 if (!wallet_items_ || wallet_items_->legal_documents().empty()) |
581 return; | 589 return; |
582 | 590 |
583 // The text has already been constructed, no need to recompute. | 591 // The text has already been constructed, no need to recompute. |
584 if (!legal_documents_text_.empty()) | 592 if (!legal_documents_text_.empty()) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 return NULL; | 668 return NULL; |
661 } | 669 } |
662 } | 670 } |
663 | 671 |
664 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForSection( | 672 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForSection( |
665 DialogSection section) { | 673 DialogSection section) { |
666 return SuggestionsMenuModelForSection(section); | 674 return SuggestionsMenuModelForSection(section); |
667 } | 675 } |
668 | 676 |
669 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForAccountChooser() { | 677 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForAccountChooser() { |
670 // When paying with wallet, but not signed in, there is no menu, just a | 678 // If there were unrecoverable Wallet errors, or if there are choices other |
671 // sign in link. | 679 // than "Pay without the wallet", show the full menu. |
672 if (account_chooser_model_.WalletIsSelected() && SignedInState() != SIGNED_IN) | 680 if (account_chooser_model_.had_wallet_error() || |
673 return NULL; | 681 account_chooser_model_.HasAccountsToChoose()) |
Evan Stade
2013/04/12 17:06:36
curlies
aruslan
2013/04/12 20:43:30
Done.
| |
682 return &account_chooser_model_; | |
674 | 683 |
675 return &account_chooser_model_; | 684 // Otherwise, there is no menu, just a sign in link. |
685 return NULL; | |
676 } | 686 } |
677 | 687 |
678 gfx::Image AutofillDialogControllerImpl::AccountChooserImage() { | 688 gfx::Image AutofillDialogControllerImpl::AccountChooserImage() { |
679 if (!MenuModelForAccountChooser()) { | 689 if (!MenuModelForAccountChooser()) { |
680 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 690 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
681 IDR_WALLET_ICON); | 691 IDR_WALLET_ICON); |
682 } | 692 } |
683 | 693 |
684 gfx::Image icon; | 694 gfx::Image icon; |
685 account_chooser_model_.GetIconAt(account_chooser_model_.checked_item(), | 695 account_chooser_model_.GetIconAt( |
686 &icon); | 696 account_chooser_model_.GetIndexOfCommandId( |
697 account_chooser_model_.checked_item()), | |
698 &icon); | |
687 return icon; | 699 return icon; |
688 } | 700 } |
689 | 701 |
690 string16 AutofillDialogControllerImpl::LabelForSection(DialogSection section) | 702 string16 AutofillDialogControllerImpl::LabelForSection(DialogSection section) |
691 const { | 703 const { |
692 switch (section) { | 704 switch (section) { |
693 case SECTION_EMAIL: | 705 case SECTION_EMAIL: |
694 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_EMAIL); | 706 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_EMAIL); |
695 case SECTION_CC: | 707 case SECTION_CC: |
696 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_CC); | 708 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_CC); |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1154 if (had_autocheckout_error_) { | 1166 if (had_autocheckout_error_) { |
1155 notifications.push_back(DialogNotification( | 1167 notifications.push_back(DialogNotification( |
1156 DialogNotification::AUTOCHECKOUT_ERROR, | 1168 DialogNotification::AUTOCHECKOUT_ERROR, |
1157 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_ERROR))); | 1169 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_ERROR))); |
1158 } | 1170 } |
1159 | 1171 |
1160 return notifications; | 1172 return notifications; |
1161 } | 1173 } |
1162 | 1174 |
1163 void AutofillDialogControllerImpl::StartSignInFlow() { | 1175 void AutofillDialogControllerImpl::StartSignInFlow() { |
1176 DCHECK(!IsPayingWithWallet()); | |
1164 DCHECK(registrar_.IsEmpty()); | 1177 DCHECK(registrar_.IsEmpty()); |
1165 | 1178 |
1166 content::Source<content::NavigationController> source(view_->ShowSignIn()); | 1179 content::Source<content::NavigationController> source(view_->ShowSignIn()); |
1167 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); | 1180 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); |
1168 } | 1181 } |
1169 | 1182 |
1170 void AutofillDialogControllerImpl::EndSignInFlow() { | 1183 void AutofillDialogControllerImpl::EndSignInFlow() { |
1171 DCHECK(!registrar_.IsEmpty()); | 1184 DCHECK(!registrar_.IsEmpty()); |
1172 registrar_.RemoveAll(); | 1185 registrar_.RemoveAll(); |
1173 view_->HideSignIn(); | 1186 view_->HideSignIn(); |
1174 } | 1187 } |
1175 | 1188 |
1176 void AutofillDialogControllerImpl::NotificationCheckboxStateChanged( | 1189 void AutofillDialogControllerImpl::NotificationCheckboxStateChanged( |
1177 DialogNotification::Type type, bool checked) { | 1190 DialogNotification::Type type, bool checked) { |
1178 if (type == DialogNotification::WALLET_USAGE_CONFIRMATION) { | 1191 if (type == DialogNotification::WALLET_USAGE_CONFIRMATION) { |
1179 int command = checked ? AccountChooserModel::kWalletItemId : | 1192 if (checked) |
1180 AccountChooserModel::kAutofillItemId; | 1193 account_chooser_model_.SelectActiveWalletAccount(); |
1181 account_chooser_model_.ExecuteCommand(command, 0); | 1194 else |
1195 account_chooser_model_.SelectAutofillData(); | |
1182 } | 1196 } |
1183 } | 1197 } |
1184 | 1198 |
1185 void AutofillDialogControllerImpl::LegalDocumentLinkClicked( | 1199 void AutofillDialogControllerImpl::LegalDocumentLinkClicked( |
1186 const ui::Range& range) { | 1200 const ui::Range& range) { |
1187 #if !defined(OS_ANDROID) | 1201 #if !defined(OS_ANDROID) |
1188 for (size_t i = 0; i < legal_document_link_ranges_.size(); ++i) { | 1202 for (size_t i = 0; i < legal_document_link_ranges_.size(); ++i) { |
1189 if (legal_document_link_ranges_[i] == range) { | 1203 if (legal_document_link_ranges_[i] == range) { |
1190 chrome::NavigateParams params( | 1204 chrome::NavigateParams params( |
1191 chrome::FindBrowserWithWebContents(web_contents()), | 1205 chrome::FindBrowserWithWebContents(web_contents()), |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1309 | 1323 |
1310 void AutofillDialogControllerImpl::Observe( | 1324 void AutofillDialogControllerImpl::Observe( |
1311 int type, | 1325 int type, |
1312 const content::NotificationSource& source, | 1326 const content::NotificationSource& source, |
1313 const content::NotificationDetails& details) { | 1327 const content::NotificationDetails& details) { |
1314 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); | 1328 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); |
1315 content::LoadCommittedDetails* load_details = | 1329 content::LoadCommittedDetails* load_details = |
1316 content::Details<content::LoadCommittedDetails>(details).ptr(); | 1330 content::Details<content::LoadCommittedDetails>(details).ptr(); |
1317 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) { | 1331 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) { |
1318 EndSignInFlow(); | 1332 EndSignInFlow(); |
1319 if (account_chooser_model_.WalletIsSelected()) | 1333 |
1334 if (account_chooser_model_.WalletIsSelected()) { | |
1320 GetWalletItems(); | 1335 GetWalletItems(); |
1336 } else { | |
1337 // The sign-in flow means that the user implicitly switched the account | |
1338 // to the Wallet. This will trigger AccountChoiceChanged. | |
Evan Stade
2013/04/12 17:06:36
one space after period (to be consistent with this
aruslan
2013/04/12 20:43:30
Done.
| |
1339 account_chooser_model_.SelectActiveWalletAccount(); | |
1340 } | |
1321 } | 1341 } |
1322 } | 1342 } |
1323 | 1343 |
1324 //////////////////////////////////////////////////////////////////////////////// | 1344 //////////////////////////////////////////////////////////////////////////////// |
1325 // SuggestionsMenuModelDelegate implementation. | 1345 // SuggestionsMenuModelDelegate implementation. |
1326 | 1346 |
1327 void AutofillDialogControllerImpl::SuggestionItemSelected( | 1347 void AutofillDialogControllerImpl::SuggestionItemSelected( |
1328 const SuggestionsMenuModel& model) { | 1348 const SuggestionsMenuModel& model) { |
1329 const DialogSection section = SectionForSuggestionsMenuModel(model); | 1349 const DialogSection section = SectionForSuggestionsMenuModel(model); |
1330 EditCancelledForSection(section); | 1350 EditCancelledForSection(section); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1372 return; | 1392 return; |
1373 } | 1393 } |
1374 | 1394 |
1375 SuggestionsUpdated(); | 1395 SuggestionsUpdated(); |
1376 view_->UpdateNotificationArea(); | 1396 view_->UpdateNotificationArea(); |
1377 view_->UpdateButtonStrip(); | 1397 view_->UpdateButtonStrip(); |
1378 } | 1398 } |
1379 | 1399 |
1380 void AutofillDialogControllerImpl::OnPassiveSigninSuccess( | 1400 void AutofillDialogControllerImpl::OnPassiveSigninSuccess( |
1381 const std::string& username) { | 1401 const std::string& username) { |
1382 current_username_ = username; | 1402 const string16 username16 = UTF8ToUTF16(username); |
1383 signin_helper_.reset(); | 1403 signin_helper_.reset(); |
1404 account_chooser_model_.SetActiveWalletAccountName(username16); | |
1384 GetWalletItems(); | 1405 GetWalletItems(); |
1385 } | 1406 } |
1386 | 1407 |
1387 void AutofillDialogControllerImpl::OnUserNameFetchSuccess( | 1408 void AutofillDialogControllerImpl::OnUserNameFetchSuccess( |
1388 const std::string& username) { | 1409 const std::string& username) { |
1389 current_username_ = username; | 1410 const string16 username16 = UTF8ToUTF16(username); |
1390 signin_helper_.reset(); | 1411 signin_helper_.reset(); |
1412 account_chooser_model_.SetActiveWalletAccountName(username16); | |
1391 OnWalletOrSigninUpdate(); | 1413 OnWalletOrSigninUpdate(); |
1392 } | 1414 } |
1393 | 1415 |
1394 void AutofillDialogControllerImpl::OnAutomaticSigninSuccess( | 1416 void AutofillDialogControllerImpl::OnAutomaticSigninSuccess( |
1395 const std::string& username) { | 1417 const std::string& username) { |
1396 // TODO(aruslan): automatic sign-in. | |
1397 NOTIMPLEMENTED(); | 1418 NOTIMPLEMENTED(); |
1398 } | 1419 } |
1399 | 1420 |
1400 void AutofillDialogControllerImpl::OnPassiveSigninFailure( | 1421 void AutofillDialogControllerImpl::OnPassiveSigninFailure( |
1401 const GoogleServiceAuthError& error) { | 1422 const GoogleServiceAuthError& error) { |
1402 // TODO(aruslan): report an error. | 1423 // TODO(aruslan): report an error. |
1403 LOG(ERROR) << "failed to passively sign-in: " << error.ToString(); | 1424 LOG(ERROR) << "failed to passively sign in: " << error.ToString(); |
1404 OnWalletSigninError(); | 1425 OnWalletSigninError(); |
1405 } | 1426 } |
1406 | 1427 |
1407 void AutofillDialogControllerImpl::OnUserNameFetchFailure( | 1428 void AutofillDialogControllerImpl::OnUserNameFetchFailure( |
1408 const GoogleServiceAuthError& error) { | 1429 const GoogleServiceAuthError& error) { |
1409 // TODO(aruslan): report an error. | 1430 // TODO(aruslan): report an error. |
1410 LOG(ERROR) << "failed to fetch the user account name: " << error.ToString(); | 1431 LOG(ERROR) << "failed to fetch the user account name: " << error.ToString(); |
1411 OnWalletSigninError(); | 1432 OnWalletSigninError(); |
1412 } | 1433 } |
1413 | 1434 |
1414 void AutofillDialogControllerImpl::OnAutomaticSigninFailure( | 1435 void AutofillDialogControllerImpl::OnAutomaticSigninFailure( |
1415 const GoogleServiceAuthError& error) { | 1436 const GoogleServiceAuthError& error) { |
1416 // TODO(aruslan): automatic sign-in failure. | 1437 // TODO(aruslan): report an error. |
1417 NOTIMPLEMENTED(); | 1438 LOG(ERROR) << "failed to automatically sign in: " << error.ToString(); |
1439 OnWalletSigninError(); | |
1418 } | 1440 } |
1419 | 1441 |
1420 void AutofillDialogControllerImpl::OnDidGetWalletItems( | 1442 void AutofillDialogControllerImpl::OnDidGetWalletItems( |
1421 scoped_ptr<wallet::WalletItems> wallet_items) { | 1443 scoped_ptr<wallet::WalletItems> wallet_items) { |
1422 DCHECK(account_chooser_model_.WalletIsSelected()); | 1444 DCHECK(account_chooser_model_.WalletIsSelected()); |
1423 | |
1424 legal_documents_text_.clear(); | 1445 legal_documents_text_.clear(); |
1425 legal_document_link_ranges_.clear(); | 1446 legal_document_link_ranges_.clear(); |
1426 | 1447 |
1427 // TODO(dbeam): verify all items support kCartCurrency? | 1448 // TODO(dbeam): verify all items support kCartCurrency? |
1428 wallet_items_ = wallet_items.Pass(); | 1449 wallet_items_ = wallet_items.Pass(); |
1429 OnWalletOrSigninUpdate(); | 1450 OnWalletOrSigninUpdate(); |
1430 } | 1451 } |
1431 | 1452 |
1432 void AutofillDialogControllerImpl::OnDidSaveAddress( | 1453 void AutofillDialogControllerImpl::OnDidSaveAddress( |
1433 const std::string& address_id, | 1454 const std::string& address_id, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1490 DisableWallet(); | 1511 DisableWallet(); |
1491 } | 1512 } |
1492 | 1513 |
1493 //////////////////////////////////////////////////////////////////////////////// | 1514 //////////////////////////////////////////////////////////////////////////////// |
1494 // PersonalDataManagerObserver implementation. | 1515 // PersonalDataManagerObserver implementation. |
1495 | 1516 |
1496 void AutofillDialogControllerImpl::OnPersonalDataChanged() { | 1517 void AutofillDialogControllerImpl::OnPersonalDataChanged() { |
1497 SuggestionsUpdated(); | 1518 SuggestionsUpdated(); |
1498 } | 1519 } |
1499 | 1520 |
1521 //////////////////////////////////////////////////////////////////////////////// | |
1522 // AccountChooserModelDelegate implementation. | |
1523 | |
1500 void AutofillDialogControllerImpl::AccountChoiceChanged() { | 1524 void AutofillDialogControllerImpl::AccountChoiceChanged() { |
1501 // Whenever the user changes the account, all manual inputs should be reset. | 1525 // Whenever the user changes the account, all manual inputs should be reset. |
1502 ResetManualInputForSection(SECTION_EMAIL); | 1526 ResetManualInputForSection(SECTION_EMAIL); |
1503 ResetManualInputForSection(SECTION_CC); | 1527 ResetManualInputForSection(SECTION_CC); |
1504 ResetManualInputForSection(SECTION_BILLING); | 1528 ResetManualInputForSection(SECTION_BILLING); |
1505 ResetManualInputForSection(SECTION_CC_BILLING); | 1529 ResetManualInputForSection(SECTION_CC_BILLING); |
1506 ResetManualInputForSection(SECTION_SHIPPING); | 1530 ResetManualInputForSection(SECTION_SHIPPING); |
1507 | 1531 |
1508 if (is_submitting_) | 1532 if (is_submitting_) |
1509 GetWalletClient()->CancelRequests(); | 1533 GetWalletClient()->CancelRequests(); |
1510 | 1534 |
1511 SetIsSubmitting(false); | 1535 SetIsSubmitting(false); |
1512 | 1536 |
1513 if (account_chooser_model_.WalletIsSelected() && !wallet_items_) | 1537 if (!signin_helper_ && account_chooser_model_.WalletIsSelected()) { |
1514 GetWalletItems(); | 1538 if (account_chooser_model_.IsActiveWalletAccountSelected()) { |
1539 // If the user has chosen an already active Wallet account, and we don't | |
1540 // have the Wallet items, an attempt to fetch the Wallet data is made to | |
1541 // see if the user is still signed in. | |
1542 // This will trigger a passive sign-in if required. | |
1543 if (!wallet_items_) | |
1544 GetWalletItems(); | |
1545 } else { | |
1546 // TODO(aruslan): trigger the automatic sign-in process. | |
1547 LOG(ERROR) << "failed to initiate an automatic sign-in"; | |
1548 OnWalletSigninError(); | |
1549 } | |
1550 } | |
1515 | 1551 |
1516 SuggestionsUpdated(); | 1552 SuggestionsUpdated(); |
1553 UpdateAccountChooserView(); | |
1554 } | |
1517 | 1555 |
1556 void AutofillDialogControllerImpl::UpdateAccountChooserView() { | |
1518 if (view_) { | 1557 if (view_) { |
1519 view_->UpdateAccountChooser(); | 1558 view_->UpdateAccountChooser(); |
1520 view_->UpdateNotificationArea(); | 1559 view_->UpdateNotificationArea(); |
1521 } | 1560 } |
1522 } | 1561 } |
1523 | 1562 |
1524 //////////////////////////////////////////////////////////////////////////////// | 1563 //////////////////////////////////////////////////////////////////////////////// |
1525 | 1564 |
1526 bool AutofillDialogControllerImpl::HandleKeyPressEventInInput( | 1565 bool AutofillDialogControllerImpl::HandleKeyPressEventInInput( |
1527 const content::NativeWebKeyboardEvent& event) { | 1566 const content::NativeWebKeyboardEvent& event) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1600 return account_chooser_model_.WalletIsSelected() && | 1639 return account_chooser_model_.WalletIsSelected() && |
1601 SignedInState() == SIGNED_IN; | 1640 SignedInState() == SIGNED_IN; |
1602 } | 1641 } |
1603 | 1642 |
1604 bool AutofillDialogControllerImpl::IsFirstRun() const { | 1643 bool AutofillDialogControllerImpl::IsFirstRun() const { |
1605 return is_first_run_; | 1644 return is_first_run_; |
1606 } | 1645 } |
1607 | 1646 |
1608 void AutofillDialogControllerImpl::DisableWallet() { | 1647 void AutofillDialogControllerImpl::DisableWallet() { |
1609 signin_helper_.reset(); | 1648 signin_helper_.reset(); |
1610 current_username_.clear(); | |
1611 account_chooser_model_.SetHadWalletError(); | 1649 account_chooser_model_.SetHadWalletError(); |
1612 GetWalletClient()->CancelRequests(); | 1650 GetWalletClient()->CancelRequests(); |
1613 wallet_items_.reset(); | 1651 wallet_items_.reset(); |
1614 full_wallet_.reset(); | 1652 full_wallet_.reset(); |
1615 SetIsSubmitting(false); | 1653 SetIsSubmitting(false); |
1616 } | 1654 } |
1617 | 1655 |
1618 void AutofillDialogControllerImpl::SuggestionsUpdated() { | 1656 void AutofillDialogControllerImpl::SuggestionsUpdated() { |
1619 suggested_email_.Reset(); | 1657 suggested_email_.Reset(); |
1620 suggested_cc_.Reset(); | 1658 suggested_cc_.Reset(); |
1621 suggested_billing_.Reset(); | 1659 suggested_billing_.Reset(); |
1622 suggested_cc_billing_.Reset(); | 1660 suggested_cc_billing_.Reset(); |
1623 suggested_shipping_.Reset(); | 1661 suggested_shipping_.Reset(); |
1624 HidePopup(); | 1662 HidePopup(); |
1625 | 1663 |
1626 if (IsPayingWithWallet()) { | 1664 if (IsPayingWithWallet()) { |
1627 // TODO(estade): fill in the email address. | 1665 if (!account_chooser_model_.active_wallet_account_name().empty()) { |
1666 suggested_email_.AddKeyedItem( | |
1667 base::IntToString(0), | |
1668 account_chooser_model_.active_wallet_account_name()); | |
1669 } | |
1628 | 1670 |
1629 const std::vector<wallet::Address*>& addresses = | 1671 const std::vector<wallet::Address*>& addresses = |
1630 wallet_items_->addresses(); | 1672 wallet_items_->addresses(); |
1631 for (size_t i = 0; i < addresses.size(); ++i) { | 1673 for (size_t i = 0; i < addresses.size(); ++i) { |
1632 // TODO(dbeam): respect wallet_items_->default_instrument_id(). | 1674 // TODO(dbeam): respect wallet_items_->default_instrument_id(). |
1633 suggested_shipping_.AddKeyedItemWithSublabel( | 1675 suggested_shipping_.AddKeyedItemWithSublabel( |
1634 base::IntToString(i), | 1676 base::IntToString(i), |
1635 addresses[i]->DisplayName(), | 1677 addresses[i]->DisplayName(), |
1636 addresses[i]->DisplayNameDetail()); | 1678 addresses[i]->DisplayNameDetail()); |
1637 } | 1679 } |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2083 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; | 2125 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; |
2084 } | 2126 } |
2085 | 2127 |
2086 // Has Wallet items. | 2128 // Has Wallet items. |
2087 return has_autofill_profiles ? | 2129 return has_autofill_profiles ? |
2088 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : | 2130 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : |
2089 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; | 2131 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; |
2090 } | 2132 } |
2091 | 2133 |
2092 } // namespace autofill | 2134 } // namespace autofill |
OLD | NEW |