Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 // Copyright (c) 2009 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.
5 #ifndef BASE_CHROME_APPLICATION_MAC_H_
6 #define BASE_CHROME_APPLICATION_MAC_H_
8 #import <AppKit/AppKit.h>
10 #include "base/basictypes.h"
11 #include "base/scoped_nsobject.h"
13 // Event hooks must implement this protocol.
14 @protocol CrApplicationEventHookProtocol
15 - (void)hookForEvent:(NSEvent*)theEvent;
16 @end
19 @interface CrApplication : NSApplication {
20 @private
21 BOOL handlingSendEvent_;
22 // Array of objects implementing the CrApplicationEventHookProtocol
23 scoped_nsobject<NSMutableArray> eventHooks_;
24 }
25 @property(readonly,
26 getter=isHandlingSendEvent,
27 nonatomic) BOOL handlingSendEvent;
29 // Add or remove an event hook to be called for every sendEvent:
30 // that the application receives. These handlers are called before
31 // the normal [NSApplication sendEvent:] call is made.
33 // This is not a good alternative to a nested event loop. It should
34 // be used only when normal event logic and notification breaks down
35 // (e.g. when clicking outside a canBecomeKey:NO window to "switch
36 // context" out of it).
37 - (void)addEventHook:(id<CrApplicationEventHookProtocol>)hook;
38 - (void)removeEventHook:(id<CrApplicationEventHookProtocol>)hook;
40 + (NSApplication*)sharedApplication;
41 @end
43 namespace chrome_application_mac {
45 // Controls the state of |handlingSendEvent_| in the event loop so that it is
46 // reset properly.
47 class ScopedSendingEvent {
48 public:
49 ScopedSendingEvent();
50 ~ScopedSendingEvent();
52 private:
53 CrApplication* app_;
54 BOOL handling_;
55 DISALLOW_COPY_AND_ASSIGN(ScopedSendingEvent);
56 };
58 } // chrome_application_mac
60 #endif // BASE_CHROME_APPLICATION_MAC_H_