Chromium Code Reviews| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), | 246 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)), |
| 247 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), | 247 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)), |
| 248 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), | 248 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)), |
| 249 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_billing_(this)), | 249 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_billing_(this)), |
| 250 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), | 250 ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)), |
| 251 section_showing_popup_(SECTION_BILLING), | 251 section_showing_popup_(SECTION_BILLING), |
| 252 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), | 252 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), |
| 253 metric_logger_(metric_logger), | 253 metric_logger_(metric_logger), |
| 254 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), | 254 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), |
| 255 dialog_type_(dialog_type), | 255 dialog_type_(dialog_type), |
| 256 is_first_run_(!profile_->GetPrefs()->HasPrefPath( | |
| 257 prefs::kAutofillDialogPayWithoutWallet)), | |
| 256 is_submitting_(false), | 258 is_submitting_(false), |
| 257 autocheckout_is_running_(false), | 259 autocheckout_is_running_(false), |
| 258 had_autocheckout_error_(false) { | 260 had_autocheckout_error_(false) { |
| 259 // TODO(estade): remove duplicates from |form|? | 261 // TODO(estade): remove duplicates from |form|? |
| 260 DCHECK(!callback_.is_null()); | 262 DCHECK(!callback_.is_null()); |
| 263 if (is_first_run_) { | |
| 264 profile_->GetPrefs()->SetBoolean(prefs::kAutofillDialogPayWithoutWallet, | |
| 265 kPayWithoutWalletDefault); | |
| 266 } | |
| 261 } | 267 } |
| 262 | 268 |
| 263 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { | 269 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { |
| 264 if (popup_controller_) | 270 if (popup_controller_) |
| 265 popup_controller_->Hide(); | 271 popup_controller_->Hide(); |
| 266 | 272 |
| 267 metric_logger_.LogDialogInitialUserState(dialog_type_, initial_user_state_); | 273 metric_logger_.LogDialogInitialUserState(dialog_type_, initial_user_state_); |
| 268 } | 274 } |
| 269 | 275 |
| 270 // static | 276 // static |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 // fields. First we must figure out what the "right" fields are. | 392 // fields. First we must figure out what the "right" fields are. |
| 387 view_.reset(CreateView()); | 393 view_.reset(CreateView()); |
| 388 view_->Show(); | 394 view_->Show(); |
| 389 GetManager()->AddObserver(this); | 395 GetManager()->AddObserver(this); |
| 390 | 396 |
| 391 // Try to see if the user is already signed-in. | 397 // Try to see if the user is already signed-in. |
| 392 // If signed-in, fetch the user's Wallet data. | 398 // If signed-in, fetch the user's Wallet data. |
| 393 // Otherwise, see if the user could be signed in passively. | 399 // Otherwise, see if the user could be signed in passively. |
| 394 // TODO(aruslan): UMA metrics for sign-in. | 400 // TODO(aruslan): UMA metrics for sign-in. |
| 395 if (account_chooser_model_.WalletIsSelected()) | 401 if (account_chooser_model_.WalletIsSelected()) |
| 396 StartFetchingWalletItems(); | 402 GetWalletItems(); |
|
Dan Beam
2013/04/05 02:50:08
this matches the other calls we have (e.g. GetFull
aruslan
2013/04/05 03:45:35
Ack. Here and in GetWalletItems below the coderevi
| |
| 397 } | 403 } |
| 398 | 404 |
| 399 void AutofillDialogControllerImpl::Hide() { | 405 void AutofillDialogControllerImpl::Hide() { |
| 400 if (view_) | 406 if (view_) |
| 401 view_->Hide(); | 407 view_->Hide(); |
| 402 } | 408 } |
| 403 | 409 |
| 404 void AutofillDialogControllerImpl::UpdateProgressBar(double value) { | 410 void AutofillDialogControllerImpl::UpdateProgressBar(double value) { |
| 405 view_->UpdateProgressBar(value); | 411 view_->UpdateProgressBar(value); |
| 406 } | 412 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 return wallet_items_.get() != NULL && | 540 return wallet_items_.get() != NULL && |
| 535 !wallet_items_->instruments().empty() && | 541 !wallet_items_->instruments().empty() && |
| 536 !wallet_items_->addresses().empty(); | 542 !wallet_items_->addresses().empty(); |
| 537 } | 543 } |
| 538 | 544 |
| 539 bool AutofillDialogControllerImpl::IsSubmitPausedOn( | 545 bool AutofillDialogControllerImpl::IsSubmitPausedOn( |
| 540 wallet::RequiredAction required_action) const { | 546 wallet::RequiredAction required_action) const { |
| 541 return full_wallet_ && full_wallet_->HasRequiredAction(required_action); | 547 return full_wallet_ && full_wallet_->HasRequiredAction(required_action); |
| 542 } | 548 } |
| 543 | 549 |
| 544 void AutofillDialogControllerImpl::StartFetchingWalletItems() { | 550 void AutofillDialogControllerImpl::GetWalletItems() { |
| 545 // TODO(dbeam): Add Risk capabilites once the UI supports risk challenges. | 551 // TODO(dbeam): Add Risk capabilites once the UI supports risk challenges. |
| 546 GetWalletClient()->GetWalletItems( | 552 GetWalletClient()->GetWalletItems( |
| 547 source_url_, | 553 source_url_, std::vector<wallet::WalletClient::RiskCapability>()); |
| 548 std::vector<wallet::WalletClient::RiskCapability>()); | |
| 549 } | 554 } |
| 550 | 555 |
| 551 void AutofillDialogControllerImpl::OnWalletOrSigninUpdate() { | 556 void AutofillDialogControllerImpl::OnWalletOrSigninUpdate() { |
| 552 if (wallet_items_.get()) { | 557 switch (SignedInState()) { |
|
Dan Beam
2013/04/05 02:50:08
this needed to work without |wallet_items_|
aruslan
2013/04/05 03:45:35
Yup, it's already like this in another CL.
In REQU
| |
| 553 DCHECK(!signin_helper_.get()); | 558 case SIGNED_IN: |
| 554 switch (SignedInState()) { | 559 // Start fetching the user name if we don't know it yet. |
| 555 case SIGNED_IN: | 560 if (current_username_.empty()) { |
| 556 // Start fetching the user name if we don't know it yet. | 561 signin_helper_.reset(new wallet::WalletSigninHelper( |
| 557 if (current_username_.empty()) { | 562 this, profile_->GetRequestContext())); |
| 558 signin_helper_.reset(new wallet::WalletSigninHelper( | 563 signin_helper_->StartUserNameFetch(); |
| 559 this, | 564 } |
| 560 profile_->GetRequestContext())); | 565 break; |
| 561 signin_helper_->StartUserNameFetch(); | |
| 562 } | |
| 563 break; | |
| 564 | 566 |
| 565 case REQUIRES_SIGN_IN: | 567 case REQUIRES_SIGN_IN: |
| 566 // TODO(aruslan): automatic sign-in? | 568 // TODO(aruslan): automatic sign-in? |
| 567 break; | 569 break; |
| 568 | 570 |
| 569 case REQUIRES_PASSIVE_SIGN_IN: | 571 case REQUIRES_PASSIVE_SIGN_IN: |
| 570 // Attempt to passively sign in the user. | 572 // Attempt to passively sign in the user. |
| 571 current_username_.clear(); | 573 current_username_.clear(); |
| 572 signin_helper_.reset(new wallet::WalletSigninHelper( | 574 signin_helper_.reset(new wallet::WalletSigninHelper( |
| 573 this, | 575 this, profile_->GetRequestContext())); |
| 574 profile_->GetRequestContext())); | 576 signin_helper_->StartPassiveSignin(); |
| 575 signin_helper_->StartPassiveSignin(); | 577 break; |
| 576 break; | |
| 577 | 578 |
| 578 case REQUIRES_RESPONSE: | 579 case REQUIRES_RESPONSE: |
| 579 NOTREACHED(); | 580 NOTREACHED(); |
| 580 } | |
| 581 } | 581 } |
| 582 | 582 |
| 583 GenerateSuggestionsModels(); | 583 GenerateSuggestionsModels(); |
| 584 view_->ModelChanged(); | 584 view_->ModelChanged(); |
| 585 view_->UpdateAccountChooser(); | 585 view_->UpdateAccountChooser(); |
| 586 view_->UpdateNotificationArea(); | 586 view_->UpdateNotificationArea(); |
| 587 | 587 |
| 588 // On the first successful response, compute the initial user state metric. | 588 // On the first successful response, compute the initial user state metric. |
| 589 if (initial_user_state_ == AutofillMetrics::DIALOG_USER_STATE_UNKNOWN) | 589 if (initial_user_state_ == AutofillMetrics::DIALOG_USER_STATE_UNKNOWN) |
| 590 initial_user_state_ = GetInitialUserState(); | 590 initial_user_state_ = GetInitialUserState(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 686 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 687 IDR_WALLET_ICON); | 687 IDR_WALLET_ICON); |
| 688 } | 688 } |
| 689 | 689 |
| 690 gfx::Image icon; | 690 gfx::Image icon; |
| 691 account_chooser_model_.GetIconAt(account_chooser_model_.checked_item(), | 691 account_chooser_model_.GetIconAt(account_chooser_model_.checked_item(), |
| 692 &icon); | 692 &icon); |
| 693 return icon; | 693 return icon; |
| 694 } | 694 } |
| 695 | 695 |
| 696 bool AutofillDialogControllerImpl::GetPayWithoutWallet() const { | |
| 697 return profile_->GetPrefs()->GetBoolean( | |
| 698 prefs::kAutofillDialogPayWithoutWallet); | |
| 699 } | |
| 700 | |
| 701 void AutofillDialogControllerImpl::SetPayWithoutWallet( | |
| 702 bool pay_without_wallet) { | |
| 703 profile_->GetPrefs()->SetBoolean(prefs::kAutofillDialogPayWithoutWallet, | |
| 704 pay_without_wallet); | |
| 705 } | |
|
Dan Beam
2013/04/05 02:50:08
^ this isn't strictly necessary to do in the contr
aruslan
2013/04/05 03:45:35
Currently, the account chooser is wired up to trig
| |
| 706 | |
| 696 string16 AutofillDialogControllerImpl::LabelForSection(DialogSection section) | 707 string16 AutofillDialogControllerImpl::LabelForSection(DialogSection section) |
| 697 const { | 708 const { |
| 698 switch (section) { | 709 switch (section) { |
| 699 case SECTION_EMAIL: | 710 case SECTION_EMAIL: |
| 700 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_EMAIL); | 711 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_EMAIL); |
| 701 case SECTION_CC: | 712 case SECTION_CC: |
| 702 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_CC); | 713 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_CC); |
| 703 case SECTION_BILLING: | 714 case SECTION_BILLING: |
| 704 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_BILLING); | 715 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_BILLING); |
| 705 case SECTION_CC_BILLING: | 716 case SECTION_CC_BILLING: |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1082 if (autocheckout_is_running_ || had_autocheckout_error_) { | 1093 if (autocheckout_is_running_ || had_autocheckout_error_) { |
| 1083 AutofillMetrics::AutocheckoutCompletionStatus metric = | 1094 AutofillMetrics::AutocheckoutCompletionStatus metric = |
| 1084 autocheckout_is_running_ ? | 1095 autocheckout_is_running_ ? |
| 1085 AutofillMetrics::AUTOCHECKOUT_SUCCEEDED : | 1096 AutofillMetrics::AUTOCHECKOUT_SUCCEEDED : |
| 1086 AutofillMetrics::AUTOCHECKOUT_FAILED; | 1097 AutofillMetrics::AUTOCHECKOUT_FAILED; |
| 1087 metric_logger_.LogAutocheckoutDuration( | 1098 metric_logger_.LogAutocheckoutDuration( |
| 1088 base::Time::Now() - autocheckout_started_timestamp_, | 1099 base::Time::Now() - autocheckout_started_timestamp_, |
| 1089 metric); | 1100 metric); |
| 1090 } | 1101 } |
| 1091 | 1102 |
| 1092 // Reset the view so that updates to the pref aren't processed. | |
| 1093 view_.reset(); | |
| 1094 // On a successful submit, if the user manually selected "pay without wallet", | |
| 1095 // stop trying to pay with Wallet on future runs of the dialog. | |
| 1096 bool manually_selected_pay_without_wallet = | |
| 1097 !account_chooser_model_.WalletIsSelected() && | |
| 1098 !account_chooser_model_.had_wallet_error(); | |
| 1099 profile_->GetPrefs()->SetBoolean(prefs::kAutofillDialogPayWithoutWallet, | |
| 1100 manually_selected_pay_without_wallet); | |
| 1101 | |
| 1102 delete this; | 1103 delete this; |
| 1103 } | 1104 } |
| 1104 | 1105 |
| 1105 std::vector<DialogNotification> | 1106 std::vector<DialogNotification> |
| 1106 AutofillDialogControllerImpl::CurrentNotifications() const { | 1107 AutofillDialogControllerImpl::CurrentNotifications() const { |
| 1107 std::vector<DialogNotification> notifications; | 1108 std::vector<DialogNotification> notifications; |
| 1108 | 1109 |
| 1109 if (account_chooser_model_.WalletIsSelected()) { | 1110 if (account_chooser_model_.had_wallet_error()) { |
| 1110 if (SignedInState() == SIGNED_IN) { | 1111 // TODO(dbeam): pass along the Wallet error or remove from the translation. |
| 1111 // On first run with a complete wallet profile, show a notification | 1112 // TODO(dbeam): figure out a way to dismiss this error after a while. |
| 1112 // explaining where this data came from. | 1113 notifications.push_back(DialogNotification( |
| 1113 if (IsFirstRun() && HasCompleteWallet()) { | 1114 DialogNotification::WALLET_ERROR, |
| 1115 l10n_util::GetStringFUTF16(IDS_AUTOFILL_DIALOG_COMPLETE_WITHOUT_WALLET, | |
| 1116 ASCIIToUTF16("Oops, [Wallet-Error].")))); | |
| 1117 } else { | |
| 1118 if (is_first_run_) { | |
| 1119 if (SignedInState() == SIGNED_IN) { | |
| 1120 if (HasCompleteWallet()) { | |
| 1121 // First run, signed in, has a complete Google Wallet. | |
| 1122 notifications.push_back(DialogNotification( | |
| 1123 DialogNotification::EXPLANATORY_MESSAGE, | |
| 1124 l10n_util::GetStringUTF16( | |
| 1125 IDS_AUTOFILL_DIALOG_DETAILS_FROM_WALLET))); | |
| 1126 } else { | |
| 1127 // First run, signed in, has an incomplete (or no) Google Wallet. | |
| 1128 notifications.push_back(DialogNotification( | |
| 1129 DialogNotification::WALLET_USAGE_CONFIRMATION, | |
| 1130 l10n_util::GetStringUTF16( | |
| 1131 IDS_AUTOFILL_DIALOG_SAVE_DETAILS_IN_WALLET))); | |
| 1132 } | |
| 1133 } else { | |
| 1134 // First run, not signed in, wallet promo. | |
| 1114 notifications.push_back(DialogNotification( | 1135 notifications.push_back(DialogNotification( |
| 1115 DialogNotification::EXPLANATORY_MESSAGE, | 1136 DialogNotification::WALLET_SIGNIN_PROMO, |
| 1116 l10n_util::GetStringUTF16( | 1137 l10n_util::GetStringUTF16( |
| 1117 IDS_AUTOFILL_DIALOG_DETAILS_FROM_WALLET))); | 1138 IDS_AUTOFILL_DIALOG_SIGN_IN_AND_SAVE_DETAILS))); |
| 1118 } else { | |
| 1119 notifications.push_back(DialogNotification( | |
| 1120 DialogNotification::WALLET_USAGE_CONFIRMATION, | |
| 1121 l10n_util::GetStringUTF16( | |
| 1122 IDS_AUTOFILL_DIALOG_SAVE_DETAILS_IN_WALLET))); | |
| 1123 } | 1139 } |
| 1124 } else if (IsFirstRun()) { | 1140 } else if (SignedInState() == SIGNED_IN && !HasCompleteWallet()) { |
| 1125 // If the user is not signed in, show an upsell notification on first run. | 1141 // After first run, signed in. |
| 1126 notifications.push_back(DialogNotification( | 1142 notifications.push_back(DialogNotification( |
| 1127 DialogNotification::WALLET_SIGNIN_PROMO, | 1143 DialogNotification::WALLET_USAGE_CONFIRMATION, |
| 1128 l10n_util::GetStringUTF16( | 1144 l10n_util::GetStringUTF16( |
| 1129 IDS_AUTOFILL_DIALOG_SIGN_IN_AND_SAVE_DETAILS))); | 1145 IDS_AUTOFILL_DIALOG_SAVE_DETAILS_IN_WALLET))); |
| 1146 } else { | |
| 1147 // If the user isn't signed in and it's after the first run, no promo. | |
| 1130 } | 1148 } |
| 1131 } | 1149 } |
| 1132 | 1150 |
| 1133 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { | 1151 if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { |
| 1134 notifications.push_back(DialogNotification( | 1152 notifications.push_back(DialogNotification( |
| 1135 DialogNotification::SECURITY_WARNING, | 1153 DialogNotification::SECURITY_WARNING, |
| 1136 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING))); | 1154 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING))); |
| 1137 } | 1155 } |
| 1138 | 1156 |
| 1139 if (!invoked_from_same_origin_) { | 1157 if (!invoked_from_same_origin_) { |
| 1140 notifications.push_back(DialogNotification( | 1158 notifications.push_back(DialogNotification( |
| 1141 DialogNotification::SECURITY_WARNING, | 1159 DialogNotification::SECURITY_WARNING, |
| 1142 l10n_util::GetStringFUTF16(IDS_AUTOFILL_DIALOG_SITE_WARNING, | 1160 l10n_util::GetStringFUTF16(IDS_AUTOFILL_DIALOG_SITE_WARNING, |
| 1143 UTF8ToUTF16(source_url_.host())))); | 1161 UTF8ToUTF16(source_url_.host())))); |
| 1144 } | 1162 } |
| 1145 | 1163 |
| 1146 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) { | 1164 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) { |
| 1147 notifications.push_back(DialogNotification( | 1165 notifications.push_back(DialogNotification( |
| 1148 DialogNotification::REQUIRED_ACTION, | 1166 DialogNotification::REQUIRED_ACTION, |
| 1149 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV))); | 1167 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV))); |
| 1150 } | 1168 } |
| 1151 | 1169 |
| 1152 if (had_autocheckout_error_) { | 1170 if (had_autocheckout_error_) { |
| 1153 notifications.push_back(DialogNotification( | 1171 notifications.push_back(DialogNotification( |
| 1154 DialogNotification::AUTOCHECKOUT_ERROR, | 1172 DialogNotification::AUTOCHECKOUT_ERROR, |
| 1155 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_ERROR))); | 1173 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_ERROR))); |
| 1156 } | 1174 } |
| 1157 | 1175 |
| 1158 if (account_chooser_model_.had_wallet_error()) { | |
| 1159 // TODO(dbeam): pass along the Wallet error or remove from the translation. | |
| 1160 // TODO(dbeam): figure out a way to dismiss this error after a while. | |
| 1161 notifications.push_back(DialogNotification( | |
| 1162 DialogNotification::WALLET_ERROR, | |
| 1163 l10n_util::GetStringFUTF16( | |
| 1164 IDS_AUTOFILL_DIALOG_COMPLETE_WITHOUT_WALLET, | |
| 1165 ASCIIToUTF16("Oops, [Wallet-Error].")))); | |
| 1166 } | |
| 1167 | |
| 1168 return notifications; | 1176 return notifications; |
| 1169 } | 1177 } |
| 1170 | 1178 |
| 1171 void AutofillDialogControllerImpl::StartSignInFlow() { | 1179 void AutofillDialogControllerImpl::StartSignInFlow() { |
| 1172 DCHECK(registrar_.IsEmpty()); | 1180 DCHECK(registrar_.IsEmpty()); |
| 1173 | 1181 |
| 1174 content::Source<content::NavigationController> source(view_->ShowSignIn()); | 1182 content::Source<content::NavigationController> source(view_->ShowSignIn()); |
| 1175 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); | 1183 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); |
| 1176 } | 1184 } |
| 1177 | 1185 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1298 void AutofillDialogControllerImpl::Observe( | 1306 void AutofillDialogControllerImpl::Observe( |
| 1299 int type, | 1307 int type, |
| 1300 const content::NotificationSource& source, | 1308 const content::NotificationSource& source, |
| 1301 const content::NotificationDetails& details) { | 1309 const content::NotificationDetails& details) { |
| 1302 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); | 1310 DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED); |
| 1303 content::LoadCommittedDetails* load_details = | 1311 content::LoadCommittedDetails* load_details = |
| 1304 content::Details<content::LoadCommittedDetails>(details).ptr(); | 1312 content::Details<content::LoadCommittedDetails>(details).ptr(); |
| 1305 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) { | 1313 if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) { |
| 1306 EndSignInFlow(); | 1314 EndSignInFlow(); |
| 1307 if (account_chooser_model_.WalletIsSelected()) | 1315 if (account_chooser_model_.WalletIsSelected()) |
| 1308 StartFetchingWalletItems(); | 1316 GetWalletItems(); |
| 1309 } | 1317 } |
| 1310 } | 1318 } |
| 1311 | 1319 |
| 1312 //////////////////////////////////////////////////////////////////////////////// | 1320 //////////////////////////////////////////////////////////////////////////////// |
| 1313 // SuggestionsMenuModelDelegate implementation. | 1321 // SuggestionsMenuModelDelegate implementation. |
| 1314 | 1322 |
| 1315 void AutofillDialogControllerImpl::SuggestionItemSelected( | 1323 void AutofillDialogControllerImpl::SuggestionItemSelected( |
| 1316 const SuggestionsMenuModel& model) { | 1324 const SuggestionsMenuModel& model) { |
| 1317 const DialogSection section = SectionForSuggestionsMenuModel(model); | 1325 const DialogSection section = SectionForSuggestionsMenuModel(model); |
| 1318 EditCancelledForSection(section); | 1326 EditCancelledForSection(section); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1359 GenerateSuggestionsModels(); | 1367 GenerateSuggestionsModels(); |
| 1360 view_->ModelChanged(); | 1368 view_->ModelChanged(); |
| 1361 view_->UpdateNotificationArea(); | 1369 view_->UpdateNotificationArea(); |
| 1362 view_->UpdateButtonStrip(); | 1370 view_->UpdateButtonStrip(); |
| 1363 } | 1371 } |
| 1364 | 1372 |
| 1365 void AutofillDialogControllerImpl::OnPassiveSigninSuccess( | 1373 void AutofillDialogControllerImpl::OnPassiveSigninSuccess( |
| 1366 const std::string& username) { | 1374 const std::string& username) { |
| 1367 current_username_ = username; | 1375 current_username_ = username; |
| 1368 signin_helper_.reset(); | 1376 signin_helper_.reset(); |
| 1369 wallet_items_.reset(); | 1377 GetWalletItems(); |
| 1370 StartFetchingWalletItems(); | |
| 1371 } | 1378 } |
| 1372 | 1379 |
| 1373 void AutofillDialogControllerImpl::OnUserNameFetchSuccess( | 1380 void AutofillDialogControllerImpl::OnUserNameFetchSuccess( |
| 1374 const std::string& username) { | 1381 const std::string& username) { |
| 1375 current_username_ = username; | 1382 current_username_ = username; |
| 1376 signin_helper_.reset(); | 1383 signin_helper_.reset(); |
| 1377 OnWalletOrSigninUpdate(); | 1384 OnWalletOrSigninUpdate(); |
| 1378 } | 1385 } |
| 1379 | 1386 |
| 1380 void AutofillDialogControllerImpl::OnAutomaticSigninSuccess( | 1387 void AutofillDialogControllerImpl::OnAutomaticSigninSuccess( |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1471 void AutofillDialogControllerImpl::OnPersonalDataChanged() { | 1478 void AutofillDialogControllerImpl::OnPersonalDataChanged() { |
| 1472 HidePopup(); | 1479 HidePopup(); |
| 1473 GenerateSuggestionsModels(); | 1480 GenerateSuggestionsModels(); |
| 1474 view_->ModelChanged(); | 1481 view_->ModelChanged(); |
| 1475 } | 1482 } |
| 1476 | 1483 |
| 1477 void AutofillDialogControllerImpl::AccountChoiceChanged() { | 1484 void AutofillDialogControllerImpl::AccountChoiceChanged() { |
| 1478 if (!view_) | 1485 if (!view_) |
| 1479 return; | 1486 return; |
| 1480 | 1487 |
| 1481 // Whenever the user changes the current account, the Wallet data should be | 1488 if (account_chooser_model_.WalletIsSelected() && !wallet_items_) |
|
Dan Beam
2013/04/05 02:50:08
^ we could probably re-fetch if we want...
aruslan
2013/04/05 03:45:35
Without the account chooser CL this doesn't matter
| |
| 1482 // cleared. If the user has chosen a Wallet account, an attempt to fetch | 1489 GetWalletItems(); |
| 1483 // the Wallet data is made to see if the user is still signed in. | |
| 1484 // This will trigger a passive sign-in if required. | |
| 1485 // TODO(aruslan): integrate an automatic sign-in. | |
| 1486 wallet_items_.reset(); | |
| 1487 if (account_chooser_model_.WalletIsSelected()) | |
| 1488 StartFetchingWalletItems(); | |
| 1489 | 1490 |
| 1490 GenerateSuggestionsModels(); | 1491 GenerateSuggestionsModels(); |
| 1491 view_->ModelChanged(); | 1492 view_->ModelChanged(); |
| 1492 view_->UpdateAccountChooser(); | 1493 view_->UpdateAccountChooser(); |
| 1493 view_->UpdateNotificationArea(); | 1494 view_->UpdateNotificationArea(); |
| 1494 } | 1495 } |
| 1495 | 1496 |
| 1496 //////////////////////////////////////////////////////////////////////////////// | 1497 //////////////////////////////////////////////////////////////////////////////// |
| 1497 | 1498 |
| 1498 bool AutofillDialogControllerImpl::HandleKeyPressEventInInput( | 1499 bool AutofillDialogControllerImpl::HandleKeyPressEventInInput( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1549 full_wallet_.reset(); | 1550 full_wallet_.reset(); |
| 1550 } | 1551 } |
| 1551 | 1552 |
| 1552 void AutofillDialogControllerImpl::OnWalletSigninError() { | 1553 void AutofillDialogControllerImpl::OnWalletSigninError() { |
| 1553 signin_helper_.reset(); | 1554 signin_helper_.reset(); |
| 1554 current_username_.clear(); | 1555 current_username_.clear(); |
| 1555 account_chooser_model_.SetHadWalletSigninError(); | 1556 account_chooser_model_.SetHadWalletSigninError(); |
| 1556 GetWalletClient()->CancelPendingRequests(); | 1557 GetWalletClient()->CancelPendingRequests(); |
| 1557 } | 1558 } |
| 1558 | 1559 |
| 1559 bool AutofillDialogControllerImpl::IsFirstRun() const { | |
| 1560 PrefService* prefs = profile_->GetPrefs(); | |
| 1561 return !prefs->HasPrefPath(prefs::kAutofillDialogPayWithoutWallet); | |
| 1562 } | |
| 1563 | |
| 1564 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { | 1560 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { |
| 1565 suggested_email_.Reset(); | 1561 suggested_email_.Reset(); |
| 1566 suggested_cc_.Reset(); | 1562 suggested_cc_.Reset(); |
| 1567 suggested_billing_.Reset(); | 1563 suggested_billing_.Reset(); |
| 1568 suggested_cc_billing_.Reset(); | 1564 suggested_cc_billing_.Reset(); |
| 1569 suggested_shipping_.Reset(); | 1565 suggested_shipping_.Reset(); |
| 1570 | 1566 |
| 1571 if (IsPayingWithWallet()) { | 1567 if (IsPayingWithWallet()) { |
| 1572 // TODO(estade): fill in the email address. | 1568 // TODO(estade): fill in the email address. |
| 1573 | 1569 |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2014 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; | 2010 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; |
| 2015 } | 2011 } |
| 2016 | 2012 |
| 2017 // Has Wallet items. | 2013 // Has Wallet items. |
| 2018 return has_autofill_profiles ? | 2014 return has_autofill_profiles ? |
| 2019 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : | 2015 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : |
| 2020 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; | 2016 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; |
| 2021 } | 2017 } |
| 2022 | 2018 |
| 2023 } // namespace autofill | 2019 } // namespace autofill |
| OLD | NEW |