| 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 void 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, |
| 284 std::vector<base::string16>* labels, | 285 std::vector<Suggestion>* suggestions) const; |
| 285 std::vector<base::string16>* icons, | |
| 286 std::vector<int>* unique_ids) const; | |
| 287 | 286 |
| 288 // Returns a list of values from the stored credit cards that match |type| and | 287 // 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. | 288 // the value of |field| and returns the labels of the matching credit cards. |
| 290 void GetCreditCardSuggestions(const FormFieldData& field, | 289 void GetCreditCardSuggestions( |
| 291 const AutofillType& type, | 290 const FormFieldData& field, |
| 292 std::vector<base::string16>* values, | 291 const AutofillType& type, |
| 293 std::vector<base::string16>* labels, | 292 std::vector<Suggestion>* suggestions) const; |
| 294 std::vector<base::string16>* icons, | |
| 295 std::vector<int>* unique_ids) const; | |
| 296 | 293 |
| 297 // Parses the forms using heuristic matching and querying the Autofill server. | 294 // Parses the forms using heuristic matching and querying the Autofill server. |
| 298 void ParseForms(const std::vector<FormData>& forms); | 295 void ParseForms(const std::vector<FormData>& forms); |
| 299 | 296 |
| 300 // Imports the form data, submitted by the user, into |personal_data_|. | 297 // Imports the form data, submitted by the user, into |personal_data_|. |
| 301 void ImportFormData(const FormStructure& submitted_form); | 298 void ImportFormData(const FormStructure& submitted_form); |
| 302 | 299 |
| 303 // If |initial_interaction_timestamp_| is unset or is set to a later time than | 300 // 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 | 301 // |interaction_timestamp|, updates the cached timestamp. The latter check is |
| 305 // needed because IPC messages can arrive out of order. | 302 // 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_; | 346 bool user_did_edit_autofilled_field_; |
| 350 // When the form finished loading. | 347 // When the form finished loading. |
| 351 std::map<FormData, base::TimeTicks> forms_loaded_timestamps_; | 348 std::map<FormData, base::TimeTicks> forms_loaded_timestamps_; |
| 352 // When the user first interacted with a potentially fillable form on this | 349 // When the user first interacted with a potentially fillable form on this |
| 353 // page. | 350 // page. |
| 354 base::TimeTicks initial_interaction_timestamp_; | 351 base::TimeTicks initial_interaction_timestamp_; |
| 355 | 352 |
| 356 // Our copy of the form data. | 353 // Our copy of the form data. |
| 357 ScopedVector<FormStructure> form_structures_; | 354 ScopedVector<FormStructure> form_structures_; |
| 358 | 355 |
| 359 // GUID to ID mapping. We keep two maps to convert back and forth. | 356 // SuggestionBackendID to ID mapping. We keep two maps to convert back and |
| 360 mutable std::map<PersonalDataManager::GUIDPair, int> guid_id_map_; | 357 // forth. These should be used only by BackendIDToInt and IntToBackendID. |
| 361 mutable std::map<int, PersonalDataManager::GUIDPair> id_guid_map_; | 358 // Note that the integers are not frontend IDs. |
| 359 mutable std::map<SuggestionBackendID, int> backend_to_int_map_; |
| 360 mutable std::map<int, SuggestionBackendID> int_to_backend_map_; |
| 362 | 361 |
| 363 // Delegate to perform external processing (display, selection) on | 362 // Delegate to perform external processing (display, selection) on |
| 364 // our behalf. Weak. | 363 // our behalf. Weak. |
| 365 AutofillExternalDelegate* external_delegate_; | 364 AutofillExternalDelegate* external_delegate_; |
| 366 | 365 |
| 367 // Delegate used in test to get notifications on certain events. | 366 // Delegate used in test to get notifications on certain events. |
| 368 AutofillManagerTestDelegate* test_delegate_; | 367 AutofillManagerTestDelegate* test_delegate_; |
| 369 | 368 |
| 370 base::WeakPtrFactory<AutofillManager> weak_ptr_factory_; | 369 base::WeakPtrFactory<AutofillManager> weak_ptr_factory_; |
| 371 | 370 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 398 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, | 397 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
| 399 AutocompleteOffRespected); | 398 AutocompleteOffRespected); |
| 400 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, | 399 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
| 401 AutocompleteOffRespectedWithFlag); | 400 AutocompleteOffRespectedWithFlag); |
| 402 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 401 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
| 403 }; | 402 }; |
| 404 | 403 |
| 405 } // namespace autofill | 404 } // namespace autofill |
| 406 | 405 |
| 407 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ | 406 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ |
| OLD | NEW |