Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: ui/views/cocoa/native_widget_mac_nswindow.mm

Issue 1250403002: [Mac] Move UI item validation to UserInterfaceItemCommandHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@commandexecute
Patch Set: Split out BrowserWindowCommandHandler and only use it in browser windows. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/base/cocoa/command_dispatcher.h ('K') | « ui/base/cocoa/command_dispatcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/cocoa/native_widget_mac_nswindow.mm
diff --git a/ui/views/cocoa/native_widget_mac_nswindow.mm b/ui/views/cocoa/native_widget_mac_nswindow.mm
index 1de283fb956b7dc53d180ed36ec06e1e07d4ae91..3f2eb7ce64c687b69f0be1a58600f102a4ea0bf1 100644
--- a/ui/views/cocoa/native_widget_mac_nswindow.mm
+++ b/ui/views/cocoa/native_widget_mac_nswindow.mm
@@ -25,6 +25,8 @@
base::scoped_nsobject<CommandDispatcher> commandDispatcher_;
}
+@synthesize commandHandler;
tapted 2015/09/04 02:56:24 With this approach (i.e. assign not retain), I thi
jackhou1 2015/09/04 06:13:59 Changed to retain.
+
- (instancetype)initWithContentRect:(NSRect)contentRect
styleMask:(NSUInteger)windowStyle
backing:(NSBackingStoreType)bufferingType
@@ -168,4 +170,29 @@
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 (NSUserInterfaceItemValidations implementation)
+
+- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
+ // Since this class implements these selectors, |super| will always say they
tapted 2015/09/04 02:56:24 Then perhaps this logic can move into commandDispa
jackhou1 2015/09/04 06:13:59 Ah, I agree sharing this logic would be good. But
+ // 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
« ui/base/cocoa/command_dispatcher.h ('K') | « ui/base/cocoa/command_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698