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

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 const BookmarkNode::MetaInfoMap* meta_info = node->GetMetaInfoMap();
141 base::DictionaryValue* value = new base::DictionaryValue();
142 if (meta_info) {
143 BookmarkNode::MetaInfoMap::const_iterator itr;
144 for (itr = meta_info->begin(); itr != meta_info->end(); itr++)
145 value->SetStringWithoutPathExpansion(itr->first, itr->second);
146 }
147 id_to_meta_info_map->Set(base::Int64ToString(node->id()), value);
148
149 if (node->is_folder()) {
150 for (int i = 0; i < node->child_count(); ++i) {
151 GetMetaInfo(node->GetChild(i), id_to_meta_info_map);
152 }
153 }
154 }
155 }
156
137 } // namespace bookmark_api_helpers 157 } // namespace bookmark_api_helpers
138 } // namespace extensions 158 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698