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 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 syncer::ModelType type) const OVERRIDE; | 66 syncer::ModelType type) const OVERRIDE; |
67 virtual syncer::SyncError ProcessSyncChanges( | 67 virtual syncer::SyncError ProcessSyncChanges( |
68 const tracked_objects::Location& from_here, | 68 const tracked_objects::Location& from_here, |
69 const syncer::SyncChangeList& change_list) OVERRIDE; | 69 const syncer::SyncChangeList& change_list) OVERRIDE; |
70 | 70 |
71 // AutofillWebDataServiceObserverOnDBThread implementation. | 71 // AutofillWebDataServiceObserverOnDBThread implementation. |
72 virtual void AutofillProfileChanged( | 72 virtual void AutofillProfileChanged( |
73 const AutofillProfileChange& change) OVERRIDE; | 73 const AutofillProfileChange& change) OVERRIDE; |
74 | 74 |
75 protected: | 75 protected: |
76 explicit AutofillProfileSyncableService( | 76 AutofillProfileSyncableService(AutofillWebDataService* web_data_service, |
77 AutofillWebDataService* web_data_service, | 77 const std::string& app_locale); |
78 const std::string& app_locale); | |
79 | 78 |
80 // A convenience wrapper of a bunch of state we pass around while | 79 // A convenience wrapper of a bunch of state we pass around while |
81 // associating models, and send to the WebDatabase for persistence. | 80 // associating models, and send to the WebDatabase for persistence. |
82 // We do this so we hold the write lock for only a small period. | 81 // We do this so we hold the write lock for only a small period. |
83 // When storing the web db we are out of the write lock. | 82 // When storing the web db we are out of the write lock. |
84 struct DataBundle; | 83 struct DataBundle; |
85 | 84 |
86 // Helper to query WebDatabase for the current autofill state. | 85 // Helper to query WebDatabase for the current autofill state. |
87 // Made virtual for ease of mocking in the unit-test. | 86 // Made virtual for ease of mocking in the unit-test. |
88 // Caller owns returned |profiles|. | 87 // Caller owns returned |profiles|. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // The same as |UpdateField|, but for multi-valued fields. | 154 // The same as |UpdateField|, but for multi-valued fields. |
156 static bool UpdateMultivaluedField( | 155 static bool UpdateMultivaluedField( |
157 AutofillFieldType field_type, | 156 AutofillFieldType field_type, |
158 const ::google::protobuf::RepeatedPtrField<std::string>& new_value, | 157 const ::google::protobuf::RepeatedPtrField<std::string>& new_value, |
159 AutofillProfile* autofill_profile); | 158 AutofillProfile* autofill_profile); |
160 | 159 |
161 // Calls merge_into->OverwriteWithOrAddTo() and then checks if the | 160 // Calls merge_into->OverwriteWithOrAddTo() and then checks if the |
162 // |merge_into| has extra data. Returns |true| if |merge_into| posseses some | 161 // |merge_into| has extra data. Returns |true| if |merge_into| posseses some |
163 // multi-valued field values that are not in |merge_from|, false otherwise. | 162 // multi-valued field values that are not in |merge_from|, false otherwise. |
164 static bool MergeProfile(const AutofillProfile& merge_from, | 163 static bool MergeProfile(const AutofillProfile& merge_from, |
165 AutofillProfile* merge_into); | 164 AutofillProfile* merge_into, |
| 165 const std::string& app_locale); |
166 | 166 |
167 // For unit-tests. | 167 // For unit-tests. |
168 AutofillProfileSyncableService(); | 168 AutofillProfileSyncableService(); |
169 void set_sync_processor(syncer::SyncChangeProcessor* sync_processor) { | 169 void set_sync_processor(syncer::SyncChangeProcessor* sync_processor) { |
170 sync_processor_.reset(sync_processor); | 170 sync_processor_.reset(sync_processor); |
171 } | 171 } |
172 | 172 |
173 AutofillWebDataService* web_data_service_; // WEAK | 173 AutofillWebDataService* web_data_service_; // WEAK |
174 std::string app_locale_; | 174 std::string app_locale_; |
175 ScopedObserver<AutofillWebDataService, AutofillProfileSyncableService> | 175 ScopedObserver<AutofillWebDataService, AutofillProfileSyncableService> |
(...skipping 21 matching lines...) Expand all Loading... |
197 std::vector<AutofillProfile*> profiles_to_add; | 197 std::vector<AutofillProfile*> profiles_to_add; |
198 | 198 |
199 // When we go through sync we find profiles that are similar but unmatched. | 199 // When we go through sync we find profiles that are similar but unmatched. |
200 // Merge such profiles. | 200 // Merge such profiles. |
201 GUIDToProfileMap candidates_to_merge; | 201 GUIDToProfileMap candidates_to_merge; |
202 // Profiles that have multi-valued fields that are not in sync. | 202 // Profiles that have multi-valued fields that are not in sync. |
203 std::vector<AutofillProfile*> profiles_to_sync_back; | 203 std::vector<AutofillProfile*> profiles_to_sync_back; |
204 }; | 204 }; |
205 | 205 |
206 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ | 206 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ |
OLD | NEW |