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 06b3d05e4329c2f875c251276a7e14fe60582079..6f250f001e3bd8bc7b447ebed3a66954393e8b36 100644 |
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| @@ -112,6 +112,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 seconds to delay enabling the submit button after showing the |
| +// dialog. This delay prevents users from accidentally clicking the submit |
| +// button on startup. |
| +const int kSubmitButtonDelaySeconds = 1; |
| + |
| // A helper class to make sure an AutofillDialogView knows when a series of |
| // updates is incoming. |
| class ScopedViewUpdates { |
| @@ -639,6 +644,8 @@ void AutofillDialogControllerImpl::Show() { |
| if (!account_chooser_model_.WalletIsSelected()) |
| LogDialogLatencyToShow(); |
| + |
| + SubmitButtonDelayBegin(); |
| } |
| void AutofillDialogControllerImpl::Hide() { |
| @@ -759,6 +766,9 @@ bool AutofillDialogControllerImpl::IsDialogButtonEnabled( |
| if (ShouldShowSpinner() || is_submitting_) |
| return false; |
| + if (is_submit_button_delayed_) |
| + return false; |
| + |
| return true; |
| } |
| @@ -2229,6 +2239,24 @@ void AutofillDialogControllerImpl::ShowNewCreditCardBubble( |
| #endif |
| } |
| +void AutofillDialogControllerImpl::SubmitButtonDelayBegin() { |
| + is_submit_button_delayed_ = true; |
|
Evan Stade
2013/09/04 02:36:28
I think this will be slightly cleaner if you use a
please use gerrit instead
2013/09/04 02:51:46
I can see using a Timer instead of PostDelayedTask
Evan Stade
2013/09/04 18:24:29
just because it was the first line of this fn (als
|
| + content::BrowserThread::PostDelayedTask( |
| + content::BrowserThread::UI, |
| + FROM_HERE, |
| + base::Bind(&AutofillDialogControllerImpl::OnSubmitButtonDelayEnd, |
| + weak_ptr_factory_.GetWeakPtr()), |
| + base::TimeDelta::FromSeconds(kSubmitButtonDelaySeconds)); |
| +} |
| + |
| +void AutofillDialogControllerImpl::OnSubmitButtonDelayEnd() { |
| + is_submit_button_delayed_ = false; |
| + if (view_) { |
| + ScopedViewUpdates updates(view_.get()); |
| + view_->UpdateButtonStrip(); |
| + } |
| +} |
| + |
| AutofillDialogControllerImpl::AutofillDialogControllerImpl( |
| content::WebContents* contents, |
| const FormData& form_structure, |
| @@ -2263,7 +2291,8 @@ AutofillDialogControllerImpl::AutofillDialogControllerImpl( |
| choose_another_instrument_or_address_(false), |
| wallet_server_validation_recoverable_(true), |
| data_was_passed_back_(false), |
| - was_ui_latency_logged_(false) { |
| + was_ui_latency_logged_(false), |
| + is_submit_button_delayed_(false) { |
| // TODO(estade): remove duplicates from |form_structure|? |
| DCHECK(!callback_.is_null()); |
| } |