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 cdddbea0d54125201e54aaea6913735f4c80dba3..9b7cdc45291b0444487beeacb82750305b5897ad 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 { |
@@ -628,6 +633,9 @@ void AutofillDialogControllerImpl::Show() { |
profile_->GetPrefs()->SetInteger(::prefs::kAutofillDialogShowCount, |
show_count + 1); |
+ SubmitButtonDelayBegin( |
+ base::TimeDelta::FromMilliseconds(kSubmitButtonDelayMs)); |
+ |
// TODO(estade): don't show the dialog if the site didn't specify the right |
// fields. First we must figure out what the "right" fields are. |
view_.reset(CreateView()); |
@@ -755,6 +763,9 @@ bool AutofillDialogControllerImpl::IsDialogButtonEnabled( |
if (ShouldShowSpinner() || is_submitting_) |
return false; |
+ if (submit_button_delay_timer_.IsRunning()) |
+ return false; |
+ |
return true; |
} |
@@ -2226,6 +2237,28 @@ void AutofillDialogControllerImpl::ShowNewCreditCardBubble( |
#endif |
} |
+void AutofillDialogControllerImpl::SubmitButtonDelayBegin( |
+ base::TimeDelta delay) { |
+ submit_button_delay_timer_.Start( |
+ FROM_HERE, |
+ delay, |
+ this, |
+ &AutofillDialogControllerImpl::OnSubmitButtonDelayEnd); |
+} |
+ |
+void AutofillDialogControllerImpl::OnSubmitButtonDelayEnd() { |
+ if (view_) { |
+ ScopedViewUpdates updates(view_.get()); |
+ view_->UpdateButtonStrip(); |
+ } |
+} |
+ |
+void AutofillDialogControllerImpl::SubmitButtonDelayEndForTesting() { |
+ if (submit_button_delay_timer_.IsRunning()) |
+ submit_button_delay_timer_.Stop(); |
+ OnSubmitButtonDelayEnd(); |
+} |
+ |
AutofillDialogControllerImpl::AutofillDialogControllerImpl( |
content::WebContents* contents, |
const FormData& form_structure, |