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

Unified Diff: chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc
index 7bfb7255124b68e1f5debd07070fc12051527122..ee278b38a5c969bac8eb2569bbf50b3e8b3e4272 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc
@@ -77,17 +77,20 @@ void BookmarkMenuDelegate::Init(views::MenuDelegate* real_delegate,
// managed node is shown as its first child, if it's not empty.
BookmarkModel* model = GetBookmarkModel();
ChromeBookmarkClient* client = GetChromeBookmarkClient();
- bool show_managed = show_options == SHOW_PERMANENT_FOLDERS &&
- node == model->bookmark_bar_node() &&
- !client->managed_node()->empty();
- bool has_children =
- (start_child_index < node->child_count()) || show_managed;
+ bool show_pushed = show_options == SHOW_PERMANENT_FOLDERS &&
+ node == model->bookmark_bar_node();
+ bool show_managed = show_pushed && !client->managed_node()->empty();
+ bool show_supervised = show_pushed && !client->supervised_node()->empty();
+ bool has_children = (start_child_index < node->child_count()) ||
+ show_managed || show_supervised;
int initial_count = parent->GetSubmenu() ?
parent->GetSubmenu()->GetMenuItemCount() : 0;
if (has_children && initial_count > 0)
parent->AppendSeparator();
if (show_managed)
BuildMenuForManagedNode(parent, &next_menu_id_);
+ if (show_supervised)
+ BuildMenuForSupervisedNode(parent, &next_menu_id_);
BuildMenu(node, start_child_index, parent, &next_menu_id_);
if (show_options == SHOW_PERMANENT_FOLDERS)
BuildMenusForPermanentNodes(parent, &next_menu_id_);
@@ -427,8 +430,10 @@ MenuItemView* BookmarkMenuDelegate::CreateMenu(const BookmarkNode* parent,
menu_id_to_node_map_[menu->GetCommand()] = parent;
menu->set_has_icons(true);
bool show_permanent = show_options == SHOW_PERMANENT_FOLDERS;
- if (show_permanent && parent == GetBookmarkModel()->bookmark_bar_node())
+ if (show_permanent && parent == GetBookmarkModel()->bookmark_bar_node()) {
BuildMenuForManagedNode(menu, &next_menu_id_);
+ BuildMenuForSupervisedNode(menu, &next_menu_id_);
+ }
BuildMenu(parent, start_child_index, menu, &next_menu_id_);
if (show_permanent)
BuildMenusForPermanentNodes(menu, &next_menu_id_);
@@ -474,9 +479,8 @@ void BookmarkMenuDelegate::BuildMenuForPermanentNode(
menu_id_to_node_map_[id] = node;
}
-void BookmarkMenuDelegate::BuildMenuForManagedNode(
- MenuItemView* menu,
- int* next_menu_id) {
+void BookmarkMenuDelegate::BuildMenuForManagedNode(MenuItemView* menu,
+ int* next_menu_id) {
// Don't add a separator for this menu.
bool added_separator = true;
const BookmarkNode* node = GetChromeBookmarkClient()->managed_node();
@@ -484,6 +488,15 @@ void BookmarkMenuDelegate::BuildMenuForManagedNode(
next_menu_id, &added_separator);
}
+void BookmarkMenuDelegate::BuildMenuForSupervisedNode(MenuItemView* menu,
+ int* next_menu_id) {
+ // Don't add a separator for this menu.
+ bool added_separator = true;
+ const BookmarkNode* node = GetChromeBookmarkClient()->supervised_node();
+ BuildMenuForPermanentNode(node, IDR_BOOKMARK_BAR_FOLDER_SUPERVISED, menu,
+ next_menu_id, &added_separator);
+}
+
void BookmarkMenuDelegate::BuildMenu(const BookmarkNode* parent,
int start_child_index,
MenuItemView* menu,

Powered by Google App Engine
This is Rietveld 408576698