diff --git a/browser/profiles/brave_bookmark_model_loaded_observer.cc b/browser/profiles/brave_bookmark_model_loaded_observer.cc index 553141df0cb4..c81223df69ad 100644 --- a/browser/profiles/brave_bookmark_model_loaded_observer.cc +++ b/browser/profiles/brave_bookmark_model_loaded_observer.cc @@ -41,5 +41,10 @@ void BraveBookmarkModelLoadedObserver::BookmarkModelLoaded( #endif profile_->GetPrefs()->SetBoolean(kOtherBookmarksMigrated, true); } + +#if BUILDFLAG(ENABLE_BRAVE_SYNC) + BraveProfileSyncServiceImpl::AddNonClonedBookmarkKeys(model); +#endif + BookmarkModelLoadedObserver::BookmarkModelLoaded(model, ids_reassigned); } diff --git a/components/brave_sync/brave_profile_sync_service_impl.cc b/components/brave_sync/brave_profile_sync_service_impl.cc index fe06bc48f342..2e041a1469cb 100644 --- a/components/brave_sync/brave_profile_sync_service_impl.cc +++ b/components/brave_sync/brave_profile_sync_service_impl.cc @@ -523,6 +523,17 @@ void BraveProfileSyncServiceImpl::OnSyncReadyBookmarksModelLoaded() { } } +// static +void BraveProfileSyncServiceImpl::AddNonClonedBookmarkKeys( + BookmarkModel* model) { + DCHECK(model); + DCHECK(model->loaded()); + model->AddNonClonedKey("object_id"); + model->AddNonClonedKey("order"); + model->AddNonClonedKey("sync_timestamp"); + model->AddNonClonedKey("version"); +} + syncer::ModelTypeSet BraveProfileSyncServiceImpl::GetPreferredDataTypes() const { // Force DEVICE_INFO type to have nudge cycle each time to fetch diff --git a/components/brave_sync/brave_profile_sync_service_impl.h b/components/brave_sync/brave_profile_sync_service_impl.h index 6d3effe0c75c..a8bfc722a393 100644 --- a/components/brave_sync/brave_profile_sync_service_impl.h +++ b/components/brave_sync/brave_profile_sync_service_impl.h @@ -175,6 +175,8 @@ class BraveProfileSyncServiceImpl BraveSyncClient* GetBraveSyncClient() override; #endif + static void AddNonClonedBookmarkKeys(BookmarkModel* model); + bool IsBraveSyncEnabled() const override; syncer::ModelTypeSet GetPreferredDataTypes() const override; diff --git a/components/brave_sync/brave_sync_service_unittest.cc b/components/brave_sync/brave_sync_service_unittest.cc index ebb005a15a6d..4523ad5c1d53 100644 --- a/components/brave_sync/brave_sync_service_unittest.cc +++ b/components/brave_sync/brave_sync_service_unittest.cc @@ -1600,3 +1600,34 @@ TEST_F(BraveSyncServiceTest, CheckOtherBookmarkChildRecord) { sync_service()->CheckOtherBookmarkChildRecord(record_a1.get()); EXPECT_EQ(record_a1->GetBookmark().parentFolderObjectId, object_id_iter1); } + +TEST_F(BraveSyncServiceTest, AddNonClonedBookmarkKeys) { + sync_service()->AddNonClonedBookmarkKeys(model()); + const bookmarks::BookmarkNode* bookmark_a1 = + model()->AddURL(model()->other_node(), 0, base::ASCIIToUTF16("A1"), + GURL("https://a1.com")); + + AsMutable(bookmark_a1)->SetMetaInfo("object_id", "object_id_value"); + AsMutable(bookmark_a1)->SetMetaInfo("order", "order_value"); + AsMutable(bookmark_a1)->SetMetaInfo("sync_timestamp", "sync_timestamp_value"); + AsMutable(bookmark_a1)->SetMetaInfo("version", "version_value"); + + model()->Copy(bookmark_a1, model()->other_node(), 1); + + const bookmarks::BookmarkNode* bookmark_copy = + model()->other_node()->children().at(1).get(); + + std::string meta_object_id; + EXPECT_FALSE(bookmark_copy->GetMetaInfo("object_id", &meta_object_id)); + EXPECT_TRUE(meta_object_id.empty()); + std::string meta_order; + EXPECT_FALSE(bookmark_copy->GetMetaInfo("order", &meta_order)); + EXPECT_TRUE(meta_order.empty()); + std::string meta_sync_timestamp; + EXPECT_FALSE( + bookmark_copy->GetMetaInfo("sync_timestamp", &meta_sync_timestamp)); + EXPECT_TRUE(meta_sync_timestamp.empty()); + std::string meta_version; + EXPECT_FALSE(bookmark_copy->GetMetaInfo("version", &meta_version)); + EXPECT_TRUE(meta_version.empty()); +}