OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/sync/glue/bookmark_model_associator.h" | 5 #include "chrome/browser/sync/glue/bookmark_model_associator.h" |
6 | 6 |
7 #include <stack> | 7 #include <stack> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 BookmarkNodeFinder::BookmarkNodeFinder(const BookmarkNode* parent_node) | 118 BookmarkNodeFinder::BookmarkNodeFinder(const BookmarkNode* parent_node) |
119 : parent_node_(parent_node) { | 119 : parent_node_(parent_node) { |
120 for (int i = 0; i < parent_node_->child_count(); ++i) { | 120 for (int i = 0; i < parent_node_->child_count(); ++i) { |
121 child_nodes_.insert(parent_node_->GetChild(i)); | 121 child_nodes_.insert(parent_node_->GetChild(i)); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 const BookmarkNode* BookmarkNodeFinder::FindBookmarkNode( | 125 const BookmarkNode* BookmarkNodeFinder::FindBookmarkNode( |
126 const syncer::BaseNode& sync_node) { | 126 const syncer::BaseNode& sync_node) { |
127 // Create a bookmark node from the given sync node. | 127 // Create a bookmark node from the given sync node. |
128 BookmarkNode temp_node(sync_node.GetURL()); | 128 BookmarkNode temp_node(GURL(sync_node.GetBookmarkSpecifics().url())); |
129 temp_node.SetTitle(UTF8ToUTF16(sync_node.GetTitle())); | 129 temp_node.SetTitle(UTF8ToUTF16(sync_node.GetTitle())); |
130 if (sync_node.GetIsFolder()) | 130 if (sync_node.GetIsFolder()) |
131 temp_node.set_type(BookmarkNode::FOLDER); | 131 temp_node.set_type(BookmarkNode::FOLDER); |
132 else | 132 else |
133 temp_node.set_type(BookmarkNode::URL); | 133 temp_node.set_type(BookmarkNode::URL); |
134 | 134 |
135 const BookmarkNode* result = NULL; | 135 const BookmarkNode* result = NULL; |
136 BookmarkNodesSet::iterator iter = child_nodes_.find(&temp_node); | 136 BookmarkNodesSet::iterator iter = child_nodes_.find(&temp_node); |
137 if (iter != child_nodes_.end()) { | 137 if (iter != child_nodes_.end()) { |
138 result = *iter; | 138 result = *iter; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 } | 317 } |
318 | 318 |
319 bool BookmarkModelAssociator::NodesMatch( | 319 bool BookmarkModelAssociator::NodesMatch( |
320 const BookmarkNode* bookmark, | 320 const BookmarkNode* bookmark, |
321 const syncer::BaseNode* sync_node) const { | 321 const syncer::BaseNode* sync_node) const { |
322 if (bookmark->GetTitle() != UTF8ToUTF16(sync_node->GetTitle())) | 322 if (bookmark->GetTitle() != UTF8ToUTF16(sync_node->GetTitle())) |
323 return false; | 323 return false; |
324 if (bookmark->is_folder() != sync_node->GetIsFolder()) | 324 if (bookmark->is_folder() != sync_node->GetIsFolder()) |
325 return false; | 325 return false; |
326 if (bookmark->is_url()) { | 326 if (bookmark->is_url()) { |
327 if (bookmark->url() != sync_node->GetURL()) | 327 if (bookmark->url() != GURL(sync_node->GetBookmarkSpecifics().url())) |
328 return false; | 328 return false; |
329 } | 329 } |
330 // Don't compare favicons here, because they are not really | 330 // Don't compare favicons here, because they are not really |
331 // user-updated and we don't have versioning information -- a site changing | 331 // user-updated and we don't have versioning information -- a site changing |
332 // its favicon shouldn't result in a bookmark mismatch. | 332 // its favicon shouldn't result in a bookmark mismatch. |
333 return true; | 333 return true; |
334 } | 334 } |
335 | 335 |
336 bool BookmarkModelAssociator::AssociateTaggedPermanentNode( | 336 bool BookmarkModelAssociator::AssociateTaggedPermanentNode( |
337 const BookmarkNode* permanent_node, const std::string&tag) { | 337 const BookmarkNode* permanent_node, const std::string&tag) { |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 UMA_HISTOGRAM_ENUMERATION("Sync.LocalModelOutOfSync", | 606 UMA_HISTOGRAM_ENUMERATION("Sync.LocalModelOutOfSync", |
607 syncer::BOOKMARKS, syncer::MODEL_TYPE_COUNT); | 607 syncer::BOOKMARKS, syncer::MODEL_TYPE_COUNT); |
608 // Clear version on bookmark model so that we only report error once. | 608 // Clear version on bookmark model so that we only report error once. |
609 bookmark_model_->DeleteNodeMetaInfo(bookmark_model_->root_node(), | 609 bookmark_model_->DeleteNodeMetaInfo(bookmark_model_->root_node(), |
610 kBookmarkTransactionVersionKey); | 610 kBookmarkTransactionVersionKey); |
611 } | 611 } |
612 } | 612 } |
613 } | 613 } |
614 | 614 |
615 } // namespace browser_sync | 615 } // namespace browser_sync |
OLD | NEW |