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

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

Issue 769153007: Managed bookmarks for supervised users (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 11 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
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 } 67 }
68 68
69 bookmark_tree_node->title = base::UTF16ToUTF8(node->GetTitle()); 69 bookmark_tree_node->title = base::UTF16ToUTF8(node->GetTitle());
70 if (!node->date_added().is_null()) { 70 if (!node->date_added().is_null()) {
71 // Javascript Date wants milliseconds since the epoch, ToDoubleT is seconds. 71 // Javascript Date wants milliseconds since the epoch, ToDoubleT is seconds.
72 bookmark_tree_node->date_added.reset( 72 bookmark_tree_node->date_added.reset(
73 new double(floor(node->date_added().ToDoubleT() * 1000))); 73 new double(floor(node->date_added().ToDoubleT() * 1000)));
74 } 74 }
75 75
76 if (client->IsDescendantOfManagedNode(node)) 76 if (client->IsDescendantOfManagedOrSupervisedNode(node))
77 bookmark_tree_node->unmodifiable = BookmarkTreeNode::UNMODIFIABLE_MANAGED; 77 bookmark_tree_node->unmodifiable = BookmarkTreeNode::UNMODIFIABLE_MANAGED;
78 78
79 if (recurse && node->is_folder()) { 79 if (recurse && node->is_folder()) {
80 std::vector<linked_ptr<BookmarkTreeNode> > children; 80 std::vector<linked_ptr<BookmarkTreeNode> > children;
81 for (int i = 0; i < node->child_count(); ++i) { 81 for (int i = 0; i < node->child_count(); ++i) {
82 const BookmarkNode* child = node->GetChild(i); 82 const BookmarkNode* child = node->GetChild(i);
83 if (child->IsVisible() && (!only_folders || child->is_folder())) { 83 if (child->IsVisible() && (!only_folders || child->is_folder())) {
84 linked_ptr<BookmarkTreeNode> child_node( 84 linked_ptr<BookmarkTreeNode> child_node(
85 GetBookmarkTreeNode(client, child, true, only_folders)); 85 GetBookmarkTreeNode(client, child, true, only_folders));
86 children.push_back(child_node); 86 children.push_back(child_node);
(...skipping 26 matching lines...) Expand all
113 std::string* error) { 113 std::string* error) {
114 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID(model, id); 114 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID(model, id);
115 if (!node) { 115 if (!node) {
116 *error = keys::kNoNodeError; 116 *error = keys::kNoNodeError;
117 return false; 117 return false;
118 } 118 }
119 if (model->is_permanent_node(node)) { 119 if (model->is_permanent_node(node)) {
120 *error = keys::kModifySpecialError; 120 *error = keys::kModifySpecialError;
121 return false; 121 return false;
122 } 122 }
123 if (client->IsDescendantOfManagedNode(node)) { 123 if (client->IsDescendantOfManagedOrSupervisedNode(node)) {
124 *error = keys::kModifyManagedError; 124 *error = keys::kModifyManagedError;
125 return false; 125 return false;
126 } 126 }
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));
(...skipping 17 matching lines...) Expand all
151 151
152 if (node.is_folder()) { 152 if (node.is_folder()) {
153 for (int i = 0; i < node.child_count(); ++i) { 153 for (int i = 0; i < node.child_count(); ++i) {
154 GetMetaInfo(*(node.GetChild(i)), id_to_meta_info_map); 154 GetMetaInfo(*(node.GetChild(i)), id_to_meta_info_map);
155 } 155 }
156 } 156 }
157 } 157 }
158 158
159 } // namespace bookmark_api_helpers 159 } // namespace bookmark_api_helpers
160 } // namespace extensions 160 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698