OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "base/gfx/rect.h" | 5 #include "base/gfx/rect.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/app/chrome_dll_resource.h" |
8 #include "chrome/browser/bookmarks/bookmark_utils.h" | 9 #include "chrome/browser/bookmarks/bookmark_utils.h" |
9 #include "chrome/browser/cocoa/browser_window_cocoa.h" | 10 #include "chrome/browser/cocoa/browser_window_cocoa.h" |
10 #import "chrome/browser/cocoa/browser_window_controller.h" | 11 #import "chrome/browser/cocoa/browser_window_controller.h" |
11 #import "chrome/browser/cocoa/clear_browsing_data_controller.h" | 12 #import "chrome/browser/cocoa/clear_browsing_data_controller.h" |
12 #import "chrome/browser/cocoa/download_shelf_controller.h" | 13 #import "chrome/browser/cocoa/download_shelf_controller.h" |
13 #import "chrome/browser/cocoa/keyword_editor_cocoa_controller.h" | 14 #import "chrome/browser/cocoa/keyword_editor_cocoa_controller.h" |
14 #import "chrome/browser/cocoa/nsmenuitem_additions.h" | 15 #import "chrome/browser/cocoa/nsmenuitem_additions.h" |
15 #include "chrome/browser/cocoa/page_info_window_mac.h" | 16 #include "chrome/browser/cocoa/page_info_window_mac.h" |
16 #include "chrome/browser/cocoa/status_bubble_mac.h" | 17 #include "chrome/browser/cocoa/status_bubble_mac.h" |
17 #include "chrome/browser/cocoa/task_manager_mac.h" | 18 #include "chrome/browser/cocoa/task_manager_mac.h" |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 if ([event.os_event type] != NSKeyDown) | 358 if ([event.os_event type] != NSKeyDown) |
358 return -1; | 359 return -1; |
359 | 360 |
360 // Look in menu. | 361 // Look in menu. |
361 NSMenuItem* item = [MenuWalker itemForKeyEquivalent:event.os_event | 362 NSMenuItem* item = [MenuWalker itemForKeyEquivalent:event.os_event |
362 menu:[NSApp mainMenu]]; | 363 menu:[NSApp mainMenu]]; |
363 | 364 |
364 if (item && [item action] == @selector(commandDispatch:) && [item tag] > 0) | 365 if (item && [item action] == @selector(commandDispatch:) && [item tag] > 0) |
365 return [item tag]; | 366 return [item tag]; |
366 | 367 |
| 368 // "Close window" doesn't use the |commandDispatch:| mechanism. Menu items |
| 369 // that do not correspond to IDC_ constants need no special treatment however, |
| 370 // as they can't be blacklisted in |Browser::IsReservedAccelerator()| anyhow. |
| 371 if (item && [item action] == @selector(performClose:)) |
| 372 return IDC_CLOSE_WINDOW; |
| 373 |
367 // Look in secondary keyboard shortcuts. | 374 // Look in secondary keyboard shortcuts. |
368 NSUInteger modifiers = [event.os_event modifierFlags]; | 375 NSUInteger modifiers = [event.os_event modifierFlags]; |
369 const bool cmdKey = (modifiers & NSCommandKeyMask) != 0; | 376 const bool cmdKey = (modifiers & NSCommandKeyMask) != 0; |
370 const bool shiftKey = (modifiers & NSShiftKeyMask) != 0; | 377 const bool shiftKey = (modifiers & NSShiftKeyMask) != 0; |
371 const bool cntrlKey = (modifiers & NSControlKeyMask) != 0; | 378 const bool cntrlKey = (modifiers & NSControlKeyMask) != 0; |
372 const bool optKey = (modifiers & NSAlternateKeyMask) != 0; | 379 const bool optKey = (modifiers & NSAlternateKeyMask) != 0; |
373 const int keyCode = [event.os_event keyCode]; | 380 const int keyCode = [event.os_event keyCode]; |
374 | 381 |
375 int cmdNum = CommandForWindowKeyboardShortcut( | 382 int cmdNum = CommandForWindowKeyboardShortcut( |
376 cmdKey, shiftKey, cntrlKey, optKey, keyCode); | 383 cmdKey, shiftKey, cntrlKey, optKey, keyCode); |
(...skipping 22 matching lines...) Expand all Loading... |
399 break; | 406 break; |
400 } | 407 } |
401 } | 408 } |
402 | 409 |
403 void BrowserWindowCocoa::DestroyBrowser() { | 410 void BrowserWindowCocoa::DestroyBrowser() { |
404 [controller_ destroyBrowser]; | 411 [controller_ destroyBrowser]; |
405 | 412 |
406 // at this point the controller is dead (autoreleased), so | 413 // at this point the controller is dead (autoreleased), so |
407 // make sure we don't try to reference it any more. | 414 // make sure we don't try to reference it any more. |
408 } | 415 } |
OLD | NEW |