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_PERSONAL_DATA_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ |
6 #define CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ | 6 #define CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 virtual void RemoveObserver(PersonalDataManager::Observer* observer); | 57 virtual void RemoveObserver(PersonalDataManager::Observer* observer); |
58 | 58 |
59 // If AutoFill is able to determine the field types of a significant number | 59 // If AutoFill is able to determine the field types of a significant number |
60 // of field types that contain information in the FormStructures and the user | 60 // of field types that contain information in the FormStructures and the user |
61 // has not previously been prompted, the user will be asked if he would like | 61 // has not previously been prompted, the user will be asked if he would like |
62 // to import the data. If the user selects yes, a profile will be created | 62 // to import the data. If the user selects yes, a profile will be created |
63 // with all of the information from recognized fields. | 63 // with all of the information from recognized fields. |
64 bool ImportFormData(const std::vector<FormStructure*>& form_structures, | 64 bool ImportFormData(const std::vector<FormStructure*>& form_structures, |
65 AutoFillManager* autofill_manager); | 65 AutoFillManager* autofill_manager); |
66 | 66 |
67 // Saves |imported_profile_| and |imported_credit_card_| to the WebDB if they | |
68 // exist. | |
69 virtual void SaveImportedFormData(); | |
70 | |
71 // Gets |imported_profile_| and |imported_credit_card_| and returns their | 67 // Gets |imported_profile_| and |imported_credit_card_| and returns their |
72 // values in |profile| and |credit_card| parameters respectively. One or | 68 // values in |profile| and |credit_card| parameters respectively. One or |
73 // both may return NULL. The objects returned are owned by the | 69 // both may return NULL. The objects returned are owned by the |
74 // PersonalDataManager, so should be considered weak references by caller. | 70 // PersonalDataManager, so should be considered weak references by caller. |
75 // TODO(dhollowa) Now that we aren't immediately saving the imported form | 71 // TODO(dhollowa) Now that we aren't immediately saving the imported form |
76 // data, we should store the profile and CC in the AFM instead of the PDM. | 72 // data, we should store the profile and CC in the AFM instead of the PDM. |
77 void GetImportedFormData(AutoFillProfile** profile, CreditCard** credit_card); | 73 void GetImportedFormData(AutoFillProfile** profile, CreditCard** credit_card); |
78 | 74 |
79 // Sets |web_profiles_| to the contents of |profiles| and updates the web | 75 // Sets |web_profiles_| to the contents of |profiles| and updates the web |
80 // database by adding, updating and removing profiles. Sets the unique ID of | 76 // database by adding, updating and removing profiles. Sets the unique ID of |
81 // newly-added profiles. | 77 // newly-added profiles. |
82 // | 78 // |
83 // The relationship between this and Refresh is subtle. | 79 // The relationship between this and Refresh is subtle. |
84 // A call to SetProfile could include out-of-date data that may conflict | 80 // A call to SetProfile could include out-of-date data that may conflict |
85 // if we didn't refresh-to-latest before an autofill window was opened for | 81 // if we didn't refresh-to-latest before an AutoFill window was opened for |
86 // editing. SetProfile is implemented to make a "best effort" to apply the | 82 // editing. SetProfile is implemented to make a "best effort" to apply the |
87 // changes, but in extremely rare edge cases it is possible not all of the | 83 // changes, but in extremely rare edge cases it is possible not all of the |
88 // updates in |profiles| make it to the DB. This is why SetProfiles will | 84 // updates in |profiles| make it to the DB. This is why SetProfiles will |
89 // invoke Refresh after finishing, to ensure we get into a | 85 // invoke Refresh after finishing, to ensure we get into a |
90 // consistent state. See Refresh for details. | 86 // consistent state. See Refresh for details. |
91 void SetProfiles(std::vector<AutoFillProfile>* profiles); | 87 void SetProfiles(std::vector<AutoFillProfile>* profiles); |
92 | 88 |
93 // Sets |credit_cards_| to the contents of |credit_cards| and updates the web | 89 // Sets |credit_cards_| to the contents of |credit_cards| and updates the web |
94 // database by adding, updating and removing credit cards. Sets the unique | 90 // database by adding, updating and removing credit cards. Sets the unique |
95 // ID of newly-added profiles. | 91 // ID of newly-added profiles. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // query handle. | 181 // query handle. |
186 void CancelPendingQuery(WebDataService::Handle* handle); | 182 void CancelPendingQuery(WebDataService::Handle* handle); |
187 | 183 |
188 // Ensures that all profile labels are unique by appending an increasing digit | 184 // Ensures that all profile labels are unique by appending an increasing digit |
189 // to the end of non-unique labels. | 185 // to the end of non-unique labels. |
190 // TODO(jhawkins): Create a new interface for labeled entities and turn these | 186 // TODO(jhawkins): Create a new interface for labeled entities and turn these |
191 // two methods into one. | 187 // two methods into one. |
192 void SetUniqueProfileLabels(std::vector<AutoFillProfile>* profiles); | 188 void SetUniqueProfileLabels(std::vector<AutoFillProfile>* profiles); |
193 void SetUniqueCreditCardLabels(std::vector<CreditCard>* credit_cards); | 189 void SetUniqueCreditCardLabels(std::vector<CreditCard>* credit_cards); |
194 | 190 |
| 191 // Saves |imported_profile_| to the WebDB if it exists. |
| 192 // TODO(jhawkins): SaveImportedCreditCard. |
| 193 void SaveImportedProfile(); |
| 194 |
195 // The profile hosting this PersonalDataManager. | 195 // The profile hosting this PersonalDataManager. |
196 Profile* profile_; | 196 Profile* profile_; |
197 | 197 |
198 // True if personal data has been loaded from the web database. | 198 // True if personal data has been loaded from the web database. |
199 bool is_data_loaded_; | 199 bool is_data_loaded_; |
200 | 200 |
201 // The set of already created unique profile IDs, used to create a new unique | 201 // The set of already created unique profile IDs, used to create a new unique |
202 // profile ID. | 202 // profile ID. |
203 std::set<int> unique_profile_ids_; | 203 std::set<int> unique_profile_ids_; |
204 | 204 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 WebDataService::Handle pending_profiles_query_; | 239 WebDataService::Handle pending_profiles_query_; |
240 WebDataService::Handle pending_creditcards_query_; | 240 WebDataService::Handle pending_creditcards_query_; |
241 | 241 |
242 // The observers. This can be empty. | 242 // The observers. This can be empty. |
243 std::vector<PersonalDataManager::Observer*> observers_; | 243 std::vector<PersonalDataManager::Observer*> observers_; |
244 | 244 |
245 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 245 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
246 }; | 246 }; |
247 | 247 |
248 #endif // CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ | 248 #endif // CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ |
OLD | NEW |