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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 // WebDB, and hence should not be modified, so that it remains consistent over | 107 // WebDB, and hence should not be modified, so that it remains consistent over |
108 // time. | 108 // time. |
109 const char kAutofillDialogOrigin[] = "Chrome Autofill dialog"; | 109 const char kAutofillDialogOrigin[] = "Chrome Autofill dialog"; |
110 | 110 |
111 // HSL shift to gray out an image. | 111 // HSL shift to gray out an image. |
112 const color_utils::HSL kGrayImageShift = {-1, 0, 0.8}; | 112 const color_utils::HSL kGrayImageShift = {-1, 0, 0.8}; |
113 | 113 |
114 // Limit Wallet items refresh rate to at most once per minute. | 114 // Limit Wallet items refresh rate to at most once per minute. |
115 const int kWalletItemsRefreshRateSeconds = 60; | 115 const int kWalletItemsRefreshRateSeconds = 60; |
116 | 116 |
117 // The number of milliseconds to delay enabling the submit button after showing | |
118 // the dialog. This delay prevents users from accidentally clicking the submit | |
119 // button on startup. | |
120 const int kSubmitButtonDelayMs = 1000; | |
121 | |
117 // A helper class to make sure an AutofillDialogView knows when a series of | 122 // A helper class to make sure an AutofillDialogView knows when a series of |
118 // updates is incoming. | 123 // updates is incoming. |
119 class ScopedViewUpdates { | 124 class ScopedViewUpdates { |
120 public: | 125 public: |
121 explicit ScopedViewUpdates(AutofillDialogView* view) : view_(view) { | 126 explicit ScopedViewUpdates(AutofillDialogView* view) : view_(view) { |
122 if (view_) | 127 if (view_) |
123 view_->UpdatesStarted(); | 128 view_->UpdatesStarted(); |
124 } | 129 } |
125 | 130 |
126 ~ScopedViewUpdates() { | 131 ~ScopedViewUpdates() { |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
644 | 649 |
645 // Try to see if the user is already signed-in. If signed-in, fetch the user's | 650 // Try to see if the user is already signed-in. If signed-in, fetch the user's |
646 // Wallet data. Otherwise, see if the user could be signed in passively. | 651 // Wallet data. Otherwise, see if the user could be signed in passively. |
647 // TODO(aruslan): UMA metrics for sign-in. | 652 // TODO(aruslan): UMA metrics for sign-in. |
648 signin_helper_.reset(new wallet::WalletSigninHelper( | 653 signin_helper_.reset(new wallet::WalletSigninHelper( |
649 this, profile_->GetRequestContext())); | 654 this, profile_->GetRequestContext())); |
650 signin_helper_->StartWalletCookieValueFetch(); | 655 signin_helper_->StartWalletCookieValueFetch(); |
651 | 656 |
652 if (!account_chooser_model_.WalletIsSelected()) | 657 if (!account_chooser_model_.WalletIsSelected()) |
653 LogDialogLatencyToShow(); | 658 LogDialogLatencyToShow(); |
659 | |
660 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().
| |
654 } | 661 } |
655 | 662 |
656 void AutofillDialogControllerImpl::Hide() { | 663 void AutofillDialogControllerImpl::Hide() { |
657 if (view_) | 664 if (view_) |
658 view_->Hide(); | 665 view_->Hide(); |
659 } | 666 } |
660 | 667 |
661 void AutofillDialogControllerImpl::TabActivated() { | 668 void AutofillDialogControllerImpl::TabActivated() { |
662 // If the user switched away from this tab and then switched back, reload the | 669 // If the user switched away from this tab and then switched back, reload the |
663 // Wallet items, in case they've changed. | 670 // Wallet items, in case they've changed. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
756 | 763 |
757 bool AutofillDialogControllerImpl::IsDialogButtonEnabled( | 764 bool AutofillDialogControllerImpl::IsDialogButtonEnabled( |
758 ui::DialogButton button) const { | 765 ui::DialogButton button) const { |
759 if (button == ui::DIALOG_BUTTON_OK) { | 766 if (button == ui::DIALOG_BUTTON_OK) { |
760 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) | 767 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) |
761 return true; | 768 return true; |
762 | 769 |
763 if (ShouldShowSpinner() || is_submitting_) | 770 if (ShouldShowSpinner() || is_submitting_) |
764 return false; | 771 return false; |
765 | 772 |
773 if (submit_buton_delay_timer_.IsRunning()) | |
774 return false; | |
775 | |
766 return true; | 776 return true; |
767 } | 777 } |
768 | 778 |
769 DCHECK_EQ(ui::DIALOG_BUTTON_CANCEL, button); | 779 DCHECK_EQ(ui::DIALOG_BUTTON_CANCEL, button); |
770 return !is_submitting_ || IsSubmitPausedOn(wallet::VERIFY_CVV); | 780 return !is_submitting_ || IsSubmitPausedOn(wallet::VERIFY_CVV); |
771 } | 781 } |
772 | 782 |
773 DialogOverlayState AutofillDialogControllerImpl::GetDialogOverlay() const { | 783 DialogOverlayState AutofillDialogControllerImpl::GetDialogOverlay() const { |
774 bool show_wallet_interstitial = IsPayingWithWallet() && is_submitting_ && | 784 bool show_wallet_interstitial = IsPayingWithWallet() && is_submitting_ && |
775 !IsSubmitPausedOn(wallet::VERIFY_CVV) && | 785 !IsSubmitPausedOn(wallet::VERIFY_CVV) && |
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2233 void AutofillDialogControllerImpl::ShowNewCreditCardBubble( | 2243 void AutofillDialogControllerImpl::ShowNewCreditCardBubble( |
2234 scoped_ptr<CreditCard> new_card, | 2244 scoped_ptr<CreditCard> new_card, |
2235 scoped_ptr<AutofillProfile> billing_profile) { | 2245 scoped_ptr<AutofillProfile> billing_profile) { |
2236 #if !defined(OS_ANDROID) | 2246 #if !defined(OS_ANDROID) |
2237 NewCreditCardBubbleController::Show(profile(), | 2247 NewCreditCardBubbleController::Show(profile(), |
2238 new_card.Pass(), | 2248 new_card.Pass(), |
2239 billing_profile.Pass()); | 2249 billing_profile.Pass()); |
2240 #endif | 2250 #endif |
2241 } | 2251 } |
2242 | 2252 |
2253 void AutofillDialogControllerImpl::SubmitButtonDelayBegin(int delay_ms) { | |
2254 submit_buton_delay_timer_.Start( | |
2255 FROM_HERE, | |
2256 base::TimeDelta::FromMilliseconds(delay_ms), | |
2257 this, | |
2258 &AutofillDialogControllerImpl::OnSubmitButtonDelayEnd); | |
2259 } | |
2260 | |
2261 void AutofillDialogControllerImpl::OnSubmitButtonDelayEnd() { | |
2262 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
| |
2263 submit_buton_delay_timer_.Stop(); | |
2264 if (view_) { | |
2265 ScopedViewUpdates updates(view_.get()); | |
2266 view_->UpdateButtonStrip(); | |
2267 } | |
2268 } | |
2269 | |
2243 AutofillDialogControllerImpl::AutofillDialogControllerImpl( | 2270 AutofillDialogControllerImpl::AutofillDialogControllerImpl( |
2244 content::WebContents* contents, | 2271 content::WebContents* contents, |
2245 const FormData& form_structure, | 2272 const FormData& form_structure, |
2246 const GURL& source_url, | 2273 const GURL& source_url, |
2247 const DialogType dialog_type, | 2274 const DialogType dialog_type, |
2248 const base::Callback<void(const FormStructure*, | 2275 const base::Callback<void(const FormStructure*, |
2249 const std::string&)>& callback) | 2276 const std::string&)>& callback) |
2250 : WebContentsObserver(contents), | 2277 : WebContentsObserver(contents), |
2251 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), | 2278 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), |
2252 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), | 2279 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), |
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3357 } | 3384 } |
3358 #if !defined(OS_ANDROID) | 3385 #if !defined(OS_ANDROID) |
3359 GeneratedCreditCardBubbleController::Show( | 3386 GeneratedCreditCardBubbleController::Show( |
3360 web_contents(), | 3387 web_contents(), |
3361 full_wallet_->TypeAndLastFourDigits(), | 3388 full_wallet_->TypeAndLastFourDigits(), |
3362 backing_last_four); | 3389 backing_last_four); |
3363 #endif | 3390 #endif |
3364 } | 3391 } |
3365 | 3392 |
3366 } // namespace autofill | 3393 } // namespace autofill |
OLD | NEW |