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" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/json/json_string_value_serializer.h" | 12 #include "base/json/json_string_value_serializer.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/sequenced_task_runner.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
17 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" | 18 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" |
18 #include "chrome/browser/bookmarks/bookmark_index.h" | 19 #include "chrome/browser/bookmarks/bookmark_index.h" |
19 #include "chrome/browser/bookmarks/bookmark_model_observer.h" | 20 #include "chrome/browser/bookmarks/bookmark_model_observer.h" |
20 #include "chrome/browser/bookmarks/bookmark_storage.h" | 21 #include "chrome/browser/bookmarks/bookmark_storage.h" |
21 #include "chrome/browser/bookmarks/bookmark_utils.h" | 22 #include "chrome/browser/bookmarks/bookmark_utils.h" |
22 #include "chrome/browser/favicon/favicon_service_factory.h" | 23 #include "chrome/browser/favicon/favicon_service_factory.h" |
23 #include "chrome/browser/history/history_notifications.h" | 24 #include "chrome/browser/history/history_notifications.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 241 |
241 expanded_state_tracker_.reset(new BookmarkExpandedStateTracker( | 242 expanded_state_tracker_.reset(new BookmarkExpandedStateTracker( |
242 profile_, this)); | 243 profile_, this)); |
243 | 244 |
244 // Listen for changes to favicons so that we can update the favicon of the | 245 // Listen for changes to favicons so that we can update the favicon of the |
245 // node appropriately. | 246 // node appropriately. |
246 registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED, | 247 registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED, |
247 content::Source<Profile>(profile_)); | 248 content::Source<Profile>(profile_)); |
248 | 249 |
249 // Load the bookmarks. BookmarkStorage notifies us when done. | 250 // Load the bookmarks. BookmarkStorage notifies us when done. |
250 store_ = new BookmarkStorage(profile_, this); | 251 store_ = new BookmarkStorage(profile_, this, profile_->GetIOTaskRunner()); |
251 store_->LoadBookmarks(CreateLoadDetails()); | 252 store_->LoadBookmarks(CreateLoadDetails()); |
252 } | 253 } |
253 | 254 |
254 bool BookmarkModel::IsLoaded() const { | 255 bool BookmarkModel::IsLoaded() const { |
255 return loaded_; | 256 return loaded_; |
256 } | 257 } |
257 | 258 |
258 const BookmarkNode* BookmarkModel::GetParentForNewNodes() { | 259 const BookmarkNode* BookmarkModel::GetParentForNewNodes() { |
259 std::vector<const BookmarkNode*> nodes = | 260 std::vector<const BookmarkNode*> nodes = |
260 bookmark_utils::GetMostRecentlyModifiedFolders(this, 1); | 261 bookmark_utils::GetMostRecentlyModifiedFolders(this, 1); |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 BookmarkPermanentNode* bb_node = | 980 BookmarkPermanentNode* bb_node = |
980 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); | 981 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); |
981 BookmarkPermanentNode* other_node = | 982 BookmarkPermanentNode* other_node = |
982 CreatePermanentNode(BookmarkNode::OTHER_NODE); | 983 CreatePermanentNode(BookmarkNode::OTHER_NODE); |
983 BookmarkPermanentNode* mobile_node = | 984 BookmarkPermanentNode* mobile_node = |
984 CreatePermanentNode(BookmarkNode::MOBILE); | 985 CreatePermanentNode(BookmarkNode::MOBILE); |
985 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, | 986 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, |
986 new BookmarkIndex(profile_), | 987 new BookmarkIndex(profile_), |
987 next_node_id_); | 988 next_node_id_); |
988 } | 989 } |
OLD | NEW |