| 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_change_processor.h" | 5 #include "chrome/browser/sync/glue/bookmark_change_processor.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <stack> | 8 #include <stack> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 foster_parent->child_count()); | 600 foster_parent->child_count()); |
| 601 } | 601 } |
| 602 } | 602 } |
| 603 DCHECK_EQ(dst->child_count(), 0) << "Node being deleted has children"; | 603 DCHECK_EQ(dst->child_count(), 0) << "Node being deleted has children"; |
| 604 | 604 |
| 605 model_associator_->Disassociate(it->id); | 605 model_associator_->Disassociate(it->id); |
| 606 | 606 |
| 607 const BookmarkNode* parent = dst->parent(); | 607 const BookmarkNode* parent = dst->parent(); |
| 608 int index = parent->GetIndexOf(dst); | 608 int index = parent->GetIndexOf(dst); |
| 609 if (index > -1) | 609 if (index > -1) |
| 610 model->Remove(parent, index); | 610 model->Remove(parent->GetChild(index)); |
| 611 } | 611 } |
| 612 | 612 |
| 613 // A map to keep track of some reordering work we defer until later. | 613 // A map to keep track of some reordering work we defer until later. |
| 614 std::multimap<int, const BookmarkNode*> to_reposition; | 614 std::multimap<int, const BookmarkNode*> to_reposition; |
| 615 | 615 |
| 616 syncer::ReadNode synced_bookmarks(trans); | 616 syncer::ReadNode synced_bookmarks(trans); |
| 617 int64 synced_bookmarks_id = syncer::kInvalidId; | 617 int64 synced_bookmarks_id = syncer::kInvalidId; |
| 618 if (synced_bookmarks.InitByTagLookupForBookmarks(kMobileBookmarksTag) == | 618 if (synced_bookmarks.InitByTagLookupForBookmarks(kMobileBookmarksTag) == |
| 619 syncer::BaseNode::INIT_OK) { | 619 syncer::BaseNode::INIT_OK) { |
| 620 synced_bookmarks_id = synced_bookmarks.GetId(); | 620 synced_bookmarks_id = synced_bookmarks.GetId(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 for (std::multimap<int, const BookmarkNode*>::iterator it = | 702 for (std::multimap<int, const BookmarkNode*>::iterator it = |
| 703 to_reposition.begin(); it != to_reposition.end(); ++it) { | 703 to_reposition.begin(); it != to_reposition.end(); ++it) { |
| 704 const BookmarkNode* parent = it->second->parent(); | 704 const BookmarkNode* parent = it->second->parent(); |
| 705 model->Move(it->second, parent, it->first); | 705 model->Move(it->second, parent, it->first); |
| 706 } | 706 } |
| 707 | 707 |
| 708 // Clean up the temporary node. | 708 // Clean up the temporary node. |
| 709 if (foster_parent) { | 709 if (foster_parent) { |
| 710 // There should be no nodes left under the foster parent. | 710 // There should be no nodes left under the foster parent. |
| 711 DCHECK_EQ(foster_parent->child_count(), 0); | 711 DCHECK_EQ(foster_parent->child_count(), 0); |
| 712 model->Remove(foster_parent->parent(), | 712 model->Remove(foster_parent); |
| 713 foster_parent->parent()->GetIndexOf(foster_parent)); | |
| 714 foster_parent = NULL; | 713 foster_parent = NULL; |
| 715 } | 714 } |
| 716 | 715 |
| 717 // The visibility of the mobile node may need to change. | 716 // The visibility of the mobile node may need to change. |
| 718 model_associator_->UpdatePermanentNodeVisibility(); | 717 model_associator_->UpdatePermanentNodeVisibility(); |
| 719 | 718 |
| 720 // Notify UI intensive observers of BookmarkModel that all updates have been | 719 // Notify UI intensive observers of BookmarkModel that all updates have been |
| 721 // applied, and that they may now be consumed. This prevents issues like the | 720 // applied, and that they may now be consumed. This prevents issues like the |
| 722 // one described in crbug.com/281562, where old and new items on the bookmarks | 721 // one described in crbug.com/281562, where old and new items on the bookmarks |
| 723 // bar would overlap. | 722 // bar would overlap. |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 updated_specifics.set_icon_url(bookmark_node->icon_url().spec()); | 937 updated_specifics.set_icon_url(bookmark_node->icon_url().spec()); |
| 939 sync_node->SetBookmarkSpecifics(updated_specifics); | 938 sync_node->SetBookmarkSpecifics(updated_specifics); |
| 940 } | 939 } |
| 941 } | 940 } |
| 942 | 941 |
| 943 bool BookmarkChangeProcessor::CanSyncNode(const BookmarkNode* node) { | 942 bool BookmarkChangeProcessor::CanSyncNode(const BookmarkNode* node) { |
| 944 return bookmark_model_->client()->CanSyncNode(node); | 943 return bookmark_model_->client()->CanSyncNode(node); |
| 945 } | 944 } |
| 946 | 945 |
| 947 } // namespace browser_sync | 946 } // namespace browser_sync |
| OLD | NEW |