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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_COCOA_CHROME_EVENT_PROCESSING_WINDOW_H_
6#define CHROME_BROWSER_UI_COCOA_CHROME_EVENT_PROCESSING_WINDOW_H_
7
8#import <Cocoa/Cocoa.h>
9
10#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
11
12// Override NSWindow to access unhandled keyboard events (for command
13// processing); subclassing NSWindow is the only method to do
14// this.
15@interface ChromeEventProcessingWindow : UnderlayOpenGLHostingWindow {
16 @private
17  BOOL redispatchingEvent_;
18  BOOL eventHandled_;
19}
20
21// Sends a key event to |NSApp sendEvent:|, but also makes sure that it's not
22// short-circuited to the RWHV. This is used to send keyboard events to the menu
23// and the cmd-` handler if a keyboard event comes back unhandled from the
24// renderer. The event must be of type |NSKeyDown|, |NSKeyUp|, or
25// |NSFlagsChanged|.
26// Returns |YES| if |event| has been handled.
27- (BOOL)redispatchKeyEvent:(NSEvent*)event;
28
29// See global_keyboard_shortcuts_mac.h for details on the next two functions.
30
31// Checks if |event| is a window keyboard shortcut. If so, dispatches it to the
32// window controller's |executeCommand:| and returns |YES|.
33- (BOOL)handleExtraWindowKeyboardShortcut:(NSEvent*)event;
34
35// Checks if |event| is a delayed window keyboard shortcut. If so, dispatches
36// it to the window controller's |executeCommand:| and returns |YES|.
37- (BOOL)handleDelayedWindowKeyboardShortcut:(NSEvent*)event;
38
39// Checks if |event| is a browser keyboard shortcut. If so, dispatches it to the
40// window controller's |executeCommand:| and returns |YES|.
41- (BOOL)handleExtraBrowserKeyboardShortcut:(NSEvent*)event;
42
43// Override, so we can handle global keyboard events.
44- (BOOL)performKeyEquivalent:(NSEvent*)theEvent;
45
46@end
47
48#endif  // CHROME_BROWSER_UI_COCOA_CHROME_EVENT_PROCESSING_WINDOW_H_
49