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/bookmarks/bookmark_model.h" | 5 #include "chrome/browser/bookmarks/bookmark_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 if (!profile_) { | 212 if (!profile_) { |
213 // Profile is null during testing. | 213 // Profile is null during testing. |
214 DoneLoading(CreateLoadDetails()); | 214 DoneLoading(CreateLoadDetails()); |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 BookmarkModel::~BookmarkModel() { | 218 BookmarkModel::~BookmarkModel() { |
219 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, | 219 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, |
220 BookmarkModelBeingDeleted(this)); | 220 BookmarkModelBeingDeleted(this)); |
221 | 221 |
222 if (store_) { | 222 if (store_.get()) { |
223 // The store maintains a reference back to us. We need to tell it we're gone | 223 // The store maintains a reference back to us. We need to tell it we're gone |
224 // so that it doesn't try and invoke a method back on us again. | 224 // so that it doesn't try and invoke a method back on us again. |
225 store_->BookmarkModelDeleted(); | 225 store_->BookmarkModelDeleted(); |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 void BookmarkModel::Shutdown() { | 229 void BookmarkModel::Shutdown() { |
230 if (loaded_) | 230 if (loaded_) |
231 return; | 231 return; |
232 | 232 |
(...skipping 13 matching lines...) Expand all Loading... |
246 | 246 |
247 expanded_state_tracker_.reset(new BookmarkExpandedStateTracker( | 247 expanded_state_tracker_.reset(new BookmarkExpandedStateTracker( |
248 profile_, this)); | 248 profile_, this)); |
249 | 249 |
250 // Listen for changes to favicons so that we can update the favicon of the | 250 // Listen for changes to favicons so that we can update the favicon of the |
251 // node appropriately. | 251 // node appropriately. |
252 registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED, | 252 registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED, |
253 content::Source<Profile>(profile_)); | 253 content::Source<Profile>(profile_)); |
254 | 254 |
255 // Load the bookmarks. BookmarkStorage notifies us when done. | 255 // Load the bookmarks. BookmarkStorage notifies us when done. |
256 store_ = new BookmarkStorage(profile_, this, task_runner); | 256 store_ = new BookmarkStorage(profile_, this, task_runner.get()); |
257 store_->LoadBookmarks(CreateLoadDetails()); | 257 store_->LoadBookmarks(CreateLoadDetails()); |
258 } | 258 } |
259 | 259 |
260 const BookmarkNode* BookmarkModel::GetParentForNewNodes() { | 260 const BookmarkNode* BookmarkModel::GetParentForNewNodes() { |
261 std::vector<const BookmarkNode*> nodes = | 261 std::vector<const BookmarkNode*> nodes = |
262 bookmark_utils::GetMostRecentlyModifiedFolders(this, 1); | 262 bookmark_utils::GetMostRecentlyModifiedFolders(this, 1); |
263 DCHECK(!nodes.empty()); // This list is always padded with default folders. | 263 DCHECK(!nodes.empty()); // This list is always padded with default folders. |
264 return nodes[0]; | 264 return nodes[0]; |
265 } | 265 } |
266 | 266 |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 BookmarkPermanentNode* bb_node = | 995 BookmarkPermanentNode* bb_node = |
996 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); | 996 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); |
997 BookmarkPermanentNode* other_node = | 997 BookmarkPermanentNode* other_node = |
998 CreatePermanentNode(BookmarkNode::OTHER_NODE); | 998 CreatePermanentNode(BookmarkNode::OTHER_NODE); |
999 BookmarkPermanentNode* mobile_node = | 999 BookmarkPermanentNode* mobile_node = |
1000 CreatePermanentNode(BookmarkNode::MOBILE); | 1000 CreatePermanentNode(BookmarkNode::MOBILE); |
1001 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, | 1001 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, |
1002 new BookmarkIndex(profile_), | 1002 new BookmarkIndex(profile_), |
1003 next_node_id_); | 1003 next_node_id_); |
1004 } | 1004 } |
OLD | NEW |