Commit 9e583647 authored by kinaba@chromium.org's avatar kinaba@chromium.org

Bookmark: change Move() with no effect to keep the folder timestamp.

Bookmark Sync may try to Move an entry to the location where it already is placed.
Updating the folder's timestamp with such no-op moves unwillingly disorders
the "recently used" list of folders; it should better be avoided.

BUG=162764

Review URL: https://chromiumcodereview.appspot.com/11411346

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171134 0039d316-1c4b-4281-b951-d872f2087c98
parent 4267cb8f
......@@ -310,8 +310,6 @@ void BookmarkModel::Move(const BookmarkNode* node,
return;
}
SetDateFolderModified(new_parent, Time::Now());
const BookmarkNode* old_parent = node->parent();
int old_index = old_parent->GetIndexOf(node);
......@@ -321,6 +319,8 @@ void BookmarkModel::Move(const BookmarkNode* node,
return;
}
SetDateFolderModified(new_parent, Time::Now());
if (old_parent == new_parent && index > old_index)
index--;
BookmarkNode* mutable_new_parent = AsMutable(new_parent);
......
......@@ -516,6 +516,22 @@ TEST_F(BookmarkModelTest, Move) {
EXPECT_EQ(0, root->child_count());
}
TEST_F(BookmarkModelTest, NonMovingMoveCall) {
const BookmarkNode* root = model_.bookmark_bar_node();
const string16 title(ASCIIToUTF16("foo"));
const GURL url("http://foo.com");
const base::Time old_date(base::Time::Now() - base::TimeDelta::FromDays(1));
const BookmarkNode* node = model_.AddURL(root, 0, title, url);
model_.SetDateFolderModified(root, old_date);
// Since |node| is already at the index 0 of |root|, this is no-op.
model_.Move(node, root, 0);
// Check that the modification date is kept untouched.
EXPECT_EQ(old_date, root->date_folder_modified());
}
TEST_F(BookmarkModelTest, Copy) {
const BookmarkNode* root = model_.bookmark_bar_node();
static const std::string model_string("a 1:[ b c ] d 2:[ e f g ] h ");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment