diff options
Diffstat (limited to 'Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp')
-rw-r--r-- | Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp | 106 |
1 files changed, 59 insertions, 47 deletions
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp index f1f3d1878..00bd6cd83 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp @@ -32,13 +32,23 @@ #include "NetscapePlugin.h" #include "PluginController.h" #include <WebCore/HTTPHeaderMap.h> +#include <WebCore/HTTPHeaderNames.h> #include <WebCore/IdentifierRep.h> #include <WebCore/NotImplemented.h> #include <WebCore/ProtectionSpace.h> #include <WebCore/SharedBuffer.h> +#include <memory> #include <utility> #include <wtf/text/StringBuilder.h> +#if PLATFORM(COCOA) +#include <WebCore/MachSendRight.h> +#endif + +#if PLUGIN_ARCHITECTURE(X11) +#include <WebCore/PlatformDisplayX11.h> +#endif + using namespace WebCore; namespace WebKit { @@ -49,11 +59,11 @@ public: explicit PluginDestructionProtector(NetscapePlugin* plugin) { if (plugin) - m_protector = adoptPtr(new PluginController::PluginDestructionProtector(static_cast<Plugin*>(plugin)->controller())); + m_protector = std::make_unique<PluginController::PluginDestructionProtector>(static_cast<Plugin*>(plugin)->controller()); } private: - OwnPtr<PluginController::PluginDestructionProtector> m_protector; + std::unique_ptr<PluginController::PluginDestructionProtector> m_protector; }; static bool startsWithBlankLine(const char* bytes, unsigned length) @@ -121,25 +131,13 @@ static String capitalizeRFC822HeaderFieldName(const String& name) { bool capitalizeCharacter = true; StringBuilder result; - for (unsigned i = 0; i < name.length(); i++) { - UChar c; - - if (capitalizeCharacter && name[i] >= 'a' && name[i] <= 'z') - c = toASCIIUpper(name[i]); - else if (!capitalizeCharacter && name[i] >= 'A' && name[i] <= 'Z') - c = toASCIILower(name[i]); - else - c = name[i]; - + result.append(capitalizeCharacter ? toASCIIUpper(name[i]) : toASCIILower(name[i])); if (name[i] == '-') capitalizeCharacter = true; else capitalizeCharacter = false; - - result.append(c); } - return result.toString(); } @@ -195,7 +193,7 @@ static HTTPHeaderMap parseRFC822HeaderFields(const char* bytes, unsigned length) break; } if (colon == endOfLine) - value = ""; + value = emptyString(); else value = String(colon, endOfLine - colon); @@ -244,15 +242,14 @@ static NPError parsePostBuffer(bool isFile, const char *buffer, uint32_t length, // Sometimes plugins like to set Content-Length themselves when they post, // but WebFoundation does not like that. So we will remove the header // and instead truncate the data to the requested length. - String contentLength = headerFields.get("Content-Length"); + String contentLength = headerFields.get(HTTPHeaderName::ContentLength); if (!contentLength.isNull()) dataLength = std::min(contentLength.toInt(), (int)dataLength); - headerFields.remove("Content-Length"); + headerFields.remove(HTTPHeaderName::ContentLength); postBuffer += location; postBufferSize = dataLength; - } } } @@ -298,7 +295,7 @@ static NPError NPN_PostURL(NPP npp, const char* url, const char* target, uint32_ return error; RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); - plugin->loadURL("POST", makeURLString(url), target, headerFields, postData, false, 0); + plugin->loadURL("POST", makeURLString(url), target, WTFMove(headerFields), postData, false, 0); return NPERR_NO_ERROR; } @@ -331,7 +328,7 @@ static void NPN_Status(NPP npp, const char* message) { String statusbarText; if (!message) - statusbarText = ""; + statusbarText = emptyString(); else statusbarText = String::fromUTF8WithLatin1Fallback(message, strlen(message)); @@ -400,7 +397,7 @@ static NPError NPN_PostURLNotify(NPP npp, const char* url, const char* target, u return NPERR_NO_ERROR; } -#if PLATFORM(MAC) +#if PLATFORM(COCOA) // Whether the browser supports compositing of Core Animation plug-ins. static const unsigned WKNVSupportsCompositingCoreAnimationPluginsBool = 74656; @@ -409,8 +406,6 @@ static const unsigned WKNVExpectsNonretainedLayer = 74657; // 74658 and 74659 are no longer implemented. -static const unsigned WKNVPlugInContainer = 74660; - #endif static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value) @@ -441,7 +436,13 @@ static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value) *(NPBool*)value = plugin->isPrivateBrowsingEnabled(); break; } -#if PLATFORM(MAC) + + case NPNVmuteAudioBool: { + RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); + *(NPBool*)value = plugin->isMuted(); + break; + } +#if PLATFORM(COCOA) case NPNVsupportsCoreGraphicsBool: // Always claim to support the Core Graphics drawing model. *(NPBool*)value = true; @@ -482,7 +483,7 @@ static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value) case WKNVCALayerRenderServerPort: { RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); - *(mach_port_t*)value = plugin->compositingRenderServerPort(); + *(mach_port_t*)value = plugin->compositingRenderServerPort().sendRight(); break; } @@ -495,12 +496,6 @@ static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value) break; } - case WKNVPlugInContainer: { - RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); - *reinterpret_cast<void**>(value) = plugin->plugInContainer(); - break; - } - #ifndef NP_NO_QUICKDRAW case NPNVsupportsQuickDrawBool: // We don't support the QuickDraw drawing model. @@ -513,18 +508,21 @@ static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value) break; #endif #elif PLUGIN_ARCHITECTURE(X11) - case NPNVxDisplay: { - if (!npp) - return NPERR_GENERIC_ERROR; - *reinterpret_cast<Display**>(value) = NetscapePlugin::x11HostDisplay(); - break; - } - case NPNVSupportsXEmbedBool: - *static_cast<NPBool*>(value) = true; - break; - case NPNVSupportsWindowless: - *static_cast<NPBool*>(value) = true; - break; + case NPNVxDisplay: { + if (!npp) + return NPERR_GENERIC_ERROR; + auto& display = PlatformDisplay::sharedDisplay(); + if (display.type() != PlatformDisplay::Type::X11) + return NPERR_GENERIC_ERROR; + *reinterpret_cast<Display**>(value) = downcast<PlatformDisplayX11>(display).native(); + break; + } + case NPNVSupportsXEmbedBool: + *static_cast<NPBool*>(value) = PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11; + break; + case NPNVSupportsWindowless: + *static_cast<NPBool*>(value) = true; + break; case NPNVToolkit: { // Gtk based plugins need to be assured about the toolkit version. @@ -546,7 +544,7 @@ static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value) static NPError NPN_SetValue(NPP npp, NPPVariable variable, void *value) { switch (variable) { -#if PLATFORM(MAC) +#if PLATFORM(COCOA) case NPPVpluginDrawingModel: { RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); @@ -574,6 +572,12 @@ static NPError NPN_SetValue(NPP npp, NPPVariable variable, void *value) return NPERR_NO_ERROR; } + case NPPVpluginIsPlayingAudio: { + RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); + plugin->setIsPlayingAudio(value); + return NPERR_NO_ERROR; + } + default: notImplemented(); return NPERR_GENERIC_ERROR; @@ -940,7 +944,7 @@ static void NPN_UnscheduleTimer(NPP npp, uint32_t timerID) plugin->unscheduleTimer(timerID); } -#if PLATFORM(MAC) +#if PLATFORM(COCOA) static NPError NPN_PopUpContextMenu(NPP npp, NPMenu* menu) { RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); @@ -966,6 +970,13 @@ static NPBool NPN_ConvertPoint(NPP npp, double sourceX, double sourceY, NPCoordi } #endif +static void NPN_URLRedirectResponse(NPP npp, void* notifyData, NPBool allow) +{ + RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); + + plugin->urlRedirectResponse(notifyData, allow); +} + static void initializeBrowserFuncs(NPNetscapeFuncs &netscapeFuncs) { netscapeFuncs.size = sizeof(NPNetscapeFuncs); @@ -1022,13 +1033,14 @@ static void initializeBrowserFuncs(NPNetscapeFuncs &netscapeFuncs) netscapeFuncs.getauthenticationinfo = NPN_GetAuthenticationInfo; netscapeFuncs.scheduletimer = NPN_ScheduleTimer; netscapeFuncs.unscheduletimer = NPN_UnscheduleTimer; -#if PLATFORM(MAC) +#if PLATFORM(COCOA) netscapeFuncs.popupcontextmenu = NPN_PopUpContextMenu; netscapeFuncs.convertpoint = NPN_ConvertPoint; #else netscapeFuncs.popupcontextmenu = 0; netscapeFuncs.convertpoint = 0; #endif + netscapeFuncs.urlredirectresponse = NPN_URLRedirectResponse; } NPNetscapeFuncs* netscapeBrowserFuncs() |