| 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 #import "chrome/browser/cocoa/chrome_event_processing_window.h" | 5 #import "chrome/browser/cocoa/chrome_event_processing_window.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "chrome/browser/cocoa/browser_window_controller.h" | 8 #import "chrome/browser/cocoa/browser_window_controller.h" |
| 9 #import "chrome/browser/cocoa/browser_frame_view.h" | 9 #import "chrome/browser/cocoa/browser_frame_view.h" |
| 10 #import "chrome/browser/cocoa/tab_strip_controller.h" | 10 #import "chrome/browser/cocoa/tab_strip_controller.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 return [self handleExtraKeyboardShortcut:event | 44 return [self handleExtraKeyboardShortcut:event |
| 45 fromTable:CommandForWindowKeyboardShortcut]; | 45 fromTable:CommandForWindowKeyboardShortcut]; |
| 46 } | 46 } |
| 47 | 47 |
| 48 - (BOOL)handleExtraBrowserKeyboardShortcut:(NSEvent*)event { | 48 - (BOOL)handleExtraBrowserKeyboardShortcut:(NSEvent*)event { |
| 49 return [self handleExtraKeyboardShortcut:event | 49 return [self handleExtraKeyboardShortcut:event |
| 50 fromTable:CommandForBrowserKeyboardShortcut]; | 50 fromTable:CommandForBrowserKeyboardShortcut]; |
| 51 } | 51 } |
| 52 | 52 |
| 53 - (BOOL)performKeyEquivalent:(NSEvent*)event { | 53 - (BOOL)performKeyEquivalent:(NSEvent*)event { |
| 54 // Give the web site a chance to handle the event. If it doesn't want to | 54 // We have some magic in |CrApplication sendEvent:| that always sends key |
| 55 // handle it, it will call us back with one of the |handle*| methods above. | 55 // events to |RWHVCocoa keyEvent:| so that cocoa doesn't have a chance to |
| 56 NSResponder* r = [self firstResponder]; | 56 // intercept it. |
| 57 if ([r isKindOfClass:[RenderWidgetHostViewCocoa class]]) | 57 DCHECK(![[self firstResponder] |
| 58 return [r performKeyEquivalent:event]; | 58 isKindOfClass:[RenderWidgetHostViewCocoa class]]); |
| 59 | 59 |
| 60 // Handle per-window shortcuts like cmd-1, but do not handle browser-level | 60 // Handle per-window shortcuts like cmd-1, but do not handle browser-level |
| 61 // shortcuts like cmd-left (else, cmd-left would do history navigation even | 61 // shortcuts like cmd-left (else, cmd-left would do history navigation even |
| 62 // if e.g. the Omnibox has focus). | 62 // if e.g. the Omnibox has focus). If the web has focus, don't do this here, |
| 63 // since the web needs to get a chance at swallowing the event first. |
| 63 if ([self handleExtraWindowKeyboardShortcut:event]) | 64 if ([self handleExtraWindowKeyboardShortcut:event]) |
| 64 return YES; | 65 return YES; |
| 65 return [super performKeyEquivalent:event]; | 66 return [super performKeyEquivalent:event]; |
| 66 } | 67 } |
| 67 | 68 |
| 68 @end // ChromeEventProcessingWindow | 69 @end // ChromeEventProcessingWindow |
| 69 | 70 |
| OLD | NEW |