Example #1
0
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
                char* argn[], char* argv[], NPSavedData* saved)
{


    gLogI.log(instance, kDebug_ANPLogType, "creating plugin");

    PluginObject *obj = NULL;

    // Scripting functions appeared in NPAPI version 14
    if (browser->version >= 14) {
        instance->pdata = browser->createobject (instance, getPluginClass());
        obj = static_cast<PluginObject*>(instance->pdata);
        bzero(obj, sizeof(*obj));
    } else {
        return NPERR_GENERIC_ERROR;
    }

    // select the drawing model
    ANPDrawingModel model = kBitmap_ANPDrawingModel;

    // notify the plugin API of the drawing model we wish to use. This must be
    // done prior to creating certain subPlugin objects (e.g. surfaceViews)
    NPError err = browser->setvalue(instance, kRequestDrawingModel_ANPSetValue,
                                    reinterpret_cast<void*>(model));
    if (err) {
        gLogI.log(instance, kError_ANPLogType, "request model %d err %d", model, err);
        return err;
    }

    // create the sub-plugin
    obj->subPlugin = new EventPlugin(instance);

    return NPERR_NO_ERROR;
}
Example #2
0
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData *saved)
{
    if (browser->version >= 14) {
        PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
        instance->pdata = obj;

        for (int16_t i = 0; i < argc; i++) {
            if (_stricmp(argn[i], "onstreamload") == 0 && !obj->onStreamLoad)
                obj->onStreamLoad = _strdup(argv[i]);
            else if (_stricmp(argn[i], "onStreamDestroy") == 0 && !obj->onStreamDestroy)
                obj->onStreamDestroy = _strdup(argv[i]);
            else if (_stricmp(argn[i], "onURLNotify") == 0 && !obj->onURLNotify)
                obj->onURLNotify = _strdup(argv[i]);
            else if (_stricmp(argn[i], "onDestroy") == 0 && !obj->onDestroy)
                obj->onDestroy = _strdup(argv[i]);
            else if (_stricmp(argn[i], "logSrc") == 0) {
                for (int i = 0; i < argc; i++)
                    if (_stricmp(argn[i], "src") == 0)
                        pluginLog(instance, "src: %s", argv[i]);
            } else if (_stricmp(argn[i], "testdocumentopenindestroystream") == 0)
                obj->testDocumentOpenInDestroyStream = TRUE;
            else if (_stricmp(argn[i], "testGetURLOnDestroy") == 0)
                obj->testGetURLOnDestroy = TRUE;
            else if (_stricmp(argn[i], "testwindowopen") == 0)
                obj->testWindowOpen = TRUE;
            else if (_stricmp(argn[i], "onSetWindow") == 0 && !obj->onSetWindow)
                obj->onSetWindow = strdup(argv[i]);
        }

        browser->getvalue(instance, NPNVprivateModeBool, (void *)&obj->cachedPrivateBrowsingMode);
    }

    return NPERR_NO_ERROR;
}
Example #3
0
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
{
    if (browser->version >= 14)
        instance->pdata = browser->createobject (instance, getPluginClass());

    return NPERR_NO_ERROR;
}
Example #4
0
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
{
    // Scripting functions appeared in NPAPI version 14
    if (browser->version >= 14)
        instance->pdata = browser->createobject (instance, getPluginClass());

    // Start up QuickTime.
    EnterMovies();
    
    return NPERR_NO_ERROR;
}
Example #5
0
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char *argn[], char *argv[], NPSavedData *saved)
{
#if USE_COCOA_EVENT_MODEL
    // If the browser supports the Cocoa event model, enable it.
    NPBool supportsCocoa;
    if (browser->getvalue(instance, NPNVsupportsCocoaBool, &supportsCocoa) != NPERR_NO_ERROR)
        supportsCocoa = FALSE;

    if (!supportsCocoa)
        return NPERR_INCOMPATIBLE_VERSION_ERROR;

    browser->setvalue(instance, NPPVpluginEventModel, (void *)NPEventModelCocoa);
#endif

    if (browser->version >= 14) {
        PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
 
        for (int i = 0; i < argc; i++) {
            if (strcasecmp(argn[i], "onstreamload") == 0 && !obj->onStreamLoad)
                obj->onStreamLoad = strdup(argv[i]);
            else if (strcasecmp(argn[i], "onStreamDestroy") == 0 && !obj->onStreamDestroy)
                obj->onStreamDestroy = strdup(argv[i]);
            else if (strcasecmp(argn[i], "onURLNotify") == 0 && !obj->onURLNotify)
                obj->onURLNotify = strdup(argv[i]);
            else if (strcasecmp(argn[i], "src") == 0 &&
                     strcasecmp(argv[i], "data:application/x-webkit-test-netscape,returnerrorfromnewstream") == 0)
                obj->returnErrorFromNewStream = TRUE;
            else if (strcasecmp(argn[i], "logfirstsetwindow") == 0)
                obj->logSetWindow = TRUE;
        }
        
        instance->pdata = obj;
    }
    
    return NPERR_NO_ERROR;
}
Example #6
0
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char *argn[], char *argv[], NPSavedData *saved)
{
    bool forceCarbon = false;

    // Always turn on the CG model
    NPBool supportsCoreGraphics;
    if (browser->getvalue(instance, NPNVsupportsCoreGraphicsBool, &supportsCoreGraphics) != NPERR_NO_ERROR)
        supportsCoreGraphics = false;
    
    if (!supportsCoreGraphics)
        return NPERR_INCOMPATIBLE_VERSION_ERROR;
    
    browser->setvalue(instance, NPPVpluginDrawingModel, (void *)NPDrawingModelCoreGraphics);

    PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
    instance->pdata = obj;

    for (int i = 0; i < argc; i++) {
        if (strcasecmp(argn[i], "onstreamload") == 0 && !obj->onStreamLoad)
            obj->onStreamLoad = strdup(argv[i]);
        else if (strcasecmp(argn[i], "onStreamDestroy") == 0 && !obj->onStreamDestroy)
            obj->onStreamDestroy = strdup(argv[i]);
        else if (strcasecmp(argn[i], "onURLNotify") == 0 && !obj->onURLNotify)
            obj->onURLNotify = strdup(argv[i]);
        else if (strcasecmp(argn[i], "src") == 0 &&
                 strcasecmp(argv[i], "data:application/x-webkit-test-netscape,returnerrorfromnewstream") == 0)
            obj->returnErrorFromNewStream = TRUE;
        else if (strcasecmp(argn[i], "logfirstsetwindow") == 0)
            obj->logSetWindow = TRUE;
        else if (strcasecmp(argn[i], "testnpruntime") == 0)
            testNPRuntime(instance);
        else if (strcasecmp(argn[i], "forcecarbon") == 0)
            forceCarbon = true;
        else if (strcasecmp(argn[i], "logSrc") == 0) {
            for (int i = 0; i < argc; i++)
                if (strcasecmp(argn[i], "src") == 0)
                    pluginLog(instance, "src: %s", argv[i]);
        } else if (strcasecmp(argn[i], "cleardocumentduringnew") == 0)
            executeScript(obj, "document.body.innerHTML = ''");
    }
        
#ifndef NP_NO_CARBON
    NPBool supportsCarbon = false;
#endif
    NPBool supportsCocoa = false;

#ifndef NP_NO_CARBON
    if (browser->getvalue(instance, NPNVsupportsCarbonBool, &supportsCarbon) != NPERR_NO_ERROR)
        supportsCarbon = false;
#endif

    if (browser->getvalue(instance, NPNVsupportsCocoaBool, &supportsCocoa) != NPERR_NO_ERROR)
        supportsCocoa = false;

    if (supportsCocoa && !forceCarbon) {
        obj->eventModel = NPEventModelCocoa;
#ifndef NP_NO_CARBON
    } else if (supportsCarbon) {
        obj->eventModel = NPEventModelCarbon;
#endif
    } else {
        return NPERR_INCOMPATIBLE_VERSION_ERROR;
    }
    
    browser->setvalue(instance, NPPVpluginEventModel, (void *)obj->eventModel);
    return NPERR_NO_ERROR;
}
Example #7
0
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc,
                char* argn[], char* argv[], NPSavedData* saved)
{

	NPBool supportsWindowless = FALSE;

	 //	NPP_SetValue(instance, NPNVSupportsWindowless, (void*)false);
    /* BEGIN: STANDARD PLUGIN FRAMEWORK */
    PluginObject *obj = NULL;

    // Scripting functions appeared in NPAPI version 14
    if (browser->version >= 14) {
        instance->pdata = browser->createobject (instance, getPluginClass());
        obj = static_cast<PluginObject*>(instance->pdata);
        obj->pluginType = 0;
    }
    /* END: STANDARD PLUGIN FRAMEWORK */

    // select the drawing model based on user input
    ANPDrawingModel model = kBitmap_ANPDrawingModel;

    for (int i = 0; i < argc; i++) {
        if (!strcmp(argn[i], "DrawingModel")) {
            if (!strcmp(argv[i], "Bitmap")) {
                model = kBitmap_ANPDrawingModel;
            }
            else if (!strcmp(argv[i], "Surface")) {
               model = kSurface_ANPDrawingModel;
            }
            else if (!strcmp(argv[i], "OpenGL")) {
               model = kOpenGL_ANPDrawingModel;
            }
            gLogI.log(kDebug_ANPLogType, "------ %p DrawingModel is %d", instance, model);
            break;
        }
    }

    // notify the plugin API of the drawing model we wish to use. This must be
    // done prior to creating certain subPlugin objects (e.g. surfaceViews)
    NPError err = browser->setvalue(instance, kRequestDrawingModel_ANPSetValue,
                            reinterpret_cast<void*>(model));
    if (err) {
        gLogI.log(kError_ANPLogType, "request model %d err %d", model, err);
        return err;
    }

    const char* path = gSystemI.getApplicationDataDirectory();
    if (path) {
        gLogI.log(kDebug_ANPLogType, "Application data dir is %s", path);
    } else {
        gLogI.log(kError_ANPLogType, "Can't find Application data dir");
    }

    // select the pluginType
    for (int i = 0; i < argc; i++) {
        if (!strcmp(argn[i], "PluginType")) {
            if (!strcmp(argv[i], "Animation")) {
                obj->pluginType = kAnimation_PluginType;
                obj->activePlugin = new BallAnimation(instance);
            }
            else if (!strcmp(argv[i], "Audio")) {
                obj->pluginType = kAudio_PluginType;
                obj->activePlugin = new AudioPlugin(instance);
            }
            else if (!strcmp(argv[i], "Background")) {
                obj->pluginType = kBackground_PluginType;
                obj->activePlugin = new BackgroundPlugin(instance);
            }
            else if (!strcmp(argv[i], "Form")) {
                obj->pluginType = kForm_PluginType;
                obj->activePlugin = new FormPlugin(instance);
            }
            else if (!strcmp(argv[i], "Navigation")) {
                obj->pluginType = kNavigation_PluginType;
                obj->activePlugin = new NavigationPlugin(instance);
            }
            else if (!strcmp(argv[i], "Paint")) {
                obj->pluginType = kPaint_PluginType;
                obj->activePlugin = new PaintPlugin(instance);
            }
            else if (!strcmp(argv[i], "Video")) {
                obj->pluginType = kVideo_PluginType;
                obj->activePlugin = new VideoPlugin(instance);
            }
            else {
                gLogI.log(kError_ANPLogType, "PluginType %s unknown!", argv[i]);
            }
            break;
        }
    }

    // if no pluginType is specified then default to Animation
    if (!obj->pluginType) {
        gLogI.log(kError_ANPLogType, "------ %p No PluginType attribute was found", instance);
        obj->pluginType = kAnimation_PluginType;
        obj->activePlugin = new BallAnimation(instance);
    }

    gLogI.log(kDebug_ANPLogType, "------ %p PluginType is %d", instance, obj->pluginType);

    // check to ensure the pluginType supports the model
    if (!obj->activePlugin->supportsDrawingModel(model)) {
        gLogI.log(kError_ANPLogType, "------ %p Unsupported DrawingModel (%d)", instance, model);
        return NPERR_GENERIC_ERROR;
    }

    // if the plugin uses the surface drawing model then set the java context
    if (model == kSurface_ANPDrawingModel || model == kOpenGL_ANPDrawingModel) {
        SurfaceSubPlugin* surfacePlugin = static_cast<SurfaceSubPlugin*>(obj->activePlugin);

        jobject context;
        NPError err = browser->getvalue(instance, kJavaContext_ANPGetValue,
                                        static_cast<void*>(&context));
        if (err) {
            gLogI.log(kError_ANPLogType, "request context err: %d", err);
            return err;
        }

        surfacePlugin->setContext(context);
    }


    return NPERR_NO_ERROR;
}