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.
michael@0 | 1 | /* ***** BEGIN LICENSE BLOCK ***** |
michael@0 | 2 | * |
michael@0 | 3 | * Copyright (c) 2008, Mozilla Corporation |
michael@0 | 4 | * All rights reserved. |
michael@0 | 5 | * |
michael@0 | 6 | * Redistribution and use in source and binary forms, with or without |
michael@0 | 7 | * modification, are permitted provided that the following conditions are met: |
michael@0 | 8 | * |
michael@0 | 9 | * * Redistributions of source code must retain the above copyright notice, this |
michael@0 | 10 | * list of conditions and the following disclaimer. |
michael@0 | 11 | * * Redistributions in binary form must reproduce the above copyright notice, |
michael@0 | 12 | * this list of conditions and the following disclaimer in the documentation |
michael@0 | 13 | * and/or other materials provided with the distribution. |
michael@0 | 14 | * * Neither the name of the Mozilla Corporation nor the names of its |
michael@0 | 15 | * contributors may be used to endorse or promote products derived from this |
michael@0 | 16 | * software without specific prior written permission. |
michael@0 | 17 | * |
michael@0 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
michael@0 | 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
michael@0 | 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
michael@0 | 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
michael@0 | 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
michael@0 | 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
michael@0 | 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
michael@0 | 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
michael@0 | 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 28 | * |
michael@0 | 29 | * Contributor(s): |
michael@0 | 30 | * Josh Aas <josh@mozilla.com> |
michael@0 | 31 | * |
michael@0 | 32 | * ***** END LICENSE BLOCK ***** */ |
michael@0 | 33 | |
michael@0 | 34 | #ifndef nptest_platform_h_ |
michael@0 | 35 | #define nptest_platform_h_ |
michael@0 | 36 | |
michael@0 | 37 | #include "nptest.h" |
michael@0 | 38 | |
michael@0 | 39 | /** |
michael@0 | 40 | * Returns true if the plugin supports windowed mode |
michael@0 | 41 | */ |
michael@0 | 42 | bool pluginSupportsWindowMode(); |
michael@0 | 43 | |
michael@0 | 44 | /** |
michael@0 | 45 | * Returns true if the plugin supports windowless mode. At least one of |
michael@0 | 46 | * "pluginSupportsWindowMode" and "pluginSupportsWindowlessMode" must |
michael@0 | 47 | * return true. |
michael@0 | 48 | */ |
michael@0 | 49 | bool pluginSupportsWindowlessMode(); |
michael@0 | 50 | |
michael@0 | 51 | /** |
michael@0 | 52 | * Returns true if the plugin supports async bitmap drawing. |
michael@0 | 53 | */ |
michael@0 | 54 | bool pluginSupportsAsyncBitmapDrawing(); |
michael@0 | 55 | |
michael@0 | 56 | /** |
michael@0 | 57 | * Returns true if the plugin supports DXGI bitmap drawing. |
michael@0 | 58 | */ |
michael@0 | 59 | inline bool pluginSupportsAsyncDXGIDrawing() |
michael@0 | 60 | { |
michael@0 | 61 | #ifdef XP_WIN |
michael@0 | 62 | return true; |
michael@0 | 63 | #else |
michael@0 | 64 | return false; |
michael@0 | 65 | #endif |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | /** |
michael@0 | 69 | * Initialize the plugin instance. Returning an error here will cause the |
michael@0 | 70 | * plugin instantiation to fail. |
michael@0 | 71 | */ |
michael@0 | 72 | NPError pluginInstanceInit(InstanceData* instanceData); |
michael@0 | 73 | |
michael@0 | 74 | /** |
michael@0 | 75 | * Shutdown the plugin instance. |
michael@0 | 76 | */ |
michael@0 | 77 | void pluginInstanceShutdown(InstanceData* instanceData); |
michael@0 | 78 | |
michael@0 | 79 | /** |
michael@0 | 80 | * Set the instanceData's window to newWindow. |
michael@0 | 81 | */ |
michael@0 | 82 | void pluginDoSetWindow(InstanceData* instanceData, NPWindow* newWindow); |
michael@0 | 83 | |
michael@0 | 84 | /** |
michael@0 | 85 | * Initialize the window for a windowed plugin. oldWindow is the old |
michael@0 | 86 | * native window value. This will never be called for windowless plugins. |
michael@0 | 87 | */ |
michael@0 | 88 | void pluginWidgetInit(InstanceData* instanceData, void* oldWindow); |
michael@0 | 89 | |
michael@0 | 90 | /** |
michael@0 | 91 | * Handle an event for a windowless plugin. (Windowed plugins are |
michael@0 | 92 | * responsible for listening for their own events.) |
michael@0 | 93 | */ |
michael@0 | 94 | int16_t pluginHandleEvent(InstanceData* instanceData, void* event); |
michael@0 | 95 | |
michael@0 | 96 | #ifdef XP_WIN |
michael@0 | 97 | void pluginDrawAsyncDxgiColor(InstanceData* instanceData); |
michael@0 | 98 | #endif |
michael@0 | 99 | |
michael@0 | 100 | enum RectEdge { |
michael@0 | 101 | EDGE_LEFT = 0, |
michael@0 | 102 | EDGE_TOP = 1, |
michael@0 | 103 | EDGE_RIGHT = 2, |
michael@0 | 104 | EDGE_BOTTOM = 3 |
michael@0 | 105 | }; |
michael@0 | 106 | |
michael@0 | 107 | enum { |
michael@0 | 108 | NPTEST_INT32_ERROR = 0x7FFFFFFF |
michael@0 | 109 | }; |
michael@0 | 110 | |
michael@0 | 111 | /** |
michael@0 | 112 | * Return the coordinate of the given edge of the plugin's area, relative |
michael@0 | 113 | * to the top-left corner of the toplevel window containing the plugin, |
michael@0 | 114 | * including window decorations. Only works for window-mode plugins |
michael@0 | 115 | * and Mac plugins. |
michael@0 | 116 | * Returns NPTEST_ERROR on error. |
michael@0 | 117 | */ |
michael@0 | 118 | int32_t pluginGetEdge(InstanceData* instanceData, RectEdge edge); |
michael@0 | 119 | |
michael@0 | 120 | /** |
michael@0 | 121 | * Return the number of rectangles in the plugin's clip region. Only |
michael@0 | 122 | * works for window-mode plugins and Mac plugins. |
michael@0 | 123 | * Returns NPTEST_ERROR on error. |
michael@0 | 124 | */ |
michael@0 | 125 | int32_t pluginGetClipRegionRectCount(InstanceData* instanceData); |
michael@0 | 126 | |
michael@0 | 127 | /** |
michael@0 | 128 | * Return the coordinate of the given edge of a rectangle in the plugin's |
michael@0 | 129 | * clip region, relative to the top-left corner of the toplevel window |
michael@0 | 130 | * containing the plugin, including window decorations. Only works for |
michael@0 | 131 | * window-mode plugins and Mac plugins. |
michael@0 | 132 | * Returns NPTEST_ERROR on error. |
michael@0 | 133 | */ |
michael@0 | 134 | int32_t pluginGetClipRegionRectEdge(InstanceData* instanceData, |
michael@0 | 135 | int32_t rectIndex, RectEdge edge); |
michael@0 | 136 | |
michael@0 | 137 | /** |
michael@0 | 138 | * Check that the platform-specific plugin state is internally consistent. |
michael@0 | 139 | * Just return if everything is OK, otherwise append error messages |
michael@0 | 140 | * to 'error' separated by \n. |
michael@0 | 141 | */ |
michael@0 | 142 | void pluginDoInternalConsistencyCheck(InstanceData* instanceData, std::string& error); |
michael@0 | 143 | |
michael@0 | 144 | /** |
michael@0 | 145 | * Get the current clipboard item as text. If the clipboard item |
michael@0 | 146 | * isn't text, the returned value is undefined. |
michael@0 | 147 | */ |
michael@0 | 148 | std::string pluginGetClipboardText(InstanceData* instanceData); |
michael@0 | 149 | |
michael@0 | 150 | /** |
michael@0 | 151 | * Crash while in a nested event loop. The goal is to catch the |
michael@0 | 152 | * browser processing the XPCOM event generated from the plugin's |
michael@0 | 153 | * crash while other plugin code is still on the stack. |
michael@0 | 154 | * See https://bugzilla.mozilla.org/show_bug.cgi?id=550026. |
michael@0 | 155 | */ |
michael@0 | 156 | bool pluginCrashInNestedLoop(InstanceData* instanceData); |
michael@0 | 157 | |
michael@0 | 158 | /** |
michael@0 | 159 | * Destroy gfx things that might be shared with the parent process |
michael@0 | 160 | * when we're run out-of-process. It's not expected that this |
michael@0 | 161 | * function will be called when the test plugin is loaded in-process, |
michael@0 | 162 | * and bad things will happen if it is called. |
michael@0 | 163 | * |
michael@0 | 164 | * This call leaves the plugin subprocess in an undefined state. It |
michael@0 | 165 | * must not be used after this call or weird things will happen. |
michael@0 | 166 | */ |
michael@0 | 167 | bool pluginDestroySharedGfxStuff(InstanceData* instanceData); |
michael@0 | 168 | |
michael@0 | 169 | #endif // nptest_platform_h_ |