| 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 "WebCommon.h" | |
| 35 #include <bindings/npruntime.h> | |
| 36 | |
| 37 namespace WebKit { | |
| 38 | |
| 39 class WebDragData; | |
| 40 class WebRange; | |
| 41 | |
| 42 // A haphazard collection of functions for dealing with plugins. | |
| 43 class WebBindings { | |
| 44 public: | |
| 45 // NPN Functions ------------------------------------------------------ | |
| 46 // These are all defined in npruntime.h and are well documented. | |
| 47 | |
| 48 // NPN_Construct | |
| 49 WEBKIT_API static bool construct(NPP, NPObject*, const NPVariant* args, uint32_t argCount, NPVariant* result); | |
| 50 | |
| 51 // NPN_CreateObject | |
| 52 WEBKIT_API static NPObject* createObject(NPP, NPClass*); | |
| 53 | |
| 54 // NPN_Enumerate | |
| 55 WEBKIT_API static bool enumerate(NPP, NPObject*, NPIdentifier**, uint32_t* count); | |
| 56 | |
| 57 // NPN_Evaluate | |
| 58 WEBKIT_API static bool evaluate(NPP, NPObject*, NPString* script, NPVariant* result); | |
| 59 | |
| 60 // NPN_EvaluateHelper | |
| 61 WEBKIT_API static bool evaluateHelper(NPP, bool popupsAllowed, NPObject*, NPString* script, NPVariant* result); | |
| 62 | |
| 63 // NPN_GetIntIdentifier | |
| 64 WEBKIT_API static NPIdentifier getIntIdentifier(int32_t number); | |
| 65 | |
| 66 // NPN_GetProperty | |
| 67 WEBKIT_API static bool getProperty(NPP, NPObject*, NPIdentifier propertyName, NPVariant *result); | |
| 68 | |
| 69 // NPN_GetStringIdentifier | |
| 70 WEBKIT_API static NPIdentifier getStringIdentifier(const NPUTF8* string); | |
| 71 | |
| 72 // NPN_GetStringIdentifiers | |
| 73 WEBKIT_API static void getStringIdentifiers(const NPUTF8** names, int32_t nameCount, NPIdentifier*); | |
| 74 | |
| 75 // NPN_HasMethod | |
| 76 WEBKIT_API static bool hasMethod(NPP, NPObject*, NPIdentifier methodName); | |
| 77 | |
| 78 // NPN_HasProperty | |
| 79 WEBKIT_API static bool hasProperty(NPP, NPObject*, NPIdentifier propertyName); | |
| 80 | |
| 81 // NPN_IdentifierIsString | |
| 82 WEBKIT_API static bool identifierIsString(NPIdentifier); | |
| 83 | |
| 84 // NPN_InitializeVariantWithStringCopy (though sometimes prefixed with an underscore) | |
| 85 WEBKIT_API static void initializeVariantWithStringCopy(NPVariant*, const NPString*); | |
| 86 | |
| 87 // NPN_IntFromIdentifier | |
| 88 WEBKIT_API static int32_t intFromIdentifier(NPIdentifier); | |
| 89 | |
| 90 // NPN_Invoke | |
| 91 WEBKIT_API static bool invoke(NPP, NPObject*, NPIdentifier methodName, const NPVariant* args, uint32_t count, NPVariant* result); | |
| 92 | |
| 93 // NPN_InvokeDefault | |
| 94 WEBKIT_API static bool invokeDefault(NPP, NPObject*, const NPVariant* args, uint32_t count, NPVariant* result); | |
| 95 | |
| 96 // NPN_ReleaseObject | |
| 97 WEBKIT_API static void releaseObject(NPObject*); | |
| 98 | |
| 99 // NPN_ReleaseVariantValue | |
| 100 WEBKIT_API static void releaseVariantValue(NPVariant*); | |
| 101 | |
| 102 // NPN_RemoveProperty | |
| 103 WEBKIT_API static bool removeProperty(NPP, NPObject*, NPIdentifier); | |
| 104 | |
| 105 // NPN_RetainObject | |
| 106 WEBKIT_API static NPObject* retainObject(NPObject*); | |
| 107 | |
| 108 // NPN_SetException | |
| 109 WEBKIT_API static void setException(NPObject*, const NPUTF8* message); | |
| 110 | |
| 111 // NPN_SetProperty | |
| 112 WEBKIT_API static bool setProperty(NPP, NPObject*, NPIdentifier, const NPVariant*); | |
| 113 | |
| 114 // _NPN_UnregisterObject | |
| 115 WEBKIT_API static void unregisterObject(NPObject*); | |
| 116 | |
| 117 // NPN_UTF8FromIdentifier | |
| 118 WEBKIT_API static NPUTF8* utf8FromIdentifier(NPIdentifier); | |
| 119 | |
| 120 // Miscellaneous utility functions ------------------------------------ | |
| 121 | |
| 122 // Complement to NPN_Get___Identifier functions. Extracts data from the NPIdentifier data | |
| 123 // structure. If isString is true upon return, string will be set but number's value is | |
| 124 // undefined. If iString is false, the opposite is true. | |
| 125 WEBKIT_API static void extractIdentifierData(const NPIdentifier&, const NPUTF8*& string, int32_t& number, bool& isString); | |
| 126 | |
| 127 // Return true (success) if the given npobj is the current drag event in browser dispatch, | |
| 128 // and is accessible based on context execution frames and their security origins and | |
| 129 // WebKit clipboard access policy. If so, return the event id and the clipboard data (WebDragData). | |
| 130 // This only works with V8. If compiled without V8, it'll always return false. | |
| 131 WEBKIT_API static bool getDragData(NPObject* event, int* eventId, WebDragData*); | |
| 132 | |
| 133 // Invoke the event access policy checks listed above with GetDragData(). No need for clipboard | |
| 134 // data or event_id outputs, just confirm the given npobj is the current & accessible drag event. | |
| 135 // This only works with V8. If compiled without V8, it'll always return false. | |
| 136 WEBKIT_API static bool isDragEvent(NPObject* event); | |
| 137 | |
| 138 // Return true (success) if the given npobj is a range object. | |
| 139 // If so, return that range as a WebRange object. | |
| 140 WEBKIT_API static bool getRange(NPObject* range, WebRange*); | |
| 141 }; | |
| 142 | |
| 143 } // namespace WebKit | |
| 144 | |
| 145 #endif | |
| OLD | NEW |