Index: chrome/browser/ui/cocoa/chrome_event_processing_window.mm |
diff --git a/chrome/browser/ui/cocoa/chrome_event_processing_window.mm b/chrome/browser/ui/cocoa/chrome_event_processing_window.mm |
index b7b437d923f67200e1a961bb126a05312fb709a3..838609e4fdc91232e61ac435e46c67a21910ac33 100644 |
--- a/chrome/browser/ui/cocoa/chrome_event_processing_window.mm |
+++ b/chrome/browser/ui/cocoa/chrome_event_processing_window.mm |
@@ -14,6 +14,8 @@ |
commandDispatcherDelegate_; |
} |
+@synthesize commandHandler; |
+ |
- (instancetype)initWithContentRect:(NSRect)contentRect |
styleMask:(NSUInteger)windowStyle |
backing:(NSBackingStoreType)bufferingType |
@@ -45,6 +47,14 @@ |
return [super performKeyEquivalent:event]; |
} |
+- (void)commandDispatch:(id)sender { |
+ [[self commandHandler] commandDispatch:sender window:self]; |
+} |
+ |
+- (void)commandDispatchUsingKeyModifiers:(id)sender { |
+ [[self commandHandler] commandDispatchUsingKeyModifiers:sender window:self]; |
+} |
+ |
// NSWindow overrides. |
- (BOOL)performKeyEquivalent:(NSEvent*)event { |
@@ -56,4 +66,21 @@ |
[super sendEvent:event]; |
} |
+// NSWindow overrides (NSUserInterfaceValidations implementation). |
+ |
+- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { |
+ // Since this class implements these selectors, |super| will always say they |
+ // are enabled. Only use [super] to validate other selectors. If there is no |
+ // command handler, defer to AppController. |
+ if ([item action] == @selector(commandDispatch:) || |
+ [item action] == @selector(commandDispatchUsingKeyModifiers:)) { |
+ return |
+ [self commandHandler] |
+ ? [[self commandHandler] validateUserInterfaceItem:item window:self] |
+ : [[NSApp delegate] validateUserInterfaceItem:item]; |
+ } |
+ |
+ return [super validateUserInterfaceItem:item]; |
+} |
+ |
@end // ChromeEventProcessingWindow |