| 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" |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 if (add_extra_items) { | 289 if (add_extra_items) { |
| 290 // Add menus for 'Open All Bookmarks'. | 290 // Add menus for 'Open All Bookmarks'. |
| 291 [menu addItem:[NSMenuItem separatorItem]]; | 291 [menu addItem:[NSMenuItem separatorItem]]; |
| 292 bool enabled = child_count != 0; | 292 bool enabled = child_count != 0; |
| 293 | 293 |
| 294 IncognitoModePrefs::Availability incognito_availability = | 294 IncognitoModePrefs::Availability incognito_availability = |
| 295 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()); | 295 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()); |
| 296 bool incognito_enabled = | 296 bool incognito_enabled = |
| 297 enabled && incognito_availability != IncognitoModePrefs::DISABLED; | 297 enabled && incognito_availability != IncognitoModePrefs::DISABLED; |
| 298 | 298 |
| 299 AddItemToMenu(IDC_BOOKMARK_BAR_OPEN_ALL, | 299 AddItemToMenu(IDC_BOOKMARK_BAR_OPEN_ALL, IDS_BOOKMARK_BAR_OPEN_ALL_COUNT, |
| 300 IDS_BOOKMARK_BAR_OPEN_ALL, | |
| 301 node, menu, enabled); | 300 node, menu, enabled); |
| 302 AddItemToMenu(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW, | 301 AddItemToMenu(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW, |
| 303 IDS_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW, | 302 IDS_BOOKMARK_BAR_OPEN_ALL_COUNT_NEW_WINDOW, node, menu, |
| 304 node, menu, enabled); | 303 enabled); |
| 305 AddItemToMenu(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO, | 304 AddItemToMenu(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO, |
| 306 IDS_BOOKMARK_BAR_OPEN_ALL_INCOGNITO, | 305 IDS_BOOKMARK_BAR_OPEN_ALL_COUNT_INCOGNITO, node, menu, |
| 307 node, menu, incognito_enabled); | 306 incognito_enabled); |
| 308 } | 307 } |
| 309 } | 308 } |
| 310 | 309 |
| 311 void BookmarkMenuBridge::AddItemToMenu(int command_id, | 310 void BookmarkMenuBridge::AddItemToMenu(int command_id, |
| 312 int message_id, | 311 int message_id, |
| 313 const BookmarkNode* node, | 312 const BookmarkNode* node, |
| 314 NSMenu* menu, | 313 NSMenu* menu, |
| 315 bool enabled) { | 314 bool enabled) { |
| 316 int count = (message_id == IDS_BOOKMARK_BAR_OPEN_ALL_INCOGNITO) | 315 int count = (message_id == IDS_BOOKMARK_BAR_OPEN_ALL_COUNT_INCOGNITO) |
| 317 ? chrome::OpenCount(nullptr, node, profile_) | 316 ? chrome::OpenCount(nullptr, node, profile_) |
| 318 : chrome::OpenCount(nullptr, node); | 317 : chrome::OpenCount(nullptr, node); |
| 319 | 318 |
| 320 NSString* title = l10n_util::GetPluralNSStringF(message_id, count); | 319 NSString* title = l10n_util::GetPluralNSStringF(message_id, count); |
| 321 SEL action; | 320 SEL action; |
| 322 if (!enabled) { | 321 if (!enabled) { |
| 323 // A nil action makes a menu item appear disabled. NSMenuItem setEnabled | 322 // A nil action makes a menu item appear disabled. NSMenuItem setEnabled |
| 324 // will not reflect the disabled state until the item title is set again. | 323 // will not reflect the disabled state until the item title is set again. |
| 325 action = nil; | 324 action = nil; |
| 326 } else if (command_id == IDC_BOOKMARK_BAR_OPEN_ALL) { | 325 } else if (command_id == IDC_BOOKMARK_BAR_OPEN_ALL) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 | 367 |
| 369 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { | 368 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { |
| 370 if (!node) | 369 if (!node) |
| 371 return nil; | 370 return nil; |
| 372 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = | 371 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = |
| 373 bookmark_nodes_.find(node); | 372 bookmark_nodes_.find(node); |
| 374 if (it == bookmark_nodes_.end()) | 373 if (it == bookmark_nodes_.end()) |
| 375 return nil; | 374 return nil; |
| 376 return it->second; | 375 return it->second; |
| 377 } | 376 } |
| OLD | NEW |