Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.cc

Issue 330983002: Added option to bookmarkManagerPrivate.getMetaInfo() to get meta info from all bookmarks in a one f… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/extensions/api/bookmarks/bookmark_api_helpers.h" 5 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.h"
6 6
7 #include <math.h> // For floor() 7 #include <math.h> // For floor()
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 if (node->is_folder() && !node->empty() && !recursive) { 127 if (node->is_folder() && !node->empty() && !recursive) {
128 *error = keys::kFolderNotEmptyError; 128 *error = keys::kFolderNotEmptyError;
129 return false; 129 return false;
130 } 130 }
131 131
132 const BookmarkNode* parent = node->parent(); 132 const BookmarkNode* parent = node->parent();
133 model->Remove(parent, parent->GetIndexOf(node)); 133 model->Remove(parent, parent->GetIndexOf(node));
134 return true; 134 return true;
135 } 135 }
136 136
137 void GetMetaInfo(const BookmarkNode& node,
138 base::DictionaryValue* id_to_meta_info_map) {
139 if (!node.IsVisible())
140 return;
141
142 const BookmarkNode::MetaInfoMap* meta_info = node.GetMetaInfoMap();
143 base::DictionaryValue* value = new base::DictionaryValue();
144 if (meta_info) {
145 BookmarkNode::MetaInfoMap::const_iterator itr;
146 for (itr = meta_info->begin(); itr != meta_info->end(); ++itr) {
147 value->SetStringWithoutPathExpansion(itr->first, itr->second);
148 }
149 }
150 id_to_meta_info_map->Set(base::Int64ToString(node.id()), value);
151
152 if (node.is_folder()) {
153 for (int i = 0; i < node.child_count(); ++i) {
154 GetMetaInfo(*(node.GetChild(i)), id_to_meta_info_map);
155 }
156 }
157 }
158
137 } // namespace bookmark_api_helpers 159 } // namespace bookmark_api_helpers
138 } // namespace extensions 160 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698