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