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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "base/string16.h" | 17 #include "base/string16.h" |
18 #include "chrome/browser/autofill/autofill_profile.h" | 18 #include "chrome/browser/autofill/autofill_profile.h" |
19 #include "chrome/browser/autofill/credit_card.h" | 19 #include "chrome/browser/autofill/credit_card.h" |
20 #include "chrome/browser/autofill/field_types.h" | 20 #include "chrome/browser/autofill/field_types.h" |
21 #include "chrome/browser/sync/profile_sync_service_observer.h" | 21 #include "chrome/browser/sync/profile_sync_service_observer.h" |
22 #include "chrome/browser/webdata/web_data_service.h" | 22 #include "chrome/browser/webdata/web_data_service.h" |
23 | 23 |
24 class AutofillManager; | 24 class AutofillManager; |
25 class AutofillMetrics; | 25 class AutofillMetrics; |
26 class FormStructure; | 26 class FormStructure; |
27 class Profile; | 27 class Profile; |
28 | 28 |
| 29 namespace autofill_helper { |
| 30 void SetProfiles(int, std::vector<AutofillProfile>*); |
| 31 } |
| 32 |
29 // Handles loading and saving Autofill profile information to the web database. | 33 // Handles loading and saving Autofill profile information to the web database. |
30 // This class also stores the profiles loaded from the database for use during | 34 // This class also stores the profiles loaded from the database for use during |
31 // Autofill. | 35 // Autofill. |
32 class PersonalDataManager | 36 class PersonalDataManager |
33 : public WebDataServiceConsumer, | 37 : public WebDataServiceConsumer, |
34 public ProfileSyncServiceObserver, | 38 public ProfileSyncServiceObserver, |
35 public base::RefCountedThreadSafe<PersonalDataManager> { | 39 public base::RefCountedThreadSafe<PersonalDataManager> { |
36 public: | 40 public: |
37 // An interface the PersonalDataManager uses to notify its clients (observers) | 41 // An interface the PersonalDataManager uses to notify its clients (observers) |
38 // when it has finished loading personal data from the web database. Register | 42 // when it has finished loading personal data from the web database. Register |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // result. | 138 // result. |
135 static bool MergeProfile( | 139 static bool MergeProfile( |
136 const AutofillProfile& profile, | 140 const AutofillProfile& profile, |
137 const std::vector<AutofillProfile*>& existing_profiles, | 141 const std::vector<AutofillProfile*>& existing_profiles, |
138 std::vector<AutofillProfile>* merged_profiles); | 142 std::vector<AutofillProfile>* merged_profiles); |
139 | 143 |
140 protected: | 144 protected: |
141 // Make sure that only Profile and certain tests can create an instance of | 145 // Make sure that only Profile and certain tests can create an instance of |
142 // PersonalDataManager. | 146 // PersonalDataManager. |
143 friend class base::RefCountedThreadSafe<PersonalDataManager>; | 147 friend class base::RefCountedThreadSafe<PersonalDataManager>; |
144 friend class AutofillHelper; | |
145 friend class AutofillMergeTest; | 148 friend class AutofillMergeTest; |
146 friend class PersonalDataManagerTest; | 149 friend class PersonalDataManagerTest; |
147 friend class ProfileImpl; | 150 friend class ProfileImpl; |
148 friend class ProfileSyncServiceAutofillTest; | 151 friend class ProfileSyncServiceAutofillTest; |
149 friend class TestingAutomationProvider; | 152 friend class TestingAutomationProvider; |
| 153 friend void autofill_helper::SetProfiles(int, std::vector<AutofillProfile>*); |
150 | 154 |
151 PersonalDataManager(); | 155 PersonalDataManager(); |
152 virtual ~PersonalDataManager(); | 156 virtual ~PersonalDataManager(); |
153 | 157 |
154 // Sets |web_profiles_| to the contents of |profiles| and updates the web | 158 // Sets |web_profiles_| to the contents of |profiles| and updates the web |
155 // database by adding, updating and removing profiles. | 159 // database by adding, updating and removing profiles. |
156 // The relationship between this and Refresh is subtle. | 160 // The relationship between this and Refresh is subtle. |
157 // A call to |SetProfiles| could include out-of-date data that may conflict | 161 // A call to |SetProfiles| could include out-of-date data that may conflict |
158 // if we didn't refresh-to-latest before an Autofill window was opened for | 162 // if we didn't refresh-to-latest before an Autofill window was opened for |
159 // editing. |SetProfiles| is implemented to make a "best effort" to apply the | 163 // editing. |SetProfiles| is implemented to make a "best effort" to apply the |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // For logging UMA metrics. Overridden by metrics tests. | 244 // For logging UMA metrics. Overridden by metrics tests. |
241 scoped_ptr<const AutofillMetrics> metric_logger_; | 245 scoped_ptr<const AutofillMetrics> metric_logger_; |
242 | 246 |
243 // Whether we have already logged the number of profiles this session. | 247 // Whether we have already logged the number of profiles this session. |
244 mutable bool has_logged_profile_count_; | 248 mutable bool has_logged_profile_count_; |
245 | 249 |
246 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 250 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
247 }; | 251 }; |
248 | 252 |
249 #endif // CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ | 253 #endif // CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ |
OLD | NEW |