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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 3429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3440 return has_autofill_profiles ? | 3440 return has_autofill_profiles ? |
3441 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : | 3441 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : |
3442 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; | 3442 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; |
3443 } | 3443 } |
3444 | 3444 |
3445 void AutofillDialogControllerImpl::MaybeShowCreditCardBubble() { | 3445 void AutofillDialogControllerImpl::MaybeShowCreditCardBubble() { |
3446 if (!data_was_passed_back_) | 3446 if (!data_was_passed_back_) |
3447 return; | 3447 return; |
3448 | 3448 |
3449 if (newly_saved_card_) { | 3449 if (newly_saved_card_) { |
| 3450 scoped_ptr<AutofillProfile> billing_profile; |
| 3451 |
| 3452 SuggestionsMenuModel* billing_model = |
| 3453 SuggestionsMenuModelForSection(SECTION_BILLING); |
| 3454 std::string item_key = billing_model->GetItemKeyForCheckedItem(); |
| 3455 if (IsASuggestionItemKey(item_key) && |
| 3456 !IsManuallyEditingSection(SECTION_BILLING)) { |
| 3457 // Just snag the currently suggested profile. |
| 3458 AutofillProfile* profile = GetManager()->GetProfileByGUID(item_key); |
| 3459 billing_profile.reset(new AutofillProfile(*profile)); |
| 3460 } else { |
| 3461 // Scrape the view as the user's entering or updating information. |
| 3462 DetailOutputMap outputs; |
| 3463 view_->GetUserInput(SECTION_BILLING, &outputs); |
| 3464 billing_profile.reset(new AutofillProfile); |
| 3465 FillFormGroupFromOutputs(outputs, billing_profile.get()); |
| 3466 } |
| 3467 |
| 3468 // The bubble also needs the associated email address. |
| 3469 billing_profile->SetRawInfo( |
| 3470 EMAIL_ADDRESS, |
| 3471 GetValueFromSection(SECTION_EMAIL, EMAIL_ADDRESS)); |
| 3472 |
3450 AutofillCreditCardBubbleController::ShowNewCardSavedBubble( | 3473 AutofillCreditCardBubbleController::ShowNewCardSavedBubble( |
3451 web_contents(), newly_saved_card_->TypeAndLastFourDigits()); | 3474 web_contents(), newly_saved_card_.Pass(), billing_profile.Pass()); |
3452 return; | 3475 return; |
3453 } | 3476 } |
3454 | 3477 |
3455 if (!full_wallet_ || !full_wallet_->billing_address()) | 3478 if (!full_wallet_ || !full_wallet_->billing_address()) |
3456 return; | 3479 return; |
3457 | 3480 |
3458 // Don't show GeneratedCardBubble if Autocheckout failed. | 3481 // Don't show GeneratedCardBubble if Autocheckout failed. |
3459 if (GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT && | 3482 if (GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT && |
3460 autocheckout_state_ != AUTOCHECKOUT_SUCCESS) { | 3483 autocheckout_state_ != AUTOCHECKOUT_SUCCESS) { |
3461 return; | 3484 return; |
3462 } | 3485 } |
3463 | 3486 |
3464 base::string16 backing_last_four; | 3487 base::string16 backing_last_four; |
3465 if (ActiveInstrument()) { | 3488 if (ActiveInstrument()) { |
3466 backing_last_four = ActiveInstrument()->TypeAndLastFourDigits(); | 3489 backing_last_four = ActiveInstrument()->TypeAndLastFourDigits(); |
3467 } else { | 3490 } else { |
3468 DetailOutputMap output; | 3491 DetailOutputMap output; |
3469 view_->GetUserInput(SECTION_CC_BILLING, &output); | 3492 view_->GetUserInput(SECTION_CC_BILLING, &output); |
3470 CreditCard card; | 3493 CreditCard card; |
3471 GetBillingInfoFromOutputs(output, &card, NULL, NULL); | 3494 GetBillingInfoFromOutputs(output, &card, NULL, NULL); |
3472 backing_last_four = card.TypeAndLastFourDigits(); | 3495 backing_last_four = card.TypeAndLastFourDigits(); |
3473 } | 3496 } |
3474 AutofillCreditCardBubbleController::ShowGeneratedCardUI( | 3497 AutofillCreditCardBubbleController::ShowGeneratedCardBubble( |
3475 web_contents(), backing_last_four, full_wallet_->TypeAndLastFourDigits()); | 3498 web_contents(), backing_last_four, full_wallet_->TypeAndLastFourDigits()); |
3476 } | 3499 } |
3477 | 3500 |
3478 } // namespace autofill | 3501 } // namespace autofill |
OLD | NEW |