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

Side by Side Diff: chrome/browser/ui/cocoa/chrome_event_processing_window.mm

Issue 1250403002: [Mac] Move UI item validation to UserInterfaceItemCommandHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@commandexecute
Patch Set: Sync to new CommandDispatcher design. Add UserInterfaceItemCommandHandler. 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/ui/cocoa/chrome_command_dispatcher_delegate.h" 8 #import "chrome/browser/ui/cocoa/chrome_command_dispatcher_delegate.h"
9 9
10 @implementation ChromeEventProcessingWindow 10 @implementation ChromeEventProcessingWindow
11 11
12 - (instancetype)initWithContentRect:(NSRect)contentRect 12 - (instancetype)initWithContentRect:(NSRect)contentRect
13 styleMask:(NSUInteger)windowStyle 13 styleMask:(NSUInteger)windowStyle
14 backing:(NSBackingStoreType)bufferingType 14 backing:(NSBackingStoreType)bufferingType
15 defer:(BOOL)deferCreation { 15 defer:(BOOL)deferCreation {
16 if ((self = [super initWithContentRect:contentRect 16 if ((self = [super initWithContentRect:contentRect
17 styleMask:windowStyle 17 styleMask:windowStyle
18 backing:bufferingType 18 backing:bufferingType
19 defer:deferCreation])) { 19 defer:deferCreation])) {
20 commandDispatcher_.reset([[CommandDispatcher alloc] initWithOwner:self]); 20 commandDispatcher_.reset([[CommandDispatcher alloc] initWithOwner:self]);
21 commandDispatcherDelegate_.reset( 21 commandDispatcherDelegate_.reset(
22 [[ChromeCommandDispatcherDelegate alloc] init]); 22 [[ChromeCommandDispatcherDelegate alloc] init]);
23 [commandDispatcher_ setDelegate:commandDispatcherDelegate_]; 23 [commandDispatcher_ setDelegate:commandDispatcherDelegate_];
24 [self setCommandHandler:commandDispatcherDelegate_];
24 } 25 }
25 return self; 26 return self;
26 } 27 }
27 28
28 - (BOOL)handleExtraKeyboardShortcut:(NSEvent*)event { 29 - (BOOL)handleExtraKeyboardShortcut:(NSEvent*)event {
29 return [commandDispatcherDelegate_ handleExtraKeyboardShortcut:event 30 return [commandDispatcherDelegate_ handleExtraKeyboardShortcut:event
30 window:self]; 31 window:self];
31 } 32 }
32 33
33 // CommandDispatchingWindow implementation. 34 // CommandDispatchingWindow implementation.
34 35
36 @synthesize commandHandler;
37
35 - (BOOL)redispatchKeyEvent:(NSEvent*)event { 38 - (BOOL)redispatchKeyEvent:(NSEvent*)event {
36 return [commandDispatcher_ redispatchKeyEvent:event]; 39 return [commandDispatcher_ redispatchKeyEvent:event];
37 } 40 }
38 41
39 - (BOOL)defaultPerformKeyEquivalent:(NSEvent*)event { 42 - (BOOL)defaultPerformKeyEquivalent:(NSEvent*)event {
40 return [super performKeyEquivalent:event]; 43 return [super performKeyEquivalent:event];
41 } 44 }
42 45
46 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
47 return [[self commandHandler] validateUserInterfaceItem:item window:self];
48 }
49
50 - (void)commandDispatch:(id)sender {
51 [[self commandHandler] commandDispatch:sender window:self];
52 }
53
54 - (void)commandDispatchUsingKeyModifiers:(id)sender {
55 [[self commandHandler] commandDispatchUsingKeyModifiers:sender window:self];
56 }
57
43 // NSWindow overrides. 58 // NSWindow overrides.
44 59
45 - (BOOL)performKeyEquivalent:(NSEvent*)event { 60 - (BOOL)performKeyEquivalent:(NSEvent*)event {
46 return [commandDispatcher_ performKeyEquivalent:event]; 61 return [commandDispatcher_ performKeyEquivalent:event];
47 } 62 }
48 63
49 - (void)sendEvent:(NSEvent*)event { 64 - (void)sendEvent:(NSEvent*)event {
50 if (![commandDispatcher_ preSendEvent:event]) 65 if (![commandDispatcher_ preSendEvent:event])
51 [super sendEvent:event]; 66 [super sendEvent:event];
52 } 67 }
53 68
54 @end // ChromeEventProcessingWindow 69 @end // ChromeEventProcessingWindow
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698