2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following disclaimer
|
|
|
|
// in the documentation and/or other materials provided with the
|
|
|
|
// distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
|
|
// Framework nor the names of its contributors may be used to endorse
|
|
|
|
// or promote products derived from this software without specific prior
|
|
|
|
// written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
#ifndef CEF_INCLUDE_CEF_APPLICATION_MAC_H_
|
|
|
|
#define CEF_INCLUDE_CEF_APPLICATION_MAC_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "include/cef_base.h"
|
|
|
|
|
|
|
|
#if defined(OS_MACOSX) && defined(__OBJC__)
|
|
|
|
|
2016-03-16 03:55:59 +01:00
|
|
|
#ifdef USING_CHROMIUM_INCLUDES
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// Use the existing CrAppControlProtocol definition.
|
2012-04-04 20:18:09 +02:00
|
|
|
#import "base/mac/scoped_sending_event.h"
|
|
|
|
|
2013-06-22 04:06:32 +02:00
|
|
|
// Use the existing CrAppProtocol definition.
|
|
|
|
#import "base/message_loop/message_pump_mac.h"
|
|
|
|
|
2012-04-04 20:18:09 +02:00
|
|
|
// Use the existing UnderlayableSurface definition.
|
|
|
|
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// Use the existing empty protocol definitions.
|
|
|
|
#import "base/mac/cocoa_protocols.h"
|
|
|
|
|
2013-08-08 17:58:50 +02:00
|
|
|
// Use the existing empty protocol definitions.
|
|
|
|
#import "base/mac/sdk_forward_declarations.h"
|
|
|
|
|
2016-03-16 03:55:59 +01:00
|
|
|
#else // USING_CHROMIUM_INCLUDES
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
#import <AppKit/AppKit.h>
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
2013-06-22 04:06:32 +02:00
|
|
|
// Copy of definition from base/message_loop/message_pump_mac.h.
|
2012-04-03 03:34:16 +02:00
|
|
|
@protocol CrAppProtocol
|
|
|
|
// Must return true if -[NSApplication sendEvent:] is currently on the stack.
|
|
|
|
- (BOOL)isHandlingSendEvent;
|
|
|
|
@end
|
|
|
|
|
2012-04-04 20:18:09 +02:00
|
|
|
// Copy of definition from base/mac/scoped_sending_event.h.
|
2012-04-03 03:34:16 +02:00
|
|
|
@protocol CrAppControlProtocol<CrAppProtocol>
|
|
|
|
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
|
|
|
|
@end
|
|
|
|
|
2012-04-04 20:18:09 +02:00
|
|
|
// Copy of definition from ui/base/cocoa/underlay_opengl_hosting_window.h.
|
2012-04-24 20:01:48 +02:00
|
|
|
// Common base class for windows that host a OpenGL surface that renders under
|
|
|
|
// the window. Contains methods relating to hole punching so that the OpenGL
|
|
|
|
// surface is visible through the window.
|
|
|
|
@interface UnderlayOpenGLHostingWindow : NSWindow
|
2012-04-04 20:18:09 +02:00
|
|
|
@end
|
|
|
|
|
2016-03-16 03:55:59 +01:00
|
|
|
#endif // USING_CHROMIUM_INCLUDES
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// All CEF client applications must subclass NSApplication and implement this
|
|
|
|
// protocol.
|
|
|
|
@protocol CefAppProtocol<CrAppControlProtocol>
|
|
|
|
@end
|
|
|
|
|
2017-11-15 20:55:16 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// Controls the state of |isHandlingSendEvent| in the event loop so that it is
|
|
|
|
// reset properly.
|
|
|
|
class CefScopedSendingEvent {
|
|
|
|
public:
|
|
|
|
CefScopedSendingEvent()
|
2017-05-17 11:29:28 +02:00
|
|
|
: app_(static_cast<NSApplication<CefAppProtocol>*>(
|
|
|
|
[NSApplication sharedApplication])),
|
|
|
|
handling_([app_ isHandlingSendEvent]) {
|
2012-04-03 03:34:16 +02:00
|
|
|
[app_ setHandlingSendEvent:YES];
|
|
|
|
}
|
2017-05-17 11:29:28 +02:00
|
|
|
~CefScopedSendingEvent() { [app_ setHandlingSendEvent:handling_]; }
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
NSApplication<CefAppProtocol>* app_;
|
|
|
|
BOOL handling_;
|
|
|
|
};
|
|
|
|
|
2017-11-15 20:55:16 +01:00
|
|
|
#endif // __cplusplus
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
#endif // defined(OS_MACOSX) && defined(__OBJC__)
|
|
|
|
|
|
|
|
#endif // CEF_INCLUDE_CEF_APPLICATION_MAC_H_
|