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

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: Address comments. 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.
tapted 2015/08/26 03:04:49 Should say, "If the NSWindow's firstResponder impl
jackhou1 2015/08/26 06:24:42 Done.
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
tapted 2015/08/26 03:04:49 declare performKeyEquivalent:(NSvent*)
jackhou1 2015/08/26 06:24:42 Done.
18
19 // Implements a set of hooks into the -performKeyEquivalent flow.
tapted 2015/08/26 03:04:49 perhaps more like "Provides CommandDispatcher with
jackhou1 2015/08/26 06:24:43 Done.
20 @protocol CommandDispatcherDelegate<NSObject>
21 - (BOOL)handledByExtensionCommand:(NSEvent*)event
tapted 2015/08/26 03:04:49 nit: objc style guide says stuff in .h must have a
jackhou1 2015/08/26 06:24:42 Done.
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.
tapted 2015/08/26 03:04:49 Is `RenderWidgetHostView` relevant to this part? I
jackhou1 2015/08/26 06:24:43 Done.
29 // See CommandDispatcherImpl for usage.
30 @protocol CommandDispatcher
tapted 2015/08/26 03:04:49 I think call this `CommandDispatchingWindow` (or C
jackhou1 2015/08/26 06:24:42 Done.
31 - (void)setCommandDispatcherDelegate:(id<CommandDispatcherDelegate>)delegate;
tapted 2015/08/26 03:04:49 Not sure if this belongs here (coming back to this
jackhou1 2015/08/26 06:24:43 Moved to NativeWidgetMacNSWindow.
32 // Sends a key event to |NSApp sendEvent:|, but also makes sure that it's not
tapted 2015/08/26 03:04:49 nit: blank line before
jackhou1 2015/08/26 06:24:42 Done.
33 // short-circuited to the RWHV. This is used to send keyboard events to the menu
tapted 2015/08/26 03:04:48 RHHV -> CommandDispatcherTarget
jackhou1 2015/08/26 06:24:42 Done.
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
tapted 2015/08/26 03:04:49 nit: blank line before
jackhou1 2015/08/26 06:24:42 Done.
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
tapted 2015/08/26 03:04:49 I think this class should be declared first in thi
jackhou1 2015/08/26 06:24:42 Done. Re-wrote most of the commentary in this fil
45 // to NSApplication.
46 @interface CommandDispatcherImpl : NSObject {
tapted 2015/08/26 03:04:48 Then this can just be called `CommandDispatcher`
jackhou1 2015/08/26 06:24:42 Done.
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;
tapted 2015/08/26 03:04:48 @property? (then it doesn't need a comment :p)
jackhou1 2015/08/26 06:24:42 Done.
57
58 // The CommandDispatcher should override -[NSResponder performKeyEquivalent:]
tapted 2015/08/26 03:04:48 CommandDispatcher -> CommandDispatchingWindow
jackhou1 2015/08/26 06:24:42 Done.
59 // with this. Handles various keyboard shortcut hooks before and after native
tapted 2015/08/26 03:04:49 nit: with this -> and call this instead
jackhou1 2015/08/26 06:24:43 Done.
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