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 // Use "base/basictyptes.h" instead. |
| 9 #define I18N_ADDRESSINPUT_UTIL_BASICTYPES_H_ |
| 10 |
8 #include <set> | 11 #include <set> |
9 #include <vector> | 12 #include <vector> |
10 | 13 |
| 14 #include "base/basictypes.h" |
11 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
12 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
14 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
15 #include "base/time/time.h" | 19 #include "base/time/time.h" |
16 #include "chrome/browser/ui/autofill/account_chooser_model.h" | 20 #include "chrome/browser/ui/autofill/account_chooser_model.h" |
17 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | 21 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
18 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 22 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
19 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 23 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
20 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" | 24 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" |
21 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 25 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
22 #include "chrome/browser/ui/autofill/country_combobox_model.h" | 26 #include "chrome/browser/ui/autofill/country_combobox_model.h" |
23 #include "components/autofill/content/browser/wallet/wallet_client.h" | 27 #include "components/autofill/content/browser/wallet/wallet_client.h" |
24 #include "components/autofill/content/browser/wallet/wallet_client_delegate.h" | 28 #include "components/autofill/content/browser/wallet/wallet_client_delegate.h" |
25 #include "components/autofill/content/browser/wallet/wallet_items.h" | 29 #include "components/autofill/content/browser/wallet/wallet_items.h" |
26 #include "components/autofill/content/browser/wallet/wallet_signin_helper_delega
te.h" | 30 #include "components/autofill/content/browser/wallet/wallet_signin_helper_delega
te.h" |
27 #include "components/autofill/core/browser/autofill_manager_delegate.h" | 31 #include "components/autofill/core/browser/autofill_manager_delegate.h" |
28 #include "components/autofill/core/browser/autofill_metrics.h" | 32 #include "components/autofill/core/browser/autofill_metrics.h" |
29 #include "components/autofill/core/browser/autofill_popup_delegate.h" | 33 #include "components/autofill/core/browser/autofill_popup_delegate.h" |
30 #include "components/autofill/core/browser/field_types.h" | 34 #include "components/autofill/core/browser/field_types.h" |
31 #include "components/autofill/core/browser/form_structure.h" | 35 #include "components/autofill/core/browser/form_structure.h" |
32 #include "components/autofill/core/browser/personal_data_manager.h" | 36 #include "components/autofill/core/browser/personal_data_manager.h" |
33 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 37 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
34 #include "content/public/browser/notification_observer.h" | 38 #include "content/public/browser/notification_observer.h" |
35 #include "content/public/browser/notification_registrar.h" | 39 #include "content/public/browser/notification_registrar.h" |
36 #include "content/public/browser/web_contents_observer.h" | 40 #include "content/public/browser/web_contents_observer.h" |
37 #include "content/public/common/ssl_status.h" | 41 #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" | |
40 #include "third_party/skia/include/core/SkColor.h" | 42 #include "third_party/skia/include/core/SkColor.h" |
41 #include "ui/base/models/simple_menu_model.h" | 43 #include "ui/base/models/simple_menu_model.h" |
42 #include "ui/base/ui_base_types.h" | 44 #include "ui/base/ui_base_types.h" |
43 #include "ui/gfx/animation/animation_delegate.h" | 45 #include "ui/gfx/animation/animation_delegate.h" |
44 #include "ui/gfx/animation/linear_animation.h" | 46 #include "ui/gfx/animation/linear_animation.h" |
45 #include "url/gurl.h" | 47 #include "url/gurl.h" |
46 | 48 |
| 49 #define I18N_ADDRESSINPUT_UTIL_BASICTYPES_H_ // base/basictypes.h |
| 50 #include "third_party/libaddressinput/chromium/preload_address_validator.h" |
| 51 |
47 class Profile; | 52 class Profile; |
48 | 53 |
49 namespace content { | 54 namespace content { |
50 class WebContents; | 55 class WebContents; |
51 } | 56 } |
52 | 57 |
| 58 namespace i18n { |
| 59 namespace addressinput { |
| 60 struct AddressData; |
| 61 } // namespace addressinput |
| 62 } // namespace i18n |
| 63 |
53 namespace autofill { | 64 namespace autofill { |
54 | 65 |
55 class AutofillDataModel; | 66 class AutofillDataModel; |
56 class AutofillDialogView; | 67 class AutofillDialogView; |
57 class AutofillPopupControllerImpl; | 68 class AutofillPopupControllerImpl; |
58 class DataModelWrapper; | 69 class DataModelWrapper; |
59 | 70 |
60 namespace risk { | 71 namespace risk { |
61 class Fingerprint; | 72 class Fingerprint; |
62 } | 73 } |
63 | 74 |
64 namespace wallet { | 75 namespace wallet { |
65 class WalletSigninHelper; | 76 class WalletSigninHelper; |
66 } | 77 } |
67 | 78 |
68 // This class drives the dialog that appears when a site uses the imperative | 79 // This class drives the dialog that appears when a site uses the imperative |
69 // autocomplete API to fill out a form. | 80 // autocomplete API to fill out a form. |
70 class AutofillDialogControllerImpl | 81 class AutofillDialogControllerImpl |
71 : public AutofillDialogViewDelegate, | 82 : public AutofillDialogViewDelegate, |
72 public AutofillDialogController, | 83 public AutofillDialogController, |
73 public AutofillPopupDelegate, | 84 public AutofillPopupDelegate, |
74 public content::NotificationObserver, | 85 public content::NotificationObserver, |
75 public content::WebContentsObserver, | 86 public content::WebContentsObserver, |
76 public SuggestionsMenuModelDelegate, | 87 public SuggestionsMenuModelDelegate, |
77 public wallet::WalletClientDelegate, | 88 public wallet::WalletClientDelegate, |
78 public wallet::WalletSigninHelperDelegate, | 89 public wallet::WalletSigninHelperDelegate, |
79 public PersonalDataManagerObserver, | 90 public PersonalDataManagerObserver, |
80 public AccountChooserModelDelegate, | 91 public AccountChooserModelDelegate, |
81 public gfx::AnimationDelegate, | 92 public gfx::AnimationDelegate { |
82 public ::i18n::addressinput::LoadRulesDelegate { | |
83 public: | 93 public: |
84 virtual ~AutofillDialogControllerImpl(); | 94 virtual ~AutofillDialogControllerImpl(); |
85 | 95 |
86 static base::WeakPtr<AutofillDialogControllerImpl> Create( | 96 static base::WeakPtr<AutofillDialogControllerImpl> Create( |
87 content::WebContents* contents, | 97 content::WebContents* contents, |
88 const FormData& form_structure, | 98 const FormData& form_structure, |
89 const GURL& source_url, | 99 const GURL& source_url, |
90 const AutofillManagerDelegate::ResultCallback& callback); | 100 const AutofillManagerDelegate::ResultCallback& callback); |
91 | 101 |
92 // AutofillDialogController implementation. | 102 // AutofillDialogController implementation. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 virtual void OnPassiveSigninSuccess() OVERRIDE; | 221 virtual void OnPassiveSigninSuccess() OVERRIDE; |
212 virtual void OnPassiveSigninFailure( | 222 virtual void OnPassiveSigninFailure( |
213 const GoogleServiceAuthError& error) OVERRIDE; | 223 const GoogleServiceAuthError& error) OVERRIDE; |
214 virtual void OnDidFetchWalletCookieValue( | 224 virtual void OnDidFetchWalletCookieValue( |
215 const std::string& cookie_value) OVERRIDE; | 225 const std::string& cookie_value) OVERRIDE; |
216 | 226 |
217 // gfx::AnimationDelegate implementation. | 227 // gfx::AnimationDelegate implementation. |
218 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; | 228 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
219 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 229 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
220 | 230 |
221 // ::i18n::addressinput::LoadRulesDelegate implementation. | 231 // PreloadAddressValidator::Callback implementation. |
222 virtual void OnAddressValidationRulesLoaded(const std::string& country_code, | 232 void AddressValidationRulesLoaded(bool success, |
223 bool success) OVERRIDE; | 233 const std::string& country_code, |
| 234 const int& rule_count); |
224 | 235 |
225 protected: | 236 protected: |
226 enum DialogSignedInState { | 237 enum DialogSignedInState { |
227 NOT_CHECKED, | 238 NOT_CHECKED, |
228 REQUIRES_RESPONSE, | 239 REQUIRES_RESPONSE, |
229 REQUIRES_SIGN_IN, | 240 REQUIRES_SIGN_IN, |
230 REQUIRES_PASSIVE_SIGN_IN, | 241 REQUIRES_PASSIVE_SIGN_IN, |
231 SIGNED_IN, | 242 SIGNED_IN, |
232 SIGN_IN_DISABLED, | 243 SIGN_IN_DISABLED, |
233 }; | 244 }; |
234 | 245 |
235 // Exposed for testing. | 246 // Exposed for testing. |
236 AutofillDialogControllerImpl( | 247 AutofillDialogControllerImpl( |
237 content::WebContents* contents, | 248 content::WebContents* contents, |
238 const FormData& form_structure, | 249 const FormData& form_structure, |
239 const GURL& source_url, | 250 const GURL& source_url, |
240 const AutofillManagerDelegate::ResultCallback& callback); | 251 const AutofillManagerDelegate::ResultCallback& callback); |
241 | 252 |
242 // Exposed for testing. | 253 // Exposed for testing. |
243 AutofillDialogView* view() { return view_.get(); } | 254 AutofillDialogView* view() { return view_.get(); } |
244 virtual AutofillDialogView* CreateView(); | 255 virtual AutofillDialogView* CreateView(); |
245 ServerFieldType popup_input_type() const { | 256 ServerFieldType popup_input_type() const { |
246 return popup_input_type_; | 257 return popup_input_type_; |
247 } | 258 } |
248 | 259 |
249 // Returns the PersonalDataManager for |profile_|. | 260 // Returns the PersonalDataManager for |profile_|. |
250 virtual PersonalDataManager* GetManager() const; | 261 virtual PersonalDataManager* GetManager() const; |
251 | 262 |
252 // Returns an address validation helper. May be NULL during tests. | 263 // Returns an address validation helper. May be NULL during tests. |
253 virtual ::i18n::addressinput::AddressValidator* GetValidator(); | 264 virtual PreloadAddressValidator* GetValidator(); |
254 | 265 |
255 // Returns the WalletClient* this class uses to talk to Online Wallet. Exposed | 266 // Returns the WalletClient* this class uses to talk to Online Wallet. Exposed |
256 // for testing. | 267 // for testing. |
257 const wallet::WalletClient* GetWalletClient() const; | 268 const wallet::WalletClient* GetWalletClient() const; |
258 virtual wallet::WalletClient* GetWalletClient(); | 269 virtual wallet::WalletClient* GetWalletClient(); |
259 | 270 |
260 // Call to disable communication to Online Wallet for this dialog. | 271 // Call to disable communication to Online Wallet for this dialog. |
261 // Exposed for testing. | 272 // Exposed for testing. |
262 void DisableWallet(wallet::WalletClient::ErrorType error_type); | 273 void DisableWallet(wallet::WalletClient::ErrorType error_type); |
263 | 274 |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 scoped_ptr<AccountChooserModel> account_chooser_model_; | 658 scoped_ptr<AccountChooserModel> account_chooser_model_; |
648 | 659 |
649 // The sign-in helper to fetch the user's Wallet cookie and to perform passive | 660 // The sign-in helper to fetch the user's Wallet cookie and to perform passive |
650 // sign-in. The helper is set only during fetch/sign-in, and NULL otherwise. | 661 // sign-in. The helper is set only during fetch/sign-in, and NULL otherwise. |
651 scoped_ptr<wallet::WalletSigninHelper> signin_helper_; | 662 scoped_ptr<wallet::WalletSigninHelper> signin_helper_; |
652 | 663 |
653 // A client to talk to the Online Wallet API. | 664 // A client to talk to the Online Wallet API. |
654 wallet::WalletClient wallet_client_; | 665 wallet::WalletClient wallet_client_; |
655 | 666 |
656 // A helper to validate international address input. | 667 // A helper to validate international address input. |
657 scoped_ptr< ::i18n::addressinput::AddressValidator> validator_; | 668 scoped_ptr<PreloadAddressValidator> validator_; |
658 | 669 |
659 // True if |this| has ever called GetWalletItems(). | 670 // True if |this| has ever called GetWalletItems(). |
660 bool wallet_items_requested_; | 671 bool wallet_items_requested_; |
661 | 672 |
662 // True when the user has clicked the "Use Wallet" link and we're waiting to | 673 // True when the user has clicked the "Use Wallet" link and we're waiting to |
663 // figure out whether we need to ask them to actively sign in. | 674 // figure out whether we need to ask them to actively sign in. |
664 bool handling_use_wallet_link_click_; | 675 bool handling_use_wallet_link_click_; |
665 | 676 |
666 // True when the current WalletItems has a passive auth action which was | 677 // True when the current WalletItems has a passive auth action which was |
667 // attempted and failed. | 678 // attempted and failed. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 | 837 |
827 // An animation which controls the background fade when the card is done | 838 // An animation which controls the background fade when the card is done |
828 // scrambling. | 839 // scrambling. |
829 gfx::LinearAnimation card_generated_animation_; | 840 gfx::LinearAnimation card_generated_animation_; |
830 | 841 |
831 // A username string we display in the card scrambling/generated overlay. | 842 // A username string we display in the card scrambling/generated overlay. |
832 base::string16 submitted_cardholder_name_; | 843 base::string16 submitted_cardholder_name_; |
833 | 844 |
834 base::WeakPtrFactory<AutofillDialogControllerImpl> weak_ptr_factory_; | 845 base::WeakPtrFactory<AutofillDialogControllerImpl> weak_ptr_factory_; |
835 | 846 |
| 847 const scoped_ptr<PreloadAddressValidator::Callback> |
| 848 address_validation_rules_loaded_; |
| 849 |
836 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); | 850 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); |
837 }; | 851 }; |
838 | 852 |
839 } // namespace autofill | 853 } // namespace autofill |
840 | 854 |
841 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ | 855 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ |
OLD | NEW |