Chromium Code Reviews| Index: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| index 8b5d81dbd90b01ff6fff029fa3b40d0575cfa485..db562fae47daf3cb7ab66bc1e342947ad1b4c109 100644 |
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| @@ -114,6 +114,11 @@ const color_utils::HSL kGrayImageShift = {-1, 0, 0.8}; |
| // Limit Wallet items refresh rate to at most once per minute. |
| const int kWalletItemsRefreshRateSeconds = 60; |
| +// The number of milliseconds to delay enabling the submit button after showing |
| +// the dialog. This delay prevents users from accidentally clicking the submit |
| +// button on startup. |
| +const int kSubmitButtonDelayMs = 1000; |
| + |
| // A helper class to make sure an AutofillDialogView knows when a series of |
| // updates is incoming. |
| class ScopedViewUpdates { |
| @@ -651,6 +656,8 @@ void AutofillDialogControllerImpl::Show() { |
| if (!account_chooser_model_.WalletIsSelected()) |
| LogDialogLatencyToShow(); |
| + |
| + SubmitButtonDelayBegin(kSubmitButtonDelayMs); |
|
Evan Stade
2013/09/04 21:42:52
I think you should do this before view_->Show()
please use gerrit instead
2013/09/05 02:30:58
Moved up before view_->Show().
|
| } |
| void AutofillDialogControllerImpl::Hide() { |
| @@ -763,6 +770,9 @@ bool AutofillDialogControllerImpl::IsDialogButtonEnabled( |
| if (ShouldShowSpinner() || is_submitting_) |
| return false; |
| + if (submit_buton_delay_timer_.IsRunning()) |
| + return false; |
| + |
| return true; |
| } |
| @@ -2240,6 +2250,23 @@ void AutofillDialogControllerImpl::ShowNewCreditCardBubble( |
| #endif |
| } |
| +void AutofillDialogControllerImpl::SubmitButtonDelayBegin(int delay_ms) { |
| + submit_buton_delay_timer_.Start( |
| + FROM_HERE, |
| + base::TimeDelta::FromMilliseconds(delay_ms), |
| + this, |
| + &AutofillDialogControllerImpl::OnSubmitButtonDelayEnd); |
| +} |
| + |
| +void AutofillDialogControllerImpl::OnSubmitButtonDelayEnd() { |
| + if (submit_buton_delay_timer_.IsRunning()) |
|
Evan Stade
2013/09/04 21:42:52
I dislike this because it shouldn't happen outside
please use gerrit instead
2013/09/05 02:30:58
Removed the timer check from OnSubmitButtonDelayEn
|
| + submit_buton_delay_timer_.Stop(); |
| + if (view_) { |
| + ScopedViewUpdates updates(view_.get()); |
| + view_->UpdateButtonStrip(); |
| + } |
| +} |
| + |
| AutofillDialogControllerImpl::AutofillDialogControllerImpl( |
| content::WebContents* contents, |
| const FormData& form_structure, |