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

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: Android fix; 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 83585a507206b97823cac5a0e8bf6042b7219408..a3f58a208eadf6e5c9c5e5ddb90b6820b6bbf826 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc
@@ -78,17 +78,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 &&
sky 2015/02/04 18:36:58 show_pushed is rather confusing here. How about a
Marc Treib 2015/02/05 12:57:06 I've renamed it to show_forced_folders which I hop
sky 2015/02/05 17:57:11 SGTM
+ 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_);
@@ -428,8 +431,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_);
@@ -475,9 +480,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();
@@ -485,6 +489,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