OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 // Handles loading and saving Autofill profile information to the web database. | 38 // Handles loading and saving Autofill profile information to the web database. |
39 // This class also stores the profiles loaded from the database for use during | 39 // This class also stores the profiles loaded from the database for use during |
40 // Autofill. | 40 // Autofill. |
41 class PersonalDataManager | 41 class PersonalDataManager |
42 : public WebDataServiceConsumer, | 42 : public WebDataServiceConsumer, |
43 public ProfileSyncServiceObserver, | 43 public ProfileSyncServiceObserver, |
44 public ProfileKeyedService, | 44 public ProfileKeyedService, |
45 public content::NotificationObserver { | 45 public content::NotificationObserver { |
46 public: | 46 public: |
| 47 // A pair of GUID and variant index. Represents a single FormGroup and a |
| 48 // specific data variant. |
| 49 typedef std::pair<std::string, size_t> GUIDPair; |
| 50 |
47 // WebDataServiceConsumer: | 51 // WebDataServiceConsumer: |
48 virtual void OnWebDataServiceRequestDone( | 52 virtual void OnWebDataServiceRequestDone( |
49 WebDataServiceBase::Handle h, | 53 WebDataServiceBase::Handle h, |
50 const WDTypedResult* result) OVERRIDE; | 54 const WDTypedResult* result) OVERRIDE; |
51 | 55 |
52 // Sets the listener to be notified of PersonalDataManager events. | 56 // Sets the listener to be notified of PersonalDataManager events. |
53 virtual void SetObserver(PersonalDataManagerObserver* observer); | 57 virtual void SetObserver(PersonalDataManagerObserver* observer); |
54 | 58 |
55 // Removes |observer| as the observer of this PersonalDataManager. | 59 // Removes |observer| as the observer of this PersonalDataManager. |
56 virtual void RemoveObserver(PersonalDataManagerObserver* observer); | 60 virtual void RemoveObserver(PersonalDataManagerObserver* observer); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 virtual bool IsDataLoaded() const; | 122 virtual bool IsDataLoaded() const; |
119 | 123 |
120 // This PersonalDataManager owns these profiles and credit cards. Their | 124 // This PersonalDataManager owns these profiles and credit cards. Their |
121 // lifetime is until the web database is updated with new profile and credit | 125 // lifetime is until the web database is updated with new profile and credit |
122 // card information, respectively. |profiles()| returns both web and | 126 // card information, respectively. |profiles()| returns both web and |
123 // auxiliary profiles. |web_profiles()| returns only web profiles. | 127 // auxiliary profiles. |web_profiles()| returns only web profiles. |
124 const std::vector<AutofillProfile*>& GetProfiles(); | 128 const std::vector<AutofillProfile*>& GetProfiles(); |
125 virtual const std::vector<AutofillProfile*>& web_profiles() const; | 129 virtual const std::vector<AutofillProfile*>& web_profiles() const; |
126 virtual const std::vector<CreditCard*>& credit_cards() const; | 130 virtual const std::vector<CreditCard*>& credit_cards() const; |
127 | 131 |
| 132 // Loads profiles that can suggest data for |type|. |field_contents| is the |
| 133 // part the user has already typed. |field_is_autofilled| is true if the field |
| 134 // has already been autofilled. |other_field_types| represents the rest of |
| 135 // form. Identifying info is loaded into the last four outparams. |
| 136 void GetProfileSuggestions( |
| 137 AutofillFieldType type, |
| 138 const string16& field_contents, |
| 139 bool field_is_autofilled, |
| 140 std::vector<AutofillFieldType> other_field_types, |
| 141 std::vector<string16>* labels, |
| 142 std::vector<string16>* sub_labels, |
| 143 std::vector<string16>* icons, |
| 144 std::vector<GUIDPair>* guid_pairs); |
| 145 |
128 // Re-loads profiles and credit cards from the WebDatabase asynchronously. | 146 // Re-loads profiles and credit cards from the WebDatabase asynchronously. |
129 // In the general case, this is a no-op and will re-create the same | 147 // In the general case, this is a no-op and will re-create the same |
130 // in-memory model as existed prior to the call. If any change occurred to | 148 // in-memory model as existed prior to the call. If any change occurred to |
131 // profiles in the WebDatabase directly, as is the case if the browser sync | 149 // profiles in the WebDatabase directly, as is the case if the browser sync |
132 // engine processed a change from the cloud, we will learn of these as a | 150 // engine processed a change from the cloud, we will learn of these as a |
133 // result of this call. | 151 // result of this call. |
134 // | 152 // |
135 // Also see SetProfile for more details. | 153 // Also see SetProfile for more details. |
136 virtual void Refresh(); | 154 virtual void Refresh(); |
137 | 155 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 // Whether we have already logged the number of profiles this session. | 277 // Whether we have already logged the number of profiles this session. |
260 mutable bool has_logged_profile_count_; | 278 mutable bool has_logged_profile_count_; |
261 | 279 |
262 // Manages registration lifetime for NotificationObserver implementation. | 280 // Manages registration lifetime for NotificationObserver implementation. |
263 content::NotificationRegistrar notification_registrar_; | 281 content::NotificationRegistrar notification_registrar_; |
264 | 282 |
265 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 283 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
266 }; | 284 }; |
267 | 285 |
268 #endif // CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ | 286 #endif // CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ |
OLD | NEW |