static NPError NPN_GetValueForURL(NPP npp, NPNURLVariable variable, const char* url, char** value, uint32_t* len) { if (!value || !len) return NPERR_GENERIC_ERROR; switch (variable) { case NPNURLVCookie: { RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); PluginDestructionProtector protector(plugin.get()); String cookies = plugin->cookiesForURL(makeURLString(url)); if (cookies.isNull()) return NPERR_GENERIC_ERROR; return copyCString(cookies.utf8(), value, len); } case NPNURLVProxy: { RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); PluginDestructionProtector protector(plugin.get()); String proxies = plugin->proxiesForURL(makeURLString(url)); if (proxies.isNull()) return NPERR_GENERIC_ERROR; return copyCString(proxies.utf8(), value, len); } default: notImplemented(); return NPERR_GENERIC_ERROR; } }
static NPError NPN_GetURLNotify(NPP npp, const char* url, const char* target, void* notifyData) { if (!url) return NPERR_GENERIC_ERROR; RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); plugin->loadURL("GET", makeURLString(url), target, HTTPHeaderMap(), Vector<uint8_t>(), true, notifyData); return NPERR_NO_ERROR; }
static NPError NPN_PostURLNotify(NPP npp, const char* url, const char* target, uint32_t len, const char* buf, NPBool file, void* notifyData) { HTTPHeaderMap headerFields; Vector<uint8_t> postData; NPError error = parsePostBuffer(file, buf, len, true, headerFields, postData); if (error != NPERR_NO_ERROR) return error; RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); plugin->loadURL("POST", makeURLString(url), target, headerFields, postData, true, notifyData); return NPERR_NO_ERROR; }
static NPError NPN_PostURL(NPP npp, const char* url, const char* target, uint32_t len, const char* buf, NPBool file) { HTTPHeaderMap headerFields; Vector<uint8_t> postData; // NPN_PostURL only allows headers if the post buffer points to a file. bool parseHeaders = file; NPError error = parsePostBuffer(file, buf, len, parseHeaders, headerFields, postData); if (error != NPERR_NO_ERROR) return error; RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); plugin->loadURL("POST", makeURLString(url), target, headerFields, postData, false, 0); return NPERR_NO_ERROR; }
static NPError NPN_SetValueForURL(NPP npp, NPNURLVariable variable, const char* url, const char* value, uint32_t len) { switch (variable) { case NPNURLVCookie: { RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); plugin->setCookiesForURL(makeURLString(url), String(value, len)); return NPERR_NO_ERROR; } case NPNURLVProxy: // Can't set the proxy for a URL. return NPERR_GENERIC_ERROR; default: notImplemented(); return NPERR_GENERIC_ERROR; } }