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 #ifndef CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ | 4 #ifndef CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ |
5 #define CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ | 5 #define CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "base/scoped_observer.h" | 13 #include "base/scoped_observer.h" |
14 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
16 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
17 #include "components/autofill/core/browser/autofill_type.h" | 17 #include "components/autofill/core/browser/field_types.h" |
18 #include "components/autofill/core/browser/webdata/autofill_change.h" | 18 #include "components/autofill/core/browser/webdata/autofill_change.h" |
19 #include "components/autofill/core/browser/webdata/autofill_entry.h" | 19 #include "components/autofill/core/browser/webdata/autofill_entry.h" |
20 #include "components/autofill/core/browser/webdata/autofill_webdata_backend.h" | 20 #include "components/autofill/core/browser/webdata/autofill_webdata_backend.h" |
21 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse
rver.h" | 21 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse
rver.h" |
22 #include "sync/api/sync_change.h" | 22 #include "sync/api/sync_change.h" |
23 #include "sync/api/sync_data.h" | 23 #include "sync/api/sync_data.h" |
24 #include "sync/api/sync_error.h" | 24 #include "sync/api/sync_error.h" |
25 #include "sync/api/syncable_service.h" | 25 #include "sync/api/syncable_service.h" |
26 #include "sync/protocol/autofill_specifics.pb.h" | 26 #include "sync/protocol/autofill_specifics.pb.h" |
27 | 27 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 GUIDToProfileMap* profile_map, | 155 GUIDToProfileMap* profile_map, |
156 DataBundle* bundle); | 156 DataBundle* bundle); |
157 | 157 |
158 // Syncs |change| to the cloud. | 158 // Syncs |change| to the cloud. |
159 void ActOnChange(const autofill::AutofillProfileChange& change); | 159 void ActOnChange(const autofill::AutofillProfileChange& change); |
160 | 160 |
161 autofill::AutofillTable* GetAutofillTable() const; | 161 autofill::AutofillTable* GetAutofillTable() const; |
162 | 162 |
163 // Helper to compare the local value and cloud value of a field, copy into | 163 // Helper to compare the local value and cloud value of a field, copy into |
164 // the local value if they differ, and return whether the change happened. | 164 // the local value if they differ, and return whether the change happened. |
165 static bool UpdateField(autofill::AutofillFieldType field_type, | 165 static bool UpdateField(autofill::ServerFieldType field_type, |
166 const std::string& new_value, | 166 const std::string& new_value, |
167 autofill::AutofillProfile* autofill_profile); | 167 autofill::AutofillProfile* autofill_profile); |
168 // The same as |UpdateField|, but for multi-valued fields. | 168 // The same as |UpdateField|, but for multi-valued fields. |
169 static bool UpdateMultivaluedField( | 169 static bool UpdateMultivaluedField( |
170 autofill::AutofillFieldType field_type, | 170 autofill::ServerFieldType field_type, |
171 const ::google::protobuf::RepeatedPtrField<std::string>& new_value, | 171 const ::google::protobuf::RepeatedPtrField<std::string>& new_value, |
172 autofill::AutofillProfile* autofill_profile); | 172 autofill::AutofillProfile* autofill_profile); |
173 | 173 |
174 // Calls merge_into->OverwriteWithOrAddTo() and then checks if the | 174 // Calls merge_into->OverwriteWithOrAddTo() and then checks if the |
175 // |merge_into| has extra data. Returns |true| if |merge_into| posseses some | 175 // |merge_into| has extra data. Returns |true| if |merge_into| posseses some |
176 // multi-valued field values that are not in |merge_from| or if the origins | 176 // multi-valued field values that are not in |merge_from| or if the origins |
177 // of the two profiles differ, false otherwise. | 177 // of the two profiles differ, false otherwise. |
178 // TODO(isherman): Seems like this should return |true| if |merge_into| was | 178 // TODO(isherman): Seems like this should return |true| if |merge_into| was |
179 // modified at all: http://crbug.com/248440 | 179 // modified at all: http://crbug.com/248440 |
180 static bool MergeProfile(const autofill::AutofillProfile& merge_from, | 180 static bool MergeProfile(const autofill::AutofillProfile& merge_from, |
(...skipping 29 matching lines...) Expand all Loading... |
210 std::vector<autofill::AutofillProfile*> profiles_to_add; | 210 std::vector<autofill::AutofillProfile*> profiles_to_add; |
211 | 211 |
212 // When we go through sync we find profiles that are similar but unmatched. | 212 // When we go through sync we find profiles that are similar but unmatched. |
213 // Merge such profiles. | 213 // Merge such profiles. |
214 GUIDToProfileMap candidates_to_merge; | 214 GUIDToProfileMap candidates_to_merge; |
215 // Profiles that have multi-valued fields that are not in sync. | 215 // Profiles that have multi-valued fields that are not in sync. |
216 std::vector<autofill::AutofillProfile*> profiles_to_sync_back; | 216 std::vector<autofill::AutofillProfile*> profiles_to_sync_back; |
217 }; | 217 }; |
218 | 218 |
219 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ | 219 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ |
OLD | NEW |