| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 // WebDataServiceConsumer implementation: | 44 // WebDataServiceConsumer implementation: |
| 45 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, | 45 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, |
| 46 const WDTypedResult* result); | 46 const WDTypedResult* result); |
| 47 | 47 |
| 48 // AutoFillDialogObserver implementation: | 48 // AutoFillDialogObserver implementation: |
| 49 virtual void OnAutoFillDialogApply(std::vector<AutoFillProfile>* profiles, | 49 virtual void OnAutoFillDialogApply(std::vector<AutoFillProfile>* profiles, |
| 50 std::vector<CreditCard>* credit_cards); | 50 std::vector<CreditCard>* credit_cards); |
| 51 | 51 |
| 52 // Sets the listener to be notified of PersonalDataManager events. | 52 // Sets the listener to be notified of PersonalDataManager events. |
| 53 void SetObserver(PersonalDataManager::Observer* observer); | 53 virtual void SetObserver(PersonalDataManager::Observer* observer); |
| 54 | 54 |
| 55 // Removes |observer| as the observer of this PersonalDataManager. | 55 // Removes |observer| as the observer of this PersonalDataManager. |
| 56 void RemoveObserver(PersonalDataManager::Observer* observer); | 56 virtual void RemoveObserver(PersonalDataManager::Observer* observer); |
| 57 | 57 |
| 58 // If AutoFill is able to determine the field types of a significant number | 58 // If AutoFill is able to determine the field types of a significant number |
| 59 // of field types that contain information in the FormStructures and the user | 59 // of field types that contain information in the FormStructures and the user |
| 60 // has not previously been prompted, the user will be asked if he would like | 60 // has not previously been prompted, the user will be asked if he would like |
| 61 // to import the data. If the user selects yes, a profile will be created | 61 // to import the data. If the user selects yes, a profile will be created |
| 62 // with all of the information from recognized fields. | 62 // with all of the information from recognized fields. |
| 63 bool ImportFormData(const std::vector<FormStructure*>& form_structures, | 63 bool ImportFormData(const std::vector<FormStructure*>& form_structures, |
| 64 AutoFillManager* autofill_manager); | 64 AutoFillManager* autofill_manager); |
| 65 | 65 |
| 66 // Saves |imported_profile_| and |imported_credit_card_| to the WebDB if they | 66 // Saves |imported_profile_| and |imported_credit_card_| to the WebDB if they |
| 67 // exist. | 67 // exist. |
| 68 void SaveImportedFormData(); | 68 void SaveImportedFormData(); |
| 69 | 69 |
| 70 // Gets |imported_profile_| and |imported_credit_card_| and returns their |
| 71 // values in |profile| and |credit_card| parameters respectively. One or |
| 72 // both may return NULL. The objects returned are owned by the |
| 73 // PersonalDataManager, so should be considered weak references by caller. |
| 74 // TODO(dhollowa) Now that we aren't immediately saving the imported form |
| 75 // data, we should store the profile and CC in the AFM instead of the PDM. |
| 76 void GetImportedFormData(AutoFillProfile** profile, CreditCard** credit_card); |
| 77 |
| 70 // Sets |web_profiles_| to the contents of |profiles| and updates the web | 78 // Sets |web_profiles_| to the contents of |profiles| and updates the web |
| 71 // database by adding, updating and removing profiles. Sets the unique ID of | 79 // database by adding, updating and removing profiles. Sets the unique ID of |
| 72 // newly-added profiles. | 80 // newly-added profiles. |
| 73 // | 81 // |
| 74 // The relationship between this and Refresh is subtle. | 82 // The relationship between this and Refresh is subtle. |
| 75 // A call to SetProfile could include out-of-date data that may conflict | 83 // A call to SetProfile could include out-of-date data that may conflict |
| 76 // if we didn't refresh-to-latest before an autofill window was opened for | 84 // if we didn't refresh-to-latest before an autofill window was opened for |
| 77 // editing. SetProfile is implemented to make a "best effort" to apply the | 85 // editing. SetProfile is implemented to make a "best effort" to apply the |
| 78 // changes, but in extremely rare edge cases it is possible not all of the | 86 // changes, but in extremely rare edge cases it is possible not all of the |
| 79 // updates in |profiles| make it to the DB. This is why SetProfiles will | 87 // updates in |profiles| make it to the DB. This is why SetProfiles will |
| (...skipping 15 matching lines...) Expand all Loading... |
| 95 bool HasPassword(); | 103 bool HasPassword(); |
| 96 | 104 |
| 97 // Returns whether the personal data has been loaded from the web database. | 105 // Returns whether the personal data has been loaded from the web database. |
| 98 virtual bool IsDataLoaded() const { return is_data_loaded_; } | 106 virtual bool IsDataLoaded() const { return is_data_loaded_; } |
| 99 | 107 |
| 100 // This PersonalDataManager owns these profiles and credit cards. Their | 108 // This PersonalDataManager owns these profiles and credit cards. Their |
| 101 // lifetime is until the web database is updated with new profile and credit | 109 // lifetime is until the web database is updated with new profile and credit |
| 102 // card information, respectively. |profiles()| returns both web and | 110 // card information, respectively. |profiles()| returns both web and |
| 103 // auxiliary profiles. |web_profiles()| returns only web profiles. | 111 // auxiliary profiles. |web_profiles()| returns only web profiles. |
| 104 const std::vector<AutoFillProfile*>& profiles(); | 112 const std::vector<AutoFillProfile*>& profiles(); |
| 105 const std::vector<AutoFillProfile*>& web_profiles(); | 113 virtual const std::vector<AutoFillProfile*>& web_profiles(); |
| 106 const std::vector<CreditCard*>& credit_cards() { return credit_cards_.get(); } | 114 virtual const std::vector<CreditCard*>& credit_cards() { |
| 115 return credit_cards_.get(); |
| 116 } |
| 107 | 117 |
| 108 // Returns the index of the default profile within the vector returned by | 118 // Returns the index of the default profile within the vector returned by |
| 109 // |web_profiles()|, or -1 if there are no profiles. | 119 // |web_profiles()|, or -1 if there are no profiles. |
| 110 int DefaultProfile() const; | 120 int DefaultProfile() const; |
| 111 | 121 |
| 112 // Returns the index of the default credit card within the vector returned by | 122 // Returns the index of the default credit card within the vector returned by |
| 113 // |credit_cards()|, or -1 if there are no credit cards. | 123 // |credit_cards()|, or -1 if there are no credit cards. |
| 114 int DefaultCreditCard() const; | 124 int DefaultCreditCard() const; |
| 115 | 125 |
| 116 // Creates a profile labeled |label|, with it's own locally unique ID. | 126 // Creates a profile labeled |label|, with it's own locally unique ID. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 WebDataService::Handle pending_profiles_query_; | 251 WebDataService::Handle pending_profiles_query_; |
| 242 WebDataService::Handle pending_creditcards_query_; | 252 WebDataService::Handle pending_creditcards_query_; |
| 243 | 253 |
| 244 // The observers. This can be empty. | 254 // The observers. This can be empty. |
| 245 std::vector<PersonalDataManager::Observer*> observers_; | 255 std::vector<PersonalDataManager::Observer*> observers_; |
| 246 | 256 |
| 247 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 257 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
| 248 }; | 258 }; |
| 249 | 259 |
| 250 #endif // CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ | 260 #endif // CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ |
| OLD | NEW |