OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/bookmarks/browser/bookmark_model.h" | 5 #include "components/bookmarks/browser/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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // If the store is non-null, it means Load was already invoked. Load should | 140 // If the store is non-null, it means Load was already invoked. Load should |
141 // only be invoked once. | 141 // only be invoked once. |
142 NOTREACHED(); | 142 NOTREACHED(); |
143 return; | 143 return; |
144 } | 144 } |
145 | 145 |
146 expanded_state_tracker_.reset( | 146 expanded_state_tracker_.reset( |
147 new BookmarkExpandedStateTracker(this, pref_service)); | 147 new BookmarkExpandedStateTracker(this, pref_service)); |
148 | 148 |
149 // Load the bookmarks. BookmarkStorage notifies us when done. | 149 // Load the bookmarks. BookmarkStorage notifies us when done. |
150 store_ = new BookmarkStorage(this, profile_path, io_task_runner.get()); | 150 store_ .reset(new BookmarkStorage(this, profile_path, io_task_runner.get())); |
151 store_->LoadBookmarks(CreateLoadDetails(accept_languages), ui_task_runner); | 151 store_->LoadBookmarks(CreateLoadDetails(accept_languages), ui_task_runner); |
152 } | 152 } |
153 | 153 |
154 const BookmarkNode* BookmarkModel::GetParentForNewNodes() { | 154 const BookmarkNode* BookmarkModel::GetParentForNewNodes() { |
155 std::vector<const BookmarkNode*> nodes = | 155 std::vector<const BookmarkNode*> nodes = |
156 bookmark_utils::GetMostRecentlyModifiedUserFolders(this, 1); | 156 bookmark_utils::GetMostRecentlyModifiedUserFolders(this, 1); |
157 DCHECK(!nodes.empty()); // This list is always padded with default folders. | 157 DCHECK(!nodes.empty()); // This list is always padded with default folders. |
158 return nodes[0]; | 158 return nodes[0]; |
159 } | 159 } |
160 | 160 |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 const base::string16& text, | 693 const base::string16& text, |
694 size_t max_count, | 694 size_t max_count, |
695 std::vector<BookmarkMatch>* matches) { | 695 std::vector<BookmarkMatch>* matches) { |
696 if (!loaded_) | 696 if (!loaded_) |
697 return; | 697 return; |
698 | 698 |
699 index_->GetBookmarksMatching(text, max_count, matches); | 699 index_->GetBookmarksMatching(text, max_count, matches); |
700 } | 700 } |
701 | 701 |
702 void BookmarkModel::ClearStore() { | 702 void BookmarkModel::ClearStore() { |
703 store_ = NULL; | 703 store_.reset(); |
704 } | 704 } |
705 | 705 |
706 void BookmarkModel::SetPermanentNodeVisible(BookmarkNode::Type type, | 706 void BookmarkModel::SetPermanentNodeVisible(BookmarkNode::Type type, |
707 bool value) { | 707 bool value) { |
708 BookmarkPermanentNode* node = AsMutable(PermanentNode(type)); | 708 BookmarkPermanentNode* node = AsMutable(PermanentNode(type)); |
709 node->set_visible(value || client_->IsPermanentNodeVisible(node)); | 709 node->set_visible(value || client_->IsPermanentNodeVisible(node)); |
710 } | 710 } |
711 | 711 |
712 const BookmarkPermanentNode* BookmarkModel::PermanentNode( | 712 const BookmarkPermanentNode* BookmarkModel::PermanentNode( |
713 BookmarkNode::Type type) { | 713 BookmarkNode::Type type) { |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 BookmarkPermanentNode* mobile_node = | 1007 BookmarkPermanentNode* mobile_node = |
1008 CreatePermanentNode(BookmarkNode::MOBILE); | 1008 CreatePermanentNode(BookmarkNode::MOBILE); |
1009 return scoped_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails( | 1009 return scoped_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails( |
1010 bb_node, | 1010 bb_node, |
1011 other_node, | 1011 other_node, |
1012 mobile_node, | 1012 mobile_node, |
1013 client_->GetLoadExtraNodesCallback(), | 1013 client_->GetLoadExtraNodesCallback(), |
1014 new BookmarkIndex(client_, index_urls_, accept_languages), | 1014 new BookmarkIndex(client_, index_urls_, accept_languages), |
1015 next_node_id_)); | 1015 next_node_id_)); |
1016 } | 1016 } |
OLD | NEW |