Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
| 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/gtest_prod_util.h" | |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 16 #include "chrome/browser/ui/autofill/account_chooser_model.h" | 17 #include "chrome/browser/ui/autofill/account_chooser_model.h" |
| 17 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | 18 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
| 18 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 19 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
| 19 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 20 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
| 20 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" | 21 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" |
| 21 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 22 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
| 22 #include "chrome/browser/ui/autofill/country_combobox_model.h" | 23 #include "chrome/browser/ui/autofill/country_combobox_model.h" |
| 23 #include "components/autofill/content/browser/wallet/wallet_client.h" | 24 #include "components/autofill/content/browser/wallet/wallet_client.h" |
| 24 #include "components/autofill/content/browser/wallet/wallet_client_delegate.h" | 25 #include "components/autofill/content/browser/wallet/wallet_client_delegate.h" |
| 25 #include "components/autofill/content/browser/wallet/wallet_items.h" | 26 #include "components/autofill/content/browser/wallet/wallet_items.h" |
| 26 #include "components/autofill/content/browser/wallet/wallet_signin_helper_delega te.h" | 27 #include "components/autofill/content/browser/wallet/wallet_signin_helper_delega te.h" |
| 27 #include "components/autofill/core/browser/autofill_manager_delegate.h" | 28 #include "components/autofill/core/browser/autofill_manager_delegate.h" |
| 28 #include "components/autofill/core/browser/autofill_metrics.h" | 29 #include "components/autofill/core/browser/autofill_metrics.h" |
| 29 #include "components/autofill/core/browser/autofill_popup_delegate.h" | 30 #include "components/autofill/core/browser/autofill_popup_delegate.h" |
| 30 #include "components/autofill/core/browser/field_types.h" | 31 #include "components/autofill/core/browser/field_types.h" |
| 31 #include "components/autofill/core/browser/form_structure.h" | 32 #include "components/autofill/core/browser/form_structure.h" |
| 32 #include "components/autofill/core/browser/personal_data_manager.h" | 33 #include "components/autofill/core/browser/personal_data_manager.h" |
| 33 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 34 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 34 #include "content/public/browser/notification_observer.h" | 35 #include "content/public/browser/notification_observer.h" |
| 35 #include "content/public/browser/notification_registrar.h" | 36 #include "content/public/browser/notification_registrar.h" |
| 36 #include "content/public/browser/web_contents_observer.h" | 37 #include "content/public/browser/web_contents_observer.h" |
| 37 #include "content/public/common/ssl_status.h" | 38 #include "content/public/common/ssl_status.h" |
| 39 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_validator.h" | |
| 40 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/load_ rules_delegate.h" | |
| 38 #include "third_party/skia/include/core/SkColor.h" | 41 #include "third_party/skia/include/core/SkColor.h" |
| 39 #include "ui/base/models/simple_menu_model.h" | 42 #include "ui/base/models/simple_menu_model.h" |
| 40 #include "ui/base/ui_base_types.h" | 43 #include "ui/base/ui_base_types.h" |
| 41 #include "ui/gfx/animation/animation_delegate.h" | 44 #include "ui/gfx/animation/animation_delegate.h" |
| 42 #include "ui/gfx/animation/linear_animation.h" | 45 #include "ui/gfx/animation/linear_animation.h" |
| 43 #include "url/gurl.h" | 46 #include "url/gurl.h" |
| 44 | 47 |
| 45 class Profile; | 48 class Profile; |
| 46 | 49 |
| 47 namespace content { | 50 namespace content { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 58 namespace risk { | 61 namespace risk { |
| 59 class Fingerprint; | 62 class Fingerprint; |
| 60 } | 63 } |
| 61 | 64 |
| 62 namespace wallet { | 65 namespace wallet { |
| 63 class WalletSigninHelper; | 66 class WalletSigninHelper; |
| 64 } | 67 } |
| 65 | 68 |
| 66 // This class drives the dialog that appears when a site uses the imperative | 69 // This class drives the dialog that appears when a site uses the imperative |
| 67 // autocomplete API to fill out a form. | 70 // autocomplete API to fill out a form. |
| 68 class AutofillDialogControllerImpl : public AutofillDialogViewDelegate, | 71 class AutofillDialogControllerImpl |
| 69 public AutofillDialogController, | 72 : public AutofillDialogViewDelegate, |
| 70 public AutofillPopupDelegate, | 73 public AutofillDialogController, |
| 71 public content::NotificationObserver, | 74 public AutofillPopupDelegate, |
| 72 public content::WebContentsObserver, | 75 public content::NotificationObserver, |
| 73 public SuggestionsMenuModelDelegate, | 76 public content::WebContentsObserver, |
| 74 public wallet::WalletClientDelegate, | 77 public SuggestionsMenuModelDelegate, |
| 75 public wallet::WalletSigninHelperDelegate, | 78 public wallet::WalletClientDelegate, |
| 76 public PersonalDataManagerObserver, | 79 public wallet::WalletSigninHelperDelegate, |
| 77 public AccountChooserModelDelegate, | 80 public PersonalDataManagerObserver, |
| 78 public gfx::AnimationDelegate { | 81 public AccountChooserModelDelegate, |
| 82 public gfx::AnimationDelegate, | |
| 83 public ::i18n::addressinput::LoadRulesDelegate { | |
| 79 public: | 84 public: |
| 80 virtual ~AutofillDialogControllerImpl(); | 85 virtual ~AutofillDialogControllerImpl(); |
| 81 | 86 |
| 82 static base::WeakPtr<AutofillDialogControllerImpl> Create( | 87 static base::WeakPtr<AutofillDialogControllerImpl> Create( |
| 83 content::WebContents* contents, | 88 content::WebContents* contents, |
| 84 const FormData& form_structure, | 89 const FormData& form_structure, |
| 85 const GURL& source_url, | 90 const GURL& source_url, |
| 86 const base::Callback<void(const FormStructure*)>& callback); | 91 const base::Callback<void(const FormStructure*)>& callback); |
| 87 | 92 |
| 88 // AutofillDialogController implementation. | 93 // AutofillDialogController implementation. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 virtual void OnPassiveSigninSuccess() OVERRIDE; | 214 virtual void OnPassiveSigninSuccess() OVERRIDE; |
| 210 virtual void OnPassiveSigninFailure( | 215 virtual void OnPassiveSigninFailure( |
| 211 const GoogleServiceAuthError& error) OVERRIDE; | 216 const GoogleServiceAuthError& error) OVERRIDE; |
| 212 virtual void OnDidFetchWalletCookieValue( | 217 virtual void OnDidFetchWalletCookieValue( |
| 213 const std::string& cookie_value) OVERRIDE; | 218 const std::string& cookie_value) OVERRIDE; |
| 214 | 219 |
| 215 // gfx::AnimationDelegate implementation. | 220 // gfx::AnimationDelegate implementation. |
| 216 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; | 221 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
| 217 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 222 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 218 | 223 |
| 224 // ::i18n::addressinput::LoadRulesDelegate implementation. | |
| 225 virtual void OnAddressValidationRulesLoaded(const std::string& country_code, | |
| 226 bool success) OVERRIDE; | |
| 227 | |
| 219 protected: | 228 protected: |
| 220 enum DialogSignedInState { | 229 enum DialogSignedInState { |
| 221 NOT_CHECKED, | 230 NOT_CHECKED, |
| 222 REQUIRES_RESPONSE, | 231 REQUIRES_RESPONSE, |
| 223 REQUIRES_SIGN_IN, | 232 REQUIRES_SIGN_IN, |
| 224 REQUIRES_PASSIVE_SIGN_IN, | 233 REQUIRES_PASSIVE_SIGN_IN, |
| 225 SIGNED_IN, | 234 SIGNED_IN, |
| 226 SIGN_IN_DISABLED, | 235 SIGN_IN_DISABLED, |
| 227 }; | 236 }; |
| 228 | 237 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 241 } | 250 } |
| 242 | 251 |
| 243 // Returns the PersonalDataManager for |profile_|. | 252 // Returns the PersonalDataManager for |profile_|. |
| 244 virtual PersonalDataManager* GetManager() const; | 253 virtual PersonalDataManager* GetManager() const; |
| 245 | 254 |
| 246 // Returns the WalletClient* this class uses to talk to Online Wallet. Exposed | 255 // Returns the WalletClient* this class uses to talk to Online Wallet. Exposed |
| 247 // for testing. | 256 // for testing. |
| 248 const wallet::WalletClient* GetWalletClient() const; | 257 const wallet::WalletClient* GetWalletClient() const; |
| 249 virtual wallet::WalletClient* GetWalletClient(); | 258 virtual wallet::WalletClient* GetWalletClient(); |
| 250 | 259 |
| 260 // Returns an address validation helper. May be NULL during tests. | |
| 261 virtual ::i18n::addressinput::AddressValidator* GetValidator(); | |
| 262 | |
| 251 // Call to disable communication to Online Wallet for this dialog. | 263 // Call to disable communication to Online Wallet for this dialog. |
| 252 // Exposed for testing. | 264 // Exposed for testing. |
| 253 void DisableWallet(wallet::WalletClient::ErrorType error_type); | 265 void DisableWallet(wallet::WalletClient::ErrorType error_type); |
| 254 | 266 |
| 255 // Returns whether Wallet is the current data source. Exposed for testing. | 267 // Returns whether Wallet is the current data source. Exposed for testing. |
| 256 virtual bool IsPayingWithWallet() const; | 268 virtual bool IsPayingWithWallet() const; |
| 257 | 269 |
| 258 // Asks risk module to asynchronously load fingerprint data. Data will be | 270 // Asks risk module to asynchronously load fingerprint data. Data will be |
| 259 // returned via |OnDidLoadRiskFingerprintData()|. Exposed for testing. | 271 // returned via |OnDidLoadRiskFingerprintData()|. Exposed for testing. |
| 260 virtual void LoadRiskFingerprintData(); | 272 virtual void LoadRiskFingerprintData(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 AccountChooserModel* AccountChooserModelForTesting(); | 320 AccountChooserModel* AccountChooserModelForTesting(); |
| 309 | 321 |
| 310 // Returns whether |url| matches the sign in continue URL. If so, also fills | 322 // Returns whether |url| matches the sign in continue URL. If so, also fills |
| 311 // in |user_index| with the index of the user account that just signed in. | 323 // in |user_index| with the index of the user account that just signed in. |
| 312 virtual bool IsSignInContinueUrl(const GURL& url, size_t* user_index) const; | 324 virtual bool IsSignInContinueUrl(const GURL& url, size_t* user_index) const; |
| 313 | 325 |
| 314 // Whether the user is known to be signed in. | 326 // Whether the user is known to be signed in. |
| 315 DialogSignedInState SignedInState() const; | 327 DialogSignedInState SignedInState() const; |
| 316 | 328 |
| 317 private: | 329 private: |
| 330 FRIEND_TEST_ALL_PREFIXES(AutofillDialogControllerI18nTest, | |
| 331 CorrectCountryFromInputs); | |
| 332 | |
| 318 // Initializes or updates |suggested_cc_| et al. | 333 // Initializes or updates |suggested_cc_| et al. |
| 319 void SuggestionsUpdated(); | 334 void SuggestionsUpdated(); |
| 320 | 335 |
| 321 // Starts fetching the wallet items from Online Wallet. | 336 // Starts fetching the wallet items from Online Wallet. |
| 322 void GetWalletItems(); | 337 void GetWalletItems(); |
| 323 | 338 |
| 324 // Stop showing sign in flow. | 339 // Stop showing sign in flow. |
| 325 void HideSignIn(); | 340 void HideSignIn(); |
| 326 | 341 |
| 327 // Handles the SignedInState() on Wallet or sign-in state update. | 342 // Handles the SignedInState() on Wallet or sign-in state update. |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 689 base::WeakPtr<AutofillPopupControllerImpl> popup_controller_; | 704 base::WeakPtr<AutofillPopupControllerImpl> popup_controller_; |
| 690 | 705 |
| 691 // The type of the visible Autofill popup input (or UNKNOWN_TYPE if none). | 706 // The type of the visible Autofill popup input (or UNKNOWN_TYPE if none). |
| 692 ServerFieldType popup_input_type_; | 707 ServerFieldType popup_input_type_; |
| 693 | 708 |
| 694 scoped_ptr<AutofillDialogView> view_; | 709 scoped_ptr<AutofillDialogView> view_; |
| 695 | 710 |
| 696 // A NotificationRegistrar for tracking the completion of sign-in. | 711 // A NotificationRegistrar for tracking the completion of sign-in. |
| 697 content::NotificationRegistrar signin_registrar_; | 712 content::NotificationRegistrar signin_registrar_; |
| 698 | 713 |
| 699 base::WeakPtrFactory<AutofillDialogControllerImpl> weak_ptr_factory_; | |
| 700 | |
| 701 // Set to true when the user presses the sign in link, until we're ready to | 714 // Set to true when the user presses the sign in link, until we're ready to |
| 702 // show the normal dialog again. This is used to hide the buttons while | 715 // show the normal dialog again. This is used to hide the buttons while |
| 703 // the spinner is showing after an explicit sign in. | 716 // the spinner is showing after an explicit sign in. |
| 704 bool waiting_for_explicit_sign_in_response_; | 717 bool waiting_for_explicit_sign_in_response_; |
| 705 | 718 |
| 706 // Whether a user accepted legal documents while this dialog is running. | 719 // Whether a user accepted legal documents while this dialog is running. |
| 707 bool has_accepted_legal_documents_; | 720 bool has_accepted_legal_documents_; |
| 708 | 721 |
| 709 // True after the user first accepts the dialog and presses "Submit". May | 722 // True after the user first accepts the dialog and presses "Submit". May |
| 710 // continue to be true while processing required actions. | 723 // continue to be true while processing required actions. |
| 711 bool is_submitting_; | 724 bool is_submitting_; |
| 712 | 725 |
| 726 // A helper to validate international address input. | |
| 727 scoped_ptr< ::i18n::addressinput::AddressValidator> validator_; | |
|
Evan Stade
2014/02/01 00:56:31
why is this here in the middle of various state bo
Dan Beam
2014/02/01 01:14:54
Done.
| |
| 728 | |
| 713 // True if the last call to |GetFullWallet()| returned a | 729 // True if the last call to |GetFullWallet()| returned a |
| 714 // CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS required action, indicating that the | 730 // CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS required action, indicating that the |
| 715 // selected instrument or address had become invalid since it was originally | 731 // selected instrument or address had become invalid since it was originally |
| 716 // returned in |GetWalletItems()|. | 732 // returned in |GetWalletItems()|. |
| 717 bool choose_another_instrument_or_address_; | 733 bool choose_another_instrument_or_address_; |
| 718 | 734 |
| 719 // Whether or not the server side validation errors returned by Wallet were | 735 // Whether or not the server side validation errors returned by Wallet were |
| 720 // recoverable. | 736 // recoverable. |
| 721 bool wallet_server_validation_recoverable_; | 737 bool wallet_server_validation_recoverable_; |
| 722 | 738 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 767 base::OneShotTimer<AutofillDialogControllerImpl> card_scrambling_delay_; | 783 base::OneShotTimer<AutofillDialogControllerImpl> card_scrambling_delay_; |
| 768 base::RepeatingTimer<AutofillDialogControllerImpl> card_scrambling_refresher_; | 784 base::RepeatingTimer<AutofillDialogControllerImpl> card_scrambling_refresher_; |
| 769 | 785 |
| 770 // An animation which controls the background fade when the card is done | 786 // An animation which controls the background fade when the card is done |
| 771 // scrambling. | 787 // scrambling. |
| 772 gfx::LinearAnimation card_generated_animation_; | 788 gfx::LinearAnimation card_generated_animation_; |
| 773 | 789 |
| 774 // A username string we display in the card scrambling/generated overlay. | 790 // A username string we display in the card scrambling/generated overlay. |
| 775 base::string16 submitted_cardholder_name_; | 791 base::string16 submitted_cardholder_name_; |
| 776 | 792 |
| 793 base::WeakPtrFactory<AutofillDialogControllerImpl> weak_ptr_factory_; | |
| 794 | |
| 777 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); | 795 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); |
| 778 }; | 796 }; |
| 779 | 797 |
| 780 } // namespace autofill | 798 } // namespace autofill |
| 781 | 799 |
| 782 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 800 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
| OLD | NEW |