ipc/chromium/src/base/chrome_application_mac.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/chromium/src/base/chrome_application_mac.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,60 @@
     1.4 +// Copyright (c) 2009 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#ifndef BASE_CHROME_APPLICATION_MAC_H_
     1.9 +#define BASE_CHROME_APPLICATION_MAC_H_
    1.10 +
    1.11 +#import <AppKit/AppKit.h>
    1.12 +
    1.13 +#include "base/basictypes.h"
    1.14 +#include "base/scoped_nsobject.h"
    1.15 +
    1.16 +// Event hooks must implement this protocol.
    1.17 +@protocol CrApplicationEventHookProtocol
    1.18 +- (void)hookForEvent:(NSEvent*)theEvent;
    1.19 +@end
    1.20 +
    1.21 +
    1.22 +@interface CrApplication : NSApplication {
    1.23 + @private
    1.24 +  BOOL handlingSendEvent_;
    1.25 + // Array of objects implementing the CrApplicationEventHookProtocol
    1.26 +  scoped_nsobject<NSMutableArray> eventHooks_;
    1.27 +}
    1.28 +@property(readonly,
    1.29 +          getter=isHandlingSendEvent,
    1.30 +          nonatomic) BOOL handlingSendEvent;
    1.31 +
    1.32 +// Add or remove an event hook to be called for every sendEvent:
    1.33 +// that the application receives.  These handlers are called before
    1.34 +// the normal [NSApplication sendEvent:] call is made.
    1.35 +
    1.36 +// This is not a good alternative to a nested event loop.  It should
    1.37 +// be used only when normal event logic and notification breaks down
    1.38 +// (e.g. when clicking outside a canBecomeKey:NO window to "switch
    1.39 +// context" out of it).
    1.40 +- (void)addEventHook:(id<CrApplicationEventHookProtocol>)hook;
    1.41 +- (void)removeEventHook:(id<CrApplicationEventHookProtocol>)hook;
    1.42 +
    1.43 ++ (NSApplication*)sharedApplication;
    1.44 +@end
    1.45 +
    1.46 +namespace chrome_application_mac {
    1.47 +
    1.48 +// Controls the state of |handlingSendEvent_| in the event loop so that it is
    1.49 +// reset properly.
    1.50 +class ScopedSendingEvent {
    1.51 + public:
    1.52 +  ScopedSendingEvent();
    1.53 +  ~ScopedSendingEvent();
    1.54 +
    1.55 + private:
    1.56 +  CrApplication* app_;
    1.57 +  BOOL handling_;
    1.58 +  DISALLOW_COPY_AND_ASSIGN(ScopedSendingEvent);
    1.59 +};
    1.60 +
    1.61 +}  // chrome_application_mac
    1.62 +
    1.63 +#endif  // BASE_CHROME_APPLICATION_MAC_H_

mercurial