Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVI CE_H_ | 4 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVI CE_H_ |
| 5 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVI CE_H_ | 5 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SERVI CE_H_ |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 | 114 |
| 115 // Creates syncer::SyncData based on supplied |profile|. | 115 // Creates syncer::SyncData based on supplied |profile|. |
| 116 // Exposed for unit tests. | 116 // Exposed for unit tests. |
| 117 static syncer::SyncData CreateData(const AutofillProfile& profile); | 117 static syncer::SyncData CreateData(const AutofillProfile& profile); |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 friend class ::ProfileSyncServiceAutofillTest; | 120 friend class ::ProfileSyncServiceAutofillTest; |
| 121 FRIEND_TEST_ALL_PREFIXES(AutofillProfileSyncableServiceTest, | 121 FRIEND_TEST_ALL_PREFIXES(AutofillProfileSyncableServiceTest, |
| 122 UpdateField); | 122 UpdateField); |
| 123 FRIEND_TEST_ALL_PREFIXES(AutofillProfileSyncableServiceTest, | 123 FRIEND_TEST_ALL_PREFIXES(AutofillProfileSyncableServiceTest, |
| 124 MergeProfile); | 124 MergeSimilarProfile); |
| 125 | 125 |
| 126 // The map of the guid to profiles owned by the |profiles_| vector. | 126 // The map of the guid to profiles owned by the |profiles_| vector. |
| 127 typedef std::map<std::string, AutofillProfile*> GUIDToProfileMap; | 127 typedef std::map<std::string, AutofillProfile*> GUIDToProfileMap; |
| 128 | 128 |
| 129 // Helper function that overwrites |profile| with data from proto-buffer | 129 // Helper function that overwrites |profile| with data from proto-buffer |
| 130 // |specifics|. | 130 // |specifics|. |
| 131 static bool OverwriteProfileWithServerData( | 131 static bool OverwriteProfileWithServerData( |
| 132 const sync_pb::AutofillProfileSpecifics& specifics, | 132 const sync_pb::AutofillProfileSpecifics& specifics, |
| 133 AutofillProfile* profile); | 133 AutofillProfile* profile); |
| 134 | 134 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 155 void ActOnChange(const AutofillProfileChange& change); | 155 void ActOnChange(const AutofillProfileChange& change); |
| 156 | 156 |
| 157 AutofillTable* GetAutofillTable() const; | 157 AutofillTable* GetAutofillTable() const; |
| 158 | 158 |
| 159 // Helper to compare the local value and cloud value of a field, copy into | 159 // Helper to compare the local value and cloud value of a field, copy into |
| 160 // the local value if they differ, and return whether the change happened. | 160 // the local value if they differ, and return whether the change happened. |
| 161 static bool UpdateField(ServerFieldType field_type, | 161 static bool UpdateField(ServerFieldType field_type, |
| 162 const std::string& new_value, | 162 const std::string& new_value, |
| 163 AutofillProfile* autofill_profile); | 163 AutofillProfile* autofill_profile); |
| 164 | 164 |
| 165 // Calls merge_into->OverwriteWithOrAddTo() and then checks if the | 165 // Calls merge_into->OverwriteWith() and then checks if the |
| 166 // |merge_into| has extra data. Returns true if |merge_from| needs updating to | 166 // |merge_into| has extra data. Returns true the merge has made a change to |
|
Mathieu
2016/04/22 20:54:28
*if the merge
sebsg
2016/04/25 15:35:39
Done.
| |
| 167 // be in sync with |merge_into|. | 167 // |merge_into|. This should be used only for similar profiles ie. profiles |
| 168 // TODO(isherman): Seems like this should return |true| if |merge_into| was | 168 // where the PrimaryValue() matches. |
| 169 // modified at all: http://crbug.com/248440 | 169 static bool MergeSimilarProfile(const AutofillProfile& merge_from, |
|
Mathieu
2016/04/22 20:54:28
nit: MergeSimilarProfiles?
sebsg
2016/04/25 15:35:39
Done.
| |
| 170 static bool MergeProfile(const AutofillProfile& merge_from, | 170 AutofillProfile* merge_into, |
| 171 AutofillProfile* merge_into, | 171 const std::string& app_locale); |
| 172 const std::string& app_locale); | |
| 173 | 172 |
| 174 AutofillWebDataBackend* webdata_backend_; // WEAK | 173 AutofillWebDataBackend* webdata_backend_; // WEAK |
| 175 std::string app_locale_; | 174 std::string app_locale_; |
| 176 ScopedObserver<AutofillWebDataBackend, | 175 ScopedObserver<AutofillWebDataBackend, |
| 177 AutofillProfileSyncableService> scoped_observer_; | 176 AutofillProfileSyncableService> scoped_observer_; |
| 178 | 177 |
| 179 // Cached Autofill profiles. *Warning* deleted profiles are still in the | 178 // Cached Autofill profiles. *Warning* deleted profiles are still in the |
| 180 // vector - use the |profiles_map_| to iterate through actual profiles. | 179 // vector - use the |profiles_map_| to iterate through actual profiles. |
| 181 ScopedVector<AutofillProfile> profiles_; | 180 ScopedVector<AutofillProfile> profiles_; |
| 182 GUIDToProfileMap profiles_map_; | 181 GUIDToProfileMap profiles_map_; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 203 // When we go through sync we find profiles that are similar but unmatched. | 202 // When we go through sync we find profiles that are similar but unmatched. |
| 204 // Merge such profiles. | 203 // Merge such profiles. |
| 205 GUIDToProfileMap candidates_to_merge; | 204 GUIDToProfileMap candidates_to_merge; |
| 206 // Profiles that have multi-valued fields that are not in sync. | 205 // Profiles that have multi-valued fields that are not in sync. |
| 207 std::vector<AutofillProfile*> profiles_to_sync_back; | 206 std::vector<AutofillProfile*> profiles_to_sync_back; |
| 208 }; | 207 }; |
| 209 | 208 |
| 210 } // namespace autofill | 209 } // namespace autofill |
| 211 | 210 |
| 212 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SE RVICE_H_ | 211 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_PROFILE_SYNCABLE_SE RVICE_H_ |
| OLD | NEW |