diff options
Diffstat (limited to 'Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp')
-rw-r--r-- | Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp | 193 |
1 files changed, 136 insertions, 57 deletions
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp index 5d894e754..5c9a91824 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp @@ -42,6 +42,10 @@ #include <utility> #include <wtf/text/CString.h> +#if PLUGIN_ARCHITECTURE(X11) +#include "NetscapePluginUnix.h" +#endif + using namespace WebCore; namespace WebKit { @@ -49,20 +53,21 @@ namespace WebKit { // The plug-in that we're currently calling NPP_New for. static NetscapePlugin* currentNPPNewPlugin; -PassRefPtr<NetscapePlugin> NetscapePlugin::create(PassRefPtr<NetscapePluginModule> pluginModule) +RefPtr<NetscapePlugin> NetscapePlugin::create(PassRefPtr<NetscapePluginModule> pluginModule) { if (!pluginModule) - return 0; + return nullptr; - return adoptRef(new NetscapePlugin(pluginModule)); + return adoptRef(*new NetscapePlugin(pluginModule)); } NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule) - : m_nextRequestID(0) + : Plugin(NetscapePluginType) + , m_nextRequestID(0) , m_pluginModule(pluginModule) , m_npWindow() , m_isStarted(false) -#if PLATFORM(MAC) +#if PLATFORM(COCOA) , m_isWindowed(false) #else , m_isWindowed(true) @@ -73,11 +78,11 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule) , m_hasCalledSetWindow(false) , m_isVisible(false) , m_nextTimerID(0) -#if PLATFORM(MAC) +#if PLATFORM(COCOA) , m_drawingModel(static_cast<NPDrawingModel>(-1)) , m_eventModel(static_cast<NPEventModel>(-1)) , m_pluginReturnsNonretainedLayer(!m_pluginModule->pluginQuirks().contains(PluginQuirks::ReturnsRetainedCoreAnimationLayer)) - , m_layerHostingMode(LayerHostingModeDefault) + , m_layerHostingMode(LayerHostingMode::InProcess) , m_currentMouseEvent(0) , m_pluginHasFocus(false) , m_windowHasFocus(false) @@ -89,12 +94,6 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule) , m_nullEventTimer(RunLoop::main(), this, &NetscapePlugin::nullEventTimerFired) , m_npCGContext() #endif -#elif PLUGIN_ARCHITECTURE(X11) - , m_drawable(0) - , m_pluginDisplay(0) -#if PLATFORM(GTK) - , m_platformPluginWidget(0) -#endif #endif { m_npp.ndata = this; @@ -111,10 +110,10 @@ NetscapePlugin::~NetscapePlugin() m_pluginModule->decrementLoadCount(); } -PassRefPtr<NetscapePlugin> NetscapePlugin::fromNPP(NPP npp) +RefPtr<NetscapePlugin> NetscapePlugin::fromNPP(NPP npp) { if (!npp) - return 0; + return nullptr; return static_cast<NetscapePlugin*>(npp->ndata); } @@ -147,13 +146,6 @@ const char* NetscapePlugin::userAgent(NPP npp) const char* NetscapePlugin::userAgent() { -#if PLUGIN_ARCHITECTURE(WIN) - static const char* MozillaUserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0"; - - if (quirks().contains(PluginQuirks::WantsMozillaUserAgent)) - return MozillaUserAgent; -#endif - if (m_userAgent.isNull()) { String userAgent = controller()->userAgent(); ASSERT(!userAgent.isNull()); @@ -177,10 +169,10 @@ void NetscapePlugin::loadURL(const String& method, const String& urlString, cons if (target.isNull()) { // The browser is going to send the data in a stream, create a plug-in stream. - RefPtr<NetscapePluginStream> pluginStream = NetscapePluginStream::create(this, requestID, urlString, sendNotification, notificationData); + auto pluginStream = NetscapePluginStream::create(this, requestID, urlString, sendNotification, notificationData); ASSERT(!m_streams.contains(requestID)); - m_streams.set(requestID, pluginStream.release()); + m_streams.set(requestID, WTFMove(pluginStream)); return; } @@ -254,6 +246,11 @@ bool NetscapePlugin::isPrivateBrowsingEnabled() return controller()->isPrivateBrowsingEnabled(); } +bool NetscapePlugin::isMuted() const +{ + return controller()->isMuted(); +} + NPObject* NetscapePlugin::windowScriptNPObject() { return controller()->windowScriptNPObject(); @@ -278,7 +275,7 @@ void NetscapePlugin::cancelStreamLoad(NetscapePluginStream* pluginStream) void NetscapePlugin::removePluginStream(NetscapePluginStream* pluginStream) { if (pluginStream == m_manualStream) { - m_manualStream = 0; + m_manualStream = nullptr; return; } @@ -288,11 +285,7 @@ void NetscapePlugin::removePluginStream(NetscapePluginStream* pluginStream) bool NetscapePlugin::isAcceleratedCompositingEnabled() { -#if USE(ACCELERATED_COMPOSITING) return controller()->isAcceleratedCompositingEnabled(); -#else - return false; -#endif } void NetscapePlugin::pushPopupsEnabledState(bool state) @@ -309,15 +302,12 @@ void NetscapePlugin::popPopupsEnabledState() void NetscapePlugin::pluginThreadAsyncCall(void (*function)(void*), void* userData) { - RunLoop::main()->dispatch(WTF::bind(&NetscapePlugin::handlePluginThreadAsyncCall, this, function, userData)); -} - -void NetscapePlugin::handlePluginThreadAsyncCall(void (*function)(void*), void* userData) -{ - if (!m_isStarted) - return; + RunLoop::main().dispatch([protectedThis = makeRef(*this), function, userData] { + if (!protectedThis->m_isStarted) + return; - function(userData); + function(userData); + }); } NetscapePlugin::Timer::Timer(NetscapePlugin* netscapePlugin, unsigned timerID, unsigned interval, bool repeat, TimerFunc timerFunc) @@ -369,7 +359,7 @@ uint32_t NetscapePlugin::scheduleTimer(unsigned interval, bool repeat, void (*ti // FIXME: Based on the plug-in visibility, figure out if we should throttle the timer, or if we should start it at all. timer->start(); - m_timers.set(timerID, std::move(timer)); + m_timers.set(timerID, WTFMove(timer)); return timerID; } @@ -403,7 +393,41 @@ void NetscapePlugin::setCookiesForURL(const String& urlString, const String& coo bool NetscapePlugin::getAuthenticationInfo(const ProtectionSpace& protectionSpace, String& username, String& password) { return controller()->getAuthenticationInfo(protectionSpace, username, password); -} +} + +void NetscapePlugin::registerRedirect(NetscapePluginStream* stream, const URL& requestURL, int redirectResponseStatus, void* notificationData) +{ + // NPP_URLRedirectNotify may synchronously request this stream back out, so set it first + m_redirects.set(notificationData, std::make_pair(stream, requestURL.string())); + if (!NPP_URLRedirectNotify(requestURL.string().utf8().data(), redirectResponseStatus, notificationData)) { + m_redirects.take(notificationData); + controller()->continueStreamLoad(stream->streamID()); + } +} + +void NetscapePlugin::urlRedirectResponse(void* notifyData, bool allow) +{ + if (!m_redirects.contains(notifyData)) + return; + + auto redirect = m_redirects.take(notifyData); + if (!redirect.first) + return; + + RefPtr<NetscapePluginStream> stream = redirect.first; + if (!allow) { + controller()->cancelStreamLoad(stream->streamID()); + stream->stop(NPRES_USER_BREAK); + } else { + stream->setURL(redirect.second); + controller()->continueStreamLoad(stream->streamID()); + } +} + +void NetscapePlugin::setIsPlayingAudio(bool isPlayingAudio) +{ + controller()->setPluginIsPlayingAudio(isPlayingAudio); +} NPError NetscapePlugin::NPP_New(NPMIMEType pluginType, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* savedData) { @@ -455,6 +479,15 @@ void NetscapePlugin::NPP_URLNotify(const char* url, NPReason reason, void* notif m_pluginModule->pluginFuncs().urlnotify(&m_npp, url, reason, notifyData); } +bool NetscapePlugin::NPP_URLRedirectNotify(const char* url, int32_t status, void* notifyData) +{ + if (!m_pluginModule->pluginFuncs().urlredirectnotify) + return false; + + m_pluginModule->pluginFuncs().urlredirectnotify(&m_npp, url, status, notifyData); + return true; +} + NPError NetscapePlugin::NPP_GetValue(NPPVariable variable, void *value) { if (!m_pluginModule->pluginFuncs().getvalue) @@ -572,7 +605,7 @@ static bool isTransparentSilverlightBackgroundValue(const String& lowercaseBackg } } else if (lowercaseBackgroundValue.startsWith("sc#")) { Vector<String> components; - lowercaseBackgroundValue.substring(3).split(",", components); + lowercaseBackgroundValue.substring(3).split(',', components); // An ScRGB value with alpha transparency, in the form sc#A,R,G,B. if (components.size() == 4) { @@ -604,13 +637,31 @@ bool NetscapePlugin::initialize(const Parameters& parameters) #if PLUGIN_ARCHITECTURE(MAC) if (m_pluginModule->pluginQuirks().contains(PluginQuirks::WantsLowercaseParameterNames)) - parameterName = parameterName.lower(); + parameterName = parameterName.convertToASCIILowercase(); #endif paramNames.append(parameterName.utf8()); paramValues.append(parameters.values[i].utf8()); } +#if PLUGIN_ARCHITECTURE(X11) + if (equalLettersIgnoringASCIICase(parameters.mimeType, "application/x-shockwave-flash")) { + size_t wmodeIndex = parameters.names.find("wmode"); + if (wmodeIndex != notFound) { + // Transparent window mode is not supported by X11 backend. + if (equalLettersIgnoringASCIICase(parameters.values[wmodeIndex], "transparent") + || (m_pluginModule->pluginQuirks().contains(PluginQuirks::ForceFlashWindowlessMode) && equalLettersIgnoringASCIICase(parameters.values[wmodeIndex], "window"))) + paramValues[wmodeIndex] = "opaque"; + } else if (m_pluginModule->pluginQuirks().contains(PluginQuirks::ForceFlashWindowlessMode)) { + paramNames.append("wmode"); + paramValues.append("opaque"); + } + } else if (equalLettersIgnoringASCIICase(parameters.mimeType, "application/x-webkit-test-netscape")) { + paramNames.append("windowedPlugin"); + paramValues.append("false"); + } +#endif + // The strings that these pointers point to are kept alive by paramNames and paramValues. Vector<const char*> names; Vector<const char*> values; @@ -622,8 +673,8 @@ bool NetscapePlugin::initialize(const Parameters& parameters) #if PLUGIN_ARCHITECTURE(MAC) if (m_pluginModule->pluginQuirks().contains(PluginQuirks::MakeOpaqueUnlessTransparentSilverlightBackgroundAttributeExists)) { for (size_t i = 0; i < parameters.names.size(); ++i) { - if (equalIgnoringCase(parameters.names[i], "background")) { - setIsTransparent(isTransparentSilverlightBackgroundValue(parameters.values[i].lower())); + if (equalLettersIgnoringASCIICase(parameters.names[i], "background")) { + setIsTransparent(isTransparentSilverlightBackgroundValue(parameters.values[i].convertToASCIILowercase())); break; } } @@ -686,17 +737,17 @@ void NetscapePlugin::destroy() m_timers.clear(); } -void NetscapePlugin::paint(GraphicsContext* context, const IntRect& dirtyRect) +void NetscapePlugin::paint(GraphicsContext& context, const IntRect& dirtyRect) { ASSERT(m_isStarted); platformPaint(context, dirtyRect); } -PassRefPtr<ShareableBitmap> NetscapePlugin::snapshot() +RefPtr<ShareableBitmap> NetscapePlugin::snapshot() { if (!supportsSnapshotting() || m_pluginSize.isEmpty()) - return 0; + return nullptr; ASSERT(m_isStarted); @@ -708,11 +759,11 @@ PassRefPtr<ShareableBitmap> NetscapePlugin::snapshot() // FIXME: We should really call applyDeviceScaleFactor instead of scale, but that ends up calling into WKSI // which we currently don't have initiated in the plug-in process. - context->scale(FloatSize(contentsScaleFactor(), contentsScaleFactor())); + context->scale(contentsScaleFactor()); - platformPaint(context.get(), IntRect(IntPoint(), m_pluginSize), true); + platformPaint(*context, IntRect(IntPoint(), m_pluginSize), true); - return bitmap.release(); + return bitmap; } bool NetscapePlugin::isTransparent() @@ -744,8 +795,10 @@ void NetscapePlugin::geometryDidChange(const IntSize& pluginSize, const IntRect& m_clipRect = clipRect; m_pluginToRootViewTransform = pluginToRootViewTransform; +#if PLUGIN_ARCHITECTURE(X11) IntPoint frameRectLocationInWindowCoordinates = m_pluginToRootViewTransform.mapPoint(IntPoint()); m_frameRectInWindowCoordinates = IntRect(frameRectLocationInWindowCoordinates, m_pluginSize); +#endif platformGeometryDidChange(); @@ -796,6 +849,14 @@ void NetscapePlugin::didEvaluateJavaScript(uint64_t requestID, const String& res pluginStream->sendJavaScriptStream(result); } +void NetscapePlugin::streamWillSendRequest(uint64_t streamID, const URL& requestURL, const URL& redirectResponseURL, int redirectResponseStatus) +{ + ASSERT(m_isStarted); + + if (NetscapePluginStream* pluginStream = streamFromID(streamID)) + pluginStream->willSendRequest(requestURL, redirectResponseURL, redirectResponseStatus); +} + void NetscapePlugin::streamDidReceiveResponse(uint64_t streamID, const URL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers, const String& /* suggestedFileName */) { @@ -929,7 +990,7 @@ bool NetscapePlugin::shouldAllowNavigationFromDrags() return false; } -bool NetscapePlugin::handlesPageScaleFactor() +bool NetscapePlugin::handlesPageScaleFactor() const { return false; } @@ -1040,15 +1101,15 @@ Scrollbar* NetscapePlugin::verticalScrollbar() bool NetscapePlugin::supportsSnapshotting() const { -#if PLATFORM(MAC) +#if PLATFORM(COCOA) return m_pluginModule && m_pluginModule->pluginQuirks().contains(PluginQuirks::SupportsSnapshotting); #endif return false; } -PassRefPtr<WebCore::SharedBuffer> NetscapePlugin::liveResourceData() const +RefPtr<WebCore::SharedBuffer> NetscapePlugin::liveResourceData() const { - return 0; + return nullptr; } IntPoint NetscapePlugin::convertToRootView(const IntPoint& pointInPluginCoordinates) const @@ -1058,13 +1119,31 @@ IntPoint NetscapePlugin::convertToRootView(const IntPoint& pointInPluginCoordina bool NetscapePlugin::convertFromRootView(const IntPoint& pointInRootViewCoordinates, IntPoint& pointInPluginCoordinates) { - if (!m_pluginToRootViewTransform.isInvertible()) - return false; + if (auto inverse = m_pluginToRootViewTransform.inverse()) { + pointInPluginCoordinates = inverse.value().mapPoint(pointInRootViewCoordinates); + return true; + } + return false; +} - pointInPluginCoordinates = m_pluginToRootViewTransform.inverse().mapPoint(pointInRootViewCoordinates); - return true; +void NetscapePlugin::mutedStateChanged(bool muted) +{ + NPBool value = muted; + NPP_SetValue(NPNVmuteAudioBool, &value); } +#if !PLATFORM(COCOA) + +void NetscapePlugin::windowFocusChanged(bool) +{ +} + +void NetscapePlugin::windowVisibilityChanged(bool) +{ +} + +#endif + } // namespace WebKit #endif // ENABLE(NETSCAPE_PLUGIN_API) |