michael@0: // vim:set ts=2 sts=2 sw=2 et cin: michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // michael@0: // Redistribution and use in source and binary forms, with or without michael@0: // modification, are permitted provided that the following conditions are michael@0: // met: michael@0: // michael@0: // * Redistributions of source code must retain the above copyright michael@0: // notice, this list of conditions and the following disclaimer. michael@0: // * Redistributions in binary form must reproduce the above michael@0: // copyright notice, this list of conditions and the following disclaimer michael@0: // in the documentation and/or other materials provided with the michael@0: // distribution. michael@0: // * Neither the name of Google Inc. nor the names of its michael@0: // contributors may be used to endorse or promote products derived from michael@0: // this software without specific prior written permission. michael@0: // michael@0: // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR michael@0: // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT michael@0: // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@0: // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@0: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, michael@0: // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY michael@0: // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT michael@0: // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE michael@0: // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: michael@0: #ifndef DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H michael@0: #define DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H michael@0: michael@0: #include "base/basictypes.h" michael@0: #include "nsPoint.h" michael@0: #include "npapi.h" michael@0: michael@0: // Make this includable from non-Objective-C code. michael@0: #ifndef __OBJC__ michael@0: class NSCursor; michael@0: #else michael@0: #import michael@0: #endif michael@0: michael@0: // The header file QuickdrawAPI.h is missing on OS X 10.7 and up (though the michael@0: // QuickDraw APIs defined in it are still present) -- so we need to supply the michael@0: // relevant parts of its contents here. It's likely that Apple will eventually michael@0: // remove the APIs themselves (probably in OS X 10.8), so we need to make them michael@0: // weak imports, and test for their presence before using them. michael@0: #if !defined(__QUICKDRAWAPI__) michael@0: michael@0: typedef short Bits16[16]; michael@0: struct Cursor { michael@0: Bits16 data; michael@0: Bits16 mask; michael@0: Point hotSpot; michael@0: }; michael@0: typedef struct Cursor Cursor; michael@0: michael@0: #endif /* __QUICKDRAWAPI__ */ michael@0: michael@0: namespace mac_plugin_interposing { michael@0: michael@0: // Class used to serialize NSCursor objects over IPC between processes. michael@0: class NSCursorInfo { michael@0: public: michael@0: enum Type { michael@0: TypeCustom, michael@0: TypeArrow, michael@0: TypeClosedHand, michael@0: TypeContextualMenu, // Only supported on OS X 10.6 and up michael@0: TypeCrosshair, michael@0: TypeDisappearingItem, michael@0: TypeDragCopy, // Only supported on OS X 10.6 and up michael@0: TypeDragLink, // Only supported on OS X 10.6 and up michael@0: TypeIBeam, michael@0: TypeNotAllowed, // Only supported on OS X 10.6 and up michael@0: TypeOpenHand, michael@0: TypePointingHand, michael@0: TypeResizeDown, michael@0: TypeResizeLeft, michael@0: TypeResizeLeftRight, michael@0: TypeResizeRight, michael@0: TypeResizeUp, michael@0: TypeResizeUpDown, michael@0: TypeTransparent // Special type michael@0: }; michael@0: michael@0: NSCursorInfo(); michael@0: NSCursorInfo(NSCursor* aCursor); michael@0: NSCursorInfo(const Cursor* aCursor); michael@0: ~NSCursorInfo(); michael@0: michael@0: NSCursor* GetNSCursor() const; michael@0: Type GetType() const; michael@0: const char* GetTypeName() const; michael@0: nsPoint GetHotSpot() const; michael@0: uint8_t* GetCustomImageData() const; michael@0: uint32_t GetCustomImageDataLength() const; michael@0: michael@0: void SetType(Type aType); michael@0: void SetHotSpot(nsPoint aHotSpot); michael@0: void SetCustomImageData(uint8_t* aData, uint32_t aDataLength); michael@0: michael@0: static bool GetNativeCursorsSupported(); michael@0: michael@0: private: michael@0: NSCursor* GetTransparentCursor() const; michael@0: michael@0: Type mType; michael@0: // The hot spot's coordinate system is the cursor's coordinate system, and michael@0: // has an upper-left origin (in both Cocoa and pre-Cocoa systems). michael@0: nsPoint mHotSpot; michael@0: uint8_t* mCustomImageData; michael@0: uint32_t mCustomImageDataLength; michael@0: static int32_t mNativeCursorsSupported; michael@0: }; michael@0: michael@0: namespace parent { michael@0: michael@0: void OnPluginShowWindow(uint32_t window_id, CGRect window_bounds, bool modal); michael@0: void OnPluginHideWindow(uint32_t window_id, pid_t aPluginPid); michael@0: void OnSetCursor(const NSCursorInfo& cursorInfo); michael@0: void OnShowCursor(bool show); michael@0: void OnPushCursor(const NSCursorInfo& cursorInfo); michael@0: void OnPopCursor(); michael@0: michael@0: } michael@0: michael@0: namespace child { michael@0: michael@0: void SetUpCocoaInterposing(); michael@0: michael@0: } michael@0: michael@0: } michael@0: michael@0: #endif /* DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H */