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" |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/macros.h" |
14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/sync/glue/bookmark_change_processor.h" | 21 #include "chrome/browser/sync/glue/bookmark_change_processor.h" |
21 #include "chrome/browser/undo/bookmark_undo_service.h" | 22 #include "chrome/browser/undo/bookmark_undo_service.h" |
22 #include "chrome/browser/undo/bookmark_undo_service_factory.h" | 23 #include "chrome/browser/undo/bookmark_undo_service_factory.h" |
23 #include "chrome/browser/undo/bookmark_undo_utils.h" | 24 #include "chrome/browser/undo/bookmark_undo_utils.h" |
| 25 #include "components/bookmarks/core/browser/bookmark_client.h" |
24 #include "components/bookmarks/core/browser/bookmark_model.h" | 26 #include "components/bookmarks/core/browser/bookmark_model.h" |
25 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
26 #include "sync/api/sync_error.h" | 28 #include "sync/api/sync_error.h" |
27 #include "sync/internal_api/public/delete_journal.h" | 29 #include "sync/internal_api/public/delete_journal.h" |
28 #include "sync/internal_api/public/read_node.h" | 30 #include "sync/internal_api/public/read_node.h" |
29 #include "sync/internal_api/public/read_transaction.h" | 31 #include "sync/internal_api/public/read_transaction.h" |
30 #include "sync/internal_api/public/write_node.h" | 32 #include "sync/internal_api/public/write_node.h" |
31 #include "sync/internal_api/public/write_transaction.h" | 33 #include "sync/internal_api/public/write_transaction.h" |
32 #include "sync/internal_api/syncapi_internal.h" | 34 #include "sync/internal_api/syncapi_internal.h" |
33 #include "sync/syncable/syncable_write_transaction.h" | 35 #include "sync/syncable/syncable_write_transaction.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 228 } |
227 | 229 |
228 BookmarkModelAssociator::~BookmarkModelAssociator() { | 230 BookmarkModelAssociator::~BookmarkModelAssociator() { |
229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
230 } | 232 } |
231 | 233 |
232 void BookmarkModelAssociator::UpdatePermanentNodeVisibility() { | 234 void BookmarkModelAssociator::UpdatePermanentNodeVisibility() { |
233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
234 DCHECK(bookmark_model_->loaded()); | 236 DCHECK(bookmark_model_->loaded()); |
235 | 237 |
236 bookmark_model_->SetPermanentNodeVisible( | 238 BookmarkNode::Type bookmark_node_types[] = { |
237 BookmarkNode::MOBILE, | 239 BookmarkNode::BOOKMARK_BAR, |
238 id_map_.find(bookmark_model_->mobile_node()->id()) != id_map_.end()); | 240 BookmarkNode::OTHER_NODE, |
| 241 BookmarkNode::MOBILE, |
| 242 }; |
| 243 for (size_t i = 0; i < arraysize(bookmark_node_types); ++i) { |
| 244 int64 id = bookmark_model_->PermanentNode(bookmark_node_types[i])->id(); |
| 245 bookmark_model_->SetPermanentNodeVisible( |
| 246 bookmark_node_types[i], |
| 247 id_map_.find(id) != id_map_.end()); |
| 248 } |
239 } | 249 } |
240 | 250 |
241 syncer::SyncError BookmarkModelAssociator::DisassociateModels() { | 251 syncer::SyncError BookmarkModelAssociator::DisassociateModels() { |
242 id_map_.clear(); | 252 id_map_.clear(); |
243 id_map_inverse_.clear(); | 253 id_map_inverse_.clear(); |
244 dirty_associations_sync_ids_.clear(); | 254 dirty_associations_sync_ids_.clear(); |
245 return syncer::SyncError(); | 255 return syncer::SyncError(); |
246 } | 256 } |
247 | 257 |
248 int64 BookmarkModelAssociator::GetSyncIdFromChromeId(const int64& node_id) { | 258 int64 BookmarkModelAssociator::GetSyncIdFromChromeId(const int64& node_id) { |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 syncer::SyncError::PERSISTENCE_ERROR, | 775 syncer::SyncError::PERSISTENCE_ERROR, |
766 message, | 776 message, |
767 syncer::BOOKMARKS); | 777 syncer::BOOKMARKS); |
768 } | 778 } |
769 } | 779 } |
770 } | 780 } |
771 return syncer::SyncError(); | 781 return syncer::SyncError(); |
772 } | 782 } |
773 | 783 |
774 } // namespace browser_sync | 784 } // namespace browser_sync |
OLD | NEW |