| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/cocoa/chrome_event_processing_window.h" | 5 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "base/mac/foundation_util.h" |
| 9 #import "chrome/browser/app_controller_mac.h" |
| 8 #import "chrome/browser/ui/cocoa/chrome_command_dispatcher_delegate.h" | 10 #import "chrome/browser/ui/cocoa/chrome_command_dispatcher_delegate.h" |
| 9 #import "ui/base/cocoa/user_interface_item_command_handler.h" | 11 #import "ui/base/cocoa/user_interface_item_command_handler.h" |
| 10 | 12 |
| 11 @implementation ChromeEventProcessingWindow { | 13 @implementation ChromeEventProcessingWindow { |
| 12 @private | 14 @private |
| 13 base::scoped_nsobject<CommandDispatcher> commandDispatcher_; | 15 base::scoped_nsobject<CommandDispatcher> commandDispatcher_; |
| 14 base::scoped_nsobject<ChromeCommandDispatcherDelegate> | 16 base::scoped_nsobject<ChromeCommandDispatcherDelegate> |
| 15 commandDispatcherDelegate_; | 17 commandDispatcherDelegate_; |
| 16 base::scoped_nsprotocol<id<UserInterfaceItemCommandHandler>> commandHandler_; | 18 base::scoped_nsprotocol<id<UserInterfaceItemCommandHandler>> commandHandler_; |
| 17 } | 19 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 73 } |
| 72 | 74 |
| 73 // NSWindow overrides (NSUserInterfaceValidations implementation). | 75 // NSWindow overrides (NSUserInterfaceValidations implementation). |
| 74 | 76 |
| 75 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { | 77 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { |
| 76 // Since this class implements these selectors, |super| will always say they | 78 // Since this class implements these selectors, |super| will always say they |
| 77 // are enabled. Only use [super] to validate other selectors. If there is no | 79 // are enabled. Only use [super] to validate other selectors. If there is no |
| 78 // command handler, defer to AppController. | 80 // command handler, defer to AppController. |
| 79 if ([item action] == @selector(commandDispatch:) || | 81 if ([item action] == @selector(commandDispatch:) || |
| 80 [item action] == @selector(commandDispatchUsingKeyModifiers:)) { | 82 [item action] == @selector(commandDispatchUsingKeyModifiers:)) { |
| 81 return commandHandler_ | 83 if (commandHandler_) |
| 82 ? [commandHandler_ validateUserInterfaceItem:item window:self] | 84 return [commandHandler_ validateUserInterfaceItem:item window:self]; |
| 83 : [[NSApp delegate] validateUserInterfaceItem:item]; | 85 |
| 86 AppController* appController = |
| 87 base::mac::ObjCCastStrict<AppController>([NSApp delegate]); |
| 88 return [appController validateUserInterfaceItem:item]; |
| 84 } | 89 } |
| 85 | 90 |
| 86 return [super validateUserInterfaceItem:item]; | 91 return [super validateUserInterfaceItem:item]; |
| 87 } | 92 } |
| 88 | 93 |
| 89 @end // ChromeEventProcessingWindow | 94 @end // ChromeEventProcessingWindow |
| OLD | NEW |