OLD | NEW |
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 <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 virtual void UploadFormData(const FormStructure& submitted_form); | 190 virtual void UploadFormData(const FormStructure& submitted_form); |
191 | 191 |
192 // Logs quality metrics for the |submitted_form| and uploads the form data | 192 // Logs quality metrics for the |submitted_form| and uploads the form data |
193 // to the crowdsourcing server, if appropriate. | 193 // to the crowdsourcing server, if appropriate. |
194 virtual void UploadFormDataAsyncCallback( | 194 virtual void UploadFormDataAsyncCallback( |
195 const FormStructure* submitted_form, | 195 const FormStructure* submitted_form, |
196 const base::TimeTicks& load_time, | 196 const base::TimeTicks& load_time, |
197 const base::TimeTicks& interaction_time, | 197 const base::TimeTicks& interaction_time, |
198 const base::TimeTicks& submission_time); | 198 const base::TimeTicks& submission_time); |
199 | 199 |
200 // Maps GUIDs to and from IDs that are used to identify profiles and credit | 200 // Maps SuggestionBackendID to and from an integer identifying it. Two of |
201 // cards sent to and from the renderer process. | 201 // these intermediate integers are packed by MakeFrontendID to make the IDs |
202 virtual int GUIDToID(const PersonalDataManager::GUIDPair& guid) const; | 202 // that this class generates for the UI and for IPC. |
203 virtual const PersonalDataManager::GUIDPair IDToGUID(int id) const; | 203 virtual int BackendIDToInt(const SuggestionBackendID& backend_id) const; |
| 204 virtual SuggestionBackendID IntToBackendID(int int_id) const; |
204 | 205 |
205 // Methods for packing and unpacking credit card and profile IDs for sending | 206 // Methods for packing and unpacking credit card and profile IDs for sending |
206 // and receiving to and from the renderer process. | 207 // and receiving to and from the renderer process. |
207 int PackGUIDs(const PersonalDataManager::GUIDPair& cc_guid, | 208 int MakeFrontendID(const SuggestionBackendID& cc_backend_id, |
208 const PersonalDataManager::GUIDPair& profile_guid) const; | 209 const SuggestionBackendID& profile_backend_id) const; |
209 void UnpackGUIDs(int id, | 210 void SplitFrontendID(int frontend_id, |
210 PersonalDataManager::GUIDPair* cc_guid, | 211 SuggestionBackendID* cc_backend_id, |
211 PersonalDataManager::GUIDPair* profile_guid) const; | 212 SuggestionBackendID* profile_backend_id) const; |
212 | 213 |
213 const AutofillMetrics* metric_logger() const { return metric_logger_.get(); } | 214 const AutofillMetrics* metric_logger() const { return metric_logger_.get(); } |
214 void set_metric_logger(const AutofillMetrics* metric_logger); | 215 void set_metric_logger(const AutofillMetrics* metric_logger); |
215 | 216 |
216 ScopedVector<FormStructure>* form_structures() { return &form_structures_; } | 217 ScopedVector<FormStructure>* form_structures() { return &form_structures_; } |
217 | 218 |
218 // Exposed for testing. | 219 // Exposed for testing. |
219 AutofillExternalDelegate* external_delegate() { | 220 AutofillExternalDelegate* external_delegate() { |
220 return external_delegate_; | 221 return external_delegate_; |
221 } | 222 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // |cached_form| should be a pointer to the existing version of the form, or | 271 // |cached_form| should be a pointer to the existing version of the form, or |
271 // NULL if no cached version exists. The updated form is then written into | 272 // NULL if no cached version exists. The updated form is then written into |
272 // |updated_form|. Returns false if the cache could not be updated. | 273 // |updated_form|. Returns false if the cache could not be updated. |
273 bool UpdateCachedForm(const FormData& live_form, | 274 bool UpdateCachedForm(const FormData& live_form, |
274 const FormStructure* cached_form, | 275 const FormStructure* cached_form, |
275 FormStructure** updated_form) WARN_UNUSED_RESULT; | 276 FormStructure** updated_form) WARN_UNUSED_RESULT; |
276 | 277 |
277 // Returns a list of values from the stored profiles that match |type| and the | 278 // Returns a list of values from the stored profiles that match |type| and the |
278 // value of |field| and returns the labels of the matching profiles. |labels| | 279 // value of |field| and returns the labels of the matching profiles. |labels| |
279 // is filled with the Profile label. | 280 // is filled with the Profile label. |
280 void GetProfileSuggestions(const FormStructure& form, | 281 std::vector<Suggestion> GetProfileSuggestions( |
281 const FormFieldData& field, | 282 const FormStructure& form, |
282 const AutofillField& autofill_field, | 283 const FormFieldData& field, |
283 std::vector<base::string16>* values, | 284 const AutofillField& autofill_field) const; |
284 std::vector<base::string16>* labels, | |
285 std::vector<base::string16>* icons, | |
286 std::vector<int>* unique_ids) const; | |
287 | 285 |
288 // Returns a list of values from the stored credit cards that match |type| and | 286 // Returns a list of values from the stored credit cards that match |type| and |
289 // the value of |field| and returns the labels of the matching credit cards. | 287 // the value of |field| and returns the labels of the matching credit cards. |
290 void GetCreditCardSuggestions(const FormFieldData& field, | 288 std::vector<Suggestion> GetCreditCardSuggestions( |
291 const AutofillType& type, | 289 const FormFieldData& field, |
292 std::vector<base::string16>* values, | 290 const AutofillType& type) const; |
293 std::vector<base::string16>* labels, | |
294 std::vector<base::string16>* icons, | |
295 std::vector<int>* unique_ids) const; | |
296 | 291 |
297 // Parses the forms using heuristic matching and querying the Autofill server. | 292 // Parses the forms using heuristic matching and querying the Autofill server. |
298 void ParseForms(const std::vector<FormData>& forms); | 293 void ParseForms(const std::vector<FormData>& forms); |
299 | 294 |
300 // Imports the form data, submitted by the user, into |personal_data_|. | 295 // Imports the form data, submitted by the user, into |personal_data_|. |
301 void ImportFormData(const FormStructure& submitted_form); | 296 void ImportFormData(const FormStructure& submitted_form); |
302 | 297 |
303 // If |initial_interaction_timestamp_| is unset or is set to a later time than | 298 // If |initial_interaction_timestamp_| is unset or is set to a later time than |
304 // |interaction_timestamp|, updates the cached timestamp. The latter check is | 299 // |interaction_timestamp|, updates the cached timestamp. The latter check is |
305 // needed because IPC messages can arrive out of order. | 300 // needed because IPC messages can arrive out of order. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 bool user_did_edit_autofilled_field_; | 344 bool user_did_edit_autofilled_field_; |
350 // When the form finished loading. | 345 // When the form finished loading. |
351 std::map<FormData, base::TimeTicks> forms_loaded_timestamps_; | 346 std::map<FormData, base::TimeTicks> forms_loaded_timestamps_; |
352 // When the user first interacted with a potentially fillable form on this | 347 // When the user first interacted with a potentially fillable form on this |
353 // page. | 348 // page. |
354 base::TimeTicks initial_interaction_timestamp_; | 349 base::TimeTicks initial_interaction_timestamp_; |
355 | 350 |
356 // Our copy of the form data. | 351 // Our copy of the form data. |
357 ScopedVector<FormStructure> form_structures_; | 352 ScopedVector<FormStructure> form_structures_; |
358 | 353 |
359 // GUID to ID mapping. We keep two maps to convert back and forth. | 354 // SuggestionBackendID to ID mapping. We keep two maps to convert back and |
360 mutable std::map<PersonalDataManager::GUIDPair, int> guid_id_map_; | 355 // forth. These should be used only by BackendIDToInt and IntToBackendID. |
361 mutable std::map<int, PersonalDataManager::GUIDPair> id_guid_map_; | 356 // Note that the integers are not frontend IDs. |
| 357 mutable std::map<SuggestionBackendID, int> backend_to_int_map_; |
| 358 mutable std::map<int, SuggestionBackendID> int_to_backend_map_; |
362 | 359 |
363 // Delegate to perform external processing (display, selection) on | 360 // Delegate to perform external processing (display, selection) on |
364 // our behalf. Weak. | 361 // our behalf. Weak. |
365 AutofillExternalDelegate* external_delegate_; | 362 AutofillExternalDelegate* external_delegate_; |
366 | 363 |
367 // Delegate used in test to get notifications on certain events. | 364 // Delegate used in test to get notifications on certain events. |
368 AutofillManagerTestDelegate* test_delegate_; | 365 AutofillManagerTestDelegate* test_delegate_; |
369 | 366 |
370 base::WeakPtrFactory<AutofillManager> weak_ptr_factory_; | 367 base::WeakPtrFactory<AutofillManager> weak_ptr_factory_; |
371 | 368 |
(...skipping 26 matching lines...) Expand all Loading... |
398 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, | 395 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
399 AutocompleteOffRespected); | 396 AutocompleteOffRespected); |
400 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, | 397 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
401 AutocompleteOffRespectedWithFlag); | 398 AutocompleteOffRespectedWithFlag); |
402 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 399 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
403 }; | 400 }; |
404 | 401 |
405 } // namespace autofill | 402 } // namespace autofill |
406 | 403 |
407 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ | 404 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ |
OLD | NEW |