OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_AUTOFILL_AUTOFILL_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 virtual void OnLoadedAutoFillHeuristics(const std::string& heuristic_xml); | 60 virtual void OnLoadedAutoFillHeuristics(const std::string& heuristic_xml); |
61 virtual void OnUploadedAutoFillHeuristics(const std::string& form_signature); | 61 virtual void OnUploadedAutoFillHeuristics(const std::string& form_signature); |
62 virtual void OnHeuristicsRequestError( | 62 virtual void OnHeuristicsRequestError( |
63 const std::string& form_signature, | 63 const std::string& form_signature, |
64 AutoFillDownloadManager::AutoFillRequestType request_type, | 64 AutoFillDownloadManager::AutoFillRequestType request_type, |
65 int http_error); | 65 int http_error); |
66 | 66 |
67 // Returns the value of the AutoFillEnabled pref. | 67 // Returns the value of the AutoFillEnabled pref. |
68 virtual bool IsAutoFillEnabled() const; | 68 virtual bool IsAutoFillEnabled() const; |
69 | 69 |
70 // Handles the form data submitted by the user. | 70 // Imports the form data, submitted by the user, into |personal_data_|. |
71 void HandleSubmit(); | 71 void ImportFormData(const FormStructure& submitted_form); |
72 | 72 |
73 // Uploads the form data to the AutoFill server. | 73 // Uploads the form data to the AutoFill server. |
74 void UploadFormData(); | 74 void UploadFormData(const FormStructure& submitted_form); |
75 | 75 |
76 // Reset cache. | 76 // Reset cache. |
77 void Reset(); | 77 void Reset(); |
78 | 78 |
79 protected: | 79 protected: |
80 // For tests. | 80 // For tests. |
81 AutoFillManager(); | 81 AutoFillManager(); |
82 AutoFillManager(TabContents* tab_contents, | 82 AutoFillManager(TabContents* tab_contents, |
83 PersonalDataManager* personal_data); | 83 PersonalDataManager* personal_data); |
84 | 84 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 // Set |field| argument's value for phone number based on contents of the | 167 // Set |field| argument's value for phone number based on contents of the |
168 // |profile|. | 168 // |profile|. |
169 void FillPhoneNumberField(const AutoFillProfile* profile, | 169 void FillPhoneNumberField(const AutoFillProfile* profile, |
170 webkit_glue::FormField* field); | 170 webkit_glue::FormField* field); |
171 | 171 |
172 // Parses the forms using heuristic matching and querying the AutoFill server. | 172 // Parses the forms using heuristic matching and querying the AutoFill server. |
173 void ParseForms(const std::vector<webkit_glue::FormData>& forms); | 173 void ParseForms(const std::vector<webkit_glue::FormData>& forms); |
174 | 174 |
175 // Uses existing personal data to determine possible field types for the | 175 // Uses existing personal data to determine possible field types for the |
176 // |upload_form_structure_|. | 176 // |submitted_form|. |
177 void DeterminePossibleFieldTypesForUpload( | 177 void DeterminePossibleFieldTypesForUpload(FormStructure* submitted_form); |
178 const FormStructure* cached_upload_form_structure); | 178 |
| 179 void LogMetricsAboutSubmittedForm(const webkit_glue::FormData& form, |
| 180 const FormStructure* submitted_form); |
179 | 181 |
180 // The TabContents hosting this AutoFillManager. | 182 // The TabContents hosting this AutoFillManager. |
181 // Weak reference. | 183 // Weak reference. |
182 // May not be NULL. | 184 // May not be NULL. |
183 TabContents* tab_contents_; | 185 TabContents* tab_contents_; |
184 | 186 |
185 // The personal data manager, used to save and load personal data to/from the | 187 // The personal data manager, used to save and load personal data to/from the |
186 // web database. This is overridden by the AutoFillManagerTest. | 188 // web database. This is overridden by the AutoFillManagerTest. |
187 // Weak reference. | 189 // Weak reference. |
188 // May be NULL. NULL indicates OTR. | 190 // May be NULL. NULL indicates OTR. |
189 PersonalDataManager* personal_data_; | 191 PersonalDataManager* personal_data_; |
190 | 192 |
191 std::list<std::string> autofilled_forms_signatures_; | 193 std::list<std::string> autofilled_forms_signatures_; |
192 // Handles queries and uploads to AutoFill servers. | 194 // Handles queries and uploads to AutoFill servers. |
193 AutoFillDownloadManager download_manager_; | 195 AutoFillDownloadManager download_manager_; |
194 | 196 |
195 // Should be set to true in AutoFillManagerTest and other tests, false in | 197 // Should be set to true in AutoFillManagerTest and other tests, false in |
196 // AutoFillDownloadManagerTest and in non-test environment. Is false by | 198 // AutoFillDownloadManagerTest and in non-test environment. Is false by |
197 // default for the public constructor, and true by default for the test-only | 199 // default for the public constructor, and true by default for the test-only |
198 // constructors. | 200 // constructors. |
199 bool disable_download_manager_requests_; | 201 bool disable_download_manager_requests_; |
200 | 202 |
201 // For logging UMA metrics. Overridden by metrics tests. | 203 // For logging UMA metrics. Overridden by metrics tests. |
202 scoped_ptr<const AutoFillMetrics> metric_logger_; | 204 scoped_ptr<const AutoFillMetrics> metric_logger_; |
203 | 205 |
204 // Our copy of the form data. | 206 // Our copy of the form data. |
205 ScopedVector<FormStructure> form_structures_; | 207 ScopedVector<FormStructure> form_structures_; |
206 | 208 |
207 // The form data the user has submitted. | |
208 scoped_ptr<FormStructure> upload_form_structure_; | |
209 | |
210 // The InfoBar that asks for permission to store credit card information. | 209 // The InfoBar that asks for permission to store credit card information. |
211 // Deletes itself when closed. | 210 // Deletes itself when closed. |
212 AutoFillCCInfoBarDelegate* cc_infobar_; | 211 AutoFillCCInfoBarDelegate* cc_infobar_; |
213 | 212 |
214 // GUID to ID mapping. We keep two maps to convert back and forth. | 213 // GUID to ID mapping. We keep two maps to convert back and forth. |
215 std::map<std::string, int> guid_id_map_; | 214 std::map<std::string, int> guid_id_map_; |
216 std::map<int, std::string> id_guid_map_; | 215 std::map<int, std::string> id_guid_map_; |
217 | 216 |
218 friend class AutoFillManagerTest; | 217 friend class AutoFillManagerTest; |
219 friend class FormStructureBrowserTest; | 218 friend class FormStructureBrowserTest; |
220 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillCreditCardForm); | 219 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillCreditCardForm); |
221 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAddressForm); | 220 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAddressForm); |
222 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAddressAndCreditCardForm); | 221 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAddressAndCreditCardForm); |
223 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAutoFilledForm); | 222 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAutoFilledForm); |
224 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillPhoneNumber); | 223 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillPhoneNumber); |
225 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FormChangesRemoveField); | 224 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FormChangesRemoveField); |
226 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FormChangesAddField); | 225 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FormChangesAddField); |
227 FRIEND_TEST_ALL_PREFIXES(AutoFillMetricsTest, QualityMetrics); | 226 FRIEND_TEST_ALL_PREFIXES(AutoFillMetricsTest, QualityMetrics); |
228 FRIEND_TEST_ALL_PREFIXES(AutoFillMetricsTest, | 227 FRIEND_TEST_ALL_PREFIXES(AutoFillMetricsTest, |
229 NoQualityMetricsForNonAutoFillableForms); | 228 NoQualityMetricsForNonAutoFillableForms); |
230 FRIEND_TEST_ALL_PREFIXES(AutoFillMetricsTest, QualityMetricsForFailure); | 229 FRIEND_TEST_ALL_PREFIXES(AutoFillMetricsTest, QualityMetricsForFailure); |
231 | 230 |
232 DISALLOW_COPY_AND_ASSIGN(AutoFillManager); | 231 DISALLOW_COPY_AND_ASSIGN(AutoFillManager); |
233 }; | 232 }; |
234 | 233 |
235 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 234 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
OLD | NEW |