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_expanded_state_tracker.h" | 5 #include "components/bookmarks/browser/bookmark_expanded_state_tracker.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
| 9 #include <utility> |
| 10 #include <vector> |
| 11 |
9 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
10 #include "base/values.h" | 13 #include "base/values.h" |
11 #include "components/bookmarks/browser/bookmark_model.h" | 14 #include "components/bookmarks/browser/bookmark_model.h" |
12 #include "components/bookmarks/browser/bookmark_utils.h" | 15 #include "components/bookmarks/browser/bookmark_utils.h" |
13 #include "components/bookmarks/common/bookmark_pref_names.h" | 16 #include "components/bookmarks/common/bookmark_pref_names.h" |
14 #include "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" |
15 | 18 |
16 namespace bookmarks { | 19 namespace bookmarks { |
17 | 20 |
18 BookmarkExpandedStateTracker::BookmarkExpandedStateTracker( | 21 BookmarkExpandedStateTracker::BookmarkExpandedStateTracker( |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 BookmarkModel* model, | 100 BookmarkModel* model, |
98 const std::set<GURL>& removed_urls) { | 101 const std::set<GURL>& removed_urls) { |
99 // Ask for the nodes again, which removes any nodes that were deleted. | 102 // Ask for the nodes again, which removes any nodes that were deleted. |
100 GetExpandedNodes(); | 103 GetExpandedNodes(); |
101 } | 104 } |
102 | 105 |
103 void BookmarkExpandedStateTracker::UpdatePrefs(const Nodes& nodes) { | 106 void BookmarkExpandedStateTracker::UpdatePrefs(const Nodes& nodes) { |
104 if (!pref_service_) | 107 if (!pref_service_) |
105 return; | 108 return; |
106 | 109 |
107 base::ListValue values; | 110 std::vector<base::Value> values; |
108 for (Nodes::const_iterator i = nodes.begin(); i != nodes.end(); ++i) { | 111 values.reserve(nodes.size()); |
109 values.Set(values.GetSize(), | 112 for (const auto* node : nodes) { |
110 new base::Value(base::Int64ToString((*i)->id()))); | 113 values.emplace_back(base::Int64ToString(node->id())); |
111 } | 114 } |
112 | 115 |
113 pref_service_->Set(prefs::kBookmarkEditorExpandedNodes, values); | 116 pref_service_->Set(prefs::kBookmarkEditorExpandedNodes, |
| 117 base::Value(std::move(values))); |
114 } | 118 } |
115 | 119 |
116 } // namespace bookmarks | 120 } // namespace bookmarks |
OLD | NEW |