| OLD | NEW |
| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "components/sync/base/model_type.h" |
| 16 #include "components/webdata/common/web_database_table.h" | 17 #include "components/webdata/common/web_database_table.h" |
| 17 | 18 |
| 18 class WebDatabase; | 19 class WebDatabase; |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 class Time; | 22 class Time; |
| 22 } | 23 } |
| 23 | 24 |
| 25 namespace sync_pb { |
| 26 class EntityMetadata; |
| 27 class ModelTypeState; |
| 28 } |
| 29 |
| 24 namespace autofill { | 30 namespace autofill { |
| 25 | 31 |
| 26 class AutofillChange; | 32 class AutofillChange; |
| 27 class AutofillEntry; | 33 class AutofillEntry; |
| 28 class AutofillProfile; | 34 class AutofillProfile; |
| 29 class AutofillTableTest; | 35 class AutofillTableTest; |
| 30 class CreditCard; | 36 class CreditCard; |
| 31 | 37 |
| 32 struct FormFieldData; | 38 struct FormFieldData; |
| 33 | 39 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 // server_address_metadata | 227 // server_address_metadata |
| 222 // Metadata (currently, usage data) about server addresses. | 228 // Metadata (currently, usage data) about server addresses. |
| 223 // This will be synced. | 229 // This will be synced. |
| 224 // | 230 // |
| 225 // id The server ID, which matches an ID from the | 231 // id The server ID, which matches an ID from the |
| 226 // server_addresses table. | 232 // server_addresses table. |
| 227 // use_count The number of times this address has been used to fill | 233 // use_count The number of times this address has been used to fill |
| 228 // a form. | 234 // a form. |
| 229 // use_date The date this address was last used to fill a form, | 235 // use_date The date this address was last used to fill a form, |
| 230 // in internal t. | 236 // in internal t. |
| 237 // autofill_sync_metadata |
| 238 // Sync-specific metadata for autofill records. |
| 239 // |
| 240 // storage_key A string that uniquely identifies the metadata record |
| 241 // as well as the corresponding autofill record. |
| 242 // value The serialized EntityMetadata record. |
| 243 // |
| 244 // autofill_model_type_state |
| 245 // Single row table that contains the sync ModelTypeState |
| 246 // for the autofill model type. |
| 247 // |
| 248 // value The serialized ModelTypeState record. |
| 231 | 249 |
| 232 class AutofillTable : public WebDatabaseTable { | 250 class AutofillTable : public WebDatabaseTable { |
| 233 public: | 251 public: |
| 234 AutofillTable(); | 252 AutofillTable(); |
| 235 ~AutofillTable() override; | 253 ~AutofillTable() override; |
| 236 | 254 |
| 237 // Retrieves the AutofillTable* owned by |db|. | 255 // Retrieves the AutofillTable* owned by |db|. |
| 238 static AutofillTable* FromWebDatabase(WebDatabase* db); | 256 static AutofillTable* FromWebDatabase(WebDatabase* db); |
| 239 | 257 |
| 240 // WebDatabaseTable: | 258 // WebDatabaseTable: |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 // Empties the Autofill profiles "trash can". | 414 // Empties the Autofill profiles "trash can". |
| 397 bool EmptyAutofillProfilesTrash(); | 415 bool EmptyAutofillProfilesTrash(); |
| 398 | 416 |
| 399 // Retrieves all profiles in the database that have been deleted since last | 417 // Retrieves all profiles in the database that have been deleted since last |
| 400 // "empty" of the trash. | 418 // "empty" of the trash. |
| 401 bool AddAutofillGUIDToTrash(const std::string& guid); | 419 bool AddAutofillGUIDToTrash(const std::string& guid); |
| 402 | 420 |
| 403 // Clear all profiles. | 421 // Clear all profiles. |
| 404 bool ClearAutofillProfiles(); | 422 bool ClearAutofillProfiles(); |
| 405 | 423 |
| 424 // Look up the metadata record of |model_type| keyed by |storage_key| and fill |
| 425 // |metadata| with it. |
| 426 bool GetSyncMetadata(syncer::ModelType model_type, |
| 427 const std::string& storage_key, |
| 428 sync_pb::EntityMetadata* metadata); |
| 429 |
| 430 // Read all the stored metadata of |model_type| and fill |metadata_records| |
| 431 // with it. |
| 432 bool GetAllSyncMetadata( |
| 433 syncer::ModelType model_type, |
| 434 std::vector<sync_pb::EntityMetadata>* metadata_records); |
| 435 |
| 436 // Update the metadata row for |model_type|, keyed by |storage_key|, to |
| 437 // contain the contents of |metadata|. |
| 438 bool UpdateSyncMetadata(syncer::ModelType model_type, |
| 439 const std::string& storage_key, |
| 440 const sync_pb::EntityMetadata& metadata); |
| 441 |
| 442 // Remove the metadata row of type |model_type| keyed by |storage|key|. |
| 443 bool ClearSyncMetadata(syncer::ModelType model_type, |
| 444 const std::string& storage_key); |
| 445 |
| 446 // Retrieve the stored sync state for the |model_type|. |
| 447 bool GetModelTypeState(syncer::ModelType model_type, |
| 448 sync_pb::ModelTypeState* state); |
| 449 |
| 450 // Update the stored sync state for the |model_type|. |
| 451 bool UpdateModelTypeState(syncer::ModelType model_type, |
| 452 sync_pb::ModelTypeState& model_type_state); |
| 453 |
| 454 // Clear the stored sync state for |model_type|. |
| 455 bool ClearModelTypeState(syncer::ModelType model_type); |
| 456 |
| 406 // Table migration functions. NB: These do not and should not rely on other | 457 // Table migration functions. NB: These do not and should not rely on other |
| 407 // functions in this class. The implementation of a function such as | 458 // functions in this class. The implementation of a function such as |
| 408 // GetCreditCard may change over time, but MigrateToVersionXX should never | 459 // GetCreditCard may change over time, but MigrateToVersionXX should never |
| 409 // change. | 460 // change. |
| 410 bool MigrateToVersion54AddI18nFieldsAndRemoveDeprecatedFields(); | 461 bool MigrateToVersion54AddI18nFieldsAndRemoveDeprecatedFields(); |
| 411 bool MigrateToVersion55MergeAutofillDatesTable(); | 462 bool MigrateToVersion55MergeAutofillDatesTable(); |
| 412 bool MigrateToVersion56AddProfileLanguageCodeForFormatting(); | 463 bool MigrateToVersion56AddProfileLanguageCodeForFormatting(); |
| 413 bool MigrateToVersion57AddFullNameField(); | 464 bool MigrateToVersion57AddFullNameField(); |
| 414 bool MigrateToVersion60AddServerCards(); | 465 bool MigrateToVersion60AddServerCards(); |
| 415 bool MigrateToVersion61AddUsageStats(); | 466 bool MigrateToVersion61AddUsageStats(); |
| 416 bool MigrateToVersion62AddUsageStatsForUnmaskedCards(); | 467 bool MigrateToVersion62AddUsageStatsForUnmaskedCards(); |
| 417 bool MigrateToVersion63AddServerRecipientName(); | 468 bool MigrateToVersion63AddServerRecipientName(); |
| 418 bool MigrateToVersion64AddUnmaskDate(); | 469 bool MigrateToVersion64AddUnmaskDate(); |
| 419 bool MigrateToVersion65AddServerMetadataTables(); | 470 bool MigrateToVersion65AddServerMetadataTables(); |
| 420 bool MigrateToVersion66AddCardBillingAddress(); | 471 bool MigrateToVersion66AddCardBillingAddress(); |
| 421 bool MigrateToVersion67AddMaskedCardBillingAddress(); | 472 bool MigrateToVersion67AddMaskedCardBillingAddress(); |
| 473 bool MigrateToVersion70AddSyncMetadata(); |
| 422 | 474 |
| 423 // Max data length saved in the table, AKA the maximum length allowed for | 475 // Max data length saved in the table, AKA the maximum length allowed for |
| 424 // form data. | 476 // form data. |
| 425 // Copied to components/autofill/ios/browser/resources/autofill_controller.js. | 477 // Copied to components/autofill/ios/browser/resources/autofill_controller.js. |
| 426 static const size_t kMaxDataLength; | 478 static const size_t kMaxDataLength; |
| 427 | 479 |
| 428 private: | 480 private: |
| 429 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill); | 481 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill); |
| 430 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill_AddChanges); | 482 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill_AddChanges); |
| 431 FRIEND_TEST_ALL_PREFIXES( | 483 FRIEND_TEST_ALL_PREFIXES( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 bool InitProfilesTable(); | 541 bool InitProfilesTable(); |
| 490 bool InitProfileNamesTable(); | 542 bool InitProfileNamesTable(); |
| 491 bool InitProfileEmailsTable(); | 543 bool InitProfileEmailsTable(); |
| 492 bool InitProfilePhonesTable(); | 544 bool InitProfilePhonesTable(); |
| 493 bool InitProfileTrashTable(); | 545 bool InitProfileTrashTable(); |
| 494 bool InitMaskedCreditCardsTable(); | 546 bool InitMaskedCreditCardsTable(); |
| 495 bool InitUnmaskedCreditCardsTable(); | 547 bool InitUnmaskedCreditCardsTable(); |
| 496 bool InitServerCardMetadataTable(); | 548 bool InitServerCardMetadataTable(); |
| 497 bool InitServerAddressesTable(); | 549 bool InitServerAddressesTable(); |
| 498 bool InitServerAddressMetadataTable(); | 550 bool InitServerAddressMetadataTable(); |
| 551 bool InitAutofillSyncMetadataTable(); |
| 552 bool InitModelTypeStateTable(); |
| 499 | 553 |
| 500 DISALLOW_COPY_AND_ASSIGN(AutofillTable); | 554 DISALLOW_COPY_AND_ASSIGN(AutofillTable); |
| 501 }; | 555 }; |
| 502 | 556 |
| 503 } // namespace autofill | 557 } // namespace autofill |
| 504 | 558 |
| 505 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ | 559 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ |
| OLD | NEW |