| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" | 7 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" |
| 8 | 8 |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 CHECK(bar_node); | 90 CHECK(bar_node); |
| 91 if (!bar_node->empty()) { | 91 if (!bar_node->empty()) { |
| 92 [bookmark_menu addItem:[NSMenuItem separatorItem]]; | 92 [bookmark_menu addItem:[NSMenuItem separatorItem]]; |
| 93 AddNodeToMenu(bar_node, bookmark_menu, !is_submenu); | 93 AddNodeToMenu(bar_node, bookmark_menu, !is_submenu); |
| 94 } | 94 } |
| 95 | 95 |
| 96 // If the "Other Bookmarks" folder has any content, make a submenu for it | 96 // If the "Other Bookmarks" folder has any content, make a submenu for it |
| 97 // and fill it in. | 97 // and fill it in. |
| 98 if (!model->other_node()->empty()) { | 98 if (!model->other_node()->empty()) { |
| 99 NSString* other_items_title = | 99 NSString* other_items_title = |
| 100 l10n_util::GetNSString(IDS_BOOMARK_BAR_OTHER_FOLDER_NAME); | 100 l10n_util::GetNSString(IDS_BOOKMARK_BAR_OTHER_FOLDER_NAME); |
| 101 [bookmark_menu addItem:[NSMenuItem separatorItem]]; | 101 [bookmark_menu addItem:[NSMenuItem separatorItem]]; |
| 102 AddNodeAsSubmenu(bookmark_menu, | 102 AddNodeAsSubmenu(bookmark_menu, |
| 103 model->other_node(), | 103 model->other_node(), |
| 104 other_items_title, | 104 other_items_title, |
| 105 !is_submenu); | 105 !is_submenu); |
| 106 } | 106 } |
| 107 } else { | 107 } else { |
| 108 AddNodeToMenu(root_node_, bookmark_menu, true); | 108 AddNodeToMenu(root_node_, bookmark_menu, true); |
| 109 } | 109 } |
| 110 | 110 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 } else { | 252 } else { |
| 253 ConfigureMenuItem(child, item, false); | 253 ConfigureMenuItem(child, item, false); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 | 256 |
| 257 if (add_extra_items) { | 257 if (add_extra_items) { |
| 258 // Add menus for 'Open All Bookmarks'. | 258 // Add menus for 'Open All Bookmarks'. |
| 259 [menu addItem:[NSMenuItem separatorItem]]; | 259 [menu addItem:[NSMenuItem separatorItem]]; |
| 260 bool enabled = child_count != 0; | 260 bool enabled = child_count != 0; |
| 261 AddItemToMenu(IDC_BOOKMARK_BAR_OPEN_ALL, | 261 AddItemToMenu(IDC_BOOKMARK_BAR_OPEN_ALL, |
| 262 IDS_BOOMARK_BAR_OPEN_ALL, | 262 IDS_BOOKMARK_BAR_OPEN_ALL, |
| 263 node, menu, enabled); | 263 node, menu, enabled); |
| 264 AddItemToMenu(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW, | 264 AddItemToMenu(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW, |
| 265 IDS_BOOMARK_BAR_OPEN_ALL_NEW_WINDOW, | 265 IDS_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW, |
| 266 node, menu, enabled); | 266 node, menu, enabled); |
| 267 AddItemToMenu(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO, | 267 AddItemToMenu(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO, |
| 268 IDS_BOOMARK_BAR_OPEN_INCOGNITO, | 268 IDS_BOOKMARK_BAR_OPEN_INCOGNITO, |
| 269 node, menu, enabled); | 269 node, menu, enabled); |
| 270 } | 270 } |
| 271 } | 271 } |
| 272 | 272 |
| 273 void BookmarkMenuBridge::AddItemToMenu(int command_id, | 273 void BookmarkMenuBridge::AddItemToMenu(int command_id, |
| 274 int message_id, | 274 int message_id, |
| 275 const BookmarkNode* node, | 275 const BookmarkNode* node, |
| 276 NSMenu* menu, | 276 NSMenu* menu, |
| 277 bool enabled) { | 277 bool enabled) { |
| 278 NSString* title = l10n_util::GetNSStringWithFixup(message_id); | 278 NSString* title = l10n_util::GetNSStringWithFixup(message_id); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 324 |
| 325 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { | 325 NSMenuItem* BookmarkMenuBridge::MenuItemForNode(const BookmarkNode* node) { |
| 326 if (!node) | 326 if (!node) |
| 327 return nil; | 327 return nil; |
| 328 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = | 328 std::map<const BookmarkNode*, NSMenuItem*>::iterator it = |
| 329 bookmark_nodes_.find(node); | 329 bookmark_nodes_.find(node); |
| 330 if (it == bookmark_nodes_.end()) | 330 if (it == bookmark_nodes_.end()) |
| 331 return nil; | 331 return nil; |
| 332 return it->second; | 332 return it->second; |
| 333 } | 333 } |
| OLD | NEW |