Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: chrome/browser/sync/glue/bookmark_model_associator.cc

Issue 7612015: sync: Make BaseNode::GetTitle() return std::string. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix syncapi_unittest Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 : parent_node_(parent_node) { 96 : parent_node_(parent_node) {
97 for (int i = 0; i < parent_node_->child_count(); ++i) { 97 for (int i = 0; i < parent_node_->child_count(); ++i) {
98 child_nodes_.insert(parent_node_->GetChild(i)); 98 child_nodes_.insert(parent_node_->GetChild(i));
99 } 99 }
100 } 100 }
101 101
102 const BookmarkNode* BookmarkNodeFinder::FindBookmarkNode( 102 const BookmarkNode* BookmarkNodeFinder::FindBookmarkNode(
103 const sync_api::BaseNode& sync_node) { 103 const sync_api::BaseNode& sync_node) {
104 // Create a bookmark node from the given sync node. 104 // Create a bookmark node from the given sync node.
105 BookmarkNode temp_node(sync_node.GetURL()); 105 BookmarkNode temp_node(sync_node.GetURL());
106 temp_node.set_title(WideToUTF16Hack(sync_node.GetTitle())); 106 temp_node.set_title(UTF8ToUTF16(sync_node.GetTitle()));
107 if (sync_node.GetIsFolder()) 107 if (sync_node.GetIsFolder())
108 temp_node.set_type(BookmarkNode::FOLDER); 108 temp_node.set_type(BookmarkNode::FOLDER);
109 else 109 else
110 temp_node.set_type(BookmarkNode::URL); 110 temp_node.set_type(BookmarkNode::URL);
111 111
112 const BookmarkNode* result = NULL; 112 const BookmarkNode* result = NULL;
113 BookmarkNodesSet::iterator iter = child_nodes_.find(&temp_node); 113 BookmarkNodesSet::iterator iter = child_nodes_.find(&temp_node);
114 if (iter != child_nodes_.end()) { 114 if (iter != child_nodes_.end()) {
115 result = *iter; 115 result = *iter;
116 // Remove the matched node so we don't match with it again. 116 // Remove the matched node so we don't match with it again.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 273
274 // Sync model has user created nodes if either one of the permanent nodes 274 // Sync model has user created nodes if either one of the permanent nodes
275 // has children. 275 // has children.
276 *has_nodes = bookmark_bar_node.GetFirstChildId() != sync_api::kInvalidId || 276 *has_nodes = bookmark_bar_node.GetFirstChildId() != sync_api::kInvalidId ||
277 other_bookmarks_node.GetFirstChildId() != sync_api::kInvalidId || 277 other_bookmarks_node.GetFirstChildId() != sync_api::kInvalidId ||
278 (has_synced_folder && 278 (has_synced_folder &&
279 synced_bookmarks_node.GetFirstChildId() != sync_api::kInvalidId); 279 synced_bookmarks_node.GetFirstChildId() != sync_api::kInvalidId);
280 return true; 280 return true;
281 } 281 }
282 282
283 bool BookmarkModelAssociator::NodesMatch(const BookmarkNode* bookmark, 283 bool BookmarkModelAssociator::NodesMatch(
284 const BookmarkNode* bookmark,
284 const sync_api::BaseNode* sync_node) const { 285 const sync_api::BaseNode* sync_node) const {
285 if (bookmark->GetTitle() != WideToUTF16Hack(sync_node->GetTitle())) 286 if (bookmark->GetTitle() != UTF8ToUTF16(sync_node->GetTitle()))
286 return false; 287 return false;
287 if (bookmark->is_folder() != sync_node->GetIsFolder()) 288 if (bookmark->is_folder() != sync_node->GetIsFolder())
288 return false; 289 return false;
289 if (bookmark->is_url()) { 290 if (bookmark->is_url()) {
290 if (bookmark->url() != sync_node->GetURL()) 291 if (bookmark->url() != sync_node->GetURL())
291 return false; 292 return false;
292 } 293 }
293 // Don't compare favicons here, because they are not really 294 // Don't compare favicons here, because they are not really
294 // user-updated and we don't have versioning information -- a site changing 295 // user-updated and we don't have versioning information -- a site changing
295 // its favicon shouldn't result in a bookmark mismatch. 296 // its favicon shouldn't result in a bookmark mismatch.
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 bool BookmarkModelAssociator::CryptoReadyIfNecessary() { 602 bool BookmarkModelAssociator::CryptoReadyIfNecessary() {
602 // We only access the cryptographer while holding a transaction. 603 // We only access the cryptographer while holding a transaction.
603 sync_api::ReadTransaction trans(FROM_HERE, user_share_); 604 sync_api::ReadTransaction trans(FROM_HERE, user_share_);
604 const syncable::ModelTypeSet& encrypted_types = 605 const syncable::ModelTypeSet& encrypted_types =
605 sync_api::GetEncryptedTypes(&trans); 606 sync_api::GetEncryptedTypes(&trans);
606 return encrypted_types.count(syncable::BOOKMARKS) == 0 || 607 return encrypted_types.count(syncable::BOOKMARKS) == 0 ||
607 trans.GetCryptographer()->is_ready(); 608 trans.GetCryptographer()->is_ready();
608 } 609 }
609 610
610 } // namespace browser_sync 611 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/bookmark_change_processor.cc ('k') | chrome/browser/sync/profile_sync_service_bookmark_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698