| OLD | NEW |
| (Empty) |
| 1 // Copyright 2009 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 // | |
| 16 // Normally, implementations of these functions are provided by the NPAPI | |
| 17 // runtime. These stub implementations are intended only for use in unit tests. | |
| 18 | |
| 19 #ifndef OMAHA_PLUGINS_UPDATE_NPAPI_TESTING_STUBS_H_ | |
| 20 #define OMAHA_PLUGINS_UPDATE_NPAPI_TESTING_STUBS_H_ | |
| 21 | |
| 22 #include <vector> | |
| 23 #include "third_party/npapi/bindings/nphostapi.h" | |
| 24 | |
| 25 namespace omaha { | |
| 26 | |
| 27 // Not part of NPAPI proper, but useful nonetheless. Note that the stub | |
| 28 // implementation of NPIdentifier does not conform to NPAPI's idea of what an | |
| 29 // NPIdentifier ought to be: specifically, uniqueness is not guaranteed. | |
| 30 class NPIdentifierFactory { | |
| 31 public: | |
| 32 NPIdentifierFactory(); | |
| 33 ~NPIdentifierFactory(); | |
| 34 NPIdentifier Create(const char* name); | |
| 35 | |
| 36 private: | |
| 37 std::vector<NPIdentifier> identifiers_; | |
| 38 | |
| 39 DISALLOW_COPY_AND_ASSIGN(NPIdentifierFactory); | |
| 40 }; | |
| 41 | |
| 42 } // namespace omaha | |
| 43 | |
| 44 extern "C" { | |
| 45 void* NPN_MemAlloc(uint32 size); | |
| 46 void NPN_MemFree(void* ptr); | |
| 47 NPUTF8* NPN_UTF8FromIdentifier(NPIdentifier identifier); | |
| 48 NPObject* NPN_CreateObject(NPP npp, NPClass* class_vtable); | |
| 49 NPObject* NPN_RetainObject(NPObject* object); | |
| 50 void NPN_ReleaseObject(NPObject* object); | |
| 51 void NPN_ReleaseVariantValue(NPVariant* variant); | |
| 52 | |
| 53 bool NPN_HasMethod(NPP npp, NPObject* object, NPIdentifier name); | |
| 54 bool NPN_Invoke(NPP npp, NPObject* object, NPIdentifier name, | |
| 55 const NPVariant* args, uint32_t arg_count, NPVariant* result); | |
| 56 bool NPN_InvokeDefault(NPP npp, NPObject* object, const NPVariant* args, | |
| 57 uint32_t arg_count, NPVariant* result); | |
| 58 bool NPN_HasProperty(NPP npp, NPObject* object, NPIdentifier name); | |
| 59 bool NPN_GetProperty(NPP npp, NPObject* object, NPIdentifier name, | |
| 60 NPVariant* result); | |
| 61 bool NPN_SetProperty(NPP npp, NPObject* object, NPIdentifier name, | |
| 62 const NPVariant* value); | |
| 63 bool NPN_RemoveProperty(NPP npp, NPObject* object, NPIdentifier name); | |
| 64 bool NPN_Enumerate(NPP npp, NPObject* object, NPIdentifier** names, | |
| 65 uint32_t* count); | |
| 66 bool NPN_Construct(NPP npp, NPObject* object, const NPVariant* args, | |
| 67 uint32_t arg_count, NPVariant* result); | |
| 68 void NPN_SetException(NPObject* object, const NPUTF8* message); | |
| 69 } // extern "C" | |
| 70 | |
| 71 #endif // OMAHA_PLUGINS_UPDATE_NPAPI_TESTING_STUBS_H_ | |
| 72 | |
| OLD | NEW |