Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Side by Side Diff: components/autofill/core/browser/webdata/autofill_profile_syncable_service.h

Issue 1212733005: Removal of UpdateMultivaluedField() as we now don't have multiple values for name,email and phone n… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 // Creates syncer::SyncData based on supplied |profile|. 114 // Creates syncer::SyncData based on supplied |profile|.
115 // Exposed for unit tests. 115 // Exposed for unit tests.
116 static syncer::SyncData CreateData(const AutofillProfile& profile); 116 static syncer::SyncData CreateData(const AutofillProfile& profile);
117 117
118 private: 118 private:
119 friend class ::ProfileSyncServiceAutofillTest; 119 friend class ::ProfileSyncServiceAutofillTest;
120 FRIEND_TEST_ALL_PREFIXES(AutofillProfileSyncableServiceTest, 120 FRIEND_TEST_ALL_PREFIXES(AutofillProfileSyncableServiceTest,
121 UpdateField); 121 UpdateField);
122 FRIEND_TEST_ALL_PREFIXES(AutofillProfileSyncableServiceTest, 122 FRIEND_TEST_ALL_PREFIXES(AutofillProfileSyncableServiceTest,
123 UpdateMultivaluedField);
124 FRIEND_TEST_ALL_PREFIXES(AutofillProfileSyncableServiceTest,
125 MergeProfile); 123 MergeProfile);
126 124
127 // The map of the guid to profiles owned by the |profiles_| vector. 125 // The map of the guid to profiles owned by the |profiles_| vector.
128 typedef std::map<std::string, AutofillProfile*> GUIDToProfileMap; 126 typedef std::map<std::string, AutofillProfile*> GUIDToProfileMap;
129 127
130 // Helper function that overwrites |profile| with data from proto-buffer 128 // Helper function that overwrites |profile| with data from proto-buffer
131 // |specifics|. 129 // |specifics|.
132 static bool OverwriteProfileWithServerData( 130 static bool OverwriteProfileWithServerData(
133 const sync_pb::AutofillProfileSpecifics& specifics, 131 const sync_pb::AutofillProfileSpecifics& specifics,
134 AutofillProfile* profile, 132 AutofillProfile* profile,
(...skipping 21 matching lines...) Expand all
156 // Syncs |change| to the cloud. 154 // Syncs |change| to the cloud.
157 void ActOnChange(const AutofillProfileChange& change); 155 void ActOnChange(const AutofillProfileChange& change);
158 156
159 AutofillTable* GetAutofillTable() const; 157 AutofillTable* GetAutofillTable() const;
160 158
161 // 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
162 // 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.
163 static bool UpdateField(ServerFieldType field_type, 161 static bool UpdateField(ServerFieldType field_type,
164 const std::string& new_value, 162 const std::string& new_value,
165 AutofillProfile* autofill_profile); 163 AutofillProfile* autofill_profile);
166 // The same as |UpdateField|, but for multi-valued fields.
167 static bool UpdateMultivaluedField(
168 ServerFieldType field_type,
169 const ::google::protobuf::RepeatedPtrField<std::string>& new_value,
170 AutofillProfile* autofill_profile);
171 164
172 // Calls merge_into->OverwriteWithOrAddTo() and then checks if the 165 // Calls merge_into->OverwriteWithOrAddTo() and then checks if the
173 // |merge_into| has extra data. Returns true if |merge_from| needs updating to 166 // |merge_into| has extra data. Returns true if |merge_from| needs updating to
174 // be in sync with |merge_into|. 167 // be in sync with |merge_into|.
175 // TODO(isherman): Seems like this should return |true| if |merge_into| was 168 // TODO(isherman): Seems like this should return |true| if |merge_into| was
176 // modified at all: http://crbug.com/248440 169 // modified at all: http://crbug.com/248440
177 static bool MergeProfile(const AutofillProfile& merge_from, 170 static bool MergeProfile(const AutofillProfile& merge_from,
178 AutofillProfile* merge_into, 171 AutofillProfile* merge_into,
179 const std::string& app_locale); 172 const std::string& app_locale);
180 173
(...skipping 28 matching lines...) Expand all
209 // 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.
210 // Merge such profiles. 203 // Merge such profiles.
211 GUIDToProfileMap candidates_to_merge; 204 GUIDToProfileMap candidates_to_merge;
212 // Profiles that have multi-valued fields that are not in sync. 205 // Profiles that have multi-valued fields that are not in sync.
213 std::vector<AutofillProfile*> profiles_to_sync_back; 206 std::vector<AutofillProfile*> profiles_to_sync_back;
214 }; 207 };
215 208
216 } // namespace autofill 209 } // namespace autofill
217 210
218 #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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698