| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h" | 5 #include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <unordered_set> | 9 #include <unordered_set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 change_processor()->ReportError( | 451 change_processor()->ReportError( |
| 452 FROM_HERE, "Failed reading autofill metadata from WebDatabase."); | 452 FROM_HERE, "Failed reading autofill metadata from WebDatabase."); |
| 453 return; | 453 return; |
| 454 } | 454 } |
| 455 change_processor()->ModelReadyToSync(std::move(batch)); | 455 change_processor()->ModelReadyToSync(std::move(batch)); |
| 456 } | 456 } |
| 457 | 457 |
| 458 std::string AutocompleteSyncBridge::GetClientTag( | 458 std::string AutocompleteSyncBridge::GetClientTag( |
| 459 const EntityData& entity_data) { | 459 const EntityData& entity_data) { |
| 460 DCHECK(entity_data.specifics.has_autofill()); | 460 DCHECK(entity_data.specifics.has_autofill()); |
| 461 // Must have the format "autofill_entry|$name|$value" where $name and $value |
| 462 // are URL escaped. This is to maintain compatibility with the previous sync |
| 463 // integration (Directory and SyncableService). |
| 461 return std::string(kAutocompleteEntryNamespaceTag) + | 464 return std::string(kAutocompleteEntryNamespaceTag) + |
| 462 EscapeIdentifiers(entity_data.specifics.autofill()); | 465 EscapeIdentifiers(entity_data.specifics.autofill()); |
| 463 } | 466 } |
| 464 | 467 |
| 465 std::string AutocompleteSyncBridge::GetStorageKey( | 468 std::string AutocompleteSyncBridge::GetStorageKey( |
| 466 const EntityData& entity_data) { | 469 const EntityData& entity_data) { |
| 467 DCHECK(entity_data.specifics.has_autofill()); | 470 DCHECK(entity_data.specifics.has_autofill()); |
| 471 // Marginally more space efficient than GetClientTag() by omitting the |
| 472 // kAutocompleteEntryNamespaceTag prefix and using protobuf serialization |
| 473 // instead of URL escaping for Unicode characters. |
| 468 const AutofillSpecifics specifics = entity_data.specifics.autofill(); | 474 const AutofillSpecifics specifics = entity_data.specifics.autofill(); |
| 469 return BuildSerializedStorageKey(specifics.name(), specifics.value()); | 475 return BuildSerializedStorageKey(specifics.name(), specifics.value()); |
| 470 } | 476 } |
| 471 | 477 |
| 472 // AutofillWebDataServiceObserverOnDBThread implementation. | 478 // AutofillWebDataServiceObserverOnDBThread implementation. |
| 473 void AutocompleteSyncBridge::AutofillEntriesChanged( | 479 void AutocompleteSyncBridge::AutofillEntriesChanged( |
| 474 const AutofillChangeList& changes) { | 480 const AutofillChangeList& changes) { |
| 475 DCHECK(thread_checker_.CalledOnValidThread()); | 481 DCHECK(thread_checker_.CalledOnValidThread()); |
| 476 ActOnLocalChanges(changes); | 482 ActOnLocalChanges(changes); |
| 477 } | 483 } |
| 478 | 484 |
| 479 AutofillTable* AutocompleteSyncBridge::GetAutofillTable() const { | 485 AutofillTable* AutocompleteSyncBridge::GetAutofillTable() const { |
| 480 return AutofillTable::FromWebDatabase(web_data_backend_->GetDatabase()); | 486 return AutofillTable::FromWebDatabase(web_data_backend_->GetDatabase()); |
| 481 } | 487 } |
| 482 | 488 |
| 483 } // namespace autofill | 489 } // namespace autofill |
| OLD | NEW |