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

Side by Side Diff: chrome/browser/chrome_browser_application_mac.h

Issue 11667005: Drop event hooking in CrApplication. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chrome_browser_application_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_ 5 #ifndef CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_
6 #define CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_ 6 #define CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_
7 7
8 #ifdef __OBJC__ 8 #ifdef __OBJC__
9 9
10 #import <AppKit/AppKit.h> 10 #import <AppKit/AppKit.h>
11 11
12 #include <vector> 12 #include <vector>
13 13
14 #import "base/mac/scoped_sending_event.h" 14 #import "base/mac/scoped_sending_event.h"
15 #import "base/memory/scoped_nsobject.h" 15 #import "base/memory/scoped_nsobject.h"
16 #import "base/message_pump_mac.h" 16 #import "base/message_pump_mac.h"
17 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
18 18
19 // Event hooks must implement this protocol.
20 @protocol CrApplicationEventHookProtocol
21 - (void)hookForEvent:(NSEvent*)theEvent;
22 @end
23
24 @interface BrowserCrApplication : NSApplication<CrAppProtocol, 19 @interface BrowserCrApplication : NSApplication<CrAppProtocol,
25 CrAppControlProtocol> { 20 CrAppControlProtocol> {
26 @private 21 @private
27 BOOL handlingSendEvent_; 22 BOOL handlingSendEvent_;
28 BOOL cyclingWindows_; 23 BOOL cyclingWindows_;
29 24
30 // Array of objects implementing CrApplicationEventHookProtocol.
31 scoped_nsobject<NSMutableArray> eventHooks_;
32
33 // App's previous key windows. Most recent key window is last. 25 // App's previous key windows. Most recent key window is last.
34 // Does not include current key window. Elements of this vector are weak 26 // Does not include current key window. Elements of this vector are weak
35 // references. 27 // references.
36 std::vector<NSWindow*> previousKeyWindows_; 28 std::vector<NSWindow*> previousKeyWindows_;
37 29
38 // Guards previousKeyWindows_. 30 // Guards previousKeyWindows_.
39 base::Lock previousKeyWindowsLock_; 31 base::Lock previousKeyWindowsLock_;
40 } 32 }
41 33
42 // Our implementation of |-terminate:| only attempts to terminate the 34 // Our implementation of |-terminate:| only attempts to terminate the
43 // application, i.e., begins a process which may lead to termination. This 35 // application, i.e., begins a process which may lead to termination. This
44 // method cancels that process. 36 // method cancels that process.
45 - (void)cancelTerminate:(id)sender; 37 - (void)cancelTerminate:(id)sender;
46 38
47 // Add or remove an event hook to be called for every sendEvent:
48 // that the application receives. These handlers are called before
49 // the normal [NSApplication sendEvent:] call is made.
50
51 // This is not a good alternative to a nested event loop. It should
52 // be used only when normal event logic and notification breaks down
53 // (e.g. when clicking outside a canBecomeKey:NO window to "switch
54 // context" out of it).
55 - (void)addEventHook:(id<CrApplicationEventHookProtocol>)hook;
56 - (void)removeEventHook:(id<CrApplicationEventHookProtocol>)hook;
57
58 // Keep track of the previous key windows and whether windows are being 39 // Keep track of the previous key windows and whether windows are being
59 // cycled for use in determining whether a Panel window can become the 40 // cycled for use in determining whether a Panel window can become the
60 // key window. 41 // key window.
61 - (NSWindow*)previousKeyWindow; 42 - (NSWindow*)previousKeyWindow;
62 - (BOOL)isCyclingWindows; 43 - (BOOL)isCyclingWindows;
63 @end 44 @end
64 45
65 namespace chrome_browser_application_mac { 46 namespace chrome_browser_application_mac {
66 47
67 // Bin for unknown exceptions. Exposed for testing purposes. 48 // Bin for unknown exceptions. Exposed for testing purposes.
(...skipping 18 matching lines...) Expand all
86 67
87 // Calls -[NSApp terminate:]. 68 // Calls -[NSApp terminate:].
88 void Terminate(); 69 void Terminate();
89 70
90 // Cancels a termination started by |Terminate()|. 71 // Cancels a termination started by |Terminate()|.
91 void CancelTerminate(); 72 void CancelTerminate();
92 73
93 } // namespace chrome_browser_application_mac 74 } // namespace chrome_browser_application_mac
94 75
95 #endif // CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_ 76 #endif // CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chrome_browser_application_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698