| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h" |
| 6 |
| 5 #include "app/text_elider.h" | 7 #include "app/text_elider.h" |
| 6 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 7 #include "chrome/app/chrome_dll_resource.h" // IDC_BOOKMARK_MENU | 9 #include "chrome/app/chrome_dll_resource.h" // IDC_BOOKMARK_MENU |
| 10 #import "chrome/browser/app_controller_mac.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 9 #include "chrome/browser/browser.h" | 12 #include "chrome/browser/browser.h" |
| 10 #import "chrome/browser/cocoa/bookmark_menu_bridge.h" | 13 #import "chrome/browser/cocoa/bookmark_menu_bridge.h" |
| 11 #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h" | |
| 12 #include "chrome/browser/cocoa/event_utils.h" | 14 #include "chrome/browser/cocoa/event_utils.h" |
| 13 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/tab_contents/tab_contents.h" | 16 #include "chrome/browser/tab_contents/tab_contents.h" |
| 15 #include "webkit/glue/window_open_disposition.h" | 17 #include "webkit/glue/window_open_disposition.h" |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| 19 // Menus more than this many pixels wide will get trimmed | 21 // Menus more than this many pixels wide will get trimmed |
| 20 // TODO(jrg): ask UI dudes what a good value is. | 22 // TODO(jrg): ask UI dudes what a good value is. |
| 21 const NSUInteger kMaximumMenuPixelsWide = 300; | 23 const NSUInteger kMaximumMenuPixelsWide = 300; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 47 | 49 |
| 48 - (void)dealloc { | 50 - (void)dealloc { |
| 49 [[self menu] setDelegate:nil]; | 51 [[self menu] setDelegate:nil]; |
| 50 [super dealloc]; | 52 [super dealloc]; |
| 51 } | 53 } |
| 52 | 54 |
| 53 - (NSMenu*)menu { | 55 - (NSMenu*)menu { |
| 54 return [[[NSApp mainMenu] itemWithTag:IDC_BOOKMARK_MENU] submenu]; | 56 return [[[NSApp mainMenu] itemWithTag:IDC_BOOKMARK_MENU] submenu]; |
| 55 } | 57 } |
| 56 | 58 |
| 59 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { |
| 60 AppController* controller = [NSApp delegate]; |
| 61 return [controller keyWindowIsNotModal]; |
| 62 } |
| 63 |
| 57 // NSMenu delegate method: called just before menu is displayed. | 64 // NSMenu delegate method: called just before menu is displayed. |
| 58 - (void)menuNeedsUpdate:(NSMenu*)menu { | 65 - (void)menuNeedsUpdate:(NSMenu*)menu { |
| 59 bridge_->UpdateMenu(menu); | 66 bridge_->UpdateMenu(menu); |
| 60 } | 67 } |
| 61 | 68 |
| 62 // Return the a BookmarkNode that has the given id (called | 69 // Return the a BookmarkNode that has the given id (called |
| 63 // "identifier" here to avoid conflict with objc's concept of "id"). | 70 // "identifier" here to avoid conflict with objc's concept of "id"). |
| 64 - (const BookmarkNode*)nodeForIdentifier:(int)identifier { | 71 - (const BookmarkNode*)nodeForIdentifier:(int)identifier { |
| 65 return bridge_->GetBookmarkModel()->GetNodeByID(identifier); | 72 return bridge_->GetBookmarkModel()->GetNodeByID(identifier); |
| 66 } | 73 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 81 const BookmarkNode* node = [self nodeForIdentifier:identifier]; | 88 const BookmarkNode* node = [self nodeForIdentifier:identifier]; |
| 82 DCHECK(node); | 89 DCHECK(node); |
| 83 if (!node) | 90 if (!node) |
| 84 return; // shouldn't be reached | 91 return; // shouldn't be reached |
| 85 | 92 |
| 86 [self openURLForNode:node]; | 93 [self openURLForNode:node]; |
| 87 } | 94 } |
| 88 | 95 |
| 89 @end // BookmarkMenuCocoaController | 96 @end // BookmarkMenuCocoaController |
| 90 | 97 |
| OLD | NEW |