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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.h

Issue 298863012: Use upstream libaddressinput in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review. Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/basictypes.h"
11 #include "base/gtest_prod_util.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"
38 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_validator.h" 39 #include "third_party/libaddressinput/chromium/preload_address_validator.h"
39 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/load_ rules_delegate.h"
40 #include "third_party/skia/include/core/SkColor.h" 40 #include "third_party/skia/include/core/SkColor.h"
41 #include "ui/base/models/simple_menu_model.h" 41 #include "ui/base/models/simple_menu_model.h"
42 #include "ui/base/ui_base_types.h" 42 #include "ui/base/ui_base_types.h"
43 #include "ui/gfx/animation/animation_delegate.h" 43 #include "ui/gfx/animation/animation_delegate.h"
44 #include "ui/gfx/animation/linear_animation.h" 44 #include "ui/gfx/animation/linear_animation.h"
45 #include "url/gurl.h" 45 #include "url/gurl.h"
46 46
47 class Profile; 47 class Profile;
48 48
49 namespace content { 49 namespace content {
50 class WebContents; 50 class WebContents;
51 } 51 }
52 52
53 namespace i18n {
54 namespace addressinput {
55 struct AddressData;
56 }
57 }
58
53 namespace autofill { 59 namespace autofill {
54 60
55 class AutofillDataModel; 61 class AutofillDataModel;
56 class AutofillDialogView; 62 class AutofillDialogView;
57 class AutofillPopupControllerImpl; 63 class AutofillPopupControllerImpl;
58 class DataModelWrapper; 64 class DataModelWrapper;
59 65
60 namespace risk { 66 namespace risk {
61 class Fingerprint; 67 class Fingerprint;
62 } 68 }
63 69
64 namespace wallet { 70 namespace wallet {
65 class WalletSigninHelper; 71 class WalletSigninHelper;
66 } 72 }
67 73
68 // This class drives the dialog that appears when a site uses the imperative 74 // This class drives the dialog that appears when a site uses the imperative
69 // autocomplete API to fill out a form. 75 // autocomplete API to fill out a form.
70 class AutofillDialogControllerImpl 76 class AutofillDialogControllerImpl
71 : public AutofillDialogViewDelegate, 77 : public AutofillDialogViewDelegate,
72 public AutofillDialogController, 78 public AutofillDialogController,
73 public AutofillPopupDelegate, 79 public AutofillPopupDelegate,
74 public content::NotificationObserver, 80 public content::NotificationObserver,
75 public content::WebContentsObserver, 81 public content::WebContentsObserver,
76 public SuggestionsMenuModelDelegate, 82 public SuggestionsMenuModelDelegate,
77 public wallet::WalletClientDelegate, 83 public wallet::WalletClientDelegate,
78 public wallet::WalletSigninHelperDelegate, 84 public wallet::WalletSigninHelperDelegate,
79 public PersonalDataManagerObserver, 85 public PersonalDataManagerObserver,
80 public AccountChooserModelDelegate, 86 public AccountChooserModelDelegate,
81 public gfx::AnimationDelegate, 87 public gfx::AnimationDelegate {
82 public ::i18n::addressinput::LoadRulesDelegate {
please use gerrit instead 2014/06/05 22:22:47 To reduce reviewer burden: Bring back LoadRulesDel
83 public: 88 public:
84 virtual ~AutofillDialogControllerImpl(); 89 virtual ~AutofillDialogControllerImpl();
85 90
86 static base::WeakPtr<AutofillDialogControllerImpl> Create( 91 static base::WeakPtr<AutofillDialogControllerImpl> Create(
87 content::WebContents* contents, 92 content::WebContents* contents,
88 const FormData& form_structure, 93 const FormData& form_structure,
89 const GURL& source_url, 94 const GURL& source_url,
90 const AutofillManagerDelegate::ResultCallback& callback); 95 const AutofillManagerDelegate::ResultCallback& callback);
91 96
92 // AutofillDialogController implementation. 97 // AutofillDialogController implementation.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 virtual void OnPassiveSigninSuccess() OVERRIDE; 216 virtual void OnPassiveSigninSuccess() OVERRIDE;
212 virtual void OnPassiveSigninFailure( 217 virtual void OnPassiveSigninFailure(
213 const GoogleServiceAuthError& error) OVERRIDE; 218 const GoogleServiceAuthError& error) OVERRIDE;
214 virtual void OnDidFetchWalletCookieValue( 219 virtual void OnDidFetchWalletCookieValue(
215 const std::string& cookie_value) OVERRIDE; 220 const std::string& cookie_value) OVERRIDE;
216 221
217 // gfx::AnimationDelegate implementation. 222 // gfx::AnimationDelegate implementation.
218 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; 223 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
219 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; 224 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
220 225
221 // ::i18n::addressinput::LoadRulesDelegate implementation. 226 // PreloadAddressValidator::Callback implementation.
222 virtual void OnAddressValidationRulesLoaded(const std::string& country_code, 227 void AddressValidationRulesLoaded(bool success,
223 bool success) OVERRIDE; 228 const std::string& country_code,
229 const int& rule_count);
224 230
225 protected: 231 protected:
226 enum DialogSignedInState { 232 enum DialogSignedInState {
227 NOT_CHECKED, 233 NOT_CHECKED,
228 REQUIRES_RESPONSE, 234 REQUIRES_RESPONSE,
229 REQUIRES_SIGN_IN, 235 REQUIRES_SIGN_IN,
230 REQUIRES_PASSIVE_SIGN_IN, 236 REQUIRES_PASSIVE_SIGN_IN,
231 SIGNED_IN, 237 SIGNED_IN,
232 SIGN_IN_DISABLED, 238 SIGN_IN_DISABLED,
233 }; 239 };
234 240
235 // Exposed for testing. 241 // Exposed for testing.
236 AutofillDialogControllerImpl( 242 AutofillDialogControllerImpl(
237 content::WebContents* contents, 243 content::WebContents* contents,
238 const FormData& form_structure, 244 const FormData& form_structure,
239 const GURL& source_url, 245 const GURL& source_url,
240 const AutofillManagerDelegate::ResultCallback& callback); 246 const AutofillManagerDelegate::ResultCallback& callback);
241 247
242 // Exposed for testing. 248 // Exposed for testing.
243 AutofillDialogView* view() { return view_.get(); } 249 AutofillDialogView* view() { return view_.get(); }
244 virtual AutofillDialogView* CreateView(); 250 virtual AutofillDialogView* CreateView();
245 ServerFieldType popup_input_type() const { 251 ServerFieldType popup_input_type() const {
246 return popup_input_type_; 252 return popup_input_type_;
247 } 253 }
248 254
249 // Returns the PersonalDataManager for |profile_|. 255 // Returns the PersonalDataManager for |profile_|.
250 virtual PersonalDataManager* GetManager() const; 256 virtual PersonalDataManager* GetManager() const;
251 257
252 // Returns an address validation helper. May be NULL during tests. 258 // Returns an address validation helper. May be NULL during tests.
253 virtual ::i18n::addressinput::AddressValidator* GetValidator(); 259 virtual PreloadAddressValidator* GetValidator();
254 260
255 // Returns the WalletClient* this class uses to talk to Online Wallet. Exposed 261 // Returns the WalletClient* this class uses to talk to Online Wallet. Exposed
256 // for testing. 262 // for testing.
257 const wallet::WalletClient* GetWalletClient() const; 263 const wallet::WalletClient* GetWalletClient() const;
258 virtual wallet::WalletClient* GetWalletClient(); 264 virtual wallet::WalletClient* GetWalletClient();
259 265
260 // Call to disable communication to Online Wallet for this dialog. 266 // Call to disable communication to Online Wallet for this dialog.
261 // Exposed for testing. 267 // Exposed for testing.
262 void DisableWallet(wallet::WalletClient::ErrorType error_type); 268 void DisableWallet(wallet::WalletClient::ErrorType error_type);
263 269
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 scoped_ptr<AccountChooserModel> account_chooser_model_; 653 scoped_ptr<AccountChooserModel> account_chooser_model_;
648 654
649 // The sign-in helper to fetch the user's Wallet cookie and to perform passive 655 // 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. 656 // sign-in. The helper is set only during fetch/sign-in, and NULL otherwise.
651 scoped_ptr<wallet::WalletSigninHelper> signin_helper_; 657 scoped_ptr<wallet::WalletSigninHelper> signin_helper_;
652 658
653 // A client to talk to the Online Wallet API. 659 // A client to talk to the Online Wallet API.
654 wallet::WalletClient wallet_client_; 660 wallet::WalletClient wallet_client_;
655 661
656 // A helper to validate international address input. 662 // A helper to validate international address input.
657 scoped_ptr< ::i18n::addressinput::AddressValidator> validator_; 663 scoped_ptr<PreloadAddressValidator> validator_;
658 664
659 // True if |this| has ever called GetWalletItems(). 665 // True if |this| has ever called GetWalletItems().
660 bool wallet_items_requested_; 666 bool wallet_items_requested_;
661 667
662 // True when the user has clicked the "Use Wallet" link and we're waiting to 668 // 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. 669 // figure out whether we need to ask them to actively sign in.
664 bool handling_use_wallet_link_click_; 670 bool handling_use_wallet_link_click_;
665 671
666 // True when the current WalletItems has a passive auth action which was 672 // True when the current WalletItems has a passive auth action which was
667 // attempted and failed. 673 // attempted and failed.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 832
827 // An animation which controls the background fade when the card is done 833 // An animation which controls the background fade when the card is done
828 // scrambling. 834 // scrambling.
829 gfx::LinearAnimation card_generated_animation_; 835 gfx::LinearAnimation card_generated_animation_;
830 836
831 // A username string we display in the card scrambling/generated overlay. 837 // A username string we display in the card scrambling/generated overlay.
832 base::string16 submitted_cardholder_name_; 838 base::string16 submitted_cardholder_name_;
833 839
834 base::WeakPtrFactory<AutofillDialogControllerImpl> weak_ptr_factory_; 840 base::WeakPtrFactory<AutofillDialogControllerImpl> weak_ptr_factory_;
835 841
842 const scoped_ptr<PreloadAddressValidator::Callback>
843 address_validation_rules_loaded_;
please use gerrit instead 2014/06/05 22:22:47 To reduce reviewer burden: Use autofill::LoadRules
844
836 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl); 845 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerImpl);
837 }; 846 };
838 847
839 } // namespace autofill 848 } // namespace autofill
840 849
841 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_ 850 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698