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

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: Address comments. 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
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..c3c30801410f16c9c276dd78edc5f727cb4c5c8e 100644
--- a/ui/views/cocoa/native_widget_mac_nswindow.mm
+++ b/ui/views/cocoa/native_widget_mac_nswindow.mm
@@ -23,6 +23,7 @@
@implementation NativeWidgetMacNSWindow {
@private
base::scoped_nsobject<CommandDispatcher> commandDispatcher_;
+ id<UserInterfaceItemCommandHandler> commandHandler_;
}
- (instancetype)initWithContentRect:(NSRect)contentRect
@@ -40,8 +41,10 @@
// Public methods.
-- (void)setCommandDispatcherDelegate:(id<CommandDispatcherDelegate>)delegate {
+- (void)setCommandDispatcherDelegate:
+ (id<CommandDispatcherDelegate, UserInterfaceItemCommandHandler>)delegate {
[commandDispatcher_ setDelegate:delegate];
+ commandHandler_ = delegate;
}
// Private methods.
@@ -168,4 +171,19 @@
return [super performKeyEquivalent:event];
}
+- (void)commandDispatch:(id)sender {
+ [commandHandler_ commandDispatch:sender window:self];
+}
+
+- (void)commandDispatchUsingKeyModifiers:(id)sender {
+ [commandHandler_ commandDispatchUsingKeyModifiers:sender window:self];
+}
+
+// NSWindow overrides (NSUserInterfaceItemValidations implementation)
+
+- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
+ return [commandHandler_ validateUserInterfaceItem:item window:self] &&
+ [super validateUserInterfaceItem:item];
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698