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

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

Issue 1042353003: Create syncable metadata table for Wallet credit cards and addresses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: docs Created 5 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // exp_year Four-digit year: 2017 156 // exp_year Four-digit year: 2017
157 // 157 //
158 // unmasked_credit_cards 158 // unmasked_credit_cards
159 // When a masked credit credit card is unmasked and the 159 // When a masked credit credit card is unmasked and the
160 // full number is downloaded, it will be stored here. 160 // full number is downloaded, it will be stored here.
161 // 161 //
162 // id Server ID. This can be joined with the id in the 162 // id Server ID. This can be joined with the id in the
163 // masked_credit_cards table to get the rest of the data. 163 // masked_credit_cards table to get the rest of the data.
164 // card_number_encrypted 164 // card_number_encrypted
165 // Full card number, encrypted. 165 // Full card number, encrypted.
166 // use_count The number of times this card has been used to fill 166 // use_count DEPRECATED in version 65. See server_card_metadata.
167 // a form. Added in version 62. 167 // use_date DEPRECATED in version 65. See server_card_metadata.
168 // use_date The date this card was last used to fill a form, in
169 // internal time format (NOT time_t). Added in version 62.
170 // unmask_date The date this card was unmasked in units of 168 // unmask_date The date this card was unmasked in units of
171 // Time::ToInternalValue. Added in version 64. 169 // Time::ToInternalValue. Added in version 64.
172 // 170 //
171 // server_card_metadata
172 // Metadata (currently, usage data) about server credit
173 // cards. This will be synced.
174 //
175 // id The server ID, which matches an ID from the
176 // masked_credit_cards table.
177 // use_count The number of times this card has been used to fill
178 // a form.
179 // use_date The date this card was last used to fill a form,
180 // in internal t.
181 //
173 // server_addresses This table contains Autofill address data synced from 182 // server_addresses This table contains Autofill address data synced from
174 // the wallet server. It's basically the same as the 183 // the wallet server. It's basically the same as the
175 // autofill_profiles table but locally immutable. 184 // autofill_profiles table but locally immutable.
176 // 185 //
177 // id String assigned by the server to identify this address. 186 // id String assigned by the server to identify this address.
178 // This is opaque to the client. 187 // This is opaque to the client.
179 // recipient_name Added in v63. 188 // recipient_name Added in v63.
180 // company_name 189 // company_name
181 // street_address The combined lines of the street address. 190 // street_address The combined lines of the street address.
182 // address_1 Also known as "administrative area". This is normally 191 // address_1 Also known as "administrative area". This is normally
183 // the state or province in most countries. 192 // the state or province in most countries.
184 // address_2 Also known as "locality". In the US this is the city. 193 // address_2 Also known as "locality". In the US this is the city.
185 // address_3 A sub-classification beneath the city, e.g. an 194 // address_3 A sub-classification beneath the city, e.g. an
186 // inner-city district or suburb. Also known as 195 // inner-city district or suburb. Also known as
187 // "dependent_locality". 196 // "dependent_locality".
188 // address_4 Used in certain countries. Also known as 197 // address_4 Used in certain countries. Also known as
189 // "sub_dependent_locality". 198 // "sub_dependent_locality".
190 // postal_code 199 // postal_code
191 // sorting_code Similar to the zipcode column, but used for businesses 200 // sorting_code Similar to the zipcode column, but used for businesses
192 // or organizations that might not be geographically 201 // or organizations that might not be geographically
193 // contiguous. The canonical example is CEDEX in France. 202 // contiguous. The canonical example is CEDEX in France.
194 // country_code 203 // country_code
195 // language_code The BCP 47 language code used to format the address for 204 // language_code The BCP 47 language code used to format the address for
196 // display. For example, a JP address with "ja" language 205 // display. For example, a JP address with "ja" language
197 // code starts with the postal code, but a JP address with 206 // code starts with the postal code, but a JP address with
198 // "ja-latn" language code starts with the recipient name. 207 // "ja-latn" language code starts with the recipient name.
199 // phone_number Phone number. This is a string and has no formatting 208 // phone_number Phone number. This is a string and has no formatting
200 // constraints. Added in version 64. 209 // constraints. Added in version 64.
210 //
211 // server_address_metadata
212 // Metadata (currently, usage data) about server addresses.
213 // This will be synced.
214 //
215 // id The server ID, which matches an ID from the
216 // server_addresses table.
217 // use_count The number of times this address has been used to fill
218 // a form.
219 // use_date The date this address was last used to fill a form,
220 // in internal t.
221
201 class AutofillTable : public WebDatabaseTable { 222 class AutofillTable : public WebDatabaseTable {
202 public: 223 public:
203 explicit AutofillTable(const std::string& app_locale); 224 explicit AutofillTable(const std::string& app_locale);
204 ~AutofillTable() override; 225 ~AutofillTable() override;
205 226
206 // Retrieves the AutofillTable* owned by |database|. 227 // Retrieves the AutofillTable* owned by |database|.
207 static AutofillTable* FromWebDatabase(WebDatabase* db); 228 static AutofillTable* FromWebDatabase(WebDatabase* db);
208 229
209 WebDatabaseTable::TypeKey GetTypeKey() const override; 230 WebDatabaseTable::TypeKey GetTypeKey() const override;
210 bool CreateTablesIfNecessary() override; 231 bool CreateTablesIfNecessary() override;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 virtual bool GetCreditCards(std::vector<CreditCard*>* credit_cards); 330 virtual bool GetCreditCards(std::vector<CreditCard*>* credit_cards);
310 virtual bool GetServerCreditCards(std::vector<CreditCard*>* credit_cards); 331 virtual bool GetServerCreditCards(std::vector<CreditCard*>* credit_cards);
311 332
312 // Replaces all server credit cards with the given vector. Unmasked cards 333 // Replaces all server credit cards with the given vector. Unmasked cards
313 // present in the new list will be preserved (even if the input is MASKED). 334 // present in the new list will be preserved (even if the input is MASKED).
314 void SetServerCreditCards(const std::vector<CreditCard>& credit_cards); 335 void SetServerCreditCards(const std::vector<CreditCard>& credit_cards);
315 336
316 // Cards synced from the server may be "masked" (only last 4 digits 337 // Cards synced from the server may be "masked" (only last 4 digits
317 // available) or "unmasked" (everything is available). These functions set 338 // available) or "unmasked" (everything is available). These functions set
318 // that state. 339 // that state.
319 bool UnmaskServerCreditCard(const std::string& id, 340 bool UnmaskServerCreditCard(const CreditCard& masked,
320 const base::string16& full_number); 341 const base::string16& full_number);
321 bool MaskServerCreditCard(const std::string& id); 342 bool MaskServerCreditCard(const std::string& id);
322 343
323 // Updates the use count and last use date for an unmasked server card. 344 bool UpdateServerCardUsageStats(const CreditCard& credit_card);
324 bool UpdateUnmaskedCardUsageStats(const CreditCard& credit_card); 345 bool UpdateServerAddressUsageStats(const AutofillProfile& profile);
325 346
326 // Deletes all data from the server card and profile tables. Returns true if 347 // Deletes all data from the server card and profile tables. Returns true if
327 // any data was deleted, false if not (so false means "commit not needed" 348 // any data was deleted, false if not (so false means "commit not needed"
328 // rather than "error"). 349 // rather than "error").
329 bool ClearAllServerData(); 350 bool ClearAllServerData();
330 351
331 // Removes rows from autofill_profiles and credit_cards if they were created 352 // Removes rows from autofill_profiles and credit_cards if they were created
332 // on or after |delete_begin| and strictly before |delete_end|. Returns the 353 // on or after |delete_begin| and strictly before |delete_end|. Returns the
333 // list of deleted profile guids in |profile_guids|. Return value is true if 354 // list of deleted profile guids in |profile_guids|. Return value is true if
334 // all rows were successfully removed. Returns false on database error. In 355 // all rows were successfully removed. Returns false on database error. In
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 // Table migration functions. 389 // Table migration functions.
369 bool MigrateToVersion54AddI18nFieldsAndRemoveDeprecatedFields(); 390 bool MigrateToVersion54AddI18nFieldsAndRemoveDeprecatedFields();
370 bool MigrateToVersion55MergeAutofillDatesTable(); 391 bool MigrateToVersion55MergeAutofillDatesTable();
371 bool MigrateToVersion56AddProfileLanguageCodeForFormatting(); 392 bool MigrateToVersion56AddProfileLanguageCodeForFormatting();
372 bool MigrateToVersion57AddFullNameField(); 393 bool MigrateToVersion57AddFullNameField();
373 bool MigrateToVersion60AddServerCards(); 394 bool MigrateToVersion60AddServerCards();
374 bool MigrateToVersion61AddUsageStats(); 395 bool MigrateToVersion61AddUsageStats();
375 bool MigrateToVersion62AddUsageStatsForUnmaskedCards(); 396 bool MigrateToVersion62AddUsageStatsForUnmaskedCards();
376 bool MigrateToVersion63AddServerRecipientName(); 397 bool MigrateToVersion63AddServerRecipientName();
377 bool MigrateToVersion64AddUnmaskDate(); 398 bool MigrateToVersion64AddUnmaskDate();
399 bool MigrateToVersion65AddServerMetadataTables();
378 400
379 // Max data length saved in the table; 401 // Max data length saved in the table;
380 static const size_t kMaxDataLength; 402 static const size_t kMaxDataLength;
381 403
382 private: 404 private:
383 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill); 405 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill);
384 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill_AddChanges); 406 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill_AddChanges);
385 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill_RemoveBetweenChanges); 407 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill_RemoveBetweenChanges);
386 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill_UpdateDontReplace); 408 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill_UpdateDontReplace);
387 FRIEND_TEST_ALL_PREFIXES( 409 FRIEND_TEST_ALL_PREFIXES(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 bool InitMainTable(); 459 bool InitMainTable();
438 bool InitCreditCardsTable(); 460 bool InitCreditCardsTable();
439 bool InitDatesTable(); 461 bool InitDatesTable();
440 bool InitProfilesTable(); 462 bool InitProfilesTable();
441 bool InitProfileNamesTable(); 463 bool InitProfileNamesTable();
442 bool InitProfileEmailsTable(); 464 bool InitProfileEmailsTable();
443 bool InitProfilePhonesTable(); 465 bool InitProfilePhonesTable();
444 bool InitProfileTrashTable(); 466 bool InitProfileTrashTable();
445 bool InitMaskedCreditCardsTable(); 467 bool InitMaskedCreditCardsTable();
446 bool InitUnmaskedCreditCardsTable(); 468 bool InitUnmaskedCreditCardsTable();
469 bool InitServerCardMetadataTable();
447 bool InitServerAddressesTable(); 470 bool InitServerAddressesTable();
471 bool InitServerAddressMetadataTable();
448 472
449 // The application locale. The locale is needed for the migration to version 473 // The application locale. The locale is needed for the migration to version
450 // 35. Since it must be read on the UI thread, it is set when the table is 474 // 35. Since it must be read on the UI thread, it is set when the table is
451 // created (on the UI thread), and cached here so that it can be used for 475 // created (on the UI thread), and cached here so that it can be used for
452 // migrations (on the DB thread). 476 // migrations (on the DB thread).
453 std::string app_locale_; 477 std::string app_locale_;
454 478
455 DISALLOW_COPY_AND_ASSIGN(AutofillTable); 479 DISALLOW_COPY_AND_ASSIGN(AutofillTable);
456 }; 480 };
457 481
458 } // namespace autofill 482 } // namespace autofill
459 483
460 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ 484 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698