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

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

Issue 2809003002: Making bookmark folder context menu display the number of bookmarks that will be opened by Open All (Closed)
Patch Set: Refactoring URL itteration function as per comments, addressing other formatting and style errors Created 3 years, 8 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"
11 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" 11 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
12 #include "chrome/browser/prefs/incognito_mode_prefs.h" 12 #include "chrome/browser/prefs/incognito_mode_prefs.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h"
15 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
16 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" 17 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h"
17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h" 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h"
18 #include "chrome/grit/generated_resources.h" 19 #include "chrome/grit/generated_resources.h"
19 #include "chrome/grit/theme_resources.h" 20 #include "chrome/grit/theme_resources.h"
20 #include "components/bookmarks/browser/bookmark_model.h" 21 #include "components/bookmarks/browser/bookmark_model.h"
21 #include "components/bookmarks/managed/managed_bookmark_service.h" 22 #include "components/bookmarks/managed/managed_bookmark_service.h"
22 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
24 #include "ui/gfx/image/image.h" 25 #include "ui/gfx/image/image.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 IDS_BOOKMARK_BAR_OPEN_ALL_INCOGNITO, 305 IDS_BOOKMARK_BAR_OPEN_ALL_INCOGNITO,
305 node, menu, incognito_enabled); 306 node, menu, incognito_enabled);
306 } 307 }
307 } 308 }
308 309
309 void BookmarkMenuBridge::AddItemToMenu(int command_id, 310 void BookmarkMenuBridge::AddItemToMenu(int command_id,
310 int message_id, 311 int message_id,
311 const BookmarkNode* node, 312 const BookmarkNode* node,
312 NSMenu* menu, 313 NSMenu* menu,
313 bool enabled) { 314 bool enabled) {
314 NSString* title = l10n_util::GetNSStringWithFixup(message_id); 315 int count = (message_id == IDS_BOOKMARK_BAR_OPEN_ALL_INCOGNITO)
316 ? chrome::OpenCount(nullptr, node, true, profile_)
317 : chrome::OpenCount(nullptr, node);
318
319 NSString* title = l10n_util::GetPluralNSStringF(message_id, count);
315 SEL action; 320 SEL action;
316 if (!enabled) { 321 if (!enabled) {
317 // A nil action makes a menu item appear disabled. NSMenuItem setEnabled 322 // A nil action makes a menu item appear disabled.
318 // will not reflect the disabled state until the item title is set again. 323 // NSMenuItem setEnabled will not reflect the disabled state
Peter Kasting 2017/04/14 08:17:15 Nit: Why re-linebreak this?
Paezagon 2017/04/14 18:47:24 No idea how that happened.
324 // until the item title is set again.
319 action = nil; 325 action = nil;
320 } else if (command_id == IDC_BOOKMARK_BAR_OPEN_ALL) { 326 } else if (command_id == IDC_BOOKMARK_BAR_OPEN_ALL) {
321 action = @selector(openAllBookmarks:); 327 action = @selector(openAllBookmarks:);
322 } else if (command_id == IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW) { 328 } else if (command_id == IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW) {
323 action = @selector(openAllBookmarksNewWindow:); 329 action = @selector(openAllBookmarksNewWindow:);
324 } else { 330 } else {
325 action = @selector(openAllBookmarksIncognitoWindow:); 331 action = @selector(openAllBookmarksIncognitoWindow:);
326 } 332 }
327 NSMenuItem* item = [[[NSMenuItem alloc] initWithTitle:title 333 NSMenuItem* item = [[[NSMenuItem alloc] initWithTitle:title
328 action:action 334 action:action
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 367
362 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { 368 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) {
363 if (!node) 369 if (!node)
364 return nil; 370 return nil;
365 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = 371 std::map<const BookmarkNode*, NSMenuItem*>::iterator it =
366 bookmark_nodes_.find(node); 372 bookmark_nodes_.find(node);
367 if (it == bookmark_nodes_.end()) 373 if (it == bookmark_nodes_.end())
368 return nil; 374 return nil;
369 return it->second; 375 return it->second;
370 } 376 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698