| 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 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "components/autofill/core/browser/autofill_metrics.h" | 28 #include "components/autofill/core/browser/autofill_metrics.h" |
| 29 #include "components/autofill/core/browser/autofill_popup_delegate.h" | 29 #include "components/autofill/core/browser/autofill_popup_delegate.h" |
| 30 #include "components/autofill/core/browser/field_types.h" | 30 #include "components/autofill/core/browser/field_types.h" |
| 31 #include "components/autofill/core/browser/form_structure.h" | 31 #include "components/autofill/core/browser/form_structure.h" |
| 32 #include "components/autofill/core/browser/personal_data_manager.h" | 32 #include "components/autofill/core/browser/personal_data_manager.h" |
| 33 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 33 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 34 #include "content/public/browser/notification_observer.h" | 34 #include "content/public/browser/notification_observer.h" |
| 35 #include "content/public/browser/notification_registrar.h" | 35 #include "content/public/browser/notification_registrar.h" |
| 36 #include "content/public/browser/web_contents_observer.h" | 36 #include "content/public/browser/web_contents_observer.h" |
| 37 #include "content/public/common/ssl_status.h" | 37 #include "content/public/common/ssl_status.h" |
| 38 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre
ss_validator.h" |
| 39 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/load_
rules_delegate.h" |
| 38 #include "third_party/skia/include/core/SkColor.h" | 40 #include "third_party/skia/include/core/SkColor.h" |
| 39 #include "ui/base/models/simple_menu_model.h" | 41 #include "ui/base/models/simple_menu_model.h" |
| 40 #include "ui/base/ui_base_types.h" | 42 #include "ui/base/ui_base_types.h" |
| 41 #include "ui/gfx/animation/animation_delegate.h" | 43 #include "ui/gfx/animation/animation_delegate.h" |
| 42 #include "ui/gfx/animation/linear_animation.h" | 44 #include "ui/gfx/animation/linear_animation.h" |
| 43 #include "url/gurl.h" | 45 #include "url/gurl.h" |
| 44 | 46 |
| 45 class Profile; | 47 class Profile; |
| 46 | 48 |
| 47 namespace content { | 49 namespace content { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 58 namespace risk { | 60 namespace risk { |
| 59 class Fingerprint; | 61 class Fingerprint; |
| 60 } | 62 } |
| 61 | 63 |
| 62 namespace wallet { | 64 namespace wallet { |
| 63 class WalletSigninHelper; | 65 class WalletSigninHelper; |
| 64 } | 66 } |
| 65 | 67 |
| 66 // This class drives the dialog that appears when a site uses the imperative | 68 // This class drives the dialog that appears when a site uses the imperative |
| 67 // autocomplete API to fill out a form. | 69 // autocomplete API to fill out a form. |
| 68 class AutofillDialogControllerImpl : public AutofillDialogViewDelegate, | 70 class AutofillDialogControllerImpl |
| 69 public AutofillDialogController, | 71 : public AutofillDialogViewDelegate, |
| 70 public AutofillPopupDelegate, | 72 public AutofillDialogController, |
| 71 public content::NotificationObserver, | 73 public AutofillPopupDelegate, |
| 72 public content::WebContentsObserver, | 74 public content::NotificationObserver, |
| 73 public SuggestionsMenuModelDelegate, | 75 public content::WebContentsObserver, |
| 74 public wallet::WalletClientDelegate, | 76 public SuggestionsMenuModelDelegate, |
| 75 public wallet::WalletSigninHelperDelegate, | 77 public wallet::WalletClientDelegate, |
| 76 public PersonalDataManagerObserver, | 78 public wallet::WalletSigninHelperDelegate, |
| 77 public AccountChooserModelDelegate, | 79 public PersonalDataManagerObserver, |
| 78 public gfx::AnimationDelegate { | 80 public AccountChooserModelDelegate, |
| 81 public gfx::AnimationDelegate, |
| 82 public ::i18n::addressinput::LoadRulesDelegate { |
| 79 public: | 83 public: |
| 80 virtual ~AutofillDialogControllerImpl(); | 84 virtual ~AutofillDialogControllerImpl(); |
| 81 | 85 |
| 82 static base::WeakPtr<AutofillDialogControllerImpl> Create( | 86 static base::WeakPtr<AutofillDialogControllerImpl> Create( |
| 83 content::WebContents* contents, | 87 content::WebContents* contents, |
| 84 const FormData& form_structure, | 88 const FormData& form_structure, |
| 85 const GURL& source_url, | 89 const GURL& source_url, |
| 86 const base::Callback<void(const FormStructure*)>& callback); | 90 const base::Callback<void(const FormStructure*)>& callback); |
| 87 | 91 |
| 88 // AutofillDialogController implementation. | 92 // AutofillDialogController implementation. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 virtual void OnPassiveSigninSuccess() OVERRIDE; | 213 virtual void OnPassiveSigninSuccess() OVERRIDE; |
| 210 virtual void OnPassiveSigninFailure( | 214 virtual void OnPassiveSigninFailure( |
| 211 const GoogleServiceAuthError& error) OVERRIDE; | 215 const GoogleServiceAuthError& error) OVERRIDE; |
| 212 virtual void OnDidFetchWalletCookieValue( | 216 virtual void OnDidFetchWalletCookieValue( |
| 213 const std::string& cookie_value) OVERRIDE; | 217 const std::string& cookie_value) OVERRIDE; |
| 214 | 218 |
| 215 // gfx::AnimationDelegate implementation. | 219 // gfx::AnimationDelegate implementation. |
| 216 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; | 220 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
| 217 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 221 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 218 | 222 |
| 223 // ::i18n::addressinput::LoadRulesDelegate implementation. |
| 224 virtual void OnAddressValidationRulesLoaded(const std::string& country_code, |
| 225 bool success) OVERRIDE; |
| 226 |
| 219 protected: | 227 protected: |
| 220 enum DialogSignedInState { | 228 enum DialogSignedInState { |
| 221 NOT_CHECKED, | 229 NOT_CHECKED, |
| 222 REQUIRES_RESPONSE, | 230 REQUIRES_RESPONSE, |
| 223 REQUIRES_SIGN_IN, | 231 REQUIRES_SIGN_IN, |
| 224 REQUIRES_PASSIVE_SIGN_IN, | 232 REQUIRES_PASSIVE_SIGN_IN, |
| 225 SIGNED_IN, | 233 SIGNED_IN, |
| 226 SIGN_IN_DISABLED, | 234 SIGN_IN_DISABLED, |
| 227 }; | 235 }; |
| 228 | 236 |
| 229 // Exposed for testing. | 237 // Exposed for testing. |
| 230 AutofillDialogControllerImpl( | 238 AutofillDialogControllerImpl( |
| 231 content::WebContents* contents, | 239 content::WebContents* contents, |
| 232 const FormData& form_structure, | 240 const FormData& form_structure, |
| 233 const GURL& source_url, | 241 const GURL& source_url, |
| 234 const base::Callback<void(const FormStructure*)>& callback); | 242 const base::Callback<void(const FormStructure*)>& callback); |
| 235 | 243 |
| 236 // Exposed for testing. | 244 // Exposed for testing. |
| 237 AutofillDialogView* view() { return view_.get(); } | 245 AutofillDialogView* view() { return view_.get(); } |
| 238 virtual AutofillDialogView* CreateView(); | 246 virtual AutofillDialogView* CreateView(); |
| 239 ServerFieldType popup_input_type() const { | 247 ServerFieldType popup_input_type() const { |
| 240 return popup_input_type_; | 248 return popup_input_type_; |
| 241 } | 249 } |
| 242 | 250 |
| 251 // Extract |type| from |inputs| using |section| to determine whether the info |
| 252 // should be billing or shipping specific (for sections with address info). |
| 253 static base::string16 GetInfoFromInputs(const FieldValueMap& inputs, |
| 254 DialogSection section, |
| 255 const AutofillType& type); |
| 256 |
| 243 // Returns the PersonalDataManager for |profile_|. | 257 // Returns the PersonalDataManager for |profile_|. |
| 244 virtual PersonalDataManager* GetManager() const; | 258 virtual PersonalDataManager* GetManager() const; |
| 245 | 259 |
| 246 // Returns the WalletClient* this class uses to talk to Online Wallet. Exposed | 260 // Returns the WalletClient* this class uses to talk to Online Wallet. Exposed |
| 247 // for testing. | 261 // for testing. |
| 248 const wallet::WalletClient* GetWalletClient() const; | 262 const wallet::WalletClient* GetWalletClient() const; |
| 249 virtual wallet::WalletClient* GetWalletClient(); | 263 virtual wallet::WalletClient* GetWalletClient(); |
| 250 | 264 |
| 265 // Returns an address validation helper. May be NULL during tests. |
| 266 virtual ::i18n::addressinput::AddressValidator* GetValidator(); |
| 267 |
| 251 // Call to disable communication to Online Wallet for this dialog. | 268 // Call to disable communication to Online Wallet for this dialog. |
| 252 // Exposed for testing. | 269 // Exposed for testing. |
| 253 void DisableWallet(wallet::WalletClient::ErrorType error_type); | 270 void DisableWallet(wallet::WalletClient::ErrorType error_type); |
| 254 | 271 |
| 255 // Returns whether Wallet is the current data source. Exposed for testing. | 272 // Returns whether Wallet is the current data source. Exposed for testing. |
| 256 virtual bool IsPayingWithWallet() const; | 273 virtual bool IsPayingWithWallet() const; |
| 257 | 274 |
| 258 // Asks risk module to asynchronously load fingerprint data. Data will be | 275 // Asks risk module to asynchronously load fingerprint data. Data will be |
| 259 // returned via |OnDidLoadRiskFingerprintData()|. Exposed for testing. | 276 // returned via |OnDidLoadRiskFingerprintData()|. Exposed for testing. |
| 260 virtual void LoadRiskFingerprintData(); | 277 virtual void LoadRiskFingerprintData(); |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 base::WeakPtr<AutofillPopupControllerImpl> popup_controller_; | 706 base::WeakPtr<AutofillPopupControllerImpl> popup_controller_; |
| 690 | 707 |
| 691 // The type of the visible Autofill popup input (or UNKNOWN_TYPE if none). | 708 // The type of the visible Autofill popup input (or UNKNOWN_TYPE if none). |
| 692 ServerFieldType popup_input_type_; | 709 ServerFieldType popup_input_type_; |
| 693 | 710 |
| 694 scoped_ptr<AutofillDialogView> view_; | 711 scoped_ptr<AutofillDialogView> view_; |
| 695 | 712 |
| 696 // A NotificationRegistrar for tracking the completion of sign-in. | 713 // A NotificationRegistrar for tracking the completion of sign-in. |
| 697 content::NotificationRegistrar signin_registrar_; | 714 content::NotificationRegistrar signin_registrar_; |
| 698 | 715 |
| 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 | 716 // 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 | 717 // show the normal dialog again. This is used to hide the buttons while |
| 703 // the spinner is showing after an explicit sign in. | 718 // the spinner is showing after an explicit sign in. |
| 704 bool waiting_for_explicit_sign_in_response_; | 719 bool waiting_for_explicit_sign_in_response_; |
| 705 | 720 |
| 706 // Whether a user accepted legal documents while this dialog is running. | 721 // Whether a user accepted legal documents while this dialog is running. |
| 707 bool has_accepted_legal_documents_; | 722 bool has_accepted_legal_documents_; |
| 708 | 723 |
| 709 // True after the user first accepts the dialog and presses "Submit". May | 724 // True after the user first accepts the dialog and presses "Submit". May |
| 710 // continue to be true while processing required actions. | 725 // continue to be true while processing required actions. |
| 711 bool is_submitting_; | 726 bool is_submitting_; |
| 712 | 727 |
| 728 // A helper to validate international address input. |
| 729 scoped_ptr< ::i18n::addressinput::AddressValidator> validator_; |
| 730 |
| 713 // True if the last call to |GetFullWallet()| returned a | 731 // True if the last call to |GetFullWallet()| returned a |
| 714 // CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS required action, indicating that the | 732 // CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS required action, indicating that the |
| 715 // selected instrument or address had become invalid since it was originally | 733 // selected instrument or address had become invalid since it was originally |
| 716 // returned in |GetWalletItems()|. | 734 // returned in |GetWalletItems()|. |
| 717 bool choose_another_instrument_or_address_; | 735 bool choose_another_instrument_or_address_; |
| 718 | 736 |
| 719 // Whether or not the server side validation errors returned by Wallet were | 737 // Whether or not the server side validation errors returned by Wallet were |
| 720 // recoverable. | 738 // recoverable. |
| 721 bool wallet_server_validation_recoverable_; | 739 bool wallet_server_validation_recoverable_; |
| 722 | 740 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 base::OneShotTimer<AutofillDialogControllerImpl> card_scrambling_delay_; | 785 base::OneShotTimer<AutofillDialogControllerImpl> card_scrambling_delay_; |
| 768 base::RepeatingTimer<AutofillDialogControllerImpl> card_scrambling_refresher_; | 786 base::RepeatingTimer<AutofillDialogControllerImpl> card_scrambling_refresher_; |
| 769 | 787 |
| 770 // An animation which controls the background fade when the card is done | 788 // An animation which controls the background fade when the card is done |
| 771 // scrambling. | 789 // scrambling. |
| 772 gfx::LinearAnimation card_generated_animation_; | 790 gfx::LinearAnimation card_generated_animation_; |
| 773 | 791 |
| 774 // A username string we display in the card scrambling/generated overlay. | 792 // A username string we display in the card scrambling/generated overlay. |
| 775 base::string16 submitted_cardholder_name_; | 793 base::string16 submitted_cardholder_name_; |
| 776 | 794 |
| 795 base::WeakPtrFactory<AutofillDialogControllerImpl> weak_ptr_factory_; |
| 796 |
| 777 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); | 797 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); |
| 778 }; | 798 }; |
| 779 | 799 |
| 780 } // namespace autofill | 800 } // namespace autofill |
| 781 | 801 |
| 782 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 802 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
| OLD | NEW |