Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2415)

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 23717029: Disable submit button briefly when launching rAc dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Do not extend the submit button delay in test Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..13a96840602e29a151e55a775856c08008ef68b2 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,8 @@ void AutofillDialogControllerImpl::Show() {
profile_->GetPrefs()->SetInteger(::prefs::kAutofillDialogShowCount,
show_count + 1);
+ SubmitButtonDelayBegin();
+
// 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 +762,9 @@ bool AutofillDialogControllerImpl::IsDialogButtonEnabled(
if (ShouldShowSpinner() || is_submitting_)
return false;
+ if (submit_button_delay_timer_.IsRunning())
+ return false;
+
return true;
}
@@ -2226,6 +2236,20 @@ void AutofillDialogControllerImpl::ShowNewCreditCardBubble(
#endif
}
+void AutofillDialogControllerImpl::SubmitButtonDelayBegin() {
+ submit_button_delay_timer_.Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(kSubmitButtonDelayMs),
+ this,
+ &AutofillDialogControllerImpl::OnSubmitButtonDelayEnd);
+}
+
+void AutofillDialogControllerImpl::SubmitButtonDelayEndForTesting() {
+ DCHECK(submit_button_delay_timer_.IsRunning());
+ submit_button_delay_timer_.user_task().Run();
+ submit_button_delay_timer_.Stop();
+}
+
AutofillDialogControllerImpl::AutofillDialogControllerImpl(
content::WebContents* contents,
const FormData& form_structure,
@@ -3340,4 +3364,11 @@ void AutofillDialogControllerImpl::MaybeShowCreditCardBubble() {
#endif
}
+void AutofillDialogControllerImpl::OnSubmitButtonDelayEnd() {
+ if (!view_)
+ return;
+ ScopedViewUpdates updates(view_.get());
+ view_->UpdateButtonStrip();
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698