| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/managed/managed_bookmark_service.h" | 5 #include "components/bookmarks/managed/managed_bookmark_service.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 7 #include <stdlib.h> | 8 #include <stdlib.h> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 15 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 16 #include "base/values.h" | 17 #include "base/values.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 34 initial_bookmarks_(initial_bookmarks.Pass()), | 35 initial_bookmarks_(initial_bookmarks.Pass()), |
| 35 title_id_(title_id) { | 36 title_id_(title_id) { |
| 36 DCHECK(node_); | 37 DCHECK(node_); |
| 37 } | 38 } |
| 38 | 39 |
| 39 ~BookmarkPermanentNodeLoader() {} | 40 ~BookmarkPermanentNodeLoader() {} |
| 40 | 41 |
| 41 // Initializes |node_| from |initial_bookmarks_| and |title_id_| and returns | 42 // Initializes |node_| from |initial_bookmarks_| and |title_id_| and returns |
| 42 // it. The ids are assigned starting at |next_node_id| and the value is | 43 // it. The ids are assigned starting at |next_node_id| and the value is |
| 43 // updated as a side-effect. | 44 // updated as a side-effect. |
| 44 scoped_ptr<BookmarkPermanentNode> Load(int64* next_node_id) { | 45 scoped_ptr<BookmarkPermanentNode> Load(int64_t* next_node_id) { |
| 45 node_->set_id(*next_node_id); | 46 node_->set_id(*next_node_id); |
| 46 *next_node_id = ManagedBookmarksTracker::LoadInitial( | 47 *next_node_id = ManagedBookmarksTracker::LoadInitial( |
| 47 node_.get(), initial_bookmarks_.get(), node_->id() + 1); | 48 node_.get(), initial_bookmarks_.get(), node_->id() + 1); |
| 48 node_->set_visible(!node_->empty()); | 49 node_->set_visible(!node_->empty()); |
| 49 node_->SetTitle(l10n_util::GetStringUTF16(title_id_)); | 50 node_->SetTitle(l10n_util::GetStringUTF16(title_id_)); |
| 50 return node_.Pass(); | 51 return node_.Pass(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 scoped_ptr<BookmarkPermanentNode> node_; | 55 scoped_ptr<BookmarkPermanentNode> node_; |
| 55 scoped_ptr<base::ListValue> initial_bookmarks_; | 56 scoped_ptr<base::ListValue> initial_bookmarks_; |
| 56 int title_id_; | 57 int title_id_; |
| 57 | 58 |
| 58 DISALLOW_COPY_AND_ASSIGN(BookmarkPermanentNodeLoader); | 59 DISALLOW_COPY_AND_ASSIGN(BookmarkPermanentNodeLoader); |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 // Returns a list of initialized BookmarkPermanentNodes using |next_node_id| to | 62 // Returns a list of initialized BookmarkPermanentNodes using |next_node_id| to |
| 62 // start assigning id. |next_node_id| is updated as a side effect of calling | 63 // start assigning id. |next_node_id| is updated as a side effect of calling |
| 63 // this method. | 64 // this method. |
| 64 BookmarkPermanentNodeList LoadExtraNodes( | 65 BookmarkPermanentNodeList LoadExtraNodes( |
| 65 ScopedVector<BookmarkPermanentNodeLoader> loaders, | 66 ScopedVector<BookmarkPermanentNodeLoader> loaders, |
| 66 int64* next_node_id) { | 67 int64_t* next_node_id) { |
| 67 BookmarkPermanentNodeList extra_nodes; | 68 BookmarkPermanentNodeList extra_nodes; |
| 68 for (const auto& loader : loaders) | 69 for (const auto& loader : loaders) |
| 69 extra_nodes.push_back(loader->Load(next_node_id).release()); | 70 extra_nodes.push_back(loader->Load(next_node_id).release()); |
| 70 return extra_nodes.Pass(); | 71 return extra_nodes.Pass(); |
| 71 } | 72 } |
| 72 | 73 |
| 73 } // namespace | 74 } // namespace |
| 74 | 75 |
| 75 ManagedBookmarkService::ManagedBookmarkService( | 76 ManagedBookmarkService::ManagedBookmarkService( |
| 76 PrefService* prefs, | 77 PrefService* prefs, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 175 } |
| 175 | 176 |
| 176 managed_bookmarks_tracker_.reset(); | 177 managed_bookmarks_tracker_.reset(); |
| 177 supervised_bookmarks_tracker_.reset(); | 178 supervised_bookmarks_tracker_.reset(); |
| 178 | 179 |
| 179 managed_node_ = nullptr; | 180 managed_node_ = nullptr; |
| 180 supervised_node_ = nullptr; | 181 supervised_node_ = nullptr; |
| 181 } | 182 } |
| 182 | 183 |
| 183 } // namespace bookmarks | 184 } // namespace bookmarks |
| OLD | NEW |