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

Side by Side Diff: ui/base/cocoa/command_dispatcher.h

Issue 1255783002: [Mac] Factor out keyboard shortcut handling from ChromeEventProcessingWindow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@execute
Patch Set: Separate CommandDispatcher and CommandDispatcherDelegate. Created 5 years, 4 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_BASE_COCOA_COMMAND_DISPATCHER_H_
6 #define UI_BASE_COCOA_COMMAND_DISPATCHER_H_
7
8 #import <Cocoa/Cocoa.h>
9
10 #import "base/mac/scoped_nsobject.h"
11
12 // CommandDispatcherImpl will dispatch -performKeyEquivalent to this first.
13 // If the event is not handled, CommandDispatcherTarget is expected to return
14 // the event via -redispatchKeyEvent.
15 // The Mac RenderWidgetHostView implementation conforms to this protocol.
16 @protocol CommandDispatcherTarget
17 @end
18
19 // Implements a set of hooks into the -performKeyEquivalent flow.
20 @protocol CommandDispatcherDelegate<NSObject>
21 - (BOOL)handledByExtensionCommand:(NSEvent*)event
22 isRedispatch:(BOOL)isRedispatch;
23 - (BOOL)prePerformKeyEquivalent:(NSEvent*)event window:(NSWindow*)window;
24 - (BOOL)postPerformKeyEquivalent:(NSEvent*)event window:(NSWindow*)window;
25 @end
26
27 // Interface for an NSWindow that will dispatch key events to a
28 // RenderWidgetHostView and handle redispatching them if they are not handled.
29 // See CommandDispatcherImpl for usage.
30 @protocol CommandDispatcher
tapted 2015/08/18 07:22:12 I *think* this can be merged with CommandDispatche
jackhou1 2015/08/25 06:31:12 In MacViews, NativeWidgetMacNSWindow is the Comman
tapted 2015/08/26 03:04:48 Ahhhhh. Yep. my plan would only work if we could i
31 - (void)setCommandDispatcherDelegate:(id<CommandDispatcherDelegate>)delegate;
32 // Sends a key event to |NSApp sendEvent:|, but also makes sure that it's not
33 // short-circuited to the RWHV. This is used to send keyboard events to the menu
34 // and the cmd-` handler if a keyboard event comes back unhandled from the
35 // renderer. The event must be of type |NSKeyDown|, |NSKeyUp|, or
36 // |NSFlagsChanged|.
37 // Returns |YES| if |event| has been handled.
38 - (BOOL)redispatchKeyEvent:(NSEvent*)event;
39 // Short-circuit to the default -[NSResponder performKeyEquivalent:] which
40 // CommandDispatcherImpl calls as part of its -performKeyEquivalent flow.
41 - (BOOL)defaultPerformKeyEquivalent:(NSEvent*)event;
42 @end
43
44 // Handles dispatch of key events including redispatching an unhandled event
45 // to NSApplication.
46 @interface CommandDispatcherImpl : NSObject {
47 @private
48 BOOL redispatchingEvent_;
49 BOOL eventHandled_;
50 NSWindow<CommandDispatcher>* owner_; // Weak, owns us.
51 base::scoped_nsprotocol<id<CommandDispatcherDelegate>> delegate_;
52 }
53
54 - (id)initWithOwner:(NSWindow<CommandDispatcher>*)owner;
55
56 - (void)setDelegate:(id<CommandDispatcherDelegate>)delegate;
57
58 // The CommandDispatcher should override -[NSResponder performKeyEquivalent:]
59 // with this. Handles various keyboard shortcut hooks before and after native
60 // -performKeyEquivalent. Returns YES if the event is handled.
61 - (BOOL)performKeyEquivalent:(NSEvent*)event;
62
63 // The CommandDispatcher should implement -redispatchKeyEvent: with this. Send
64 // the event to NSApp so it can be handled natively. Ensures that the event is
65 // not reposted infinitely.
66 - (BOOL)redispatchKeyEvent:(NSEvent*)event;
67
68 // The CommandDispatcher should call this before a native -sendEvent. Returns
69 // YES if the event is handled.
70 - (BOOL)preSendEvent:(NSEvent*)event;
71
72 @end
73
74 #endif // UI_BASE_COCOA_COMMAND_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698