| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2009 Google Inc. 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. | |
| 29 */ | |
| 30 | |
| 31 #ifndef WebBindings_h | |
| 32 #define WebBindings_h | |
| 33 | |
| 34 #include "../platform/WebCommon.h" | |
| 35 #include "../platform/WebString.h" | |
| 36 #include "../platform/WebVector.h" | |
| 37 #include <bindings/npruntime.h> | |
| 38 | |
| 39 namespace v8 { | |
| 40 class Value; | |
| 41 template <class T> class Handle; | |
| 42 template <class T> class Local; | |
| 43 } | |
| 44 | |
| 45 namespace WebKit { | |
| 46 | |
| 47 class WebArrayBuffer; | |
| 48 class WebArrayBufferView; | |
| 49 class WebDragData; | |
| 50 class WebElement; | |
| 51 class WebNode; | |
| 52 class WebRange; | |
| 53 | |
| 54 // A haphazard collection of functions for dealing with plugins. | |
| 55 class WebBindings { | |
| 56 public: | |
| 57 // NPN Functions ------------------------------------------------------ | |
| 58 // These are all defined in npruntime.h and are well documented. | |
| 59 | |
| 60 // NPN_Construct | |
| 61 WEBKIT_EXPORT static bool construct(NPP, NPObject*, const NPVariant* args, u
int32_t argCount, NPVariant* result); | |
| 62 | |
| 63 // NPN_CreateObject | |
| 64 WEBKIT_EXPORT static NPObject* createObject(NPP, NPClass*); | |
| 65 | |
| 66 // NPN_Enumerate | |
| 67 WEBKIT_EXPORT static bool enumerate(NPP, NPObject*, NPIdentifier**, uint32_t
* identifierCount); | |
| 68 | |
| 69 // NPN_Evaluate | |
| 70 WEBKIT_EXPORT static bool evaluate(NPP, NPObject*, NPString* script, NPVaria
nt* result); | |
| 71 | |
| 72 // NPN_EvaluateHelper | |
| 73 WEBKIT_EXPORT static bool evaluateHelper(NPP, bool popupsAllowed, NPObject*,
NPString* script, NPVariant* result); | |
| 74 | |
| 75 // NPN_GetIntIdentifier | |
| 76 WEBKIT_EXPORT static NPIdentifier getIntIdentifier(int32_t number); | |
| 77 | |
| 78 // NPN_GetProperty | |
| 79 WEBKIT_EXPORT static bool getProperty(NPP, NPObject*, NPIdentifier property,
NPVariant *result); | |
| 80 | |
| 81 // NPN_GetStringIdentifier | |
| 82 WEBKIT_EXPORT static NPIdentifier getStringIdentifier(const NPUTF8* string); | |
| 83 | |
| 84 // NPN_GetStringIdentifiers | |
| 85 WEBKIT_EXPORT static void getStringIdentifiers(const NPUTF8** names, int32_t
nameCount, NPIdentifier*); | |
| 86 | |
| 87 // NPN_HasMethod | |
| 88 WEBKIT_EXPORT static bool hasMethod(NPP, NPObject*, NPIdentifier method); | |
| 89 | |
| 90 // NPN_HasProperty | |
| 91 WEBKIT_EXPORT static bool hasProperty(NPP, NPObject*, NPIdentifier property)
; | |
| 92 | |
| 93 // NPN_IdentifierIsString | |
| 94 WEBKIT_EXPORT static bool identifierIsString(NPIdentifier); | |
| 95 | |
| 96 // NPN_InitializeVariantWithStringCopy (though sometimes prefixed with an un
derscore) | |
| 97 WEBKIT_EXPORT static void initializeVariantWithStringCopy(NPVariant*, const
NPString*); | |
| 98 | |
| 99 // NPN_IntFromIdentifier | |
| 100 WEBKIT_EXPORT static int32_t intFromIdentifier(NPIdentifier); | |
| 101 | |
| 102 // NPN_Invoke | |
| 103 WEBKIT_EXPORT static bool invoke(NPP, NPObject*, NPIdentifier method, const
NPVariant* args, uint32_t argCount, NPVariant* result); | |
| 104 | |
| 105 // NPN_InvokeDefault | |
| 106 WEBKIT_EXPORT static bool invokeDefault(NPP, NPObject*, const NPVariant* arg
s, uint32_t argCount, NPVariant* result); | |
| 107 | |
| 108 // NPN_ReleaseObject | |
| 109 WEBKIT_EXPORT static void releaseObject(NPObject*); | |
| 110 | |
| 111 // NPN_ReleaseVariantValue | |
| 112 WEBKIT_EXPORT static void releaseVariantValue(NPVariant*); | |
| 113 | |
| 114 // NPN_RemoveProperty | |
| 115 WEBKIT_EXPORT static bool removeProperty(NPP, NPObject*, NPIdentifier); | |
| 116 | |
| 117 // NPN_RetainObject | |
| 118 WEBKIT_EXPORT static NPObject* retainObject(NPObject*); | |
| 119 | |
| 120 // NPN_SetException | |
| 121 WEBKIT_EXPORT static void setException(NPObject*, const NPUTF8* message); | |
| 122 | |
| 123 // NPN_SetProperty | |
| 124 WEBKIT_EXPORT static bool setProperty(NPP, NPObject*, NPIdentifier, const NP
Variant*); | |
| 125 | |
| 126 // _NPN_RegisterObjectOwner | |
| 127 WEBKIT_EXPORT static void registerObjectOwner(NPP); | |
| 128 | |
| 129 // _NPN_UnregisterObjectOwner | |
| 130 WEBKIT_EXPORT static void unregisterObjectOwner(NPP); | |
| 131 | |
| 132 // _NPN_UnregisterObject | |
| 133 WEBKIT_EXPORT static void unregisterObject(NPObject*); | |
| 134 | |
| 135 // NPN_UTF8FromIdentifier | |
| 136 WEBKIT_EXPORT static NPUTF8* utf8FromIdentifier(NPIdentifier); | |
| 137 | |
| 138 // Miscellaneous utility functions ---------------------------------------- | |
| 139 | |
| 140 // Complement to NPN_Get___Identifier functions. Extracts data from the NPI
dentifier data | |
| 141 // structure. If isString is true upon return, string will be set but numbe
r's value is | |
| 142 // undefined. If iString is false, the opposite is true. | |
| 143 WEBKIT_EXPORT static void extractIdentifierData(const NPIdentifier&, const N
PUTF8*& string, int32_t& number, bool& isString); | |
| 144 | |
| 145 // DumpRenderTree support ------------------------------------------------- | |
| 146 | |
| 147 // Return true (success) if the given npobj is a range object. | |
| 148 // If so, return that range as a WebRange object. | |
| 149 WEBKIT_EXPORT static bool getRange(NPObject* range, WebRange*); | |
| 150 | |
| 151 // Return true (success) if the given npobj is an ArrayBuffer object. | |
| 152 // If so, return it as a WebArrayBuffer object. | |
| 153 WEBKIT_EXPORT static bool getArrayBuffer(NPObject* arrayBuffer, WebArrayBuff
er*); | |
| 154 | |
| 155 // Return true (success) if the given npobj is an ArrayBufferView object. | |
| 156 // If so, return it as a WebArrayBufferView object. | |
| 157 WEBKIT_EXPORT static bool getArrayBufferView(NPObject* arrayBufferView, WebA
rrayBufferView*); | |
| 158 | |
| 159 // Return true (success) if the given npobj is a node. | |
| 160 // If so, return that node as a WebNode object. | |
| 161 WEBKIT_EXPORT static bool getNode(NPObject* element, WebNode*); | |
| 162 | |
| 163 // Return true (success) if the given npobj is an element. | |
| 164 // If so, return that element as a WebElement object. | |
| 165 WEBKIT_EXPORT static bool getElement(NPObject* element, WebElement*); | |
| 166 | |
| 167 WEBKIT_EXPORT static NPObject* makeIntArray(const WebVector<int>&); | |
| 168 WEBKIT_EXPORT static NPObject* makeStringArray(const WebVector<WebString>&); | |
| 169 | |
| 170 // Exceptions ------------------------------------------------------------- | |
| 171 | |
| 172 typedef void (ExceptionHandler)(void* data, const NPUTF8* message); | |
| 173 | |
| 174 // The exception handler will be notified of any exceptions thrown while | |
| 175 // operating on a NPObject. | |
| 176 WEBKIT_EXPORT static void pushExceptionHandler(ExceptionHandler, void* data)
; | |
| 177 WEBKIT_EXPORT static void popExceptionHandler(); | |
| 178 | |
| 179 // Conversion utilities to/from V8 native objects and NPVariant wrappers. | |
| 180 WEBKIT_EXPORT static void toNPVariant(v8::Local<v8::Value>, NPObject* root,
NPVariant* result); | |
| 181 WEBKIT_EXPORT static v8::Handle<v8::Value> toV8Value(const NPVariant*); | |
| 182 }; | |
| 183 | |
| 184 } // namespace WebKit | |
| 185 | |
| 186 #endif | |
| OLD | NEW |