bookmark_sync_service.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/sync_bookmarks/bookmark_sync_service.h"
  5. #include "base/feature_list.h"
  6. #include "components/sync_bookmarks/bookmark_model_type_processor.h"
  7. #include "components/undo/bookmark_undo_service.h"
  8. namespace sync_bookmarks {
  9. BookmarkSyncService::BookmarkSyncService(
  10. BookmarkUndoService* bookmark_undo_service) {
  11. bookmark_model_type_processor_ =
  12. std::make_unique<sync_bookmarks::BookmarkModelTypeProcessor>(
  13. bookmark_undo_service);
  14. }
  15. BookmarkSyncService::~BookmarkSyncService() = default;
  16. std::string BookmarkSyncService::EncodeBookmarkSyncMetadata() {
  17. if (!bookmark_model_type_processor_) {
  18. return std::string();
  19. }
  20. return bookmark_model_type_processor_->EncodeSyncMetadata();
  21. }
  22. void BookmarkSyncService::DecodeBookmarkSyncMetadata(
  23. const std::string& metadata_str,
  24. const base::RepeatingClosure& schedule_save_closure,
  25. bookmarks::BookmarkModel* model) {
  26. if (bookmark_model_type_processor_) {
  27. bookmark_model_type_processor_->ModelReadyToSync(
  28. metadata_str, schedule_save_closure, model);
  29. }
  30. }
  31. base::WeakPtr<syncer::ModelTypeControllerDelegate>
  32. BookmarkSyncService::GetBookmarkSyncControllerDelegate(
  33. favicon::FaviconService* favicon_service) {
  34. DCHECK(favicon_service);
  35. if (!bookmark_model_type_processor_) {
  36. return nullptr;
  37. }
  38. bookmark_model_type_processor_->SetFaviconService(favicon_service);
  39. return bookmark_model_type_processor_->GetWeakPtr();
  40. }
  41. } // namespace sync_bookmarks