summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync
diff options
context:
space:
mode:
authorzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-30 00:45:59 +0000
committerzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-30 00:45:59 +0000
commit0491ff7fcd31ec9ec1db6a6e8fe280eab0779b89 (patch)
tree1f2da39255fd7f1fdef1d9646de5a148c3da52a5 /chrome/browser/sync
parent76e6a1170bbc8f893181e13310b1780a3d915b66 (diff)
downloadchromium_src-0491ff7fcd31ec9ec1db6a6e8fe280eab0779b89.zip
chromium_src-0491ff7fcd31ec9ec1db6a6e8fe280eab0779b89.tar.gz
chromium_src-0491ff7fcd31ec9ec1db6a6e8fe280eab0779b89.tar.bz2
Have whitespace cleanup for bookmarks happen in BookmarkNode::SetTitle(..).
Previously, BookmarkModel::SetTitle(..) would remove leading/trailing whitespace characters before modifying the bookmark node. This is problematic for any code that directly interacts with bookmark nodes (for example for comparison purposes or when loading bookmark from the persisted file). By having this functionality in the BookmarkNode itself, we ensure consistent titles, and fix a bug where sync could not find bookmarks and ended up duplicating data. BUG=108332 TEST=Add a bookmark with leading/trailing spaces. Enable Sync. Restart. Ensure the bookmark has not duplicated. unit_tests --gtest_filter="*ProfileSyncServiceBookmarkTestWithData*" Review URL: http://codereview.chromium.org/8949053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116009 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r--chrome/browser/sync/glue/bookmark_model_associator.cc2
-rw-r--r--chrome/browser/sync/profile_sync_service_bookmark_unittest.cc11
2 files changed, 9 insertions, 4 deletions
diff --git a/chrome/browser/sync/glue/bookmark_model_associator.cc b/chrome/browser/sync/glue/bookmark_model_associator.cc
index 5b11b4b..53e665b 100644
--- a/chrome/browser/sync/glue/bookmark_model_associator.cc
+++ b/chrome/browser/sync/glue/bookmark_model_associator.cc
@@ -107,7 +107,7 @@ const BookmarkNode* BookmarkNodeFinder::FindBookmarkNode(
const sync_api::BaseNode& sync_node) {
// Create a bookmark node from the given sync node.
BookmarkNode temp_node(sync_node.GetURL());
- temp_node.set_title(UTF8ToUTF16(sync_node.GetTitle()));
+ temp_node.SetTitle(UTF8ToUTF16(sync_node.GetTitle()));
if (sync_node.GetIsFolder())
temp_node.set_type(BookmarkNode::FOLDER);
else
diff --git a/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc b/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc
index 1b87769..8727e22 100644
--- a/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_bookmark_unittest.cc
@@ -980,7 +980,8 @@ namespace {
// | |-- dup
// | | +-- dupu1, http://www.dupu1.com/
// | +-- dup
-// | +-- dupu2, http://www.dupu1.com/
+// | | +-- dupu2, http://www.dupu1.com/
+// | +-- ls , http://www.ls.com/
// |
// +-- Mobile bookmarks
// |-- f5
@@ -1016,6 +1017,7 @@ static TestData kOtherBookmarkChildren[] = {
{ L"f4", NULL },
{ L"dup", NULL },
{ L"dup", NULL },
+ { L" ls ", "http://www.ls.com/" }
};
static TestData kF3Children[] = {
{ L"f3u4", "http://www.f3u4.com/" },
@@ -1076,11 +1078,14 @@ void ProfileSyncServiceBookmarkTestWithData::CompareWithTestData(
for (int i = 0; i < size; ++i) {
const BookmarkNode* child_node = node->GetChild(i);
const TestData& item = data[i];
- EXPECT_EQ(child_node->GetTitle(), WideToUTF16Hack(item.title));
+ GURL url = GURL(item.url == NULL ? "" : item.url);
+ BookmarkNode test_node(url);
+ test_node.SetTitle(WideToUTF16Hack(item.title));
+ EXPECT_EQ(child_node->GetTitle(), test_node.GetTitle());
if (item.url) {
EXPECT_FALSE(child_node->is_folder());
EXPECT_TRUE(child_node->is_url());
- EXPECT_EQ(child_node->url(), GURL(item.url));
+ EXPECT_EQ(child_node->url(), test_node.url());
} else {
EXPECT_TRUE(child_node->is_folder());
EXPECT_FALSE(child_node->is_url());