Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 = 0; |
| 316 if (message_id == IDS_BOOKMARK_BAR_OPEN_ALL_INCOGNITO) { | |
| 317 count = chrome::OpenCount(NULL, node, true, profile_); | |
|
Peter Kasting
2017/04/13 04:52:10
Nit: nullptr
Paezagon
2017/04/14 01:00:30
Done.
| |
| 318 } else { | |
| 319 count = chrome::OpenCount(NULL, node); | |
| 320 } | |
|
Peter Kasting
2017/04/13 04:52:09
Nit: Two potential simpler routes:
int count =
Paezagon
2017/04/14 01:00:30
Done.
| |
| 321 | |
| 322 NSString* title = l10n_util::GetPluralNSStringF(message_id, count); | |
| 315 SEL action; | 323 SEL action; |
| 316 if (!enabled) { | 324 if (!enabled) { |
| 317 // A nil action makes a menu item appear disabled. NSMenuItem setEnabled | 325 // A nil action makes a menu item appear disabled. NSMenuItem setEnabled |
| 318 // will not reflect the disabled state until the item title is set again. | 326 // will not reflect the disabled state until the item title is set again. |
| 319 action = nil; | 327 action = nil; |
| 320 } else if (command_id == IDC_BOOKMARK_BAR_OPEN_ALL) { | 328 } else if (command_id == IDC_BOOKMARK_BAR_OPEN_ALL) { |
| 321 action = @selector(openAllBookmarks:); | 329 action = @selector(openAllBookmarks:); |
| 322 } else if (command_id == IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW) { | 330 } else if (command_id == IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW) { |
| 323 action = @selector(openAllBookmarksNewWindow:); | 331 action = @selector(openAllBookmarksNewWindow:); |
| 324 } else { | 332 } else { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 | 369 |
| 362 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { | 370 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { |
| 363 if (!node) | 371 if (!node) |
| 364 return nil; | 372 return nil; |
| 365 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = | 373 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = |
| 366 bookmark_nodes_.find(node); | 374 bookmark_nodes_.find(node); |
| 367 if (it == bookmark_nodes_.end()) | 375 if (it == bookmark_nodes_.end()) |
| 368 return nil; | 376 return nil; |
| 369 return it->second; | 377 return it->second; |
| 370 } | 378 } |
| OLD | NEW |