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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 CreditCard* card, | 163 CreditCard* card, |
164 string16* cvc, | 164 string16* cvc, |
165 AutofillProfile* profile) { | 165 AutofillProfile* profile) { |
166 for (DetailOutputMap::const_iterator it = output.begin(); | 166 for (DetailOutputMap::const_iterator it = output.begin(); |
167 it != output.end(); ++it) { | 167 it != output.end(); ++it) { |
168 string16 trimmed; | 168 string16 trimmed; |
169 TrimWhitespace(it->second, TRIM_ALL, &trimmed); | 169 TrimWhitespace(it->second, TRIM_ALL, &trimmed); |
170 | 170 |
171 // Special case CVC as CreditCard just swallows it. | 171 // Special case CVC as CreditCard just swallows it. |
172 if (it->first->type == CREDIT_CARD_VERIFICATION_CODE) { | 172 if (it->first->type == CREDIT_CARD_VERIFICATION_CODE) { |
173 cvc->assign(trimmed); | 173 if (cvc) |
174 cvc->assign(trimmed); | |
174 } else { | 175 } else { |
175 // Copy the credit card name to |profile| in addition to |card| as | 176 // Copy the credit card name to |profile| in addition to |card| as |
176 // wallet::Instrument requires a recipient name for its billing address. | 177 // wallet::Instrument requires a recipient name for its billing address. |
177 if (it->first->type == CREDIT_CARD_NAME) | 178 if (profile && it->first->type == CREDIT_CARD_NAME) |
178 profile->SetRawInfo(NAME_FULL, trimmed); | 179 profile->SetRawInfo(NAME_FULL, trimmed); |
179 | 180 |
180 if (IsCreditCardType(it->first->type)) | 181 if (IsCreditCardType(it->first->type)) { |
181 card->SetRawInfo(it->first->type, trimmed); | 182 if (card) |
182 else | 183 card->SetRawInfo(it->first->type, trimmed); |
184 } else if (profile) { | |
183 profile->SetRawInfo(it->first->type, trimmed); | 185 profile->SetRawInfo(it->first->type, trimmed); |
186 } | |
184 } | 187 } |
185 } | 188 } |
186 } | 189 } |
187 | 190 |
188 // Returns the containing window for the given |web_contents|. The containing | 191 // Returns the containing window for the given |web_contents|. The containing |
189 // window might be a browser window for a Chrome tab, or it might be a shell | 192 // window might be a browser window for a Chrome tab, or it might be a shell |
190 // window for a platform app. | 193 // window for a platform app. |
191 BaseWindow* GetBaseWindowForWebContents( | 194 BaseWindow* GetBaseWindowForWebContents( |
192 const content::WebContents* web_contents) { | 195 const content::WebContents* web_contents) { |
193 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 196 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 string16 AutofillDialogControllerImpl::UseBillingForShippingText() const { | 423 string16 AutofillDialogControllerImpl::UseBillingForShippingText() const { |
421 return l10n_util::GetStringUTF16( | 424 return l10n_util::GetStringUTF16( |
422 IDS_AUTOFILL_DIALOG_USE_BILLING_FOR_SHIPPING); | 425 IDS_AUTOFILL_DIALOG_USE_BILLING_FOR_SHIPPING); |
423 } | 426 } |
424 | 427 |
425 string16 AutofillDialogControllerImpl::CancelButtonText() const { | 428 string16 AutofillDialogControllerImpl::CancelButtonText() const { |
426 return l10n_util::GetStringUTF16(IDS_CANCEL); | 429 return l10n_util::GetStringUTF16(IDS_CANCEL); |
427 } | 430 } |
428 | 431 |
429 string16 AutofillDialogControllerImpl::ConfirmButtonText() const { | 432 string16 AutofillDialogControllerImpl::ConfirmButtonText() const { |
430 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SUBMIT_BUTTON); | 433 return l10n_util::GetStringUTF16(IsSubmitPausedOn(wallet::VERIFY_CVV) ? |
434 IDS_AUTOFILL_DIALOG_VERIFY_BUTTON : IDS_AUTOFILL_DIALOG_SUBMIT_BUTTON); | |
431 } | 435 } |
432 | 436 |
433 string16 AutofillDialogControllerImpl::CancelSignInText() const { | 437 string16 AutofillDialogControllerImpl::CancelSignInText() const { |
434 // TODO(abodenha): real strings and l10n. | 438 // TODO(abodenha): real strings and l10n. |
435 return ASCIIToUTF16("Don't sign in."); | 439 return ASCIIToUTF16("Don't sign in."); |
436 } | 440 } |
437 | 441 |
438 string16 AutofillDialogControllerImpl::SaveLocallyText() const { | 442 string16 AutofillDialogControllerImpl::SaveLocallyText() const { |
439 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); | 443 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); |
440 } | 444 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
482 return autocheckout_is_running_; | 486 return autocheckout_is_running_; |
483 } | 487 } |
484 | 488 |
485 bool AutofillDialogControllerImpl::HadAutocheckoutError() const { | 489 bool AutofillDialogControllerImpl::HadAutocheckoutError() const { |
486 return had_autocheckout_error_; | 490 return had_autocheckout_error_; |
487 } | 491 } |
488 | 492 |
489 bool AutofillDialogControllerImpl::IsDialogButtonEnabled( | 493 bool AutofillDialogControllerImpl::IsDialogButtonEnabled( |
490 ui::DialogButton button) const { | 494 ui::DialogButton button) const { |
491 if (button == ui::DIALOG_BUTTON_OK) | 495 if (button == ui::DIALOG_BUTTON_OK) |
492 return !did_submit_; | 496 return !did_submit_ || IsSubmitPausedOn(wallet::VERIFY_CVV); |
497 | |
493 DCHECK_EQ(ui::DIALOG_BUTTON_CANCEL, button); | 498 DCHECK_EQ(ui::DIALOG_BUTTON_CANCEL, button); |
494 // TODO(ahutter): Make it possible for the user to cancel out of the dialog | 499 // TODO(ahutter): Make it possible for the user to cancel out of the dialog |
495 // while Autocheckout is in progress. | 500 // while Autocheckout is in progress. |
496 return had_autocheckout_error_ || !did_submit_; | 501 return had_autocheckout_error_ || |
502 dialog_type_ == DIALOG_TYPE_REQUEST_AUTOCOMPLETE; | |
497 } | 503 } |
498 | 504 |
499 bool AutofillDialogControllerImpl::SectionIsActive(DialogSection section) | 505 bool AutofillDialogControllerImpl::SectionIsActive(DialogSection section) |
500 const { | 506 const { |
507 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) | |
508 return section == SECTION_CC_BILLING; | |
509 | |
501 if (IsPayingWithWallet()) | 510 if (IsPayingWithWallet()) |
502 return section != SECTION_BILLING && section != SECTION_CC; | 511 return section != SECTION_BILLING && section != SECTION_CC; |
503 | 512 |
504 return section != SECTION_CC_BILLING; | 513 return section != SECTION_CC_BILLING; |
505 } | 514 } |
506 | 515 |
507 bool AutofillDialogControllerImpl::HasCompleteWallet() const { | 516 bool AutofillDialogControllerImpl::HasCompleteWallet() const { |
508 return wallet_items_.get() != NULL && | 517 return wallet_items_.get() != NULL && |
509 !wallet_items_->instruments().empty() && | 518 !wallet_items_->instruments().empty() && |
510 !wallet_items_->addresses().empty(); | 519 !wallet_items_->addresses().empty(); |
511 } | 520 } |
512 | 521 |
522 bool AutofillDialogControllerImpl::IsSubmitPausedOn( | |
523 wallet::RequiredAction required_action) const { | |
524 return full_wallet_ && full_wallet_->HasRequiredAction(required_action); | |
525 } | |
526 | |
513 const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( | 527 const DetailInputs& AutofillDialogControllerImpl::RequestedFieldsForSection( |
514 DialogSection section) const { | 528 DialogSection section) const { |
515 switch (section) { | 529 switch (section) { |
516 case SECTION_EMAIL: | 530 case SECTION_EMAIL: |
517 return requested_email_fields_; | 531 return requested_email_fields_; |
518 case SECTION_CC: | 532 case SECTION_CC: |
519 return requested_cc_fields_; | 533 return requested_cc_fields_; |
520 case SECTION_BILLING: | 534 case SECTION_BILLING: |
521 return requested_billing_fields_; | 535 return requested_billing_fields_; |
522 case SECTION_CC_BILLING: | 536 case SECTION_CC_BILLING: |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 case SECTION_SHIPPING: | 600 case SECTION_SHIPPING: |
587 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_SHIPPING); | 601 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECTION_SHIPPING); |
588 default: | 602 default: |
589 NOTREACHED(); | 603 NOTREACHED(); |
590 return string16(); | 604 return string16(); |
591 } | 605 } |
592 } | 606 } |
593 | 607 |
594 string16 AutofillDialogControllerImpl::SuggestionTextForSection( | 608 string16 AutofillDialogControllerImpl::SuggestionTextForSection( |
595 DialogSection section) { | 609 DialogSection section) { |
610 string16 action_text = RequiredActionSuggestionTextForSection(section); | |
611 if (!action_text.empty()) | |
612 return action_text; | |
613 | |
596 // When the user has clicked 'edit', don't show a suggestion (even though | 614 // When the user has clicked 'edit', don't show a suggestion (even though |
597 // there is a profile selected in the model). | 615 // there is a profile selected in the model). |
598 if (section_editing_state_[section]) | 616 if (section_editing_state_[section]) |
599 return string16(); | 617 return string16(); |
600 | 618 |
601 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); | 619 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); |
602 std::string item_key = model->GetItemKeyForCheckedItem(); | 620 std::string item_key = model->GetItemKeyForCheckedItem(); |
603 if (item_key.empty()) | 621 if (item_key.empty()) |
604 return string16(); | 622 return string16(); |
605 | 623 |
606 if (section == SECTION_EMAIL) | 624 if (section == SECTION_EMAIL) |
607 return model->GetLabelAt(model->checked_item()); | 625 return model->GetLabelAt(model->checked_item()); |
608 | 626 |
609 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); | 627 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); |
610 return wrapper->GetDisplayText(); | 628 return wrapper->GetDisplayText(); |
611 } | 629 } |
612 | 630 |
631 string16 AutofillDialogControllerImpl::RequiredActionSuggestionTextForSection( | |
632 DialogSection section) { | |
633 if (section == SECTION_CC_BILLING && IsSubmitPausedOn(wallet::VERIFY_CVV)) { | |
634 const wallet::WalletItems::MaskedInstrument* current_instrument = | |
635 wallet_items_->GetInstrumentById(active_instrument_id_); | |
636 if (current_instrument) | |
637 return current_instrument->TypeAndLastFourDigits(); | |
638 | |
639 DetailOutputMap output; | |
640 view_->GetUserInput(section, &output); | |
641 CreditCard card; | |
642 GetBillingInfoFromOutputs(output, &card, NULL, NULL); | |
643 return card.TypeAndLastFourDigits(); | |
644 } | |
645 | |
646 return string16(); | |
647 } | |
648 | |
613 scoped_ptr<DataModelWrapper> AutofillDialogControllerImpl::CreateWrapper( | 649 scoped_ptr<DataModelWrapper> AutofillDialogControllerImpl::CreateWrapper( |
614 DialogSection section) { | 650 DialogSection section) { |
615 if (IsPayingWithWallet() && full_wallet_) { | 651 if (IsPayingWithWallet() && full_wallet_ && |
652 !IsSubmitPausedOn(wallet::VERIFY_CVV)) { | |
616 if (section == SECTION_CC_BILLING) { | 653 if (section == SECTION_CC_BILLING) { |
617 return scoped_ptr<DataModelWrapper>( | 654 return scoped_ptr<DataModelWrapper>( |
618 new FullWalletBillingWrapper(full_wallet_.get())); | 655 new FullWalletBillingWrapper(full_wallet_.get())); |
619 } | 656 } |
620 if (section == SECTION_SHIPPING) { | 657 if (section == SECTION_SHIPPING) { |
621 return scoped_ptr<DataModelWrapper>( | 658 return scoped_ptr<DataModelWrapper>( |
622 new FullWalletShippingWrapper(full_wallet_.get())); | 659 new FullWalletShippingWrapper(full_wallet_.get())); |
623 } | 660 } |
624 } | 661 } |
625 | 662 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
951 | 988 |
952 if (!invoked_from_same_origin_) { | 989 if (!invoked_from_same_origin_) { |
953 notifications.push_back( | 990 notifications.push_back( |
954 DialogNotification( | 991 DialogNotification( |
955 DialogNotification::SECURITY_WARNING, | 992 DialogNotification::SECURITY_WARNING, |
956 l10n_util::GetStringFUTF16( | 993 l10n_util::GetStringFUTF16( |
957 IDS_AUTOFILL_DIALOG_SITE_WARNING, | 994 IDS_AUTOFILL_DIALOG_SITE_WARNING, |
958 UTF8ToUTF16(source_url_.host())))); | 995 UTF8ToUTF16(source_url_.host())))); |
959 } | 996 } |
960 | 997 |
998 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) { | |
999 notifications.push_back( | |
1000 DialogNotification( | |
1001 DialogNotification::REQUIRED_ACTION, | |
1002 l10n_util::GetStringUTF16( | |
1003 IDS_AUTOFILL_DIALOG_VERIFY_CVV))); | |
1004 } | |
1005 | |
961 if (had_autocheckout_error_) { | 1006 if (had_autocheckout_error_) { |
962 notifications.push_back( | 1007 notifications.push_back( |
963 DialogNotification( | 1008 DialogNotification( |
964 DialogNotification::AUTOCHECKOUT_ERROR, | 1009 DialogNotification::AUTOCHECKOUT_ERROR, |
965 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_ERROR))); | 1010 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_ERROR))); |
966 } | 1011 } |
967 | 1012 |
968 if (account_chooser_model_.had_wallet_error()) { | 1013 if (account_chooser_model_.had_wallet_error()) { |
969 // TODO(dbeam): pass along the Wallet error or remove from the translation. | 1014 // TODO(dbeam): pass along the Wallet error or remove from the translation. |
970 // TODO(dbeam): figure out a way to dismiss this error after a while. | 1015 // TODO(dbeam): figure out a way to dismiss this error after a while. |
(...skipping 30 matching lines...) Expand all Loading... | |
1001 | 1046 |
1002 // If Autocheckout has an error, it's possible that the dialog will be | 1047 // If Autocheckout has an error, it's possible that the dialog will be |
1003 // submitted to start the flow and then cancelled to close the dialog after | 1048 // submitted to start the flow and then cancelled to close the dialog after |
1004 // the error. | 1049 // the error. |
1005 if (!callback_.is_null()) { | 1050 if (!callback_.is_null()) { |
1006 callback_.Run(NULL); | 1051 callback_.Run(NULL); |
1007 callback_ = base::Callback<void(const FormStructure*)>(); | 1052 callback_ = base::Callback<void(const FormStructure*)>(); |
1008 } | 1053 } |
1009 } | 1054 } |
1010 | 1055 |
1011 void AutofillDialogControllerImpl::OnSubmit() { | 1056 void AutofillDialogControllerImpl::OnAccept() { |
1012 did_submit_ = true; | |
1013 metric_logger_.LogDialogUiDuration( | 1057 metric_logger_.LogDialogUiDuration( |
1014 base::Time::Now() - dialog_shown_timestamp_, | 1058 base::Time::Now() - dialog_shown_timestamp_, |
1015 dialog_type_, | 1059 dialog_type_, |
1016 AutofillMetrics::DIALOG_ACCEPTED); | 1060 AutofillMetrics::DIALOG_ACCEPTED); |
1017 | 1061 |
1018 if (dialog_type_ == DIALOG_TYPE_AUTOCHECKOUT) { | 1062 if (dialog_type_ == DIALOG_TYPE_AUTOCHECKOUT) { |
ahutter
2013/03/26 15:27:09
I think this block with the UpdateButtonStrip need
Dan Beam
2013/03/26 18:03:14
I can move this, but if it's pressing it'd probabl
ahutter
2013/03/26 18:08:24
VERIFY_CVV used to just fail Wallet so I think it'
Dan Beam
2013/03/26 19:03:20
Done.
| |
1019 // Stop observing PersonalDataManager to avoid the dialog redrawing while | 1063 // Stop observing PersonalDataManager to avoid the dialog redrawing while |
1020 // in an Autocheckout flow. | 1064 // in an Autocheckout flow. |
1021 GetManager()->RemoveObserver(this); | 1065 GetManager()->RemoveObserver(this); |
1022 autocheckout_is_running_ = true; | 1066 autocheckout_is_running_ = true; |
1023 autocheckout_started_timestamp_ = base::Time::Now(); | 1067 autocheckout_started_timestamp_ = base::Time::Now(); |
1024 view_->UpdateButtonStrip(); | |
1025 } | 1068 } |
1026 | 1069 |
1027 if (IsPayingWithWallet()) | 1070 // Update the button strip after autocheckout may have started. |
ahutter
2013/03/26 15:27:09
nit: Autocheckout
Dan Beam
2013/03/26 18:03:14
Done.
| |
1071 did_submit_ = true; | |
1072 view_->UpdateButtonStrip(); | |
1073 | |
1074 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) { | |
1075 DCHECK(!active_instrument_id_.empty()); | |
1076 GetWalletClient()->AuthenticateInstrument( | |
1077 active_instrument_id_, | |
1078 UTF16ToUTF8(view_->GetCvc()), | |
1079 wallet_items_->obfuscated_gaia_id()); | |
1080 } else if (IsPayingWithWallet()) { | |
1028 SubmitWithWallet(); | 1081 SubmitWithWallet(); |
1029 else | 1082 } else { |
1030 FinishSubmit(); | 1083 FinishSubmit(); |
1084 } | |
1031 } | 1085 } |
1032 | 1086 |
1033 Profile* AutofillDialogControllerImpl::profile() { | 1087 Profile* AutofillDialogControllerImpl::profile() { |
1034 return profile_; | 1088 return profile_; |
1035 } | 1089 } |
1036 | 1090 |
1037 content::WebContents* AutofillDialogControllerImpl::web_contents() { | 1091 content::WebContents* AutofillDialogControllerImpl::web_contents() { |
1038 return contents_; | 1092 return contents_; |
1039 } | 1093 } |
1040 | 1094 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1138 void AutofillDialogControllerImpl::OnDidAuthenticateInstrument(bool success) { | 1192 void AutofillDialogControllerImpl::OnDidAuthenticateInstrument(bool success) { |
1139 // TODO(dbeam): use the returned full wallet. b/8332329 | 1193 // TODO(dbeam): use the returned full wallet. b/8332329 |
1140 if (success) | 1194 if (success) |
1141 GetFullWallet(); | 1195 GetFullWallet(); |
1142 else | 1196 else |
1143 DisableWallet(); | 1197 DisableWallet(); |
1144 } | 1198 } |
1145 | 1199 |
1146 void AutofillDialogControllerImpl::OnDidGetFullWallet( | 1200 void AutofillDialogControllerImpl::OnDidGetFullWallet( |
1147 scoped_ptr<wallet::FullWallet> full_wallet) { | 1201 scoped_ptr<wallet::FullWallet> full_wallet) { |
1148 // TODO(dbeam): handle more required actions. | |
1149 full_wallet_ = full_wallet.Pass(); | 1202 full_wallet_ = full_wallet.Pass(); |
1150 | 1203 |
1151 if (full_wallet_->HasRequiredAction(wallet::VERIFY_CVV)) | 1204 if (full_wallet_->required_actions().empty()) { |
1152 DisableWallet(); | |
1153 else | |
1154 FinishSubmit(); | 1205 FinishSubmit(); |
1206 return; | |
1207 } | |
1208 | |
1209 GenerateSuggestionsModels(); | |
1210 view_->ModelChanged(); | |
1211 view_->UpdateNotificationArea(); | |
1212 view_->UpdateButtonStrip(); | |
1155 } | 1213 } |
1156 | 1214 |
1157 void AutofillDialogControllerImpl::OnDidGetWalletItems( | 1215 void AutofillDialogControllerImpl::OnDidGetWalletItems( |
1158 scoped_ptr<wallet::WalletItems> wallet_items) { | 1216 scoped_ptr<wallet::WalletItems> wallet_items) { |
1159 // TODO(dbeam): verify all items support kCartCurrency? | 1217 // TODO(dbeam): verify all items support kCartCurrency? |
1160 wallet_items_ = wallet_items.Pass(); | 1218 wallet_items_ = wallet_items.Pass(); |
1219 | |
1161 GenerateSuggestionsModels(); | 1220 GenerateSuggestionsModels(); |
1162 view_->ModelChanged(); | 1221 view_->ModelChanged(); |
1163 view_->UpdateAccountChooser(); | 1222 view_->UpdateAccountChooser(); |
1164 view_->UpdateNotificationArea(); | 1223 view_->UpdateNotificationArea(); |
1165 | 1224 |
1166 // On the first successful response, compute the initial user state metric. | 1225 // On the first successful response, compute the initial user state metric. |
1167 if (initial_user_state_ == AutofillMetrics::DIALOG_USER_STATE_UNKNOWN) | 1226 if (initial_user_state_ == AutofillMetrics::DIALOG_USER_STATE_UNKNOWN) |
1168 initial_user_state_ = GetInitialUserState(); | 1227 initial_user_state_ = GetInitialUserState(); |
1169 } | 1228 } |
1170 | 1229 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1291 } | 1350 } |
1292 | 1351 |
1293 bool AutofillDialogControllerImpl::IsPayingWithWallet() const { | 1352 bool AutofillDialogControllerImpl::IsPayingWithWallet() const { |
1294 return account_chooser_model_.WalletIsSelected(); | 1353 return account_chooser_model_.WalletIsSelected(); |
1295 } | 1354 } |
1296 | 1355 |
1297 void AutofillDialogControllerImpl::DisableWallet() { | 1356 void AutofillDialogControllerImpl::DisableWallet() { |
1298 account_chooser_model_.SetHadWalletError(); | 1357 account_chooser_model_.SetHadWalletError(); |
1299 GetWalletClient()->CancelPendingRequests(); | 1358 GetWalletClient()->CancelPendingRequests(); |
1300 wallet_items_.reset(); | 1359 wallet_items_.reset(); |
1360 full_wallet_.reset(); | |
1301 | 1361 |
1302 GenerateSuggestionsModels(); | 1362 GenerateSuggestionsModels(); |
1303 if (view_) { | 1363 if (view_) { |
1304 view_->ModelChanged(); | 1364 view_->ModelChanged(); |
1305 view_->UpdateNotificationArea(); | 1365 view_->UpdateNotificationArea(); |
1306 } | 1366 } |
1307 } | 1367 } |
1308 | 1368 |
1309 bool AutofillDialogControllerImpl::IsFirstRun() const { | 1369 bool AutofillDialogControllerImpl::IsFirstRun() const { |
1310 PrefService* prefs = profile_->GetPrefs(); | 1370 PrefService* prefs = profile_->GetPrefs(); |
1311 return !prefs->HasPrefPath(prefs::kAutofillDialogPayWithoutWallet); | 1371 return !prefs->HasPrefPath(prefs::kAutofillDialogPayWithoutWallet); |
1312 } | 1372 } |
1313 | 1373 |
1314 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { | 1374 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { |
1315 suggested_email_.Reset(); | 1375 suggested_email_.Reset(); |
1316 suggested_cc_.Reset(); | 1376 suggested_cc_.Reset(); |
1317 suggested_billing_.Reset(); | 1377 suggested_billing_.Reset(); |
1318 suggested_cc_billing_.Reset(); | 1378 suggested_cc_billing_.Reset(); |
1319 suggested_shipping_.Reset(); | 1379 suggested_shipping_.Reset(); |
1320 | 1380 |
1321 if (IsPayingWithWallet()) { | 1381 if (IsPayingWithWallet()) { |
1322 if (wallet_items_.get()) { | 1382 if (wallet_items_) { |
1323 // TODO(estade): seems we need to hardcode the email address. | 1383 // TODO(estade): seems we need to hardcode the email address. |
1324 | 1384 |
1325 const std::vector<wallet::Address*>& addresses = | 1385 const std::vector<wallet::Address*>& addresses = |
1326 wallet_items_->addresses(); | 1386 wallet_items_->addresses(); |
1327 for (size_t i = 0; i < addresses.size(); ++i) { | 1387 for (size_t i = 0; i < addresses.size(); ++i) { |
1328 // TODO(dbeam): respect wallet_items_->default_instrument_id(). | 1388 // TODO(dbeam): respect wallet_items_->default_instrument_id(). |
1329 suggested_shipping_.AddKeyedItemWithSublabel( | 1389 suggested_shipping_.AddKeyedItemWithSublabel( |
1330 base::IntToString(i), | 1390 base::IntToString(i), |
1331 addresses[i]->DisplayName(), | 1391 addresses[i]->DisplayName(), |
1332 addresses[i]->DisplayNameDetail()); | 1392 addresses[i]->DisplayNameDetail()); |
1333 } | 1393 } |
1334 | 1394 |
1335 const std::vector<wallet::WalletItems::MaskedInstrument*>& instruments = | 1395 if (!IsSubmitPausedOn(wallet::VERIFY_CVV)) { |
1336 wallet_items_->instruments(); | 1396 const std::vector<wallet::WalletItems::MaskedInstrument*>& instruments = |
1337 for (size_t i = 0; i < instruments.size(); ++i) { | 1397 wallet_items_->instruments(); |
1338 // TODO(dbeam): respect wallet_items_->default_address_id(). | 1398 for (size_t i = 0; i < instruments.size(); ++i) { |
1339 suggested_cc_billing_.AddKeyedItemWithSublabelAndIcon( | 1399 // TODO(dbeam): respect wallet_items_->default_address_id(). |
1340 base::IntToString(i), | 1400 suggested_cc_billing_.AddKeyedItemWithSublabelAndIcon( |
1341 instruments[i]->DisplayName(), | 1401 base::IntToString(i), |
1342 instruments[i]->DisplayNameDetail(), | 1402 instruments[i]->DisplayName(), |
1343 instruments[i]->CardIcon()); | 1403 instruments[i]->DisplayNameDetail(), |
1404 instruments[i]->CardIcon()); | |
1405 } | |
1344 } | 1406 } |
1345 } | 1407 } |
1346 | 1408 |
1347 suggested_cc_billing_.AddKeyedItem( | 1409 if (!IsSubmitPausedOn(wallet::VERIFY_CVV)) { |
1348 std::string(), | 1410 suggested_cc_billing_.AddKeyedItem( |
1349 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_BILLING_DETAILS)); | 1411 std::string(), |
1412 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_BILLING_DETAILS)); | |
1413 } | |
1350 } else { | 1414 } else { |
1351 PersonalDataManager* manager = GetManager(); | 1415 PersonalDataManager* manager = GetManager(); |
1352 const std::vector<CreditCard*>& cards = manager->credit_cards(); | 1416 const std::vector<CreditCard*>& cards = manager->credit_cards(); |
1353 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1417 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
1354 for (size_t i = 0; i < cards.size(); ++i) { | 1418 for (size_t i = 0; i < cards.size(); ++i) { |
1355 suggested_cc_.AddKeyedItemWithIcon( | 1419 suggested_cc_.AddKeyedItemWithIcon( |
1356 cards[i]->guid(), | 1420 cards[i]->guid(), |
1357 cards[i]->Label(), | 1421 cards[i]->Label(), |
1358 rb.GetImageNamed(cards[i]->IconResourceId())); | 1422 rb.GetImageNamed(cards[i]->IconResourceId())); |
1359 } | 1423 } |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1697 wallet::Cart(base::IntToString(kCartMax), kCartCurrency), | 1761 wallet::Cart(base::IntToString(kCartMax), kCartCurrency), |
1698 wallet_items_->google_transaction_id(), | 1762 wallet_items_->google_transaction_id(), |
1699 std::vector<wallet::WalletClient::RiskCapability>())); | 1763 std::vector<wallet::WalletClient::RiskCapability>())); |
1700 } | 1764 } |
1701 | 1765 |
1702 void AutofillDialogControllerImpl::FinishSubmit() { | 1766 void AutofillDialogControllerImpl::FinishSubmit() { |
1703 FillOutputForSection(SECTION_EMAIL); | 1767 FillOutputForSection(SECTION_EMAIL); |
1704 FillOutputForSection(SECTION_CC); | 1768 FillOutputForSection(SECTION_CC); |
1705 FillOutputForSection(SECTION_BILLING); | 1769 FillOutputForSection(SECTION_BILLING); |
1706 FillOutputForSection(SECTION_CC_BILLING); | 1770 FillOutputForSection(SECTION_CC_BILLING); |
1771 | |
1707 if (ShouldUseBillingForShipping()) { | 1772 if (ShouldUseBillingForShipping()) { |
1708 FillOutputForSectionWithComparator( | 1773 FillOutputForSectionWithComparator( |
1709 SECTION_BILLING, | 1774 SECTION_BILLING, |
1710 base::Bind(DetailInputMatchesShippingField)); | 1775 base::Bind(DetailInputMatchesShippingField)); |
1711 FillOutputForSectionWithComparator( | 1776 FillOutputForSectionWithComparator( |
1712 SECTION_CC, | 1777 SECTION_CC, |
1713 base::Bind(DetailInputMatchesShippingField)); | 1778 base::Bind(DetailInputMatchesShippingField)); |
1714 } else { | 1779 } else { |
1715 FillOutputForSection(SECTION_SHIPPING); | 1780 FillOutputForSection(SECTION_SHIPPING); |
1716 } | 1781 } |
1782 | |
1717 callback_.Run(&form_structure_); | 1783 callback_.Run(&form_structure_); |
1718 callback_ = base::Callback<void(const FormStructure*)>(); | 1784 callback_ = base::Callback<void(const FormStructure*)>(); |
1719 | 1785 |
1720 if (dialog_type_ == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) { | 1786 if (dialog_type_ == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) { |
1721 // This may delete us. | 1787 // This may delete us. |
1722 Hide(); | 1788 Hide(); |
1723 } | 1789 } |
1724 } | 1790 } |
1725 | 1791 |
1726 AutofillMetrics::DialogInitialUserStateMetric | 1792 AutofillMetrics::DialogInitialUserStateMetric |
(...skipping 20 matching lines...) Expand all Loading... | |
1747 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; | 1813 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; |
1748 } | 1814 } |
1749 | 1815 |
1750 // Has Wallet items. | 1816 // Has Wallet items. |
1751 return has_autofill_profiles ? | 1817 return has_autofill_profiles ? |
1752 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : | 1818 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : |
1753 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; | 1819 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; |
1754 } | 1820 } |
1755 | 1821 |
1756 } // namespace autofill | 1822 } // namespace autofill |
OLD | NEW |