| 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 } // namespace | 435 } // namespace |
| 436 | 436 |
| 437 AutofillDialogViewDelegate::~AutofillDialogViewDelegate() {} | 437 AutofillDialogViewDelegate::~AutofillDialogViewDelegate() {} |
| 438 | 438 |
| 439 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { | 439 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { |
| 440 if (popup_controller_) | 440 if (popup_controller_) |
| 441 popup_controller_->Hide(); | 441 popup_controller_->Hide(); |
| 442 | 442 |
| 443 GetMetricLogger().LogDialogInitialUserState( | 443 GetMetricLogger().LogDialogInitialUserState( |
| 444 GetDialogType(), initial_user_state_); | 444 GetDialogType(), initial_user_state_); |
| 445 | |
| 446 if (deemphasized_render_view_ && web_contents()) { | |
| 447 web_contents()->GetRenderViewHost()->Send( | |
| 448 new ChromeViewMsg_SetVisuallyDeemphasized( | |
| 449 web_contents()->GetRenderViewHost()->GetRoutingID(), false)); | |
| 450 } | |
| 451 } | 445 } |
| 452 | 446 |
| 453 // static | 447 // static |
| 454 base::WeakPtr<AutofillDialogControllerImpl> | 448 base::WeakPtr<AutofillDialogControllerImpl> |
| 455 AutofillDialogControllerImpl::Create( | 449 AutofillDialogControllerImpl::Create( |
| 456 content::WebContents* contents, | 450 content::WebContents* contents, |
| 457 const FormData& form_structure, | 451 const FormData& form_structure, |
| 458 const GURL& source_url, | 452 const GURL& source_url, |
| 459 const DialogType dialog_type, | 453 const DialogType dialog_type, |
| 460 const base::Callback<void(const FormStructure*, | 454 const base::Callback<void(const FormStructure*, |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 // If the user switched away from this tab and then switched back, reload the | 597 // If the user switched away from this tab and then switched back, reload the |
| 604 // Wallet items, in case they've changed. | 598 // Wallet items, in case they've changed. |
| 605 int seconds_elapsed_since_last_refresh = | 599 int seconds_elapsed_since_last_refresh = |
| 606 (base::TimeTicks::Now() - last_wallet_items_fetch_timestamp_).InSeconds(); | 600 (base::TimeTicks::Now() - last_wallet_items_fetch_timestamp_).InSeconds(); |
| 607 if (IsPayingWithWallet() && wallet_items_ && | 601 if (IsPayingWithWallet() && wallet_items_ && |
| 608 seconds_elapsed_since_last_refresh >= kWalletItemsRefreshRateSeconds) { | 602 seconds_elapsed_since_last_refresh >= kWalletItemsRefreshRateSeconds) { |
| 609 GetWalletItems(); | 603 GetWalletItems(); |
| 610 } | 604 } |
| 611 } | 605 } |
| 612 | 606 |
| 613 void AutofillDialogControllerImpl::OnAutocheckoutError() { | |
| 614 DCHECK_EQ(AUTOCHECKOUT_IN_PROGRESS, autocheckout_state_); | |
| 615 GetMetricLogger().LogAutocheckoutDuration( | |
| 616 base::Time::Now() - autocheckout_started_timestamp_, | |
| 617 AutofillMetrics::AUTOCHECKOUT_FAILED); | |
| 618 SetAutocheckoutState(AUTOCHECKOUT_ERROR); | |
| 619 autocheckout_started_timestamp_ = base::Time(); | |
| 620 } | |
| 621 | |
| 622 void AutofillDialogControllerImpl::OnAutocheckoutSuccess() { | |
| 623 DCHECK_EQ(AUTOCHECKOUT_IN_PROGRESS, autocheckout_state_); | |
| 624 GetMetricLogger().LogAutocheckoutDuration( | |
| 625 base::Time::Now() - autocheckout_started_timestamp_, | |
| 626 AutofillMetrics::AUTOCHECKOUT_SUCCEEDED); | |
| 627 SetAutocheckoutState(AUTOCHECKOUT_SUCCESS); | |
| 628 autocheckout_started_timestamp_ = base::Time(); | |
| 629 } | |
| 630 | |
| 631 | |
| 632 TestableAutofillDialogView* AutofillDialogControllerImpl::GetTestableView() { | 607 TestableAutofillDialogView* AutofillDialogControllerImpl::GetTestableView() { |
| 633 return view_ ? view_->GetTestableView() : NULL; | 608 return view_ ? view_->GetTestableView() : NULL; |
| 634 } | 609 } |
| 635 | 610 |
| 636 void AutofillDialogControllerImpl::AddAutocheckoutStep( | |
| 637 AutocheckoutStepType step_type) { | |
| 638 for (size_t i = 0; i < steps_.size(); ++i) { | |
| 639 if (steps_[i].type() == step_type) | |
| 640 return; | |
| 641 } | |
| 642 steps_.push_back( | |
| 643 DialogAutocheckoutStep(step_type, AUTOCHECKOUT_STEP_UNSTARTED)); | |
| 644 } | |
| 645 | |
| 646 void AutofillDialogControllerImpl::UpdateAutocheckoutStep( | |
| 647 AutocheckoutStepType step_type, | |
| 648 AutocheckoutStepStatus step_status) { | |
| 649 ScopedViewUpdates updates(view_.get()); | |
| 650 | |
| 651 int total_steps = 0; | |
| 652 int completed_steps = 0; | |
| 653 for (size_t i = 0; i < steps_.size(); ++i) { | |
| 654 ++total_steps; | |
| 655 if (steps_[i].status() == AUTOCHECKOUT_STEP_COMPLETED) | |
| 656 ++completed_steps; | |
| 657 if (steps_[i].type() == step_type && steps_[i].status() != step_status) | |
| 658 steps_[i] = DialogAutocheckoutStep(step_type, step_status); | |
| 659 } | |
| 660 if (view_) { | |
| 661 view_->UpdateAutocheckoutStepsArea(); | |
| 662 view_->UpdateProgressBar(1.0 * completed_steps / total_steps); | |
| 663 } | |
| 664 } | |
| 665 | |
| 666 std::vector<DialogAutocheckoutStep> | |
| 667 AutofillDialogControllerImpl::CurrentAutocheckoutSteps() const { | |
| 668 if (autocheckout_state_ != AUTOCHECKOUT_NOT_STARTED) | |
| 669 return steps_; | |
| 670 | |
| 671 std::vector<DialogAutocheckoutStep> empty_steps; | |
| 672 return empty_steps; | |
| 673 } | |
| 674 | |
| 675 //////////////////////////////////////////////////////////////////////////////// | 611 //////////////////////////////////////////////////////////////////////////////// |
| 676 // AutofillDialogViewDelegate implementation. | 612 // AutofillDialogViewDelegate implementation. |
| 677 | 613 |
| 678 string16 AutofillDialogControllerImpl::DialogTitle() const { | 614 string16 AutofillDialogControllerImpl::DialogTitle() const { |
| 679 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_TITLE); | 615 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_TITLE); |
| 680 } | 616 } |
| 681 | 617 |
| 682 string16 AutofillDialogControllerImpl::EditSuggestionText() const { | 618 string16 AutofillDialogControllerImpl::EditSuggestionText() const { |
| 683 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_EDIT); | 619 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_EDIT); |
| 684 } | 620 } |
| 685 | 621 |
| 686 string16 AutofillDialogControllerImpl::CancelButtonText() const { | 622 string16 AutofillDialogControllerImpl::CancelButtonText() const { |
| 687 return l10n_util::GetStringUTF16(IDS_CANCEL); | 623 return l10n_util::GetStringUTF16(IDS_CANCEL); |
| 688 } | 624 } |
| 689 | 625 |
| 690 string16 AutofillDialogControllerImpl::ConfirmButtonText() const { | 626 string16 AutofillDialogControllerImpl::ConfirmButtonText() const { |
| 691 if (autocheckout_state_ == AUTOCHECKOUT_ERROR) | |
| 692 return l10n_util::GetStringUTF16(IDS_OK); | |
| 693 if (autocheckout_state_ == AUTOCHECKOUT_SUCCESS) | |
| 694 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_CONTINUE_BUTTON); | |
| 695 | |
| 696 return l10n_util::GetStringUTF16(IsSubmitPausedOn(wallet::VERIFY_CVV) ? | 627 return l10n_util::GetStringUTF16(IsSubmitPausedOn(wallet::VERIFY_CVV) ? |
| 697 IDS_AUTOFILL_DIALOG_VERIFY_BUTTON : IDS_AUTOFILL_DIALOG_SUBMIT_BUTTON); | 628 IDS_AUTOFILL_DIALOG_VERIFY_BUTTON : IDS_AUTOFILL_DIALOG_SUBMIT_BUTTON); |
| 698 } | 629 } |
| 699 | 630 |
| 700 string16 AutofillDialogControllerImpl::SaveLocallyText() const { | 631 string16 AutofillDialogControllerImpl::SaveLocallyText() const { |
| 701 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); | 632 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); |
| 702 } | 633 } |
| 703 | 634 |
| 704 string16 AutofillDialogControllerImpl::SaveLocallyTooltip() const { | 635 string16 AutofillDialogControllerImpl::SaveLocallyTooltip() const { |
| 705 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_TOOLTIP); | 636 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_TOOLTIP); |
| 706 } | 637 } |
| 707 | 638 |
| 708 string16 AutofillDialogControllerImpl::LegalDocumentsText() { | 639 string16 AutofillDialogControllerImpl::LegalDocumentsText() { |
| 709 if (!IsPayingWithWallet() || autocheckout_state_ != AUTOCHECKOUT_NOT_STARTED) | 640 if (!IsPayingWithWallet()) |
| 710 return string16(); | 641 return string16(); |
| 711 | 642 |
| 712 EnsureLegalDocumentsText(); | 643 EnsureLegalDocumentsText(); |
| 713 return legal_documents_text_; | 644 return legal_documents_text_; |
| 714 } | 645 } |
| 715 | 646 |
| 716 DialogSignedInState AutofillDialogControllerImpl::SignedInState() const { | 647 DialogSignedInState AutofillDialogControllerImpl::SignedInState() const { |
| 717 if (account_chooser_model_.HadWalletError()) | 648 if (account_chooser_model_.HadWalletError()) |
| 718 return SIGN_IN_DISABLED; | 649 return SIGN_IN_DISABLED; |
| 719 | 650 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 748 string16 AutofillDialogControllerImpl::SignInLinkText() const { | 679 string16 AutofillDialogControllerImpl::SignInLinkText() const { |
| 749 return l10n_util::GetStringUTF16( | 680 return l10n_util::GetStringUTF16( |
| 750 signin_registrar_.IsEmpty() ? IDS_AUTOFILL_DIALOG_SIGN_IN : | 681 signin_registrar_.IsEmpty() ? IDS_AUTOFILL_DIALOG_SIGN_IN : |
| 751 IDS_AUTOFILL_DIALOG_CANCEL_SIGN_IN); | 682 IDS_AUTOFILL_DIALOG_CANCEL_SIGN_IN); |
| 752 } | 683 } |
| 753 | 684 |
| 754 bool AutofillDialogControllerImpl::ShouldOfferToSaveInChrome() const { | 685 bool AutofillDialogControllerImpl::ShouldOfferToSaveInChrome() const { |
| 755 return !IsPayingWithWallet() && | 686 return !IsPayingWithWallet() && |
| 756 !profile_->IsOffTheRecord() && | 687 !profile_->IsOffTheRecord() && |
| 757 IsManuallyEditingAnySection() && | 688 IsManuallyEditingAnySection() && |
| 758 ShouldShowDetailArea() && | |
| 759 !ShouldShowSpinner(); | 689 !ShouldShowSpinner(); |
| 760 } | 690 } |
| 761 | 691 |
| 762 int AutofillDialogControllerImpl::GetDialogButtons() const { | 692 int AutofillDialogControllerImpl::GetDialogButtons() const { |
| 763 if (autocheckout_state_ == AUTOCHECKOUT_IN_PROGRESS) | 693 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; |
| 764 return ui::DIALOG_BUTTON_CANCEL; | |
| 765 if (autocheckout_state_ == AUTOCHECKOUT_NOT_STARTED) | |
| 766 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; | |
| 767 return ui::DIALOG_BUTTON_OK; | |
| 768 } | 694 } |
| 769 | 695 |
| 770 bool AutofillDialogControllerImpl::IsDialogButtonEnabled( | 696 bool AutofillDialogControllerImpl::IsDialogButtonEnabled( |
| 771 ui::DialogButton button) const { | 697 ui::DialogButton button) const { |
| 772 if (button == ui::DIALOG_BUTTON_OK) { | 698 if (button == ui::DIALOG_BUTTON_OK) { |
| 773 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) | 699 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) |
| 774 return true; | 700 return true; |
| 775 | 701 |
| 776 if (ShouldShowSpinner()) | 702 if (ShouldShowSpinner() || is_submitting_) |
| 777 return false; | 703 return false; |
| 778 | 704 |
| 779 if (is_submitting_) { | |
| 780 return autocheckout_state_ == AUTOCHECKOUT_SUCCESS || | |
| 781 autocheckout_state_ == AUTOCHECKOUT_ERROR; | |
| 782 } | |
| 783 | |
| 784 return true; | 705 return true; |
| 785 } | 706 } |
| 786 | 707 |
| 787 DCHECK_EQ(ui::DIALOG_BUTTON_CANCEL, button); | 708 DCHECK_EQ(ui::DIALOG_BUTTON_CANCEL, button); |
| 788 return !is_submitting_ || IsSubmitPausedOn(wallet::VERIFY_CVV); | 709 return !is_submitting_ || IsSubmitPausedOn(wallet::VERIFY_CVV); |
| 789 } | 710 } |
| 790 | 711 |
| 791 DialogOverlayState AutofillDialogControllerImpl::GetDialogOverlay() const { | 712 DialogOverlayState AutofillDialogControllerImpl::GetDialogOverlay() const { |
| 792 bool show_wallet_interstitial = IsPayingWithWallet() && is_submitting_ && | 713 bool show_wallet_interstitial = IsPayingWithWallet() && is_submitting_ && |
| 793 !IsSubmitPausedOn(wallet::VERIFY_CVV) && | 714 !IsSubmitPausedOn(wallet::VERIFY_CVV) && |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 } | 1135 } |
| 1215 | 1136 |
| 1216 gfx::Image icon; | 1137 gfx::Image icon; |
| 1217 account_chooser_model_.GetIconAt( | 1138 account_chooser_model_.GetIconAt( |
| 1218 account_chooser_model_.GetIndexOfCommandId( | 1139 account_chooser_model_.GetIndexOfCommandId( |
| 1219 account_chooser_model_.checked_item()), | 1140 account_chooser_model_.checked_item()), |
| 1220 &icon); | 1141 &icon); |
| 1221 return icon; | 1142 return icon; |
| 1222 } | 1143 } |
| 1223 | 1144 |
| 1224 bool AutofillDialogControllerImpl::ShouldShowDetailArea() const { | |
| 1225 // Hide the detail area when Autocheckout is running or there was an error (as | |
| 1226 // there's nothing they can do after an error but cancel). | |
| 1227 return autocheckout_state_ == AUTOCHECKOUT_NOT_STARTED; | |
| 1228 } | |
| 1229 | |
| 1230 bool AutofillDialogControllerImpl::ShouldShowProgressBar() const { | |
| 1231 // Show the progress bar while Autocheckout is running but hide it on errors, | |
| 1232 // as there's no use leaving it up if the flow has failed. | |
| 1233 return autocheckout_state_ == AUTOCHECKOUT_IN_PROGRESS; | |
| 1234 } | |
| 1235 | |
| 1236 gfx::Image AutofillDialogControllerImpl::ButtonStripImage() const { | 1145 gfx::Image AutofillDialogControllerImpl::ButtonStripImage() const { |
| 1237 if (ShouldShowDetailArea() && IsPayingWithWallet()) { | 1146 if (IsPayingWithWallet()) { |
| 1238 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 1147 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 1239 IDR_WALLET_LOGO); | 1148 IDR_WALLET_LOGO); |
| 1240 } | 1149 } |
| 1241 | 1150 |
| 1242 return gfx::Image(); | 1151 return gfx::Image(); |
| 1243 } | 1152 } |
| 1244 | 1153 |
| 1245 string16 AutofillDialogControllerImpl::LabelForSection(DialogSection section) | 1154 string16 AutofillDialogControllerImpl::LabelForSection(DialogSection section) |
| 1246 const { | 1155 const { |
| 1247 switch (section) { | 1156 switch (section) { |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1788 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 1697 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 1789 IDR_PRODUCT_LOGO_NAME_48); | 1698 IDR_PRODUCT_LOGO_NAME_48); |
| 1790 } | 1699 } |
| 1791 | 1700 |
| 1792 return gfx::Image(); | 1701 return gfx::Image(); |
| 1793 } | 1702 } |
| 1794 | 1703 |
| 1795 void AutofillDialogControllerImpl::ViewClosed() { | 1704 void AutofillDialogControllerImpl::ViewClosed() { |
| 1796 GetManager()->RemoveObserver(this); | 1705 GetManager()->RemoveObserver(this); |
| 1797 | 1706 |
| 1798 // TODO(ahutter): Once a user can cancel Autocheckout mid-flow, log that | |
| 1799 // metric here. | |
| 1800 | |
| 1801 // Called from here rather than in ~AutofillDialogControllerImpl as this | 1707 // Called from here rather than in ~AutofillDialogControllerImpl as this |
| 1802 // relies on virtual methods that change to their base class in the dtor. | 1708 // relies on virtual methods that change to their base class in the dtor. |
| 1803 MaybeShowCreditCardBubble(); | 1709 MaybeShowCreditCardBubble(); |
| 1804 | 1710 |
| 1805 delete this; | 1711 delete this; |
| 1806 } | 1712 } |
| 1807 | 1713 |
| 1808 std::vector<DialogNotification> AutofillDialogControllerImpl:: | 1714 std::vector<DialogNotification> AutofillDialogControllerImpl:: |
| 1809 CurrentNotifications() { | 1715 CurrentNotifications() { |
| 1810 std::vector<DialogNotification> notifications; | 1716 std::vector<DialogNotification> notifications; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1836 IDS_AUTOFILL_DIALOG_COMPLETE_WITHOUT_WALLET, | 1742 IDS_AUTOFILL_DIALOG_COMPLETE_WITHOUT_WALLET, |
| 1837 account_chooser_model_.wallet_error_message()))); | 1743 account_chooser_model_.wallet_error_message()))); |
| 1838 } | 1744 } |
| 1839 | 1745 |
| 1840 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) { | 1746 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) { |
| 1841 notifications.push_back(DialogNotification( | 1747 notifications.push_back(DialogNotification( |
| 1842 DialogNotification::REQUIRED_ACTION, | 1748 DialogNotification::REQUIRED_ACTION, |
| 1843 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV))); | 1749 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV))); |
| 1844 } | 1750 } |
| 1845 | 1751 |
| 1846 if (autocheckout_state_ == AUTOCHECKOUT_ERROR) { | |
| 1847 notifications.push_back(DialogNotification( | |
| 1848 DialogNotification::AUTOCHECKOUT_ERROR, | |
| 1849 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_ERROR))); | |
| 1850 } | |
| 1851 | |
| 1852 if (autocheckout_state_ == AUTOCHECKOUT_SUCCESS) { | |
| 1853 notifications.push_back(DialogNotification( | |
| 1854 DialogNotification::AUTOCHECKOUT_SUCCESS, | |
| 1855 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_AUTOCHECKOUT_SUCCESS))); | |
| 1856 } | |
| 1857 | |
| 1858 if (!wallet_server_validation_recoverable_) { | 1752 if (!wallet_server_validation_recoverable_) { |
| 1859 notifications.push_back(DialogNotification( | 1753 notifications.push_back(DialogNotification( |
| 1860 DialogNotification::REQUIRED_ACTION, | 1754 DialogNotification::REQUIRED_ACTION, |
| 1861 l10n_util::GetStringUTF16( | 1755 l10n_util::GetStringUTF16( |
| 1862 IDS_AUTOFILL_DIALOG_FAILED_TO_SAVE_WALLET_DATA))); | 1756 IDS_AUTOFILL_DIALOG_FAILED_TO_SAVE_WALLET_DATA))); |
| 1863 } | 1757 } |
| 1864 | 1758 |
| 1865 if (choose_another_instrument_or_address_) { | 1759 if (choose_another_instrument_or_address_) { |
| 1866 notifications.push_back(DialogNotification( | 1760 notifications.push_back(DialogNotification( |
| 1867 DialogNotification::REQUIRED_ACTION, | 1761 DialogNotification::REQUIRED_ACTION, |
| 1868 l10n_util::GetStringUTF16( | 1762 l10n_util::GetStringUTF16( |
| 1869 IDS_AUTOFILL_DIALOG_CHOOSE_DIFFERENT_WALLET_INSTRUMENT))); | 1763 IDS_AUTOFILL_DIALOG_CHOOSE_DIFFERENT_WALLET_INSTRUMENT))); |
| 1870 } | 1764 } |
| 1871 | 1765 |
| 1872 if (should_show_wallet_promo_ && ShouldShowDetailArea() && | 1766 if (should_show_wallet_promo_ && notifications.empty()) { |
| 1873 notifications.empty()) { | |
| 1874 if (IsPayingWithWallet() && HasCompleteWallet()) { | 1767 if (IsPayingWithWallet() && HasCompleteWallet()) { |
| 1875 notifications.push_back(DialogNotification( | 1768 notifications.push_back(DialogNotification( |
| 1876 DialogNotification::EXPLANATORY_MESSAGE, | 1769 DialogNotification::EXPLANATORY_MESSAGE, |
| 1877 l10n_util::GetStringUTF16( | 1770 l10n_util::GetStringUTF16( |
| 1878 IDS_AUTOFILL_DIALOG_DETAILS_FROM_WALLET))); | 1771 IDS_AUTOFILL_DIALOG_DETAILS_FROM_WALLET))); |
| 1879 } else if ((IsPayingWithWallet() && !HasCompleteWallet()) || | 1772 } else if ((IsPayingWithWallet() && !HasCompleteWallet()) || |
| 1880 has_shown_wallet_usage_confirmation_) { | 1773 has_shown_wallet_usage_confirmation_) { |
| 1881 DialogNotification notification( | 1774 DialogNotification notification( |
| 1882 DialogNotification::WALLET_USAGE_CONFIRMATION, | 1775 DialogNotification::WALLET_USAGE_CONFIRMATION, |
| 1883 l10n_util::GetStringUTF16( | 1776 l10n_util::GetStringUTF16( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1939 void AutofillDialogControllerImpl::OverlayButtonPressed() { | 1832 void AutofillDialogControllerImpl::OverlayButtonPressed() { |
| 1940 DCHECK(is_submitting_); | 1833 DCHECK(is_submitting_); |
| 1941 DCHECK(full_wallet_); | 1834 DCHECK(full_wallet_); |
| 1942 profile_->GetPrefs()->SetBoolean(::prefs::kAutofillDialogHasPaidWithWallet, | 1835 profile_->GetPrefs()->SetBoolean(::prefs::kAutofillDialogHasPaidWithWallet, |
| 1943 true); | 1836 true); |
| 1944 FinishSubmit(); | 1837 FinishSubmit(); |
| 1945 } | 1838 } |
| 1946 | 1839 |
| 1947 bool AutofillDialogControllerImpl::OnCancel() { | 1840 bool AutofillDialogControllerImpl::OnCancel() { |
| 1948 HidePopup(); | 1841 HidePopup(); |
| 1949 if (autocheckout_state_ == AUTOCHECKOUT_NOT_STARTED && !is_submitting_) | 1842 if (!is_submitting_) |
| 1950 LogOnCancelMetrics(); | 1843 LogOnCancelMetrics(); |
| 1951 if (autocheckout_state_ == AUTOCHECKOUT_IN_PROGRESS) { | |
| 1952 GetMetricLogger().LogAutocheckoutDuration( | |
| 1953 base::Time::Now() - autocheckout_started_timestamp_, | |
| 1954 AutofillMetrics::AUTOCHECKOUT_CANCELLED); | |
| 1955 } | |
| 1956 callback_.Run(NULL, std::string()); | 1844 callback_.Run(NULL, std::string()); |
| 1957 return true; | 1845 return true; |
| 1958 } | 1846 } |
| 1959 | 1847 |
| 1960 bool AutofillDialogControllerImpl::OnAccept() { | 1848 bool AutofillDialogControllerImpl::OnAccept() { |
| 1961 // If autocheckout has already started, the only thing left to do is to | |
| 1962 // close the dialog. | |
| 1963 if (autocheckout_state_ != AUTOCHECKOUT_NOT_STARTED) | |
| 1964 return true; | |
| 1965 | |
| 1966 choose_another_instrument_or_address_ = false; | 1849 choose_another_instrument_or_address_ = false; |
| 1967 wallet_server_validation_recoverable_ = true; | 1850 wallet_server_validation_recoverable_ = true; |
| 1968 HidePopup(); | 1851 HidePopup(); |
| 1969 if (IsPayingWithWallet()) { | |
| 1970 bool has_proxy_card_step = false; | |
| 1971 for (size_t i = 0; i < steps_.size(); ++i) { | |
| 1972 if (steps_[i].type() == AUTOCHECKOUT_STEP_PROXY_CARD) { | |
| 1973 has_proxy_card_step = true; | |
| 1974 break; | |
| 1975 } | |
| 1976 } | |
| 1977 if (!has_proxy_card_step) { | |
| 1978 steps_.insert(steps_.begin(), | |
| 1979 DialogAutocheckoutStep(AUTOCHECKOUT_STEP_PROXY_CARD, | |
| 1980 AUTOCHECKOUT_STEP_UNSTARTED)); | |
| 1981 } | |
| 1982 } | |
| 1983 | |
| 1984 if (GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT) | |
| 1985 DeemphasizeRenderView(); | |
| 1986 | 1852 |
| 1987 SetIsSubmitting(true); | 1853 SetIsSubmitting(true); |
| 1988 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) { | 1854 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) { |
| 1989 DCHECK(!active_instrument_id_.empty()); | 1855 DCHECK(!active_instrument_id_.empty()); |
| 1990 GetWalletClient()->AuthenticateInstrument( | 1856 GetWalletClient()->AuthenticateInstrument( |
| 1991 active_instrument_id_, | 1857 active_instrument_id_, |
| 1992 UTF16ToUTF8(view_->GetCvc())); | 1858 UTF16ToUTF8(view_->GetCvc())); |
| 1993 } else if (IsPayingWithWallet()) { | 1859 } else if (IsPayingWithWallet()) { |
| 1994 // TODO(dbeam): disallow interacting with the dialog while submitting. | 1860 // TODO(dbeam): disallow interacting with the dialog while submitting. |
| 1995 // http://crbug.com/230932 | 1861 // http://crbug.com/230932 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2160 } | 2026 } |
| 2161 | 2027 |
| 2162 void AutofillDialogControllerImpl::OnDidGetFullWallet( | 2028 void AutofillDialogControllerImpl::OnDidGetFullWallet( |
| 2163 scoped_ptr<wallet::FullWallet> full_wallet) { | 2029 scoped_ptr<wallet::FullWallet> full_wallet) { |
| 2164 DCHECK(is_submitting_ && IsPayingWithWallet()); | 2030 DCHECK(is_submitting_ && IsPayingWithWallet()); |
| 2165 ScopedViewUpdates updates(view_.get()); | 2031 ScopedViewUpdates updates(view_.get()); |
| 2166 | 2032 |
| 2167 full_wallet_ = full_wallet.Pass(); | 2033 full_wallet_ = full_wallet.Pass(); |
| 2168 | 2034 |
| 2169 if (full_wallet_->required_actions().empty()) { | 2035 if (full_wallet_->required_actions().empty()) { |
| 2170 UpdateAutocheckoutStep(AUTOCHECKOUT_STEP_PROXY_CARD, | |
| 2171 AUTOCHECKOUT_STEP_COMPLETED); | |
| 2172 FinishSubmit(); | 2036 FinishSubmit(); |
| 2173 return; | 2037 return; |
| 2174 } | 2038 } |
| 2175 | 2039 |
| 2176 SetAutocheckoutState(AUTOCHECKOUT_NOT_STARTED); | |
| 2177 | |
| 2178 switch (full_wallet_->required_actions()[0]) { | 2040 switch (full_wallet_->required_actions()[0]) { |
| 2179 case wallet::CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS: | 2041 case wallet::CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS: |
| 2180 choose_another_instrument_or_address_ = true; | 2042 choose_another_instrument_or_address_ = true; |
| 2181 SetIsSubmitting(false); | 2043 SetIsSubmitting(false); |
| 2182 GetWalletItems(); | 2044 GetWalletItems(); |
| 2183 view_->UpdateNotificationArea(); | 2045 view_->UpdateNotificationArea(); |
| 2184 view_->UpdateButtonStrip(); | 2046 view_->UpdateButtonStrip(); |
| 2185 break; | 2047 break; |
| 2186 | 2048 |
| 2187 case wallet::VERIFY_CVV: | 2049 case wallet::VERIFY_CVV: |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2338 content::WebContents* contents, | 2200 content::WebContents* contents, |
| 2339 const FormData& form_structure, | 2201 const FormData& form_structure, |
| 2340 const GURL& source_url, | 2202 const GURL& source_url, |
| 2341 const DialogType dialog_type, | 2203 const DialogType dialog_type, |
| 2342 const base::Callback<void(const FormStructure*, | 2204 const base::Callback<void(const FormStructure*, |
| 2343 const std::string&)>& callback) | 2205 const std::string&)>& callback) |
| 2344 : WebContentsObserver(contents), | 2206 : WebContentsObserver(contents), |
| 2345 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), | 2207 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), |
| 2346 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), | 2208 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), |
| 2347 dialog_type_(dialog_type), | 2209 dialog_type_(dialog_type), |
| 2348 form_structure_(form_structure, std::string()), | 2210 form_structure_(form_structure), |
| 2349 invoked_from_same_origin_(true), | 2211 invoked_from_same_origin_(true), |
| 2350 source_url_(source_url), | 2212 source_url_(source_url), |
| 2351 callback_(callback), | 2213 callback_(callback), |
| 2352 account_chooser_model_(this, profile_->GetPrefs(), metric_logger_, | 2214 account_chooser_model_(this, profile_->GetPrefs(), metric_logger_, |
| 2353 dialog_type), | 2215 dialog_type), |
| 2354 wallet_client_(profile_->GetRequestContext(), this), | 2216 wallet_client_(profile_->GetRequestContext(), this), |
| 2355 suggested_email_(this), | 2217 suggested_email_(this), |
| 2356 suggested_cc_(this), | 2218 suggested_cc_(this), |
| 2357 suggested_billing_(this), | 2219 suggested_billing_(this), |
| 2358 suggested_cc_billing_(this), | 2220 suggested_cc_billing_(this), |
| 2359 suggested_shipping_(this), | 2221 suggested_shipping_(this), |
| 2360 cares_about_shipping_(true), | 2222 cares_about_shipping_(true), |
| 2361 input_showing_popup_(NULL), | 2223 input_showing_popup_(NULL), |
| 2362 weak_ptr_factory_(this), | 2224 weak_ptr_factory_(this), |
| 2363 should_show_wallet_promo_(!profile_->GetPrefs()->GetBoolean( | 2225 should_show_wallet_promo_(!profile_->GetPrefs()->GetBoolean( |
| 2364 ::prefs::kAutofillDialogHasPaidWithWallet)), | 2226 ::prefs::kAutofillDialogHasPaidWithWallet)), |
| 2365 has_shown_wallet_usage_confirmation_(false), | 2227 has_shown_wallet_usage_confirmation_(false), |
| 2366 has_accepted_legal_documents_(false), | 2228 has_accepted_legal_documents_(false), |
| 2367 is_submitting_(false), | 2229 is_submitting_(false), |
| 2368 choose_another_instrument_or_address_(false), | 2230 choose_another_instrument_or_address_(false), |
| 2369 wallet_server_validation_recoverable_(true), | 2231 wallet_server_validation_recoverable_(true), |
| 2370 data_was_passed_back_(false), | 2232 data_was_passed_back_(false), |
| 2371 autocheckout_state_(AUTOCHECKOUT_NOT_STARTED), | 2233 was_ui_latency_logged_(false) { |
| 2372 was_ui_latency_logged_(false), | |
| 2373 deemphasized_render_view_(false) { | |
| 2374 // TODO(estade): remove duplicates from |form_structure|? | 2234 // TODO(estade): remove duplicates from |form_structure|? |
| 2375 DCHECK(!callback_.is_null()); | 2235 DCHECK(!callback_.is_null()); |
| 2376 } | 2236 } |
| 2377 | 2237 |
| 2378 AutofillDialogView* AutofillDialogControllerImpl::CreateView() { | 2238 AutofillDialogView* AutofillDialogControllerImpl::CreateView() { |
| 2379 return AutofillDialogView::Create(this); | 2239 return AutofillDialogView::Create(this); |
| 2380 } | 2240 } |
| 2381 | 2241 |
| 2382 PersonalDataManager* AutofillDialogControllerImpl::GetManager() { | 2242 PersonalDataManager* AutofillDialogControllerImpl::GetManager() { |
| 2383 return PersonalDataManagerFactory::GetForProfile(profile_); | 2243 return PersonalDataManagerFactory::GetForProfile(profile_); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2457 GetWalletClient()->CancelRequests(); | 2317 GetWalletClient()->CancelRequests(); |
| 2458 LogDialogLatencyToShow(); | 2318 LogDialogLatencyToShow(); |
| 2459 } | 2319 } |
| 2460 | 2320 |
| 2461 void AutofillDialogControllerImpl::DisableWallet( | 2321 void AutofillDialogControllerImpl::DisableWallet( |
| 2462 wallet::WalletClient::ErrorType error_type) { | 2322 wallet::WalletClient::ErrorType error_type) { |
| 2463 signin_helper_.reset(); | 2323 signin_helper_.reset(); |
| 2464 wallet_items_.reset(); | 2324 wallet_items_.reset(); |
| 2465 wallet_errors_.clear(); | 2325 wallet_errors_.clear(); |
| 2466 GetWalletClient()->CancelRequests(); | 2326 GetWalletClient()->CancelRequests(); |
| 2467 SetAutocheckoutState(AUTOCHECKOUT_NOT_STARTED); | |
| 2468 for (std::vector<DialogAutocheckoutStep>::iterator it = steps_.begin(); | |
| 2469 it != steps_.end(); ++it) { | |
| 2470 if (it->type() == AUTOCHECKOUT_STEP_PROXY_CARD) { | |
| 2471 steps_.erase(it); | |
| 2472 break; | |
| 2473 } | |
| 2474 } | |
| 2475 SetIsSubmitting(false); | 2327 SetIsSubmitting(false); |
| 2476 account_chooser_model_.SetHadWalletError(WalletErrorMessage(error_type)); | 2328 account_chooser_model_.SetHadWalletError(WalletErrorMessage(error_type)); |
| 2477 } | 2329 } |
| 2478 | 2330 |
| 2479 void AutofillDialogControllerImpl::SuggestionsUpdated() { | 2331 void AutofillDialogControllerImpl::SuggestionsUpdated() { |
| 2480 ScopedViewUpdates updates(view_.get()); | 2332 ScopedViewUpdates updates(view_.get()); |
| 2481 | 2333 |
| 2482 const DetailOutputMap snapshot = TakeUserInputSnapshot(); | 2334 const DetailOutputMap snapshot = TakeUserInputSnapshot(); |
| 2483 | 2335 |
| 2484 suggested_email_.Reset(); | 2336 suggested_email_.Reset(); |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3044 } | 2896 } |
| 3045 | 2897 |
| 3046 const wallet::Address* active_address = ActiveShippingAddress(); | 2898 const wallet::Address* active_address = ActiveShippingAddress(); |
| 3047 if (!IsManuallyEditingSection(SECTION_SHIPPING) && | 2899 if (!IsManuallyEditingSection(SECTION_SHIPPING) && |
| 3048 !ShouldUseBillingForShipping() && | 2900 !ShouldUseBillingForShipping() && |
| 3049 IsShippingAddressRequired()) { | 2901 IsShippingAddressRequired()) { |
| 3050 active_address_id_ = active_address->object_id(); | 2902 active_address_id_ = active_address->object_id(); |
| 3051 DCHECK(!active_address_id_.empty()); | 2903 DCHECK(!active_address_id_.empty()); |
| 3052 } | 2904 } |
| 3053 | 2905 |
| 3054 if (GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT) { | |
| 3055 DCHECK_EQ(AUTOCHECKOUT_NOT_STARTED, autocheckout_state_); | |
| 3056 SetAutocheckoutState(AUTOCHECKOUT_IN_PROGRESS); | |
| 3057 } | |
| 3058 | |
| 3059 scoped_ptr<wallet::Instrument> inputted_instrument = | 2906 scoped_ptr<wallet::Instrument> inputted_instrument = |
| 3060 CreateTransientInstrument(); | 2907 CreateTransientInstrument(); |
| 3061 if (inputted_instrument && IsEditingExistingData(SECTION_CC_BILLING)) { | 2908 if (inputted_instrument && IsEditingExistingData(SECTION_CC_BILLING)) { |
| 3062 inputted_instrument->set_object_id(active_instrument->object_id()); | 2909 inputted_instrument->set_object_id(active_instrument->object_id()); |
| 3063 DCHECK(!inputted_instrument->object_id().empty()); | 2910 DCHECK(!inputted_instrument->object_id().empty()); |
| 3064 } | 2911 } |
| 3065 | 2912 |
| 3066 scoped_ptr<wallet::Address> inputted_address; | 2913 scoped_ptr<wallet::Address> inputted_address; |
| 3067 if (active_address_id_.empty() && IsShippingAddressRequired()) { | 2914 if (active_address_id_.empty() && IsShippingAddressRequired()) { |
| 3068 if (ShouldUseBillingForShipping()) { | 2915 if (ShouldUseBillingForShipping()) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3133 void AutofillDialogControllerImpl::GetFullWallet() { | 2980 void AutofillDialogControllerImpl::GetFullWallet() { |
| 3134 DCHECK(is_submitting_); | 2981 DCHECK(is_submitting_); |
| 3135 DCHECK(IsPayingWithWallet()); | 2982 DCHECK(IsPayingWithWallet()); |
| 3136 DCHECK(wallet_items_); | 2983 DCHECK(wallet_items_); |
| 3137 DCHECK(!active_instrument_id_.empty()); | 2984 DCHECK(!active_instrument_id_.empty()); |
| 3138 DCHECK(!active_address_id_.empty() || !IsShippingAddressRequired()); | 2985 DCHECK(!active_address_id_.empty() || !IsShippingAddressRequired()); |
| 3139 | 2986 |
| 3140 std::vector<wallet::WalletClient::RiskCapability> capabilities; | 2987 std::vector<wallet::WalletClient::RiskCapability> capabilities; |
| 3141 capabilities.push_back(wallet::WalletClient::VERIFY_CVC); | 2988 capabilities.push_back(wallet::WalletClient::VERIFY_CVC); |
| 3142 | 2989 |
| 3143 UpdateAutocheckoutStep(AUTOCHECKOUT_STEP_PROXY_CARD, | |
| 3144 AUTOCHECKOUT_STEP_STARTED); | |
| 3145 | |
| 3146 GetWalletClient()->GetFullWallet(wallet::WalletClient::FullWalletRequest( | 2990 GetWalletClient()->GetFullWallet(wallet::WalletClient::FullWalletRequest( |
| 3147 active_instrument_id_, | 2991 active_instrument_id_, |
| 3148 active_address_id_, | 2992 active_address_id_, |
| 3149 source_url_, | 2993 source_url_, |
| 3150 wallet_items_->google_transaction_id(), | 2994 wallet_items_->google_transaction_id(), |
| 3151 capabilities, | 2995 capabilities, |
| 3152 wallet_items_->HasRequiredAction(wallet::SETUP_WALLET))); | 2996 wallet_items_->HasRequiredAction(wallet::SETUP_WALLET))); |
| 3153 } | 2997 } |
| 3154 | 2998 |
| 3155 void AutofillDialogControllerImpl::HandleSaveOrUpdateRequiredActions( | 2999 void AutofillDialogControllerImpl::HandleSaveOrUpdateRequiredActions( |
| 3156 const std::vector<wallet::RequiredAction>& required_actions) { | 3000 const std::vector<wallet::RequiredAction>& required_actions) { |
| 3157 DCHECK(!required_actions.empty()); | 3001 DCHECK(!required_actions.empty()); |
| 3158 | 3002 |
| 3159 // TODO(ahutter): Invesitigate if we need to support more generic actions on | 3003 // TODO(ahutter): Invesitigate if we need to support more generic actions on |
| 3160 // this call such as GAIA_AUTH. See crbug.com/243457. | 3004 // this call such as GAIA_AUTH. See crbug.com/243457. |
| 3161 for (std::vector<wallet::RequiredAction>::const_iterator iter = | 3005 for (std::vector<wallet::RequiredAction>::const_iterator iter = |
| 3162 required_actions.begin(); | 3006 required_actions.begin(); |
| 3163 iter != required_actions.end(); ++iter) { | 3007 iter != required_actions.end(); ++iter) { |
| 3164 if (*iter != wallet::INVALID_FORM_FIELD) { | 3008 if (*iter != wallet::INVALID_FORM_FIELD) { |
| 3165 // TODO(dbeam): handle this more gracefully. | 3009 // TODO(dbeam): handle this more gracefully. |
| 3166 DisableWallet(wallet::WalletClient::UNKNOWN_ERROR); | 3010 DisableWallet(wallet::WalletClient::UNKNOWN_ERROR); |
| 3167 } | 3011 } |
| 3168 } | 3012 } |
| 3169 SetAutocheckoutState(AUTOCHECKOUT_NOT_STARTED); | |
| 3170 SetIsSubmitting(false); | 3013 SetIsSubmitting(false); |
| 3171 } | 3014 } |
| 3172 | 3015 |
| 3173 void AutofillDialogControllerImpl::FinishSubmit() { | 3016 void AutofillDialogControllerImpl::FinishSubmit() { |
| 3174 if (IsPayingWithWallet() && | 3017 if (IsPayingWithWallet() && |
| 3175 !profile_->GetPrefs()->GetBoolean( | 3018 !profile_->GetPrefs()->GetBoolean( |
| 3176 ::prefs::kAutofillDialogHasPaidWithWallet)) { | 3019 ::prefs::kAutofillDialogHasPaidWithWallet)) { |
| 3177 if (GetDialogType() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) { | 3020 if (GetDialogType() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) { |
| 3178 // To get past this point, the view must call back OverlayButtonPressed. | 3021 // To get past this point, the view must call back OverlayButtonPressed. |
| 3179 #if defined(TOOLKIT_VIEWS) | 3022 #if defined(TOOLKIT_VIEWS) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3228 // stop trying to pay with Wallet on future runs of the dialog. On the other | 3071 // stop trying to pay with Wallet on future runs of the dialog. On the other |
| 3229 // hand, if there was an error that prevented the user from having the choice | 3072 // hand, if there was an error that prevented the user from having the choice |
| 3230 // of using Wallet, leave the pref alone. | 3073 // of using Wallet, leave the pref alone. |
| 3231 if (!account_chooser_model_.HadWalletError() && | 3074 if (!account_chooser_model_.HadWalletError() && |
| 3232 account_chooser_model_.HasAccountsToChoose()) { | 3075 account_chooser_model_.HasAccountsToChoose()) { |
| 3233 profile_->GetPrefs()->SetBoolean( | 3076 profile_->GetPrefs()->SetBoolean( |
| 3234 ::prefs::kAutofillDialogPayWithoutWallet, | 3077 ::prefs::kAutofillDialogPayWithoutWallet, |
| 3235 !account_chooser_model_.WalletIsSelected()); | 3078 !account_chooser_model_.WalletIsSelected()); |
| 3236 } | 3079 } |
| 3237 | 3080 |
| 3238 if (GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT) { | |
| 3239 // Stop observing PersonalDataManager to avoid the dialog redrawing while | |
| 3240 // in an Autocheckout flow. | |
| 3241 GetManager()->RemoveObserver(this); | |
| 3242 autocheckout_started_timestamp_ = base::Time::Now(); | |
| 3243 SetAutocheckoutState(AUTOCHECKOUT_IN_PROGRESS); | |
| 3244 } | |
| 3245 | |
| 3246 LogOnFinishSubmitMetrics(); | 3081 LogOnFinishSubmitMetrics(); |
| 3247 | 3082 |
| 3248 // Callback should be called as late as possible. | 3083 // Callback should be called as late as possible. |
| 3249 callback_.Run(&form_structure_, !wallet_items_ ? std::string() : | 3084 callback_.Run(&form_structure_, !wallet_items_ ? std::string() : |
| 3250 wallet_items_->google_transaction_id()); | 3085 wallet_items_->google_transaction_id()); |
| 3251 data_was_passed_back_ = true; | 3086 data_was_passed_back_ = true; |
| 3252 | 3087 |
| 3253 // This might delete us. | 3088 // This might delete us. |
| 3254 if (GetDialogType() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) | 3089 if (GetDialogType() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) |
| 3255 Hide(); | 3090 Hide(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3386 void AutofillDialogControllerImpl::LogDialogLatencyToShow() { | 3221 void AutofillDialogControllerImpl::LogDialogLatencyToShow() { |
| 3387 if (was_ui_latency_logged_) | 3222 if (was_ui_latency_logged_) |
| 3388 return; | 3223 return; |
| 3389 | 3224 |
| 3390 GetMetricLogger().LogDialogLatencyToShow( | 3225 GetMetricLogger().LogDialogLatencyToShow( |
| 3391 GetDialogType(), | 3226 GetDialogType(), |
| 3392 base::Time::Now() - dialog_shown_timestamp_); | 3227 base::Time::Now() - dialog_shown_timestamp_); |
| 3393 was_ui_latency_logged_ = true; | 3228 was_ui_latency_logged_ = true; |
| 3394 } | 3229 } |
| 3395 | 3230 |
| 3396 void AutofillDialogControllerImpl::SetAutocheckoutState( | |
| 3397 AutocheckoutState autocheckout_state) { | |
| 3398 if (autocheckout_state_ == autocheckout_state) | |
| 3399 return; | |
| 3400 | |
| 3401 autocheckout_state_ = autocheckout_state; | |
| 3402 if (view_) { | |
| 3403 ScopedViewUpdates updates(view_.get()); | |
| 3404 view_->UpdateDetailArea(); | |
| 3405 view_->UpdateButtonStrip(); | |
| 3406 view_->UpdateAutocheckoutStepsArea(); | |
| 3407 view_->UpdateNotificationArea(); | |
| 3408 } | |
| 3409 } | |
| 3410 | |
| 3411 void AutofillDialogControllerImpl::DeemphasizeRenderView() { | |
| 3412 web_contents()->GetRenderViewHost()->Send( | |
| 3413 new ChromeViewMsg_SetVisuallyDeemphasized( | |
| 3414 web_contents()->GetRenderViewHost()->GetRoutingID(), true)); | |
| 3415 deemphasized_render_view_ = true; | |
| 3416 } | |
| 3417 | |
| 3418 AutofillMetrics::DialogInitialUserStateMetric | 3231 AutofillMetrics::DialogInitialUserStateMetric |
| 3419 AutofillDialogControllerImpl::GetInitialUserState() const { | 3232 AutofillDialogControllerImpl::GetInitialUserState() const { |
| 3420 // Consider a user to be an Autofill user if the user has any credit cards | 3233 // Consider a user to be an Autofill user if the user has any credit cards |
| 3421 // or addresses saved. Check that the item count is greater than 2 because | 3234 // or addresses saved. Check that the item count is greater than 2 because |
| 3422 // an "empty" menu still has the "add new" menu item and "manage" menu item. | 3235 // an "empty" menu still has the "add new" menu item and "manage" menu item. |
| 3423 const bool has_autofill_profiles = | 3236 const bool has_autofill_profiles = |
| 3424 suggested_cc_.GetItemCount() > 2 || | 3237 suggested_cc_.GetItemCount() > 2 || |
| 3425 suggested_billing_.GetItemCount() > 2; | 3238 suggested_billing_.GetItemCount() > 2; |
| 3426 | 3239 |
| 3427 if (SignedInState() != SIGNED_IN) { | 3240 if (SignedInState() != SIGNED_IN) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3471 GetValueFromSection(SECTION_EMAIL, EMAIL_ADDRESS)); | 3284 GetValueFromSection(SECTION_EMAIL, EMAIL_ADDRESS)); |
| 3472 | 3285 |
| 3473 ShowNewCreditCardBubble(newly_saved_card_.Pass(), | 3286 ShowNewCreditCardBubble(newly_saved_card_.Pass(), |
| 3474 billing_profile.Pass()); | 3287 billing_profile.Pass()); |
| 3475 return; | 3288 return; |
| 3476 } | 3289 } |
| 3477 | 3290 |
| 3478 if (!full_wallet_ || !full_wallet_->billing_address()) | 3291 if (!full_wallet_ || !full_wallet_->billing_address()) |
| 3479 return; | 3292 return; |
| 3480 | 3293 |
| 3481 // Don't show GeneratedCardBubble if Autocheckout failed. | |
| 3482 if (GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT && | |
| 3483 autocheckout_state_ != AUTOCHECKOUT_SUCCESS) { | |
| 3484 return; | |
| 3485 } | |
| 3486 | |
| 3487 base::string16 backing_last_four; | 3294 base::string16 backing_last_four; |
| 3488 if (ActiveInstrument()) { | 3295 if (ActiveInstrument()) { |
| 3489 backing_last_four = ActiveInstrument()->TypeAndLastFourDigits(); | 3296 backing_last_four = ActiveInstrument()->TypeAndLastFourDigits(); |
| 3490 } else { | 3297 } else { |
| 3491 DetailOutputMap output; | 3298 DetailOutputMap output; |
| 3492 view_->GetUserInput(SECTION_CC_BILLING, &output); | 3299 view_->GetUserInput(SECTION_CC_BILLING, &output); |
| 3493 CreditCard card; | 3300 CreditCard card; |
| 3494 GetBillingInfoFromOutputs(output, &card, NULL, NULL); | 3301 GetBillingInfoFromOutputs(output, &card, NULL, NULL); |
| 3495 backing_last_four = card.TypeAndLastFourDigits(); | 3302 backing_last_four = card.TypeAndLastFourDigits(); |
| 3496 } | 3303 } |
| 3497 #if !defined(OS_ANDROID) | 3304 #if !defined(OS_ANDROID) |
| 3498 GeneratedCreditCardBubbleController::Show( | 3305 GeneratedCreditCardBubbleController::Show( |
| 3499 web_contents(), | 3306 web_contents(), |
| 3500 backing_last_four, | 3307 backing_last_four, |
| 3501 full_wallet_->TypeAndLastFourDigits()); | 3308 full_wallet_->TypeAndLastFourDigits()); |
| 3502 #endif | 3309 #endif |
| 3503 } | 3310 } |
| 3504 | 3311 |
| 3505 } // namespace autofill | 3312 } // namespace autofill |
| OLD | NEW |