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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 // fields. First we must figure out what the "right" fields are. | 372 // fields. First we must figure out what the "right" fields are. |
373 view_.reset(CreateView()); | 373 view_.reset(CreateView()); |
374 view_->Show(); | 374 view_->Show(); |
375 GetManager()->AddObserver(this); | 375 GetManager()->AddObserver(this); |
376 | 376 |
377 // Try to see if the user is already signed-in. | 377 // Try to see if the user is already signed-in. |
378 // If signed-in, fetch the user's Wallet data. | 378 // If signed-in, fetch the user's Wallet data. |
379 // Otherwise, see if the user could be signed in passively. | 379 // Otherwise, see if the user could be signed in passively. |
380 // TODO(aruslan): UMA metrics for sign-in. | 380 // TODO(aruslan): UMA metrics for sign-in. |
381 if (account_chooser_model_.WalletIsSelected()) | 381 if (account_chooser_model_.WalletIsSelected()) |
382 StartFetchingWalletItems(); | 382 GetWalletItems(); |
383 } | 383 } |
384 | 384 |
385 void AutofillDialogControllerImpl::Hide() { | 385 void AutofillDialogControllerImpl::Hide() { |
386 if (view_) | 386 if (view_) |
387 view_->Hide(); | 387 view_->Hide(); |
388 } | 388 } |
389 | 389 |
390 void AutofillDialogControllerImpl::UpdateProgressBar(double value) { | 390 void AutofillDialogControllerImpl::UpdateProgressBar(double value) { |
391 view_->UpdateProgressBar(value); | 391 view_->UpdateProgressBar(value); |
392 } | 392 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 return wallet_items_.get() != NULL && | 522 return wallet_items_.get() != NULL && |
523 !wallet_items_->instruments().empty() && | 523 !wallet_items_->instruments().empty() && |
524 !wallet_items_->addresses().empty(); | 524 !wallet_items_->addresses().empty(); |
525 } | 525 } |
526 | 526 |
527 bool AutofillDialogControllerImpl::IsSubmitPausedOn( | 527 bool AutofillDialogControllerImpl::IsSubmitPausedOn( |
528 wallet::RequiredAction required_action) const { | 528 wallet::RequiredAction required_action) const { |
529 return full_wallet_ && full_wallet_->HasRequiredAction(required_action); | 529 return full_wallet_ && full_wallet_->HasRequiredAction(required_action); |
530 } | 530 } |
531 | 531 |
532 void AutofillDialogControllerImpl::StartFetchingWalletItems() { | 532 void AutofillDialogControllerImpl::GetWalletItems() { |
533 // TODO(dbeam): Add Risk capabilites once the UI supports risk challenges. | 533 // TODO(dbeam): Add Risk capabilites once the UI supports risk challenges. |
534 GetWalletClient()->GetWalletItems( | 534 GetWalletClient()->GetWalletItems( |
535 source_url_, | 535 source_url_, std::vector<wallet::WalletClient::RiskCapability>()); |
536 std::vector<wallet::WalletClient::RiskCapability>()); | |
537 } | 536 } |
538 | 537 |
539 void AutofillDialogControllerImpl::OnWalletOrSigninUpdate() { | 538 void AutofillDialogControllerImpl::OnWalletOrSigninUpdate() { |
540 if (wallet_items_.get()) { | 539 switch (SignedInState()) { |
541 DCHECK(!signin_helper_.get()); | 540 case SIGNED_IN: |
542 switch (SignedInState()) { | 541 // Start fetching the user name if we don't know it yet. |
543 case SIGNED_IN: | 542 if (current_username_.empty()) { |
544 // Start fetching the user name if we don't know it yet. | 543 signin_helper_.reset(new wallet::WalletSigninHelper( |
545 if (current_username_.empty()) { | 544 this, profile_->GetRequestContext())); |
546 signin_helper_.reset(new wallet::WalletSigninHelper( | 545 signin_helper_->StartUserNameFetch(); |
547 this, | 546 } |
548 profile_->GetRequestContext())); | 547 break; |
549 signin_helper_->StartUserNameFetch(); | |
550 } | |
551 break; | |
552 | 548 |
553 case REQUIRES_SIGN_IN: | 549 case REQUIRES_SIGN_IN: |
554 // TODO(aruslan): automatic sign-in? | 550 // TODO(aruslan): automatic sign-in? |
555 break; | 551 break; |
556 | 552 |
557 case REQUIRES_PASSIVE_SIGN_IN: | 553 case REQUIRES_PASSIVE_SIGN_IN: |
558 // Attempt to passively sign in the user. | 554 // Attempt to passively sign in the user. |
559 current_username_.clear(); | 555 current_username_.clear(); |
560 signin_helper_.reset(new wallet::WalletSigninHelper( | 556 signin_helper_.reset(new wallet::WalletSigninHelper( |
561 this, | 557 this, profile_->GetRequestContext())); |
562 profile_->GetRequestContext())); | 558 signin_helper_->StartPassiveSignin(); |
563 signin_helper_->StartPassiveSignin(); | 559 break; |
564 break; | |
565 | 560 |
566 case REQUIRES_RESPONSE: | 561 case REQUIRES_RESPONSE: |
567 NOTREACHED(); | 562 break; |
568 } | |
569 } | 563 } |
570 | 564 |
571 SuggestionsUpdated(); | 565 SuggestionsUpdated(); |
572 view_->UpdateAccountChooser(); | 566 view_->UpdateAccountChooser(); |
573 view_->UpdateNotificationArea(); | 567 view_->UpdateNotificationArea(); |
574 | 568 |
575 // On the first successful response, compute the initial user state metric. | 569 // On the first successful response, compute the initial user state metric. |
576 if (initial_user_state_ == AutofillMetrics::DIALOG_USER_STATE_UNKNOWN) | 570 if (initial_user_state_ == AutofillMetrics::DIALOG_USER_STATE_UNKNOWN) |
577 initial_user_state_ = GetInitialUserState(); | 571 initial_user_state_ = GetInitialUserState(); |
578 } | 572 } |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 if (autocheckout_is_running_ || had_autocheckout_error_) { | 1073 if (autocheckout_is_running_ || had_autocheckout_error_) { |
1080 AutofillMetrics::AutocheckoutCompletionStatus metric = | 1074 AutofillMetrics::AutocheckoutCompletionStatus metric = |
1081 autocheckout_is_running_ ? | 1075 autocheckout_is_running_ ? |
1082 AutofillMetrics::AUTOCHECKOUT_SUCCEEDED : | 1076 AutofillMetrics::AUTOCHECKOUT_SUCCEEDED : |
1083 AutofillMetrics::AUTOCHECKOUT_FAILED; | 1077 AutofillMetrics::AUTOCHECKOUT_FAILED; |
1084 GetMetricLogger().LogAutocheckoutDuration( | 1078 GetMetricLogger().LogAutocheckoutDuration( |
1085 base::Time::Now() - autocheckout_started_timestamp_, | 1079 base::Time::Now() - autocheckout_started_timestamp_, |
1086 metric); | 1080 metric); |
1087 } | 1081 } |
1088 | 1082 |
1089 // Reset the view so that updates to the pref aren't processed. | |
1090 view_.reset(); | |
1091 // On a successful submit, if the user manually selected "pay without wallet", | |
1092 // stop trying to pay with Wallet on future runs of the dialog. | |
1093 bool manually_selected_pay_without_wallet = | |
1094 !account_chooser_model_.WalletIsSelected() && | |
1095 !account_chooser_model_.had_wallet_error(); | |
1096 profile_->GetPrefs()->SetBoolean(prefs::kAutofillDialogPayWithoutWallet, | |
1097 manually_selected_pay_without_wallet); | |
1098 | |
1099 delete this; | 1083 delete this; |
1100 } | 1084 } |
1101 | 1085 |
1102 std::vector<DialogNotification> | 1086 std::vector<DialogNotification> |
1103 AutofillDialogControllerImpl::CurrentNotifications() const { | 1087 AutofillDialogControllerImpl::CurrentNotifications() const { |
1104 std::vector<DialogNotification> notifications; | 1088 std::vector<DialogNotification> notifications; |
1105 | 1089 |
1106 if (account_chooser_model_.WalletIsSelected()) { | 1090 if (account_chooser_model_.had_wallet_error()) { |
1107 if (SignedInState() == SIGNED_IN) { | 1091 // TODO(dbeam): pass along the Wallet error or remove from the translation. |
1108 // On first run with a complete wallet profile, show a notification | 1092 // TODO(dbeam): figure out a way to dismiss this error after a while. |
1109 // explaining where this data came from. | 1093 notifications.push_back(DialogNotification( |
1110 if (IsFirstRun() && HasCompleteWallet()) { | 1094 DialogNotification::WALLET_ERROR, |
| 1095 l10n_util::GetStringFUTF16(IDS_AUTOFILL_DIALOG_COMPLETE_WITHOUT_WALLET, |
| 1096 ASCIIToUTF16("[Wallet-Error].")))); |
| 1097 } else { |
| 1098 if (IsFirstRun()) { |
| 1099 if (SignedInState() == SIGNED_IN) { |
| 1100 if (account_chooser_model_.WalletIsSelected() && HasCompleteWallet()) { |
| 1101 // First run, signed in, has a complete Google Wallet. |
| 1102 notifications.push_back(DialogNotification( |
| 1103 DialogNotification::EXPLANATORY_MESSAGE, |
| 1104 l10n_util::GetStringUTF16( |
| 1105 IDS_AUTOFILL_DIALOG_DETAILS_FROM_WALLET))); |
| 1106 } else { |
| 1107 // First run, signed in, has an incomplete (or no) Google Wallet. |
| 1108 DialogNotification notification( |
| 1109 DialogNotification::WALLET_USAGE_CONFIRMATION, |
| 1110 l10n_util::GetStringUTF16( |
| 1111 IDS_AUTOFILL_DIALOG_SAVE_DETAILS_IN_WALLET)); |
| 1112 notification.set_checked(account_chooser_model_.WalletIsSelected()); |
| 1113 notification.set_interactive(!is_submitting_); |
| 1114 notifications.push_back(notification); |
| 1115 } |
| 1116 } else if (account_chooser_model_.WalletIsSelected()) { |
| 1117 // First run, not signed in, wallet promo. |
1111 notifications.push_back(DialogNotification( | 1118 notifications.push_back(DialogNotification( |
1112 DialogNotification::EXPLANATORY_MESSAGE, | 1119 DialogNotification::WALLET_SIGNIN_PROMO, |
1113 l10n_util::GetStringUTF16( | 1120 l10n_util::GetStringUTF16( |
1114 IDS_AUTOFILL_DIALOG_DETAILS_FROM_WALLET))); | 1121 IDS_AUTOFILL_DIALOG_SIGN_IN_AND_SAVE_DETAILS))); |
1115 } else { | |
1116 notifications.push_back(DialogNotification( | |
1117 DialogNotification::WALLET_USAGE_CONFIRMATION, | |
1118 l10n_util::GetStringUTF16( | |
1119 IDS_AUTOFILL_DIALOG_SAVE_DETAILS_IN_WALLET))); | |
1120 notifications.back().set_interactive(!is_submitting_); | |
1121 } | 1122 } |
1122 } else if (IsFirstRun()) { | 1123 } else if (SignedInState() == SIGNED_IN && !HasCompleteWallet()) { |
1123 // If the user is not signed in, show an upsell notification on first run. | 1124 // After first run, signed in. |
1124 notifications.push_back(DialogNotification( | 1125 DialogNotification notification( |
1125 DialogNotification::WALLET_SIGNIN_PROMO, | 1126 DialogNotification::WALLET_USAGE_CONFIRMATION, |
1126 l10n_util::GetStringUTF16( | 1127 l10n_util::GetStringUTF16( |
1127 IDS_AUTOFILL_DIALOG_SIGN_IN_AND_SAVE_DETAILS))); | 1128 IDS_AUTOFILL_DIALOG_SAVE_DETAILS_IN_WALLET)); |
| 1129 notification.set_checked(account_chooser_model_.WalletIsSelected()); |
| 1130 notification.set_interactive(!is_submitting_); |
| 1131 notifications.push_back(notification); |
| 1132 } else { |
| 1133 // If the user isn't signed in and it's after the first run, no promo. |
1128 } | 1134 } |
1129 } | 1135 } |
1130 | 1136 |
1131 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { | 1137 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { |
1132 notifications.push_back(DialogNotification( | 1138 notifications.push_back(DialogNotification( |
1133 DialogNotification::SECURITY_WARNING, | 1139 DialogNotification::SECURITY_WARNING, |
1134 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING))); | 1140 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING))); |
1135 } | 1141 } |
1136 | 1142 |
1137 if (!invoked_from_same_origin_) { | 1143 if (!invoked_from_same_origin_) { |
1138 notifications.push_back(DialogNotification( | 1144 notifications.push_back(DialogNotification( |
1139 DialogNotification::SECURITY_WARNING, | 1145 DialogNotification::SECURITY_WARNING, |
1140 l10n_util::GetStringFUTF16(IDS_AUTOFILL_DIALOG_SITE_WARNING, | 1146 l10n_util::GetStringFUTF16(IDS_AUTOFILL_DIALOG_SITE_WARNING, |
1141 UTF8ToUTF16(source_url_.host())))); | 1147 UTF8ToUTF16(source_url_.host())))); |
1142 } | 1148 } |
1143 | 1149 |
1144 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) { | 1150 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) { |
1145 notifications.push_back(DialogNotification( | 1151 notifications.push_back(DialogNotification( |
1146 DialogNotification::REQUIRED_ACTION, | 1152 DialogNotification::REQUIRED_ACTION, |
1147 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV))); | 1153 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV))); |
1148 } | 1154 } |
1149 | 1155 |
1150 if (had_autocheckout_error_) { | 1156 if (had_autocheckout_error_) { |
1151 notifications.push_back(DialogNotification( | 1157 notifications.push_back(DialogNotification( |
1152 DialogNotification::AUTOCHECKOUT_ERROR, | 1158 DialogNotification::AUTOCHECKOUT_ERROR, |
1153 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_ERROR))); | 1159 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_ERROR))); |
1154 } | 1160 } |
1155 | 1161 |
1156 if (account_chooser_model_.had_wallet_error()) { | |
1157 // TODO(dbeam): pass along the Wallet error or remove from the translation. | |
1158 // TODO(dbeam): figure out a way to dismiss this error after a while. | |
1159 notifications.push_back(DialogNotification( | |
1160 DialogNotification::WALLET_ERROR, | |
1161 l10n_util::GetStringFUTF16( | |
1162 IDS_AUTOFILL_DIALOG_COMPLETE_WITHOUT_WALLET, | |
1163 ASCIIToUTF16("[Wallet-Error].")))); | |
1164 } | |
1165 | |
1166 return notifications; | 1162 return notifications; |
1167 } | 1163 } |
1168 | 1164 |
1169 void AutofillDialogControllerImpl::StartSignInFlow() { | 1165 void AutofillDialogControllerImpl::StartSignInFlow() { |
1170 DCHECK(registrar_.IsEmpty()); | 1166 DCHECK(registrar_.IsEmpty()); |
1171 | 1167 |
1172 content::Source<content::NavigationController> source(view_->ShowSignIn()); | 1168 content::Source<content::NavigationController> source(view_->ShowSignIn()); |
1173 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); | 1169 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); |
1174 } | 1170 } |
1175 | 1171 |
1176 void AutofillDialogControllerImpl::EndSignInFlow() { | 1172 void AutofillDialogControllerImpl::EndSignInFlow() { |
1177 DCHECK(!registrar_.IsEmpty()); | 1173 DCHECK(!registrar_.IsEmpty()); |
1178 registrar_.RemoveAll(); | 1174 registrar_.RemoveAll(); |
1179 view_->HideSignIn(); | 1175 view_->HideSignIn(); |
1180 } | 1176 } |
1181 | 1177 |
| 1178 void AutofillDialogControllerImpl::NotificationCheckboxStateChanged( |
| 1179 DialogNotification::Type type, bool checked) { |
| 1180 if (type == DialogNotification::WALLET_USAGE_CONFIRMATION) { |
| 1181 int command = checked ? AccountChooserModel::kWalletItemId : |
| 1182 AccountChooserModel::kAutofillItemId; |
| 1183 account_chooser_model_.ExecuteCommand(command, 0); |
| 1184 } |
| 1185 } |
| 1186 |
1182 void AutofillDialogControllerImpl::LegalDocumentLinkClicked( | 1187 void AutofillDialogControllerImpl::LegalDocumentLinkClicked( |
1183 const ui::Range& range) { | 1188 const ui::Range& range) { |
1184 #if !defined(OS_ANDROID) | 1189 #if !defined(OS_ANDROID) |
1185 for (size_t i = 0; i < legal_document_link_ranges_.size(); ++i) { | 1190 for (size_t i = 0; i < legal_document_link_ranges_.size(); ++i) { |
1186 if (legal_document_link_ranges_[i] == range) { | 1191 if (legal_document_link_ranges_[i] == range) { |
1187 chrome::NavigateParams params( | 1192 chrome::NavigateParams params( |
1188 chrome::FindBrowserWithWebContents(web_contents()), | 1193 chrome::FindBrowserWithWebContents(web_contents()), |
1189 wallet_items_->legal_documents()[i]->url(), | 1194 wallet_items_->legal_documents()[i]->url(), |
1190 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 1195 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
1191 params.disposition = NEW_BACKGROUND_TAB; | 1196 params.disposition = NEW_BACKGROUND_TAB; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 void AutofillDialogControllerImpl::Observe( | 1312 void AutofillDialogControllerImpl::Observe( |
1308 int type, | 1313 int type, |
1309 const content::NotificationSource& source, | 1314 const content::NotificationSource& source, |
1310 const content::NotificationDetails& details) { | 1315 const content::NotificationDetails& details) { |
1311 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); | 1316 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); |
1312 content::LoadCommittedDetails* load_details = | 1317 content::LoadCommittedDetails* load_details = |
1313 content::Details<content::LoadCommittedDetails>(details).ptr(); | 1318 content::Details<content::LoadCommittedDetails>(details).ptr(); |
1314 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) { | 1319 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) { |
1315 EndSignInFlow(); | 1320 EndSignInFlow(); |
1316 if (account_chooser_model_.WalletIsSelected()) | 1321 if (account_chooser_model_.WalletIsSelected()) |
1317 StartFetchingWalletItems(); | 1322 GetWalletItems(); |
1318 } | 1323 } |
1319 } | 1324 } |
1320 | 1325 |
1321 //////////////////////////////////////////////////////////////////////////////// | 1326 //////////////////////////////////////////////////////////////////////////////// |
1322 // SuggestionsMenuModelDelegate implementation. | 1327 // SuggestionsMenuModelDelegate implementation. |
1323 | 1328 |
1324 void AutofillDialogControllerImpl::SuggestionItemSelected( | 1329 void AutofillDialogControllerImpl::SuggestionItemSelected( |
1325 const SuggestionsMenuModel& model) { | 1330 const SuggestionsMenuModel& model) { |
1326 const DialogSection section = SectionForSuggestionsMenuModel(model); | 1331 const DialogSection section = SectionForSuggestionsMenuModel(model); |
1327 EditCancelledForSection(section); | 1332 EditCancelledForSection(section); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 | 1376 |
1372 SuggestionsUpdated(); | 1377 SuggestionsUpdated(); |
1373 view_->UpdateNotificationArea(); | 1378 view_->UpdateNotificationArea(); |
1374 view_->UpdateButtonStrip(); | 1379 view_->UpdateButtonStrip(); |
1375 } | 1380 } |
1376 | 1381 |
1377 void AutofillDialogControllerImpl::OnPassiveSigninSuccess( | 1382 void AutofillDialogControllerImpl::OnPassiveSigninSuccess( |
1378 const std::string& username) { | 1383 const std::string& username) { |
1379 current_username_ = username; | 1384 current_username_ = username; |
1380 signin_helper_.reset(); | 1385 signin_helper_.reset(); |
1381 wallet_items_.reset(); | 1386 GetWalletItems(); |
1382 StartFetchingWalletItems(); | |
1383 } | 1387 } |
1384 | 1388 |
1385 void AutofillDialogControllerImpl::OnUserNameFetchSuccess( | 1389 void AutofillDialogControllerImpl::OnUserNameFetchSuccess( |
1386 const std::string& username) { | 1390 const std::string& username) { |
1387 current_username_ = username; | 1391 current_username_ = username; |
1388 signin_helper_.reset(); | 1392 signin_helper_.reset(); |
1389 OnWalletOrSigninUpdate(); | 1393 OnWalletOrSigninUpdate(); |
1390 } | 1394 } |
1391 | 1395 |
1392 void AutofillDialogControllerImpl::OnAutomaticSigninSuccess( | 1396 void AutofillDialogControllerImpl::OnAutomaticSigninSuccess( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 } | 1493 } |
1490 | 1494 |
1491 //////////////////////////////////////////////////////////////////////////////// | 1495 //////////////////////////////////////////////////////////////////////////////// |
1492 // PersonalDataManagerObserver implementation. | 1496 // PersonalDataManagerObserver implementation. |
1493 | 1497 |
1494 void AutofillDialogControllerImpl::OnPersonalDataChanged() { | 1498 void AutofillDialogControllerImpl::OnPersonalDataChanged() { |
1495 SuggestionsUpdated(); | 1499 SuggestionsUpdated(); |
1496 } | 1500 } |
1497 | 1501 |
1498 void AutofillDialogControllerImpl::AccountChoiceChanged() { | 1502 void AutofillDialogControllerImpl::AccountChoiceChanged() { |
1499 if (!view_) | |
1500 return; | |
1501 | |
1502 // Whenever the user changes the account, all manual inputs should be reset. | 1503 // Whenever the user changes the account, all manual inputs should be reset. |
1503 ResetManualInputForSection(SECTION_EMAIL); | 1504 ResetManualInputForSection(SECTION_EMAIL); |
1504 ResetManualInputForSection(SECTION_CC); | 1505 ResetManualInputForSection(SECTION_CC); |
1505 ResetManualInputForSection(SECTION_BILLING); | 1506 ResetManualInputForSection(SECTION_BILLING); |
1506 ResetManualInputForSection(SECTION_CC_BILLING); | 1507 ResetManualInputForSection(SECTION_CC_BILLING); |
1507 ResetManualInputForSection(SECTION_SHIPPING); | 1508 ResetManualInputForSection(SECTION_SHIPPING); |
1508 | 1509 |
1509 // Whenever the user changes the current account, the Wallet data should be | 1510 if (is_submitting_) |
1510 // cleared. If the user has chosen a Wallet account, an attempt to fetch | 1511 GetWalletClient()->CancelRequests(); |
1511 // the Wallet data is made to see if the user is still signed in. | |
1512 // This will trigger a passive sign-in if required. | |
1513 wallet_items_.reset(); | |
1514 full_wallet_.reset(); | |
1515 GetWalletClient()->CancelRequests(); | |
1516 | 1512 |
1517 SetIsSubmitting(false); | 1513 SetIsSubmitting(false); |
1518 | 1514 |
1519 // TODO(aruslan): integrate an automatic sign-in. | 1515 if (account_chooser_model_.WalletIsSelected() && !wallet_items_) |
1520 if (account_chooser_model_.WalletIsSelected()) | 1516 GetWalletItems(); |
1521 StartFetchingWalletItems(); | |
1522 | 1517 |
1523 SuggestionsUpdated(); | 1518 SuggestionsUpdated(); |
1524 view_->UpdateAccountChooser(); | 1519 |
1525 view_->UpdateNotificationArea(); | 1520 if (view_) { |
| 1521 view_->UpdateAccountChooser(); |
| 1522 view_->UpdateNotificationArea(); |
| 1523 } |
1526 } | 1524 } |
1527 | 1525 |
1528 //////////////////////////////////////////////////////////////////////////////// | 1526 //////////////////////////////////////////////////////////////////////////////// |
1529 | 1527 |
1530 bool AutofillDialogControllerImpl::HandleKeyPressEventInInput( | 1528 bool AutofillDialogControllerImpl::HandleKeyPressEventInInput( |
1531 const content::NativeWebKeyboardEvent& event) { | 1529 const content::NativeWebKeyboardEvent& event) { |
1532 if (popup_controller_) | 1530 if (popup_controller_) |
1533 return popup_controller_->HandleKeyPressEvent(event); | 1531 return popup_controller_->HandleKeyPressEvent(event); |
1534 | 1532 |
1535 return false; | 1533 return false; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 wallet_client_(profile_->GetRequestContext(), this)), | 1570 wallet_client_(profile_->GetRequestContext(), this)), |
1573 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), | 1571 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), |
1574 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), | 1572 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), |
1575 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), | 1573 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), |
1576 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_billing_(this)), | 1574 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_billing_(this)), |
1577 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), | 1575 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), |
1578 input_showing_popup_(NULL), | 1576 input_showing_popup_(NULL), |
1579 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), | 1577 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), |
1580 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), | 1578 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), |
1581 dialog_type_(dialog_type), | 1579 dialog_type_(dialog_type), |
| 1580 is_first_run_(!profile_->GetPrefs()->HasPrefPath( |
| 1581 prefs::kAutofillDialogPayWithoutWallet)), |
1582 is_submitting_(false), | 1582 is_submitting_(false), |
1583 autocheckout_is_running_(false), | 1583 autocheckout_is_running_(false), |
1584 had_autocheckout_error_(false) { | 1584 had_autocheckout_error_(false) { |
1585 // TODO(estade): remove duplicates from |form_structure|? | 1585 // TODO(estade): remove duplicates from |form_structure|? |
1586 DCHECK(!callback_.is_null()); | 1586 DCHECK(!callback_.is_null()); |
1587 } | 1587 } |
1588 | 1588 |
1589 AutofillDialogView* AutofillDialogControllerImpl::CreateView() { | 1589 AutofillDialogView* AutofillDialogControllerImpl::CreateView() { |
1590 return AutofillDialogView::Create(this); | 1590 return AutofillDialogView::Create(this); |
1591 } | 1591 } |
1592 | 1592 |
1593 PersonalDataManager* AutofillDialogControllerImpl::GetManager() { | 1593 PersonalDataManager* AutofillDialogControllerImpl::GetManager() { |
1594 return PersonalDataManagerFactory::GetForProfile(profile_); | 1594 return PersonalDataManagerFactory::GetForProfile(profile_); |
1595 } | 1595 } |
1596 | 1596 |
1597 wallet::WalletClient* AutofillDialogControllerImpl::GetWalletClient() { | 1597 wallet::WalletClient* AutofillDialogControllerImpl::GetWalletClient() { |
1598 return &wallet_client_; | 1598 return &wallet_client_; |
1599 } | 1599 } |
1600 | 1600 |
1601 bool AutofillDialogControllerImpl::IsPayingWithWallet() const { | 1601 bool AutofillDialogControllerImpl::IsPayingWithWallet() const { |
1602 return account_chooser_model_.WalletIsSelected() && | 1602 return account_chooser_model_.WalletIsSelected() && |
1603 SignedInState() == SIGNED_IN; | 1603 SignedInState() == SIGNED_IN; |
1604 } | 1604 } |
1605 | 1605 |
| 1606 bool AutofillDialogControllerImpl::IsFirstRun() const { |
| 1607 return is_first_run_; |
| 1608 } |
| 1609 |
1606 void AutofillDialogControllerImpl::DisableWallet() { | 1610 void AutofillDialogControllerImpl::DisableWallet() { |
1607 signin_helper_.reset(); | 1611 signin_helper_.reset(); |
1608 current_username_.clear(); | 1612 current_username_.clear(); |
1609 account_chooser_model_.SetHadWalletError(); | 1613 account_chooser_model_.SetHadWalletError(); |
1610 GetWalletClient()->CancelRequests(); | 1614 GetWalletClient()->CancelRequests(); |
1611 wallet_items_.reset(); | 1615 wallet_items_.reset(); |
1612 full_wallet_.reset(); | 1616 full_wallet_.reset(); |
1613 SetIsSubmitting(false); | 1617 SetIsSubmitting(false); |
1614 } | 1618 } |
1615 | 1619 |
1616 bool AutofillDialogControllerImpl::IsFirstRun() const { | |
1617 PrefService* prefs = profile_->GetPrefs(); | |
1618 return !prefs->HasPrefPath(prefs::kAutofillDialogPayWithoutWallet); | |
1619 } | |
1620 | |
1621 void AutofillDialogControllerImpl::SuggestionsUpdated() { | 1620 void AutofillDialogControllerImpl::SuggestionsUpdated() { |
1622 suggested_email_.Reset(); | 1621 suggested_email_.Reset(); |
1623 suggested_cc_.Reset(); | 1622 suggested_cc_.Reset(); |
1624 suggested_billing_.Reset(); | 1623 suggested_billing_.Reset(); |
1625 suggested_cc_billing_.Reset(); | 1624 suggested_cc_billing_.Reset(); |
1626 suggested_shipping_.Reset(); | 1625 suggested_shipping_.Reset(); |
1627 HidePopup(); | 1626 HidePopup(); |
1628 | 1627 |
1629 if (IsPayingWithWallet()) { | 1628 if (IsPayingWithWallet()) { |
1630 // TODO(estade): fill in the email address. | 1629 // TODO(estade): fill in the email address. |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; | 2085 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; |
2087 } | 2086 } |
2088 | 2087 |
2089 // Has Wallet items. | 2088 // Has Wallet items. |
2090 return has_autofill_profiles ? | 2089 return has_autofill_profiles ? |
2091 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : | 2090 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : |
2092 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; | 2091 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; |
2093 } | 2092 } |
2094 | 2093 |
2095 } // namespace autofill | 2094 } // namespace autofill |
OLD | NEW |