Skip to content

Commit

Permalink
Move BookmarkModel::MigrateOtherNode to a standalone function BraveMi…
Browse files Browse the repository at this point in the history
…grateOtherNode
  • Loading branch information
darkdh committed Oct 16, 2019
1 parent f892c5d commit 4dab70c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 29 deletions.
4 changes: 2 additions & 2 deletions browser/profiles/brave_bookmark_model_loaded_observer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ void BraveBookmarkModelLoadedObserver::BookmarkModelLoaded(
// When sync is enabled, we need to send migration records to other devices so
// it is handled in BraveProfileSyncServiceImpl::OnSyncReady
if (!brave_profile_service->IsBraveSyncEnabled())
model->MigrateOtherNode();
BraveMigrateOtherNode(model);
#else
model->MigrateOtherNode();
BraveMigrateOtherNode(model);
#endif
model->RemoveObserver(this);
delete this;
Expand Down
16 changes: 9 additions & 7 deletions chromium_src/components/bookmarks/browser/bookmark_model.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* Copyright 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand All @@ -10,14 +9,17 @@ namespace bookmarks {

// Move bookmarks under "Other Bookmarks" permanent node to a same name folder
// at the end of "Bookmark Bar" permanent node
void BookmarkModel::MigrateOtherNode() {
if (!other_node()->children().empty()) {
void BraveMigrateOtherNode(BookmarkModel* model) {
DCHECK(model);
if (!model->other_node()->children().empty()) {
const bookmarks::BookmarkNode* new_other_node =
AddFolder(bookmark_bar_node(), bookmark_bar_node()->children().size(),
other_node()->GetTitledUrlNodeTitle());
size_t children_size = other_node()->children().size();
model->AddFolder(model->bookmark_bar_node(),
model->bookmark_bar_node()->children().size(),
model->other_node()->GetTitledUrlNodeTitle());
size_t children_size = model->other_node()->children().size();
for (size_t i = 0; i < children_size; ++i) {
Move(other_node()->children().front().get(), new_other_node, i);
model->Move(model->other_node()->children().front().get(), new_other_node,
i);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions chromium_src/components/bookmarks/browser/bookmark_model.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* Copyright 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand All @@ -7,9 +6,10 @@
#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_
#define BRAVE_CHROMIUM_SRC_COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_

#define BRAVE_BOOKMARK_MODEL_H_ \
void MigrateOtherNode();
#include "../../../../../components/bookmarks/browser/bookmark_model.h"
#undef BRAVE_BOOKMARK_MODEL_H_

namespace bookmarks {
void BraveMigrateOtherNode(BookmarkModel* model);
} // namespace bookmarks

#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ TEST_F(BookmarkModelTest, BraveMostRecentlyModifiedFolders) {
ASSERT_TRUE(most_recent_folders[0] != folder);
}

TEST_F(BookmarkModelTest, MigrateOtherNode) {
TEST_F(BookmarkModelTest, BraveMigrateOtherNode) {
// -- Bookmarks
// |-- A
// -- Other Bookmarks
Expand All @@ -107,7 +107,7 @@ TEST_F(BookmarkModelTest, MigrateOtherNode) {
// |-- B
// | |--B1.com
// |-- C.com
model_->MigrateOtherNode();
BraveMigrateOtherNode(model_.get());
ASSERT_EQ(model_->other_node()->children().size(), 0u);
ASSERT_EQ(model_->bookmark_bar_node()->children().size(), 2u);
EXPECT_EQ(model_->bookmark_bar_node()->children()[0]->GetTitle(),
Expand Down
2 changes: 1 addition & 1 deletion components/brave_sync/brave_profile_sync_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ void BraveProfileSyncServiceImpl::OnSyncReady() {
ProfileSyncService::GetUserSettings()->SetSyncRequested(true);
}

model_->MigrateOtherNode();
BraveMigrateOtherNode(model_);
}

syncer::ModelTypeSet BraveProfileSyncServiceImpl::GetPreferredDataTypes()
Expand Down
13 changes: 0 additions & 13 deletions patches/components-bookmarks-browser-bookmark_model.h.patch

This file was deleted.

0 comments on commit 4dab70c

Please sign in to comment.