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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.mm

Issue 769153007: Managed bookmarks for supervised users (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build (Android & unit_tests) Created 5 years, 10 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 #import <AppKit/AppKit.h> 5 #import <AppKit/AppKit.h>
6 6
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #import "chrome/browser/app_controller_mac.h" 9 #import "chrome/browser/app_controller_mac.h"
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return; 67 return;
68 68
69 if (!folder_image_) { 69 if (!folder_image_) {
70 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 70 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
71 folder_image_.reset( 71 folder_image_.reset(
72 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER).CopyNSImage()); 72 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER).CopyNSImage());
73 } 73 }
74 74
75 ClearBookmarkMenu(bookmark_menu); 75 ClearBookmarkMenu(bookmark_menu);
76 76
77 // Add at most one separator for the bookmark bar and the managed bookmarks 77 // Add at most one separator for the bookmark bar and the managed and
78 // folder. 78 // supervised bookmarks folders.
79 ChromeBookmarkClient* client = 79 ChromeBookmarkClient* client =
80 ChromeBookmarkClientFactory::GetForProfile(profile_); 80 ChromeBookmarkClientFactory::GetForProfile(profile_);
81 const BookmarkNode* barNode = model->bookmark_bar_node(); 81 const BookmarkNode* barNode = model->bookmark_bar_node();
82 const BookmarkNode* managedNode = client->managed_node(); 82 const BookmarkNode* managedNode = client->managed_node();
83 if (!barNode->empty() || !managedNode->empty()) 83 const BookmarkNode* supervisedNode = client->supervised_node();
84 if (!barNode->empty() || !managedNode->empty() || !supervisedNode->empty())
84 [bookmark_menu addItem:[NSMenuItem separatorItem]]; 85 [bookmark_menu addItem:[NSMenuItem separatorItem]];
85 if (!managedNode->empty()) { 86 if (!managedNode->empty()) {
86 // Most users never see this node, so the image is only loaded if needed. 87 // Most users never see this node, so the image is only loaded if needed.
87 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 88 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
88 NSImage* image = 89 NSImage* image =
89 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER_MANAGED).ToNSImage(); 90 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER_MANAGED).ToNSImage();
90 AddNodeAsSubmenu(bookmark_menu, managedNode, image, !is_submenu); 91 AddNodeAsSubmenu(bookmark_menu, managedNode, image, !is_submenu);
91 } 92 }
93 if (!supervisedNode->empty()) {
94 // Most users never see this node, so the image is only loaded if needed.
95 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
96 NSImage* image =
97 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER_SUPERVISED).ToNSImage();
98 AddNodeAsSubmenu(bookmark_menu, supervisedNode, image, !is_submenu);
99 }
92 if (!barNode->empty()) 100 if (!barNode->empty())
93 AddNodeToMenu(barNode, bookmark_menu, !is_submenu); 101 AddNodeToMenu(barNode, bookmark_menu, !is_submenu);
94 102
95 // If the "Other Bookmarks" folder has any content, make a submenu for it and 103 // If the "Other Bookmarks" folder has any content, make a submenu for it and
96 // fill it in. 104 // fill it in.
97 if (!model->other_node()->empty()) { 105 if (!model->other_node()->empty()) {
98 [bookmark_menu addItem:[NSMenuItem separatorItem]]; 106 [bookmark_menu addItem:[NSMenuItem separatorItem]];
99 AddNodeAsSubmenu(bookmark_menu, 107 AddNodeAsSubmenu(bookmark_menu,
100 model->other_node(), 108 model->other_node(),
101 folder_image_, 109 folder_image_,
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 361
354 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { 362 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) {
355 if (!node) 363 if (!node)
356 return nil; 364 return nil;
357 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = 365 std::map<const BookmarkNode*, NSMenuItem*>::iterator it =
358 bookmark_nodes_.find(node); 366 bookmark_nodes_.find(node);
359 if (it == bookmark_nodes_.end()) 367 if (it == bookmark_nodes_.end())
360 return nil; 368 return nil;
361 return it->second; 369 return it->second;
362 } 370 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.mm ('k') | chrome/browser/ui/view_ids.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698