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 <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "components/sync/base/model_type.h" | 17 #include "components/sync/base/model_type.h" |
18 #include "components/sync/model/metadata_batch.h" | 18 #include "components/sync/model/metadata_batch.h" |
| 19 #include "components/sync/model/metadata_table.h" |
19 #include "components/webdata/common/web_database_table.h" | 20 #include "components/webdata/common/web_database_table.h" |
20 | 21 |
21 class WebDatabase; | 22 class WebDatabase; |
22 | 23 |
23 namespace base { | 24 namespace base { |
24 class Time; | 25 class Time; |
25 } | 26 } |
26 | 27 |
27 namespace autofill { | 28 namespace autofill { |
28 | 29 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // storage_key A string that uniquely identifies the metadata record | 243 // storage_key A string that uniquely identifies the metadata record |
243 // as well as the corresponding autofill record. | 244 // as well as the corresponding autofill record. |
244 // value The serialized EntityMetadata record. | 245 // value The serialized EntityMetadata record. |
245 // | 246 // |
246 // autofill_model_type_state | 247 // autofill_model_type_state |
247 // Single row table that contains the sync ModelTypeState | 248 // Single row table that contains the sync ModelTypeState |
248 // for the autofill model type. | 249 // for the autofill model type. |
249 // | 250 // |
250 // value The serialized ModelTypeState record. | 251 // value The serialized ModelTypeState record. |
251 | 252 |
252 class AutofillTable : public WebDatabaseTable { | 253 class AutofillTable : public WebDatabaseTable, public syncer::MetadataTable { |
253 public: | 254 public: |
254 AutofillTable(); | 255 AutofillTable(); |
255 ~AutofillTable() override; | 256 ~AutofillTable() override; |
256 | 257 |
257 // Retrieves the AutofillTable* owned by |db|. | 258 // Retrieves the AutofillTable* owned by |db|. |
258 static AutofillTable* FromWebDatabase(WebDatabase* db); | 259 static AutofillTable* FromWebDatabase(WebDatabase* db); |
259 | 260 |
260 // WebDatabaseTable: | 261 // WebDatabaseTable: |
261 WebDatabaseTable::TypeKey GetTypeKey() const override; | 262 WebDatabaseTable::TypeKey GetTypeKey() const override; |
262 bool CreateTablesIfNecessary() override; | 263 bool CreateTablesIfNecessary() override; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 bool AddAutofillGUIDToTrash(const std::string& guid); | 420 bool AddAutofillGUIDToTrash(const std::string& guid); |
420 | 421 |
421 // Clear all profiles. | 422 // Clear all profiles. |
422 bool ClearAutofillProfiles(); | 423 bool ClearAutofillProfiles(); |
423 | 424 |
424 // Read all the stored metadata for |model_type| and fill |metadata_batch| | 425 // Read all the stored metadata for |model_type| and fill |metadata_batch| |
425 // with it. | 426 // with it. |
426 bool GetAllSyncMetadata(syncer::ModelType model_type, | 427 bool GetAllSyncMetadata(syncer::ModelType model_type, |
427 syncer::MetadataBatch* metadata_batch); | 428 syncer::MetadataBatch* metadata_batch); |
428 | 429 |
429 // Update the metadata row for |model_type|, keyed by |storage_key|, to | 430 // syncer::MetadataTable implementation. |
430 // contain the contents of |metadata|. | |
431 bool UpdateSyncMetadata(syncer::ModelType model_type, | 431 bool UpdateSyncMetadata(syncer::ModelType model_type, |
432 const std::string& storage_key, | 432 const std::string& storage_key, |
433 const sync_pb::EntityMetadata& metadata); | 433 const sync_pb::EntityMetadata& metadata) override; |
434 | |
435 // Remove the metadata row of type |model_type| keyed by |storage|key|. | |
436 bool ClearSyncMetadata(syncer::ModelType model_type, | 434 bool ClearSyncMetadata(syncer::ModelType model_type, |
437 const std::string& storage_key); | 435 const std::string& storage_key) override; |
438 | 436 bool UpdateModelTypeState( |
439 // Update the stored sync state for the |model_type|. | 437 syncer::ModelType model_type, |
440 bool UpdateModelTypeState(syncer::ModelType model_type, | 438 const sync_pb::ModelTypeState& model_type_state) override; |
441 const sync_pb::ModelTypeState& model_type_state); | 439 bool ClearModelTypeState(syncer::ModelType model_type) override; |
442 | |
443 // Clear the stored sync state for |model_type|. | |
444 bool ClearModelTypeState(syncer::ModelType model_type); | |
445 | 440 |
446 // Table migration functions. NB: These do not and should not rely on other | 441 // Table migration functions. NB: These do not and should not rely on other |
447 // functions in this class. The implementation of a function such as | 442 // functions in this class. The implementation of a function such as |
448 // GetCreditCard may change over time, but MigrateToVersionXX should never | 443 // GetCreditCard may change over time, but MigrateToVersionXX should never |
449 // change. | 444 // change. |
450 bool MigrateToVersion54AddI18nFieldsAndRemoveDeprecatedFields(); | 445 bool MigrateToVersion54AddI18nFieldsAndRemoveDeprecatedFields(); |
451 bool MigrateToVersion55MergeAutofillDatesTable(); | 446 bool MigrateToVersion55MergeAutofillDatesTable(); |
452 bool MigrateToVersion56AddProfileLanguageCodeForFormatting(); | 447 bool MigrateToVersion56AddProfileLanguageCodeForFormatting(); |
453 bool MigrateToVersion57AddFullNameField(); | 448 bool MigrateToVersion57AddFullNameField(); |
454 bool MigrateToVersion60AddServerCards(); | 449 bool MigrateToVersion60AddServerCards(); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 bool InitModelTypeStateTable(); | 543 bool InitModelTypeStateTable(); |
549 | 544 |
550 std::unique_ptr<AutofillTableEncryptor> autofill_table_encryptor_; | 545 std::unique_ptr<AutofillTableEncryptor> autofill_table_encryptor_; |
551 | 546 |
552 DISALLOW_COPY_AND_ASSIGN(AutofillTable); | 547 DISALLOW_COPY_AND_ASSIGN(AutofillTable); |
553 }; | 548 }; |
554 | 549 |
555 } // namespace autofill | 550 } // namespace autofill |
556 | 551 |
557 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ | 552 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ |
OLD | NEW |