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