| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // Removes the credit card represented by |guid|. | 114 // Removes the credit card represented by |guid|. |
| 115 void RemoveCreditCard(const std::string& guid); | 115 void RemoveCreditCard(const std::string& guid); |
| 116 | 116 |
| 117 // Returns the credit card with the specified |guid|, or NULL if there is | 117 // Returns the credit card with the specified |guid|, or NULL if there is |
| 118 // no credit card with the specified |guid|. | 118 // no credit card with the specified |guid|. |
| 119 CreditCard* GetCreditCardByGUID(const std::string& guid); | 119 CreditCard* GetCreditCardByGUID(const std::string& guid); |
| 120 | 120 |
| 121 // Gets the possible field types for the given text, determined by matching | 121 // Gets the possible field types for the given text, determined by matching |
| 122 // the text with all known personal information and returning matching types. | 122 // the text with all known personal information and returning matching types. |
| 123 void GetPossibleFieldTypes(const string16& text, | 123 void GetPossibleFieldTypes(const string16& text, |
| 124 FieldTypeSet* possible_types); | 124 FieldTypeSet* possible_types) const; |
| 125 |
| 126 // Gets the field types availabe in the stored address and credit card data. |
| 127 void GetAvailableFieldTypes(FieldTypeSet* available_types) const; |
| 125 | 128 |
| 126 // Returns true if the credit card information is stored with a password. | 129 // Returns true if the credit card information is stored with a password. |
| 127 bool HasPassword(); | 130 bool HasPassword(); |
| 128 | 131 |
| 129 // Returns whether the personal data has been loaded from the web database. | 132 // Returns whether the personal data has been loaded from the web database. |
| 130 virtual bool IsDataLoaded() const; | 133 virtual bool IsDataLoaded() const; |
| 131 | 134 |
| 132 // This PersonalDataManager owns these profiles and credit cards. Their | 135 // This PersonalDataManager owns these profiles and credit cards. Their |
| 133 // lifetime is until the web database is updated with new profile and credit | 136 // lifetime is until the web database is updated with new profile and credit |
| 134 // card information, respectively. |profiles()| returns both web and | 137 // card information, respectively. |profiles()| returns both web and |
| 135 // auxiliary profiles. |web_profiles()| returns only web profiles. | 138 // auxiliary profiles. |web_profiles()| returns only web profiles. |
| 136 const std::vector<AutofillProfile*>& profiles(); | 139 const std::vector<AutofillProfile*>& profiles() const; |
| 137 virtual const std::vector<AutofillProfile*>& web_profiles(); | 140 virtual const std::vector<AutofillProfile*>& web_profiles() const; |
| 138 virtual const std::vector<CreditCard*>& credit_cards(); | 141 virtual const std::vector<CreditCard*>& credit_cards() const; |
| 139 | 142 |
| 140 // Re-loads profiles and credit cards from the WebDatabase asynchronously. | 143 // Re-loads profiles and credit cards from the WebDatabase asynchronously. |
| 141 // In the general case, this is a no-op and will re-create the same | 144 // In the general case, this is a no-op and will re-create the same |
| 142 // in-memory model as existed prior to the call. If any change occurred to | 145 // in-memory model as existed prior to the call. If any change occurred to |
| 143 // profiles in the WebDatabase directly, as is the case if the browser sync | 146 // profiles in the WebDatabase directly, as is the case if the browser sync |
| 144 // engine processed a change from the cloud, we will learn of these as a | 147 // engine processed a change from the cloud, we will learn of these as a |
| 145 // result of this call. | 148 // result of this call. |
| 146 // | 149 // |
| 147 // Also see SetProfile for more details. | 150 // Also see SetProfile for more details. |
| 148 virtual void Refresh(); | 151 virtual void Refresh(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 170 friend class ProfileImpl; | 173 friend class ProfileImpl; |
| 171 friend class ProfileSyncServiceAutofillTest; | 174 friend class ProfileSyncServiceAutofillTest; |
| 172 | 175 |
| 173 PersonalDataManager(); | 176 PersonalDataManager(); |
| 174 virtual ~PersonalDataManager(); | 177 virtual ~PersonalDataManager(); |
| 175 | 178 |
| 176 // Loads the saved profiles from the web database. | 179 // Loads the saved profiles from the web database. |
| 177 virtual void LoadProfiles(); | 180 virtual void LoadProfiles(); |
| 178 | 181 |
| 179 // Loads the auxiliary profiles. Currently Mac only. | 182 // Loads the auxiliary profiles. Currently Mac only. |
| 180 void LoadAuxiliaryProfiles(); | 183 void LoadAuxiliaryProfiles() const; |
| 181 | 184 |
| 182 // Loads the saved credit cards from the web database. | 185 // Loads the saved credit cards from the web database. |
| 183 virtual void LoadCreditCards(); | 186 virtual void LoadCreditCards(); |
| 184 | 187 |
| 185 // Receives the loaded profiles from the web data service and stores them in | 188 // Receives the loaded profiles from the web data service and stores them in |
| 186 // |credit_cards_|. | 189 // |credit_cards_|. |
| 187 void ReceiveLoadedProfiles(WebDataService::Handle h, | 190 void ReceiveLoadedProfiles(WebDataService::Handle h, |
| 188 const WDTypedResult* result); | 191 const WDTypedResult* result); |
| 189 | 192 |
| 190 // Receives the loaded credit cards from the web data service and stores them | 193 // Receives the loaded credit cards from the web data service and stores them |
| (...skipping 25 matching lines...) Expand all Loading... |
| 216 // The profile hosting this PersonalDataManager. | 219 // The profile hosting this PersonalDataManager. |
| 217 Profile* profile_; | 220 Profile* profile_; |
| 218 | 221 |
| 219 // True if personal data has been loaded from the web database. | 222 // True if personal data has been loaded from the web database. |
| 220 bool is_data_loaded_; | 223 bool is_data_loaded_; |
| 221 | 224 |
| 222 // The loaded web profiles. | 225 // The loaded web profiles. |
| 223 ScopedVector<AutofillProfile> web_profiles_; | 226 ScopedVector<AutofillProfile> web_profiles_; |
| 224 | 227 |
| 225 // Auxiliary profiles. | 228 // Auxiliary profiles. |
| 226 ScopedVector<AutofillProfile> auxiliary_profiles_; | 229 mutable ScopedVector<AutofillProfile> auxiliary_profiles_; |
| 227 | 230 |
| 228 // Storage for combined web and auxiliary profiles. Contents are weak | 231 // Storage for combined web and auxiliary profiles. Contents are weak |
| 229 // references. Lifetime managed by |web_profiles_| and |auxiliary_profiles_|. | 232 // references. Lifetime managed by |web_profiles_| and |auxiliary_profiles_|. |
| 230 std::vector<AutofillProfile*> profiles_; | 233 mutable std::vector<AutofillProfile*> profiles_; |
| 231 | 234 |
| 232 // The loaded credit cards. | 235 // The loaded credit cards. |
| 233 ScopedVector<CreditCard> credit_cards_; | 236 ScopedVector<CreditCard> credit_cards_; |
| 234 | 237 |
| 235 // The hash of the password used to store the credit card. This is empty if | 238 // The hash of the password used to store the credit card. This is empty if |
| 236 // no password exists. | 239 // no password exists. |
| 237 string16 password_hash_; | 240 string16 password_hash_; |
| 238 | 241 |
| 239 // When the manager makes a request from WebDataService, the database | 242 // When the manager makes a request from WebDataService, the database |
| 240 // is queried on another thread, we record the query handle until we | 243 // is queried on another thread, we record the query handle until we |
| 241 // get called back. We store handles for both profile and credit card queries | 244 // get called back. We store handles for both profile and credit card queries |
| 242 // so they can be loaded at the same time. | 245 // so they can be loaded at the same time. |
| 243 WebDataService::Handle pending_profiles_query_; | 246 WebDataService::Handle pending_profiles_query_; |
| 244 WebDataService::Handle pending_creditcards_query_; | 247 WebDataService::Handle pending_creditcards_query_; |
| 245 | 248 |
| 246 // The observers. | 249 // The observers. |
| 247 ObserverList<Observer> observers_; | 250 ObserverList<Observer> observers_; |
| 248 | 251 |
| 249 private: | 252 private: |
| 250 // For logging UMA metrics. Overridden by metrics tests. | 253 // For logging UMA metrics. Overridden by metrics tests. |
| 251 scoped_ptr<const AutofillMetrics> metric_logger_; | 254 scoped_ptr<const AutofillMetrics> metric_logger_; |
| 252 | 255 |
| 253 // Whether we have already logged the number of profiles this session. | 256 // Whether we have already logged the number of profiles this session. |
| 254 mutable bool has_logged_profile_count_; | 257 mutable bool has_logged_profile_count_; |
| 255 | 258 |
| 256 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 259 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
| 257 }; | 260 }; |
| 258 | 261 |
| 259 #endif // CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ | 262 #endif // CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ |
| OLD | NEW |