| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 : parent_node_(parent_node) { | 124 : parent_node_(parent_node) { |
| 125 for (int i = 0; i < parent_node_->child_count(); ++i) { | 125 for (int i = 0; i < parent_node_->child_count(); ++i) { |
| 126 child_nodes_.insert(parent_node_->GetChild(i)); | 126 child_nodes_.insert(parent_node_->GetChild(i)); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 const BookmarkNode* BookmarkNodeFinder::FindBookmarkNode( | 130 const BookmarkNode* BookmarkNodeFinder::FindBookmarkNode( |
| 131 const GURL& url, const std::string& title, bool is_folder) { | 131 const GURL& url, const std::string& title, bool is_folder) { |
| 132 // Create a bookmark node from the given bookmark attributes. | 132 // Create a bookmark node from the given bookmark attributes. |
| 133 BookmarkNode temp_node(url); | 133 BookmarkNode temp_node(url); |
| 134 temp_node.SetTitle(UTF8ToUTF16(title)); | 134 temp_node.SetTitle(base::UTF8ToUTF16(title)); |
| 135 if (is_folder) | 135 if (is_folder) |
| 136 temp_node.set_type(BookmarkNode::FOLDER); | 136 temp_node.set_type(BookmarkNode::FOLDER); |
| 137 else | 137 else |
| 138 temp_node.set_type(BookmarkNode::URL); | 138 temp_node.set_type(BookmarkNode::URL); |
| 139 | 139 |
| 140 const BookmarkNode* result = NULL; | 140 const BookmarkNode* result = NULL; |
| 141 BookmarkNodesSet::iterator iter = child_nodes_.find(&temp_node); | 141 BookmarkNodesSet::iterator iter = child_nodes_.find(&temp_node); |
| 142 if (iter != child_nodes_.end()) { | 142 if (iter != child_nodes_.end()) { |
| 143 result = *iter; | 143 result = *iter; |
| 144 // Remove the matched node so we don't match with it again. | 144 // Remove the matched node so we don't match with it again. |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 // children. | 319 // children. |
| 320 *has_nodes = bookmark_bar_node.HasChildren() || | 320 *has_nodes = bookmark_bar_node.HasChildren() || |
| 321 other_bookmarks_node.HasChildren() || | 321 other_bookmarks_node.HasChildren() || |
| 322 (has_mobile_folder && mobile_bookmarks_node.HasChildren()); | 322 (has_mobile_folder && mobile_bookmarks_node.HasChildren()); |
| 323 return true; | 323 return true; |
| 324 } | 324 } |
| 325 | 325 |
| 326 bool BookmarkModelAssociator::NodesMatch( | 326 bool BookmarkModelAssociator::NodesMatch( |
| 327 const BookmarkNode* bookmark, | 327 const BookmarkNode* bookmark, |
| 328 const syncer::BaseNode* sync_node) const { | 328 const syncer::BaseNode* sync_node) const { |
| 329 if (bookmark->GetTitle() != UTF8ToUTF16(sync_node->GetTitle())) | 329 if (bookmark->GetTitle() != base::UTF8ToUTF16(sync_node->GetTitle())) |
| 330 return false; | 330 return false; |
| 331 if (bookmark->is_folder() != sync_node->GetIsFolder()) | 331 if (bookmark->is_folder() != sync_node->GetIsFolder()) |
| 332 return false; | 332 return false; |
| 333 if (bookmark->is_url()) { | 333 if (bookmark->is_url()) { |
| 334 if (bookmark->url() != GURL(sync_node->GetBookmarkSpecifics().url())) | 334 if (bookmark->url() != GURL(sync_node->GetBookmarkSpecifics().url())) |
| 335 return false; | 335 return false; |
| 336 } | 336 } |
| 337 // Don't compare favicons here, because they are not really | 337 // Don't compare favicons here, because they are not really |
| 338 // user-updated and we don't have versioning information -- a site changing | 338 // user-updated and we don't have versioning information -- a site changing |
| 339 // its favicon shouldn't result in a bookmark mismatch. | 339 // its favicon shouldn't result in a bookmark mismatch. |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 syncer::SyncError::PERSISTENCE_ERROR, | 746 syncer::SyncError::PERSISTENCE_ERROR, |
| 747 message, | 747 message, |
| 748 syncer::BOOKMARKS); | 748 syncer::BOOKMARKS); |
| 749 } | 749 } |
| 750 } | 750 } |
| 751 } | 751 } |
| 752 return syncer::SyncError(); | 752 return syncer::SyncError(); |
| 753 } | 753 } |
| 754 | 754 |
| 755 } // namespace browser_sync | 755 } // namespace browser_sync |
| OLD | NEW |