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

Side by Side Diff: components/autofill/core/browser/autofill_manager.h

Issue 2839023003: WebView autofill implementation (Closed)
Patch Set: fix coordinates Created 3 years, 7 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
OLDNEW
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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 namespace autofill { 54 namespace autofill {
55 55
56 class AutofillDataModel; 56 class AutofillDataModel;
57 class AutofillDownloadManager; 57 class AutofillDownloadManager;
58 class AutofillExternalDelegate; 58 class AutofillExternalDelegate;
59 class AutofillField; 59 class AutofillField;
60 class AutofillClient; 60 class AutofillClient;
61 class AutofillManagerTestDelegate; 61 class AutofillManagerTestDelegate;
62 class AutofillProfile; 62 class AutofillProfile;
63 class AutofillProvider;
63 class AutofillType; 64 class AutofillType;
64 class CreditCard; 65 class CreditCard;
65 class FormStructureBrowserTest; 66 class FormStructureBrowserTest;
66 67
67 struct FormData; 68 struct FormData;
68 struct FormFieldData; 69 struct FormFieldData;
69 70
70 // We show the credit card signin promo only a certain number of times. 71 // We show the credit card signin promo only a certain number of times.
71 extern const int kCreditCardSigninPromoImpressionLimit; 72 extern const int kCreditCardSigninPromoImpressionLimit;
72 73
73 // Manages saving and restoring the user's personal information entered into web 74 // Manages saving and restoring the user's personal information entered into web
74 // forms. One per frame; owned by the AutofillDriver. 75 // forms. One per frame; owned by the AutofillDriver.
75 class AutofillManager : public AutofillDownloadManager::Observer, 76 class AutofillManager : public AutofillDownloadManager::Observer,
76 public payments::PaymentsClientDelegate, 77 public payments::PaymentsClientDelegate,
77 public payments::FullCardRequest::ResultDelegate, 78 public payments::FullCardRequest::ResultDelegate,
78 public payments::FullCardRequest::UIDelegate { 79 public payments::FullCardRequest::UIDelegate {
79 public: 80 public:
80 enum AutofillDownloadManagerState { 81 enum AutofillDownloadManagerState {
81 ENABLE_AUTOFILL_DOWNLOAD_MANAGER, 82 ENABLE_AUTOFILL_DOWNLOAD_MANAGER,
82 DISABLE_AUTOFILL_DOWNLOAD_MANAGER, 83 DISABLE_AUTOFILL_DOWNLOAD_MANAGER,
83 }; 84 };
84 85
85 // Registers our Enable/Disable Autofill pref. 86 // Registers our Enable/Disable Autofill pref.
86 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 87 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
87 88
88 AutofillManager(AutofillDriver* driver, 89 AutofillManager(AutofillDriver* driver,
89 AutofillClient* client, 90 AutofillClient* client,
90 const std::string& app_locale, 91 const std::string& app_locale,
91 AutofillDownloadManagerState enable_download_manager); 92 AutofillDownloadManagerState enable_download_manager,
93 AutofillProvider* provider);
92 ~AutofillManager() override; 94 ~AutofillManager() override;
93 95
94 // Sets an external delegate. 96 // Sets an external delegate.
95 void SetExternalDelegate(AutofillExternalDelegate* delegate); 97 void SetExternalDelegate(AutofillExternalDelegate* delegate);
96 98
97 void ShowAutofillSettings(); 99 void ShowAutofillSettings();
98 100
99 // Whether the |field| should show an entry to scan a credit card. 101 // Whether the |field| should show an entry to scan a credit card.
100 virtual bool ShouldShowScanCreditCard(const FormData& form, 102 virtual bool ShouldShowScanCreditCard(const FormData& form,
101 const FormFieldData& field); 103 const FormFieldData& field);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 return download_manager_.get(); 157 return download_manager_.get();
156 } 158 }
157 159
158 payments::FullCardRequest* GetOrCreateFullCardRequest(); 160 payments::FullCardRequest* GetOrCreateFullCardRequest();
159 161
160 base::WeakPtr<payments::FullCardRequest::UIDelegate> 162 base::WeakPtr<payments::FullCardRequest::UIDelegate>
161 GetAsFullCardRequestUIDelegate() { 163 GetAsFullCardRequestUIDelegate() {
162 return weak_ptr_factory_.GetWeakPtr(); 164 return weak_ptr_factory_.GetWeakPtr();
163 } 165 }
164 166
167 base::WeakPtr<AutofillManager> GetWeakPtr() {
168 return weak_ptr_factory_.GetWeakPtr();
169 }
170
165 const std::string& app_locale() const { return app_locale_; } 171 const std::string& app_locale() const { return app_locale_; }
166 172
167 // Only for testing. 173 // Only for testing.
168 void SetTestDelegate(AutofillManagerTestDelegate* delegate); 174 void SetTestDelegate(AutofillManagerTestDelegate* delegate);
169 175
170 void OnFormsSeen(const std::vector<FormData>& forms, 176 void OnFormsSeen(const std::vector<FormData>& forms,
171 const base::TimeTicks& timestamp); 177 const base::TimeTicks& timestamp);
172 178
173 void set_app_locale(std::string app_locale) { app_locale_ = app_locale; } 179 void set_app_locale(std::string app_locale) { app_locale_ = app_locale; }
174 180
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 228
223 // Returns true if all the conditions for enabling the upload of credit card 229 // Returns true if all the conditions for enabling the upload of credit card
224 // are satisfied. 230 // are satisfied.
225 virtual bool IsCreditCardUploadEnabled(); 231 virtual bool IsCreditCardUploadEnabled();
226 232
227 // Shared code to determine if |form| should be uploaded to the Autofill 233 // Shared code to determine if |form| should be uploaded to the Autofill
228 // server. It verifies that uploading is allowed and |form| meets conditions 234 // server. It verifies that uploading is allowed and |form| meets conditions
229 // to be uploadable. Exposed for testing. 235 // to be uploadable. Exposed for testing.
230 bool ShouldUploadForm(const FormStructure& form); 236 bool ShouldUploadForm(const FormStructure& form);
231 237
238 void SendFormDataToRenderer(int query_id,
239 AutofillDriver::RendererFormDataAction action,
240 const FormData& data);
241
232 protected: 242 protected:
233 // Test code should prefer to use this constructor. 243 // Test code should prefer to use this constructor.
234 AutofillManager(AutofillDriver* driver, 244 AutofillManager(AutofillDriver* driver,
235 AutofillClient* client, 245 AutofillClient* client,
236 PersonalDataManager* personal_data); 246 PersonalDataManager* personal_data);
237 247
238 // Uploads the form data to the Autofill server. |observed_submission| 248 // Uploads the form data to the Autofill server. |observed_submission|
239 // indicates that upload is the result of a submission event. 249 // indicates that upload is the result of a submission event.
240 virtual void UploadFormData(const FormStructure& submitted_form, 250 virtual void UploadFormData(const FormStructure& submitted_form,
241 bool observed_submission); 251 bool observed_submission);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 // our behalf. Weak. 590 // our behalf. Weak.
581 AutofillExternalDelegate* external_delegate_; 591 AutofillExternalDelegate* external_delegate_;
582 592
583 // Delegate used in test to get notifications on certain events. 593 // Delegate used in test to get notifications on certain events.
584 AutofillManagerTestDelegate* test_delegate_; 594 AutofillManagerTestDelegate* test_delegate_;
585 595
586 #if defined(OS_ANDROID) || defined(OS_IOS) 596 #if defined(OS_ANDROID) || defined(OS_IOS)
587 AutofillAssistant autofill_assistant_; 597 AutofillAssistant autofill_assistant_;
588 #endif 598 #endif
589 599
600 AutofillProvider* provider_;
601
590 base::WeakPtrFactory<AutofillManager> weak_ptr_factory_; 602 base::WeakPtrFactory<AutofillManager> weak_ptr_factory_;
591 603
592 friend class AutofillManagerTest; 604 friend class AutofillManagerTest;
593 friend class FormStructureBrowserTest; 605 friend class FormStructureBrowserTest;
594 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, 606 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
595 DeterminePossibleFieldTypesForUpload); 607 DeterminePossibleFieldTypesForUpload);
596 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, 608 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
597 DeterminePossibleFieldTypesForUploadStressTest); 609 DeterminePossibleFieldTypesForUploadStressTest);
598 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, DisambiguateUploadTypes); 610 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, DisambiguateUploadTypes);
599 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, 611 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, 643 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
632 OnLoadedServerPredictions_ResetManager); 644 OnLoadedServerPredictions_ResetManager);
633 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, DontOfferToSavePaymentsCard); 645 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, DontOfferToSavePaymentsCard);
634 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, FillInUpdatedExpirationDate); 646 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, FillInUpdatedExpirationDate);
635 DISALLOW_COPY_AND_ASSIGN(AutofillManager); 647 DISALLOW_COPY_AND_ASSIGN(AutofillManager);
636 }; 648 };
637 649
638 } // namespace autofill 650 } // namespace autofill
639 651
640 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ 652 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698