⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webnetscapepluginpackage.mm

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 MM
📖 第 1 页 / 共 2 页
字号:
            if (!NP_Initialize || !NP_GetEntryPoints || !NP_Shutdown)                return NO;#ifdef SUPPORT_CFM        }    } else {        // single CFM file        FSSpec spec;        FSRef fref;        OSErr err;                err = FSPathMakeRef((UInt8 *)[path fileSystemRepresentation], &fref, NULL);        if (err != noErr) {            LOG_ERROR("FSPathMakeRef failed. Error=%d", err);            return NO;        }        err = FSGetCatalogInfo(&fref, kFSCatInfoNone, NULL, NULL, &spec, NULL);        if (err != noErr) {            LOG_ERROR("FSGetCatalogInfo failed. Error=%d", err);            return NO;        }        err = WebGetDiskFragment(&spec, 0, kCFragGoesToEOF, nil, kPrivateCFragCopy, &connID, (Ptr *)&pluginMainFunc, nil);        if (err != noErr) {            LOG_ERROR("WebGetDiskFragment failed. Error=%d", err);            return NO;        }#if !LOG_DISABLED        currentTime = CFAbsoluteTimeGetCurrent();        duration = currentTime - start;#endif        LOG(Plugins, "%f WebGetDiskFragment took %f seconds", currentTime, duration);        isLoaded = YES;                pluginMainFunc = (MainFuncPtr)functionPointerForTVector((TransitionVector)pluginMainFunc);        if (!pluginMainFunc) {            return NO;        }        // NOTE: pluginMainFunc is freed after it is called. Be sure not to return before that.                isCFM = YES;    }#endif /* SUPPORT_CFM */        // Plugins (at least QT) require that you call UseResFile on the resource file before loading it.    resourceRef = [self openResourceFile];    if (resourceRef != -1) {        UseResFile(resourceRef);    }        // swap function tables#ifdef SUPPORT_CFM    if (isCFM) {        browserFuncs.version = NP_VERSION_MINOR;        browserFuncs.size = sizeof(NPNetscapeFuncs);        browserFuncs.geturl = (NPN_GetURLProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_GetURL);        browserFuncs.posturl = (NPN_PostURLProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PostURL);        browserFuncs.requestread = (NPN_RequestReadProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_RequestRead);        browserFuncs.newstream = (NPN_NewStreamProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_NewStream);        browserFuncs.write = (NPN_WriteProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_Write);        browserFuncs.destroystream = (NPN_DestroyStreamProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_DestroyStream);        browserFuncs.status = (NPN_StatusProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_Status);        browserFuncs.uagent = (NPN_UserAgentProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_UserAgent);        browserFuncs.memalloc = (NPN_MemAllocProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_MemAlloc);        browserFuncs.memfree = (NPN_MemFreeProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_MemFree);        browserFuncs.memflush = (NPN_MemFlushProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_MemFlush);        browserFuncs.reloadplugins = (NPN_ReloadPluginsProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_ReloadPlugins);        browserFuncs.geturlnotify = (NPN_GetURLNotifyProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_GetURLNotify);        browserFuncs.posturlnotify = (NPN_PostURLNotifyProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PostURLNotify);        browserFuncs.getvalue = (NPN_GetValueProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_GetValue);        browserFuncs.setvalue = (NPN_SetValueProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_SetValue);        browserFuncs.invalidaterect = (NPN_InvalidateRectProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_InvalidateRect);        browserFuncs.invalidateregion = (NPN_InvalidateRegionProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_InvalidateRegion);        browserFuncs.forceredraw = (NPN_ForceRedrawProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_ForceRedraw);        browserFuncs.getJavaEnv = (NPN_GetJavaEnvProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_GetJavaEnv);        browserFuncs.getJavaPeer = (NPN_GetJavaPeerProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_GetJavaPeer);        browserFuncs.pushpopupsenabledstate = (NPN_PushPopupsEnabledStateProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PushPopupsEnabledState);        browserFuncs.poppopupsenabledstate = (NPN_PopPopupsEnabledStateProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PopPopupsEnabledState);        browserFuncs.pluginthreadasynccall = (NPN_PluginThreadAsyncCallProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PluginThreadAsyncCall);        browserFuncs.scheduletimer = (NPN_ScheduleTimerProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_ScheduleTimer);        browserFuncs.unscheduletimer = (NPN_UnscheduleTimerProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_UnscheduleTimer);        browserFuncs.popupcontextmenu = (NPN_PopUpContextMenuProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PopUpContextMenu);                browserFuncs.releasevariantvalue = (NPN_ReleaseVariantValueProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_ReleaseVariantValue);        browserFuncs.getstringidentifier = (NPN_GetStringIdentifierProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_GetStringIdentifier);        browserFuncs.getstringidentifiers = (NPN_GetStringIdentifiersProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_GetStringIdentifiers);        browserFuncs.getintidentifier = (NPN_GetIntIdentifierProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_GetIntIdentifier);        browserFuncs.identifierisstring = (NPN_IdentifierIsStringProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_IdentifierIsString);        browserFuncs.utf8fromidentifier = (NPN_UTF8FromIdentifierProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_UTF8FromIdentifier);        browserFuncs.intfromidentifier = (NPN_IntFromIdentifierProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_IntFromIdentifier);        browserFuncs.createobject = (NPN_CreateObjectProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_CreateObject);        browserFuncs.retainobject = (NPN_RetainObjectProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_RetainObject);        browserFuncs.releaseobject = (NPN_ReleaseObjectProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_ReleaseObject);        browserFuncs.hasmethod = (NPN_HasMethodProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_HasProperty);        browserFuncs.invoke = (NPN_InvokeProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_Invoke);        browserFuncs.invokeDefault = (NPN_InvokeDefaultProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_InvokeDefault);        browserFuncs.evaluate = (NPN_EvaluateProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_Evaluate);        browserFuncs.hasproperty = (NPN_HasPropertyProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_HasProperty);        browserFuncs.getproperty = (NPN_GetPropertyProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_GetProperty);        browserFuncs.setproperty = (NPN_SetPropertyProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_SetProperty);        browserFuncs.removeproperty = (NPN_RemovePropertyProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_RemoveProperty);        browserFuncs.setexception = (NPN_SetExceptionProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_SetException);        browserFuncs.enumerate = (NPN_EnumerateProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_Enumerate);        browserFuncs.construct = (NPN_ConstructProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_Construct);                [self _applyDjVuWorkaround];        #if !LOG_DISABLED        CFAbsoluteTime mainStart = CFAbsoluteTimeGetCurrent();#endif        LOG(Plugins, "%f main timing started", mainStart);        NPP_ShutdownProcPtr shutdownFunction;        npErr = pluginMainFunc(&browserFuncs, &pluginFuncs, &shutdownFunction);        NP_Shutdown = (NPP_ShutdownProcPtr)functionPointerForTVector((TransitionVector)shutdownFunction);        if (!isBundle)            // Don't free pluginMainFunc if we got it from a bundle because it is owned by CFBundle in that case.            free(reinterpret_cast<void*>(pluginMainFunc));                // Workaround for 3270576. The RealPlayer plug-in fails to load if its preference file is out of date.        // Launch the RealPlayer application to refresh the file.        if (npErr != NPERR_NO_ERROR) {            if (npErr == NPERR_MODULE_LOAD_FAILED_ERROR && [[self filename] isEqualToString:RealPlayerPluginFilename])                [self launchRealPlayer];            return NO;        }#if !LOG_DISABLED        currentTime = CFAbsoluteTimeGetCurrent();        duration = currentTime - mainStart;#endif        LOG(Plugins, "%f main took %f seconds", currentTime, duration);                pluginSize = pluginFuncs.size;        pluginVersion = pluginFuncs.version;        LOG(Plugins, "pluginMainFunc: %d, size=%d, version=%d", npErr, pluginSize, pluginVersion);                pluginFuncs.newp = (NPP_NewProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.newp);        pluginFuncs.destroy = (NPP_DestroyProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.destroy);        pluginFuncs.setwindow = (NPP_SetWindowProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.setwindow);        pluginFuncs.newstream = (NPP_NewStreamProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.newstream);        pluginFuncs.destroystream = (NPP_DestroyStreamProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.destroystream);        pluginFuncs.asfile = (NPP_StreamAsFileProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.asfile);        pluginFuncs.writeready = (NPP_WriteReadyProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.writeready);        pluginFuncs.write = (NPP_WriteProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.write);        pluginFuncs.print = (NPP_PrintProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.print);        pluginFuncs.event = (NPP_HandleEventProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.event);        pluginFuncs.urlnotify = (NPP_URLNotifyProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.urlnotify);        pluginFuncs.getvalue = (NPP_GetValueProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.getvalue);        pluginFuncs.setvalue = (NPP_SetValueProcPtr)functionPointerForTVector((TransitionVector)pluginFuncs.setvalue);        // LiveConnect support        pluginFuncs.javaClass = (JRIGlobalRef)functionPointerForTVector((TransitionVector)pluginFuncs.javaClass);        if (pluginFuncs.javaClass) {            LOG(LiveConnect, "%@:  CFM entry point for NPP_GetJavaClass = %p", [self name], pluginFuncs.javaClass);        } else {            LOG(LiveConnect, "%@:  no entry point for NPP_GetJavaClass", [self name]);        }    } else {#endif        // no function pointer conversion necessary for Mach-O        browserFuncs.version = NP_VERSION_MINOR;        browserFuncs.size = sizeof(NPNetscapeFuncs);        browserFuncs.geturl = NPN_GetURL;        browserFuncs.posturl = NPN_PostURL;        browserFuncs.requestread = NPN_RequestRead;        browserFuncs.newstream = NPN_NewStream;        browserFuncs.write = NPN_Write;        browserFuncs.destroystream = NPN_DestroyStream;        browserFuncs.status = NPN_Status;        browserFuncs.uagent = NPN_UserAgent;        browserFuncs.memalloc = NPN_MemAlloc;        browserFuncs.memfree = NPN_MemFree;        browserFuncs.memflush = NPN_MemFlush;        browserFuncs.reloadplugins = NPN_ReloadPlugins;        browserFuncs.geturlnotify = NPN_GetURLNotify;        browserFuncs.posturlnotify = NPN_PostURLNotify;        browserFuncs.getvalue = NPN_GetValue;        browserFuncs.setvalue = NPN_SetValue;        browserFuncs.invalidaterect = NPN_InvalidateRect;        browserFuncs.invalidateregion = NPN_InvalidateRegion;        browserFuncs.forceredraw = NPN_ForceRedraw;        browserFuncs.getJavaEnv = NPN_GetJavaEnv;        browserFuncs.getJavaPeer = NPN_GetJavaPeer;        browserFuncs.pushpopupsenabledstate = NPN_PushPopupsEnabledState;        browserFuncs.poppopupsenabledstate = NPN_PopPopupsEnabledState;        browserFuncs.pluginthreadasynccall = NPN_PluginThreadAsyncCall;        browserFuncs.scheduletimer = NPN_ScheduleTimer;        browserFuncs.unscheduletimer = NPN_UnscheduleTimer;        browserFuncs.popupcontextmenu = NPN_PopUpContextMenu;                browserFuncs.releasevariantvalue = _NPN_ReleaseVariantValue;        browserFuncs.getstringidentifier = _NPN_GetStringIdentifier;        browserFuncs.getstringidentifiers = _NPN_GetStringIdentifiers;        browserFuncs.getintidentifier = _NPN_GetIntIdentifier;        browserFuncs.identifierisstring = _NPN_IdentifierIsString;        browserFuncs.utf8fromidentifier = _NPN_UTF8FromIdentifier;        browserFuncs.intfromidentifier = _NPN_IntFromIdentifier;        browserFuncs.createobject = _NPN_CreateObject;        browserFuncs.retainobject = _NPN_RetainObject;        browserFuncs.releaseobject = _NPN_ReleaseObject;        browserFuncs.hasmethod = _NPN_HasMethod;        browserFuncs.invoke = _NPN_Invoke;        browserFuncs.invokeDefault = _NPN_InvokeDefault;        browserFuncs.evaluate = _NPN_Evaluate;        browserFuncs.hasproperty = _NPN_HasProperty;        browserFuncs.getproperty = _NPN_GetProperty;        browserFuncs.setproperty = _NPN_SetProperty;        browserFuncs.removeproperty = _NPN_RemoveProperty;        browserFuncs.setexception = _NPN_SetException;        browserFuncs.enumerate = _NPN_Enumerate;        browserFuncs.construct = _NPN_Construct;                [self _applyDjVuWorkaround];#if !LOG_DISABLED        CFAbsoluteTime initializeStart = CFAbsoluteTimeGetCurrent();#endif        LOG(Plugins, "%f NP_Initialize timing started", initializeStart);        npErr = NP_Initialize(&browserFuncs);        if (npErr != NPERR_NO_ERROR)            return NO;#if !LOG_DISABLED        currentTime = CFAbsoluteTimeGetCurrent();        duration = currentTime - initializeStart;#endif        LOG(Plugins, "%f NP_Initialize took %f seconds", currentTime, duration);        pluginFuncs.size = sizeof(NPPluginFuncs);                npErr = NP_GetEntryPoints(&pluginFuncs);        if (npErr != NPERR_NO_ERROR)            return NO;                pluginSize = pluginFuncs.size;        pluginVersion = pluginFuncs.version;                if (pluginFuncs.javaClass)            LOG(LiveConnect, "%@:  mach-o entry point for NPP_GetJavaClass = %p", [self name], pluginFuncs.javaClass);        else            LOG(LiveConnect, "%@:  no entry point for NPP_GetJavaClass", [self name]);#ifdef SUPPORT_CFM    }#endif#if !LOG_DISABLED    currentTime = CFAbsoluteTimeGetCurrent();    duration = currentTime - start;#endif    LOG(Plugins, "%f Total load time: %f seconds", currentTime, duration);    return YES;}- (BOOL)load{        if ([self _tryLoad])        return [super load];    [self _unloadWithShutdown:NO];    return NO;}- (NPPluginFuncs *)pluginFuncs{    return &pluginFuncs;}- (void)wasRemovedFromPluginDatabase:(WebPluginDatabase *)database{    [super wasRemovedFromPluginDatabase:database];        // Unload when removed from final plug-in database    if ([pluginDatabases count] == 0)        [self _unloadWithShutdown:YES];}- (void)open{    instanceCount++;        // Handle the case where all instances close a plug-in package, but another    // instance opens the package before it is unloaded (which only happens when    // the plug-in database is refreshed)    needsUnload = NO;        if (!isLoaded) {        // Should load when the first instance opens the plug-in package        ASSERT(instanceCount == 1);        [self load];    }}- (void)close{    ASSERT(instanceCount > 0);    instanceCount--;    if (instanceCount == 0 && needsUnload)        [self _unloadWithShutdown:YES];}@end#ifdef SUPPORT_CFM// function pointer convertersFunctionPointer functionPointerForTVector(TransitionVector tvp){    const uint32 temp[6] = {0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420};    uint32 *newGlue = NULL;    if (tvp != NULL) {        newGlue = (uint32 *)malloc(sizeof(temp));        if (newGlue != NULL) {            unsigned i;            for (i = 0; i < 6; i++) newGlue[i] = temp[i];            newGlue[0] |= ((uintptr_t)tvp >> 16);            newGlue[1] |= ((uintptr_t)tvp & 0xFFFF);            MakeDataExecutable(newGlue, sizeof(temp));        }    }        return (FunctionPointer)newGlue;}TransitionVector tVectorForFunctionPointer(FunctionPointer fp){    FunctionPointer *newGlue = NULL;    if (fp != NULL) {        newGlue = (FunctionPointer *)malloc(2 * sizeof(FunctionPointer));        if (newGlue != NULL) {            newGlue[0] = fp;            newGlue[1] = NULL;        }    }    return (TransitionVector)newGlue;}#endif@implementation WebNetscapePluginPackage (Internal)- (void)_unloadWithShutdown:(BOOL)shutdown{    if (!isLoaded)        return;        LOG(Plugins, "Unloading %@...", name);    // Cannot unload a plug-in package while an instance is still using it    if (instanceCount > 0) {        needsUnload = YES;        return;    }    if (shutdown && NP_Shutdown)        NP_Shutdown();    if (resourceRef != -1)        [self closeResourceFile:resourceRef];#ifdef SUPPORT_CFM    if (isBundle)#endif        CFBundleUnloadExecutable(cfBundle);#ifdef SUPPORT_CFM    else        WebCloseConnection(&connID);#endif    LOG(Plugins, "Plugin Unloaded");    isLoaded = NO;}@end#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -