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" | 8 #import "base/mac/foundation_util.h" |
9 #import "chrome/browser/app_controller_mac.h" | 9 #import "chrome/browser/app_controller_mac.h" |
10 #import "chrome/browser/ui/cocoa/chrome_command_dispatcher_delegate.h" | 10 #import "chrome/browser/ui/cocoa/chrome_command_dispatcher_delegate.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 } | 46 } |
47 | 47 |
48 - (BOOL)redispatchKeyEvent:(NSEvent*)event { | 48 - (BOOL)redispatchKeyEvent:(NSEvent*)event { |
49 return [commandDispatcher_ redispatchKeyEvent:event]; | 49 return [commandDispatcher_ redispatchKeyEvent:event]; |
50 } | 50 } |
51 | 51 |
52 - (BOOL)defaultPerformKeyEquivalent:(NSEvent*)event { | 52 - (BOOL)defaultPerformKeyEquivalent:(NSEvent*)event { |
53 return [super performKeyEquivalent:event]; | 53 return [super performKeyEquivalent:event]; |
54 } | 54 } |
55 | 55 |
56 - (BOOL)defaultValidateUserInterfaceItem: | |
57 (id<NSValidatedUserInterfaceItem>)item { | |
58 return [super validateUserInterfaceItem:item]; | |
59 } | |
60 | |
56 - (void)commandDispatch:(id)sender { | 61 - (void)commandDispatch:(id)sender { |
57 [commandHandler_ commandDispatch:sender window:self]; | 62 [commandDispatcher_ dispatch:sender forHandler:commandHandler_]; |
58 } | 63 } |
59 | 64 |
60 - (void)commandDispatchUsingKeyModifiers:(id)sender { | 65 - (void)commandDispatchUsingKeyModifiers:(id)sender { |
61 [commandHandler_ commandDispatchUsingKeyModifiers:sender window:self]; | 66 [commandDispatcher_ dispatchUsingKeyModifiers:sender |
67 forHandler:commandHandler_]; | |
62 } | 68 } |
63 | 69 |
64 // NSWindow overrides. | 70 // NSWindow overrides. |
65 | 71 |
66 - (BOOL)performKeyEquivalent:(NSEvent*)event { | 72 - (BOOL)performKeyEquivalent:(NSEvent*)event { |
67 return [commandDispatcher_ performKeyEquivalent:event]; | 73 return [commandDispatcher_ performKeyEquivalent:event]; |
68 } | 74 } |
69 | 75 |
70 - (void)sendEvent:(NSEvent*)event { | 76 - (void)sendEvent:(NSEvent*)event { |
71 if (![commandDispatcher_ preSendEvent:event]) | 77 if (![commandDispatcher_ preSendEvent:event]) |
72 [super sendEvent:event]; | 78 [super sendEvent:event]; |
73 } | 79 } |
74 | 80 |
75 // NSWindow overrides (NSUserInterfaceValidations implementation). | 81 // NSWindow overrides (NSUserInterfaceValidations implementation). |
76 | 82 |
77 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { | 83 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { |
78 // Since this class implements these selectors, |super| will always say they | 84 return [commandDispatcher_ validateUserInterfaceItem:item |
79 // are enabled. Only use [super] to validate other selectors. If there is no | 85 forHandler:commandHandler_]; |
80 // command handler, defer to AppController. | |
81 if ([item action] == @selector(commandDispatch:) || | |
tapted
2017/02/01 10:35:01
(this logic now moves into CommandDispatcher -- it
| |
82 [item action] == @selector(commandDispatchUsingKeyModifiers:)) { | |
83 if (commandHandler_) | |
84 return [commandHandler_ validateUserInterfaceItem:item window:self]; | |
85 | |
86 AppController* appController = | |
87 base::mac::ObjCCastStrict<AppController>([NSApp delegate]); | |
88 return [appController validateUserInterfaceItem:item]; | |
89 } | |
90 | |
91 return [super validateUserInterfaceItem:item]; | |
92 } | 86 } |
93 | 87 |
94 @end // ChromeEventProcessingWindow | 88 @end // ChromeEventProcessingWindow |
OLD | NEW |