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 // vim:set ts=2 sts=2 sw=2 et cin:
2 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H
31 #define DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H
33 #include "base/basictypes.h"
34 #include "nsPoint.h"
35 #include "npapi.h"
37 // Make this includable from non-Objective-C code.
38 #ifndef __OBJC__
39 class NSCursor;
40 #else
41 #import <Cocoa/Cocoa.h>
42 #endif
44 // The header file QuickdrawAPI.h is missing on OS X 10.7 and up (though the
45 // QuickDraw APIs defined in it are still present) -- so we need to supply the
46 // relevant parts of its contents here. It's likely that Apple will eventually
47 // remove the APIs themselves (probably in OS X 10.8), so we need to make them
48 // weak imports, and test for their presence before using them.
49 #if !defined(__QUICKDRAWAPI__)
51 typedef short Bits16[16];
52 struct Cursor {
53 Bits16 data;
54 Bits16 mask;
55 Point hotSpot;
56 };
57 typedef struct Cursor Cursor;
59 #endif /* __QUICKDRAWAPI__ */
61 namespace mac_plugin_interposing {
63 // Class used to serialize NSCursor objects over IPC between processes.
64 class NSCursorInfo {
65 public:
66 enum Type {
67 TypeCustom,
68 TypeArrow,
69 TypeClosedHand,
70 TypeContextualMenu, // Only supported on OS X 10.6 and up
71 TypeCrosshair,
72 TypeDisappearingItem,
73 TypeDragCopy, // Only supported on OS X 10.6 and up
74 TypeDragLink, // Only supported on OS X 10.6 and up
75 TypeIBeam,
76 TypeNotAllowed, // Only supported on OS X 10.6 and up
77 TypeOpenHand,
78 TypePointingHand,
79 TypeResizeDown,
80 TypeResizeLeft,
81 TypeResizeLeftRight,
82 TypeResizeRight,
83 TypeResizeUp,
84 TypeResizeUpDown,
85 TypeTransparent // Special type
86 };
88 NSCursorInfo();
89 NSCursorInfo(NSCursor* aCursor);
90 NSCursorInfo(const Cursor* aCursor);
91 ~NSCursorInfo();
93 NSCursor* GetNSCursor() const;
94 Type GetType() const;
95 const char* GetTypeName() const;
96 nsPoint GetHotSpot() const;
97 uint8_t* GetCustomImageData() const;
98 uint32_t GetCustomImageDataLength() const;
100 void SetType(Type aType);
101 void SetHotSpot(nsPoint aHotSpot);
102 void SetCustomImageData(uint8_t* aData, uint32_t aDataLength);
104 static bool GetNativeCursorsSupported();
106 private:
107 NSCursor* GetTransparentCursor() const;
109 Type mType;
110 // The hot spot's coordinate system is the cursor's coordinate system, and
111 // has an upper-left origin (in both Cocoa and pre-Cocoa systems).
112 nsPoint mHotSpot;
113 uint8_t* mCustomImageData;
114 uint32_t mCustomImageDataLength;
115 static int32_t mNativeCursorsSupported;
116 };
118 namespace parent {
120 void OnPluginShowWindow(uint32_t window_id, CGRect window_bounds, bool modal);
121 void OnPluginHideWindow(uint32_t window_id, pid_t aPluginPid);
122 void OnSetCursor(const NSCursorInfo& cursorInfo);
123 void OnShowCursor(bool show);
124 void OnPushCursor(const NSCursorInfo& cursorInfo);
125 void OnPopCursor();
127 }
129 namespace child {
131 void SetUpCocoaInterposing();
133 }
135 }
137 #endif /* DOM_PLUGINS_IPC_PLUGININTERPOSEOSX_H */