diff options
Diffstat (limited to 'Source/WebKit2/Shared/Plugins')
20 files changed, 224 insertions, 127 deletions
diff --git a/Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp b/Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp index 029e6abd8..93c3ce925 100644 --- a/Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp +++ b/Source/WebKit2/Shared/Plugins/NPIdentifierData.cpp @@ -28,8 +28,8 @@ #if ENABLE(NETSCAPE_PLUGIN_API) -#include "ArgumentDecoder.h" -#include "ArgumentEncoder.h" +#include "Decoder.h" +#include "Encoder.h" #include "WebCoreArgumentCoders.h" #include <WebCore/IdentifierRep.h> @@ -67,7 +67,7 @@ NPIdentifier NPIdentifierData::createNPIdentifier() const return static_cast<NPIdentifier>(IdentifierRep::get(m_number)); } -void NPIdentifierData::encode(IPC::ArgumentEncoder& encoder) const +void NPIdentifierData::encode(IPC::Encoder& encoder) const { encoder << m_isString; if (m_isString) @@ -76,7 +76,7 @@ void NPIdentifierData::encode(IPC::ArgumentEncoder& encoder) const encoder << m_number; } -bool NPIdentifierData::decode(IPC::ArgumentDecoder& decoder, NPIdentifierData& result) +bool NPIdentifierData::decode(IPC::Decoder& decoder, NPIdentifierData& result) { if (!decoder.decode(result.m_isString)) return false; diff --git a/Source/WebKit2/Shared/Plugins/NPIdentifierData.h b/Source/WebKit2/Shared/Plugins/NPIdentifierData.h index 5b5179337..4f678a445 100644 --- a/Source/WebKit2/Shared/Plugins/NPIdentifierData.h +++ b/Source/WebKit2/Shared/Plugins/NPIdentifierData.h @@ -32,8 +32,8 @@ #include <wtf/text/CString.h> namespace IPC { - class ArgumentDecoder; - class ArgumentEncoder; +class Decoder; +class Encoder; } namespace WebKit { @@ -45,8 +45,8 @@ public: static NPIdentifierData fromNPIdentifier(NPIdentifier); NPIdentifier createNPIdentifier() const; - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, NPIdentifierData&); + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, NPIdentifierData&); private: bool m_isString; diff --git a/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp b/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp index e5567cfff..328ef7b20 100644 --- a/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp +++ b/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp @@ -32,6 +32,8 @@ #include "NPRemoteObjectMap.h" #include "NPRuntimeUtilities.h" #include "NPVariantData.h" +#include "Plugin.h" +#include "PluginController.h" namespace WebKit { @@ -80,6 +82,8 @@ void NPObjectMessageReceiver::invoke(const NPIdentifierData& methodNameData, con NPVariant result; VOID_TO_NPVARIANT(result); + PluginController::PluginDestructionProtector protector(m_plugin->controller()); + returnValue = m_npObject->_class->invoke(m_npObject, methodNameData.createNPIdentifier(), arguments.data(), arguments.size(), &result); if (returnValue) { // Convert the NPVariant to an NPVariantData. @@ -108,6 +112,8 @@ void NPObjectMessageReceiver::invokeDefault(const Vector<NPVariantData>& argumen NPVariant result; VOID_TO_NPVARIANT(result); + PluginController::PluginDestructionProtector protector(m_plugin->controller()); + returnValue = m_npObject->_class->invokeDefault(m_npObject, arguments.data(), arguments.size(), &result); if (returnValue) { // Convert the NPVariant to an NPVariantData. @@ -142,14 +148,15 @@ void NPObjectMessageReceiver::getProperty(const NPIdentifierData& propertyNameDa NPVariant result; VOID_TO_NPVARIANT(result); + PluginController::PluginDestructionProtector protector(m_plugin->controller()); + returnValue = m_npObject->_class->getProperty(m_npObject, propertyNameData.createNPIdentifier(), &result); if (!returnValue) return; - // Convert the NPVariant to an NPVariantData. + resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin); - // And release the result. releaseNPVariantValue(&result); } @@ -162,10 +169,10 @@ void NPObjectMessageReceiver::setProperty(const NPIdentifierData& propertyNameDa NPVariant propertyValue = m_npRemoteObjectMap->npVariantDataToNPVariant(propertyValueData, m_plugin); - // Set the property. + PluginController::PluginDestructionProtector protector(m_plugin->controller()); + returnValue = m_npObject->_class->setProperty(m_npObject, propertyNameData.createNPIdentifier(), &propertyValue); - // And release the value. releaseNPVariantValue(&propertyValue); } @@ -213,17 +220,15 @@ void NPObjectMessageReceiver::construct(const Vector<NPVariantData>& argumentsDa NPVariant result; VOID_TO_NPVARIANT(result); + PluginController::PluginDestructionProtector protector(m_plugin->controller()); + returnValue = m_npObject->_class->construct(m_npObject, arguments.data(), arguments.size(), &result); - if (returnValue) { - // Convert the NPVariant to an NPVariantData. + if (returnValue) resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin); - } - // Release all arguments. for (size_t i = 0; i < argumentsData.size(); ++i) releaseNPVariantValue(&arguments[i]); - // And release the result. releaseNPVariantValue(&result); } diff --git a/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h b/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h index ee14d6da7..2759893fa 100644 --- a/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h +++ b/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h @@ -46,7 +46,7 @@ public: NPObjectMessageReceiver(NPRemoteObjectMap*, Plugin*, uint64_t npObjectID, NPObject*); ~NPObjectMessageReceiver(); - void didReceiveSyncNPObjectMessageReceiverMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&); + void didReceiveSyncNPObjectMessageReceiverMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&); Plugin* plugin() const { return m_plugin; } NPObject* npObject() const { return m_npObject; } diff --git a/Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp b/Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp index a34f19dc5..ef6c79130 100644 --- a/Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp +++ b/Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp @@ -57,7 +57,7 @@ NPObjectProxy::NPObjectProxy() NPObjectProxy::~NPObjectProxy() { - ASSERT(isMainThread()); + ASSERT(RunLoop::isMain()); if (!m_npRemoteObjectMap) return; @@ -303,7 +303,9 @@ void NPObjectProxy::NP_Deallocate(NPObject* npObject) // that is known to be misused during plugin teardown, and to not be concerned about change in behavior if this // occured at any other time. if (!isMainThread()) { - RunLoop::main()->dispatch(bind(&NPObjectProxy::NP_Deallocate, npObject)); + RunLoop::main().dispatch([npObject] { + NP_Deallocate(npObject); + }); return; } diff --git a/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp b/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp index 8138c2ff7..61e1f9402 100644 --- a/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp +++ b/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp @@ -32,7 +32,6 @@ #include "NPObjectProxy.h" #include "NPRuntimeUtilities.h" #include "NPVariantData.h" -#include <wtf/OwnPtr.h> namespace WebKit { @@ -42,9 +41,9 @@ static uint64_t generateNPObjectID() return ++generateNPObjectID; } -PassRefPtr<NPRemoteObjectMap> NPRemoteObjectMap::create(IPC::Connection* connection) +Ref<NPRemoteObjectMap> NPRemoteObjectMap::create(IPC::Connection* connection) { - return adoptRef(new NPRemoteObjectMap(connection)); + return adoptRef(*new NPRemoteObjectMap(connection)); } NPRemoteObjectMap::NPRemoteObjectMap(IPC::Connection* connection) @@ -196,38 +195,29 @@ NPVariant NPRemoteObjectMap::npVariantDataToNPVariant(const NPVariantData& npVar void NPRemoteObjectMap::pluginDestroyed(Plugin* plugin) { - Vector<NPObjectMessageReceiver*> messageReceivers; - - // Gather the receivers associated with this plug-in. - for (HashMap<uint64_t, NPObjectMessageReceiver*>::const_iterator it = m_registeredNPObjects.begin(), end = m_registeredNPObjects.end(); it != end; ++it) { - NPObjectMessageReceiver* npObjectMessageReceiver = it->value; - if (npObjectMessageReceiver->plugin() == plugin) - messageReceivers.append(npObjectMessageReceiver); - } - - // Now delete all the receivers. - deprecatedDeleteAllValues(messageReceivers); - - Vector<NPObjectProxy*> objectProxies; - for (HashSet<NPObjectProxy*>::const_iterator it = m_npObjectProxies.begin(), end = m_npObjectProxies.end(); it != end; ++it) { - NPObjectProxy* npObjectProxy = *it; - - if (npObjectProxy->plugin() == plugin) - objectProxies.append(npObjectProxy); + // Gather and delete the receivers associated with this plug-in. + Vector<NPObjectMessageReceiver*> receivers; + for (auto* receiver : m_registeredNPObjects.values()) { + if (receiver->plugin() == plugin) + receivers.append(receiver); } + for (auto* receiver : receivers) + delete receiver; // Invalidate and remove all proxies associated with this plug-in. - for (size_t i = 0; i < objectProxies.size(); ++i) { - NPObjectProxy* npObjectProxy = objectProxies[i]; - - npObjectProxy->invalidate(); - - ASSERT(m_npObjectProxies.contains(npObjectProxy)); - m_npObjectProxies.remove(npObjectProxy); + Vector<NPObjectProxy*> proxies; + for (auto* proxy : m_npObjectProxies) { + if (proxy->plugin() == plugin) + proxies.append(proxy); + } + for (auto* proxy : proxies) { + proxy->invalidate(); + ASSERT(m_npObjectProxies.contains(proxy)); + m_npObjectProxies.remove(proxy); } } -void NPRemoteObjectMap::didReceiveSyncMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder) +void NPRemoteObjectMap::didReceiveSyncMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder) { NPObjectMessageReceiver* messageReceiver = m_registeredNPObjects.get(decoder.destinationID()); if (!messageReceiver) diff --git a/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h b/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h index cd075f810..ed105a73c 100644 --- a/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h +++ b/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h @@ -43,7 +43,7 @@ class Plugin; class NPRemoteObjectMap : public RefCounted<NPRemoteObjectMap> { public: - static PassRefPtr<NPRemoteObjectMap> create(IPC::Connection*); + static Ref<NPRemoteObjectMap> create(IPC::Connection*); ~NPRemoteObjectMap(); // Creates an NPObjectProxy wrapper for the remote object with the given remote object ID. @@ -61,7 +61,7 @@ public: void pluginDestroyed(Plugin*); - void didReceiveSyncMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&); + void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&); private: explicit NPRemoteObjectMap(IPC::Connection*); diff --git a/Source/WebKit2/Shared/Plugins/NPVariantData.cpp b/Source/WebKit2/Shared/Plugins/NPVariantData.cpp index b460d0972..d2e671bcb 100644 --- a/Source/WebKit2/Shared/Plugins/NPVariantData.cpp +++ b/Source/WebKit2/Shared/Plugins/NPVariantData.cpp @@ -28,8 +28,8 @@ #if ENABLE(NETSCAPE_PLUGIN_API) -#include "ArgumentDecoder.h" -#include "ArgumentEncoder.h" +#include "Decoder.h" +#include "Encoder.h" #include "WebCoreArgumentCoders.h" namespace WebKit { @@ -118,7 +118,7 @@ NPVariantData NPVariantData::makeRemoteNPObjectID(uint64_t value) return npVariantData; } -void NPVariantData::encode(IPC::ArgumentEncoder& encoder) const +void NPVariantData::encode(IPC::Encoder& encoder) const { encoder << m_type; @@ -147,7 +147,7 @@ void NPVariantData::encode(IPC::ArgumentEncoder& encoder) const } } -bool NPVariantData::decode(IPC::ArgumentDecoder& decoder, NPVariantData& result) +bool NPVariantData::decode(IPC::Decoder& decoder, NPVariantData& result) { uint32_t type; if (!decoder.decode(type)) diff --git a/Source/WebKit2/Shared/Plugins/NPVariantData.h b/Source/WebKit2/Shared/Plugins/NPVariantData.h index da056a94c..2c5f2c9f6 100644 --- a/Source/WebKit2/Shared/Plugins/NPVariantData.h +++ b/Source/WebKit2/Shared/Plugins/NPVariantData.h @@ -31,8 +31,8 @@ #include <wtf/text/CString.h> namespace IPC { - class ArgumentDecoder; - class ArgumentEncoder; +class Decoder; +class Encoder; } namespace WebKit { @@ -98,8 +98,8 @@ public: return m_remoteNPObjectIDValue; } - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, NPVariantData&); + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, NPVariantData&); private: uint32_t m_type; diff --git a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp index 10b4f1952..ad7063b24 100644 --- a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp +++ b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp @@ -131,7 +131,7 @@ void NetscapePluginModule::shutdown() size_t pluginModuleIndex = initializedNetscapePluginModules().find(this); ASSERT(pluginModuleIndex != notFound); - + initializedNetscapePluginModules().remove(pluginModuleIndex); } @@ -145,13 +145,13 @@ PassRefPtr<NetscapePluginModule> NetscapePluginModule::getOrCreate(const String& return pluginModule; } - RefPtr<NetscapePluginModule> pluginModule(adoptRef(new NetscapePluginModule(pluginPath))); + auto pluginModule(adoptRef(*new NetscapePluginModule(pluginPath))); // Try to load and initialize the plug-in module. if (!pluginModule->load()) - return 0; + return nullptr; - return pluginModule.release(); + return WTFMove(pluginModule); } void NetscapePluginModule::incrementLoadCount() @@ -169,7 +169,7 @@ void NetscapePluginModule::decrementLoadCount() ASSERT(m_loadCount > 0); m_loadCount--; - if (!m_loadCount) { + if (!m_loadCount && m_isInitialized) { shutdown(); unload(); } @@ -263,9 +263,6 @@ bool NetscapePluginModule::tryLoad() #endif return result; -#elif PLUGIN_ARCHITECTURE(WIN) - if (getEntryPointsFuncPtr(&m_pluginFuncs) != NPERR_NO_ERROR || initializeFuncPtr(netscapeBrowserFuncs()) != NPERR_NO_ERROR) - return false; #elif PLUGIN_ARCHITECTURE(X11) if (initializeFuncPtr(netscapeBrowserFuncs(), &m_pluginFuncs) != NPERR_NO_ERROR) return false; diff --git a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h index fb5e88b8c..f19f94161 100644 --- a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h +++ b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h @@ -41,7 +41,7 @@ struct MimeClassInfo; namespace WebKit { -class RawPluginMetaData; +struct RawPluginMetaData; class NetscapePluginModule : public RefCounted<NetscapePluginModule> { public: @@ -65,10 +65,6 @@ public: Module* module() const { return m_module.get(); } -#if PLUGIN_ARCHITECTURE(MAC) - static bool createPluginMIMETypesPreferences(const String& pluginPath); -#endif - #if PLUGIN_ARCHITECTURE(X11) static bool scanPlugin(const String& pluginPath); static void parseMIMEDescription(const String& mimeDescription, Vector<WebCore::MimeClassInfo>& result); diff --git a/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.cpp b/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.cpp index ec15420bd..cc39e559c 100644 --- a/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.cpp +++ b/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.cpp @@ -108,7 +108,7 @@ String plugInInformationReplacementObscuredKey() return ASCIILiteral("PlugInInformationReplacementObscured"); } -void getPluginModuleInformation(const PluginModuleInfo& plugin, ImmutableDictionary::MapType& map) +void getPluginModuleInformation(const PluginModuleInfo& plugin, API::Dictionary::MapType& map) { #if ENABLE(NETSCAPE_PLUGIN_API) map.set(pluginInformationPathKey(), API::String::create(plugin.path)); @@ -122,17 +122,17 @@ void getPluginModuleInformation(const PluginModuleInfo& plugin, ImmutableDiction #endif } -PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const PluginModuleInfo& plugin) +Ref<API::Dictionary> createPluginInformationDictionary(const PluginModuleInfo& plugin) { - ImmutableDictionary::MapType map; + API::Dictionary::MapType map; getPluginModuleInformation(plugin, map); - return ImmutableDictionary::create(std::move(map)); + return API::Dictionary::create(WTFMove(map)); } -PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const PluginModuleInfo& plugin, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString, bool replacementObscured) +Ref<API::Dictionary> createPluginInformationDictionary(const PluginModuleInfo& plugin, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString, bool replacementObscured) { - ImmutableDictionary::MapType map; + API::Dictionary::MapType map; getPluginModuleInformation(plugin, map); if (!frameURLString.isEmpty()) @@ -147,12 +147,12 @@ PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const PluginMo map.set(pluginInformationPluginURLKey(), API::URL::create(pluginURLString)); map.set(plugInInformationReplacementObscuredKey(), API::Boolean::create(replacementObscured)); - return ImmutableDictionary::create(std::move(map)); + return API::Dictionary::create(WTFMove(map)); } -PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const String& mimeType, const String& frameURLString, const String& pageURLString) +Ref<API::Dictionary> createPluginInformationDictionary(const String& mimeType, const String& frameURLString, const String& pageURLString) { - ImmutableDictionary::MapType map; + API::Dictionary::MapType map; if (!frameURLString.isEmpty()) map.set(pluginInformationFrameURLKey(), API::URL::create(frameURLString)); @@ -161,11 +161,11 @@ PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const String& if (!pageURLString.isEmpty()) map.set(pluginInformationPageURLKey(), API::URL::create(pageURLString)); - return ImmutableDictionary::create(std::move(map)); + return API::Dictionary::create(WTFMove(map)); } -#if !PLATFORM(MAC) -void getPlatformPluginModuleInformation(const PluginModuleInfo&, ImmutableDictionary::MapType&) +#if !PLATFORM(COCOA) +void getPlatformPluginModuleInformation(const PluginModuleInfo&, API::Dictionary::MapType&) { } #endif diff --git a/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.h b/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.h index 7f6e19986..969e85a0a 100644 --- a/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.h +++ b/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.h @@ -26,7 +26,7 @@ #ifndef PluginInformation_h #define PluginInformation_h -#include "ImmutableDictionary.h" +#include "APIDictionary.h" #include <wtf/Forward.h> namespace WebKit { @@ -51,12 +51,12 @@ String pluginInformationPluginspageAttributeURLKey(); String pluginInformationPluginURLKey(); String plugInInformationReplacementObscuredKey(); -PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const PluginModuleInfo&); -PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const PluginModuleInfo&, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString, bool replacementObscured = false); -PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const String& mimeType, const String& frameURLString, const String& pageURLString); +Ref<API::Dictionary> createPluginInformationDictionary(const PluginModuleInfo&); +Ref<API::Dictionary> createPluginInformationDictionary(const PluginModuleInfo&, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString, bool replacementObscured = false); +Ref<API::Dictionary> createPluginInformationDictionary(const String& mimeType, const String& frameURLString, const String& pageURLString); -void getPluginModuleInformation(const PluginModuleInfo&, ImmutableDictionary::MapType&); -void getPlatformPluginModuleInformation(const PluginModuleInfo&, ImmutableDictionary::MapType&); +void getPluginModuleInformation(const PluginModuleInfo&, API::Dictionary::MapType&); +void getPlatformPluginModuleInformation(const PluginModuleInfo&, API::Dictionary::MapType&); } // namespace WebKit diff --git a/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp b/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp index 368e9d00a..a1a0ed9ec 100644 --- a/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp +++ b/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp @@ -59,12 +59,15 @@ StdoutDevNullRedirector::StdoutDevNullRedirector() return; m_savedStdout = dup(STDOUT_FILENO); dup2(newStdout, STDOUT_FILENO); + close(newStdout); } StdoutDevNullRedirector::~StdoutDevNullRedirector() { - if (m_savedStdout != -1) + if (m_savedStdout != -1) { dup2(m_savedStdout, STDOUT_FILENO); + close(m_savedStdout); + } } @@ -73,7 +76,7 @@ void NetscapePluginModule::parseMIMEDescription(const String& mimeDescription, V ASSERT_ARG(result, result.isEmpty()); Vector<String> types; - mimeDescription.lower().split(UChar(';'), false, types); + mimeDescription.convertToASCIILowercase().split(UChar(';'), false, types); result.reserveInitialCapacity(types.size()); size_t mimeInfoCount = 0; @@ -163,13 +166,15 @@ bool NetscapePluginModule::getPluginInfo(const String& pluginPath, PluginModuleI plugin.info.name = metaData.name; plugin.info.desc = metaData.description; parseMIMEDescription(metaData.mimeDescription, plugin.info.mimes); +#if PLATFORM(GTK) + plugin.requiresGtk2 = metaData.requiresGtk2; +#endif return true; } void NetscapePluginModule::determineQuirks() { -#if CPU(X86_64) RawPluginMetaData metaData; if (!getPluginInfoForLoadedPlugin(metaData)) return; @@ -178,12 +183,13 @@ void NetscapePluginModule::determineQuirks() parseMIMEDescription(metaData.mimeDescription, mimeTypes); for (size_t i = 0; i < mimeTypes.size(); ++i) { if (mimeTypes[i].type == "application/x-shockwave-flash") { +#if CPU(X86_64) m_pluginQuirks.add(PluginQuirks::IgnoreRightClickInWindowlessMode); +#endif m_pluginQuirks.add(PluginQuirks::DoNotCancelSrcStreamInWindowedMode); break; } } -#endif } static void writeCharacter(char byte) diff --git a/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h b/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h index bc0302957..e5360f8d4 100644 --- a/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h +++ b/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h @@ -23,12 +23,11 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef PluginModuleInfo_h -#define PluginModuleInfo_h +#pragma once #include <WebCore/PluginData.h> -#if PLATFORM(MAC) +#if PLATFORM(COCOA) #include <mach/machine.h> #endif @@ -43,22 +42,23 @@ enum PluginModuleLoadPolicy { // The plug-in should be blocked from being instantiated. // Note that the plug-in will still be seen by e.g. navigator.plugins - PluginModuleBlocked, + PluginModuleBlockedForSecurity, + PluginModuleBlockedForCompatibility, }; struct PluginModuleInfo { String path; WebCore::PluginInfo info; -#if PLATFORM(MAC) +#if PLATFORM(COCOA) cpu_type_t pluginArchitecture; String bundleIdentifier; String versionString; String shortVersionString; - String preferencePanePath; + bool hasSandboxProfile; +#elif PLATFORM(GTK) + bool requiresGtk2; #endif }; } // namespace WebKit - -#endif // PluginModuleInfo_h diff --git a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp index a53fdef00..3988e8ca9 100644 --- a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp +++ b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.cpp @@ -27,8 +27,10 @@ #include "PluginProcessCreationParameters.h" #if ENABLE(NETSCAPE_PLUGIN_API) - -#include "ArgumentCoders.h" +#if PLATFORM(COCOA) +#include "ArgumentCodersCF.h" +#endif +#include "WebCoreArgumentCoders.h" namespace WebKit { @@ -37,18 +39,24 @@ PluginProcessCreationParameters::PluginProcessCreationParameters() { } -void PluginProcessCreationParameters::encode(IPC::ArgumentEncoder& encoder) const +void PluginProcessCreationParameters::encode(IPC::Encoder& encoder) const { encoder.encodeEnum(processType); encoder << supportsAsynchronousPluginInitialization; encoder << minimumLifetime; encoder << terminationTimeout; -#if PLATFORM(MAC) +#if PLATFORM(COCOA) encoder << acceleratedCompositingPort; +#if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) + IPC::encode(encoder, networkATSContext.get()); +#endif +#endif +#if OS(LINUX) + encoder << memoryPressureMonitorHandle; #endif } -bool PluginProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, PluginProcessCreationParameters& result) +bool PluginProcessCreationParameters::decode(IPC::Decoder& decoder, PluginProcessCreationParameters& result) { if (!decoder.decodeEnum(result.processType)) return false; @@ -58,9 +66,17 @@ bool PluginProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, Plug return false; if (!decoder.decode(result.terminationTimeout)) return false; -#if PLATFORM(MAC) +#if PLATFORM(COCOA) if (!decoder.decode(result.acceleratedCompositingPort)) return false; +#if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) + if (!IPC::decode(decoder, result.networkATSContext)) + return false; +#endif +#endif +#if OS(LINUX) + if (!decoder.decode(result.memoryPressureMonitorHandle)) + return false; #endif return true; diff --git a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h index e0f9d6b2e..a12a4445b 100644 --- a/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h +++ b/Source/WebKit2/Shared/Plugins/PluginProcessCreationParameters.h @@ -28,15 +28,16 @@ #if ENABLE(NETSCAPE_PLUGIN_API) +#include "Attachment.h" #include "PluginProcessAttributes.h" -#if PLATFORM(MAC) -#include "MachPort.h" +#if PLATFORM(COCOA) +#include <WebCore/MachSendRight.h> #endif namespace IPC { - class ArgumentDecoder; - class ArgumentEncoder; +class Decoder; +class Encoder; } namespace WebKit { @@ -44,8 +45,8 @@ namespace WebKit { struct PluginProcessCreationParameters { PluginProcessCreationParameters(); - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, PluginProcessCreationParameters&); + void encode(IPC::Encoder&) const; + static bool decode(IPC::Decoder&, PluginProcessCreationParameters&); PluginProcessType processType; bool supportsAsynchronousPluginInitialization; @@ -53,8 +54,14 @@ struct PluginProcessCreationParameters { double minimumLifetime; double terminationTimeout; -#if PLATFORM(MAC) - IPC::MachPort acceleratedCompositingPort; +#if PLATFORM(COCOA) + WebCore::MachSendRight acceleratedCompositingPort; +#if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) + RetainPtr<CFDataRef> networkATSContext; +#endif +#endif +#if OS(LINUX) + IPC::Attachment memoryPressureMonitorHandle; #endif }; diff --git a/Source/WebKit2/Shared/Plugins/PluginQuirks.h b/Source/WebKit2/Shared/Plugins/PluginQuirks.h index e48db58ad..1a0b74021 100644 --- a/Source/WebKit2/Shared/Plugins/PluginQuirks.h +++ b/Source/WebKit2/Shared/Plugins/PluginQuirks.h @@ -89,15 +89,11 @@ public: // freeze when sending right click events to them in windowed mode. IgnoreRightClickInWindowlessMode, + // Some ports don't support windowed plugins. + ForceFlashWindowlessMode, + // Flash crashes when NPP_GetValue is called for NPPVpluginCancelSrcStream in windowed mode. DoNotCancelSrcStreamInWindowedMode, - - // Windows specific quirks: -#elif PLUGIN_ARCHITECTURE(WIN) - // Whether NPN_UserAgent should always return a Mozilla user agent. - // Flash on Windows prior to version 10 only requests windowless plugins - // if we return a Mozilla user agent. - WantsMozillaUserAgent, #endif // This isn't really a quirk as much as the opposite of a quirk. By default, we don't send wheel events diff --git a/Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.cpp b/Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.cpp new file mode 100644 index 000000000..7e892f00c --- /dev/null +++ b/Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2015 Igalia S.L. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "PluginSearchPath.h" + +#include <WebCore/FileSystem.h> + +using namespace WebCore; + +namespace WebKit { + +Vector<String> pluginsDirectories() +{ + Vector<String> result; + +#if ENABLE(NETSCAPE_PLUGIN_API) + String mozillaPaths(getenv("MOZ_PLUGIN_PATH")); + if (!mozillaPaths.isEmpty()) { + Vector<String> paths; + mozillaPaths.split(UChar(':'), /* allowEmptyEntries */ false, paths); + result.appendVector(paths); + } + + String mozillaHome(getenv("MOZILLA_HOME")); + if (!mozillaHome.isEmpty()) + result.append(mozillaHome + "/plugins"); + + result.append(homeDirectoryPath() + "/.mozilla/plugins"); + result.append(homeDirectoryPath() + "/.netscape/plugins"); + result.append("/usr/lib/browser/plugins"); + result.append("/usr/local/lib/mozilla/plugins"); + result.append("/usr/lib/firefox/plugins"); + result.append("/usr/lib64/browser-plugins"); + result.append("/usr/lib/browser-plugins"); + result.append("/usr/lib/mozilla/plugins"); + result.append("/usr/local/netscape/plugins"); + result.append("/opt/mozilla/plugins"); + result.append("/opt/mozilla/lib/plugins"); + result.append("/opt/netscape/plugins"); + result.append("/opt/netscape/communicator/plugins"); + result.append("/usr/lib/netscape/plugins"); + result.append("/usr/lib/netscape/plugins-libc5"); + result.append("/usr/lib/netscape/plugins-libc6"); + result.append("/usr/lib64/netscape/plugins"); + result.append("/usr/lib64/mozilla/plugins"); + result.append("/usr/lib/nsbrowser/plugins"); + result.append("/usr/lib64/nsbrowser/plugins"); +#endif + + return result; +} + +} // namespace WebKit diff --git a/Source/WebKit2/Shared/Plugins/PluginModuleInfo.cpp b/Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.h index bb60b5d46..25a13ec8e 100644 --- a/Source/WebKit2/Shared/Plugins/PluginModuleInfo.cpp +++ b/Source/WebKit2/Shared/Plugins/unix/PluginSearchPath.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2015 Igalia S.L. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,10 +23,16 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include "config.h" -#include "PluginModuleInfo.h" +#ifndef PluginSearchPath_h +#define PluginSearchPath_h + +#include <wtf/Forward.h> +#include <wtf/Vector.h> namespace WebKit { +Vector<String> pluginsDirectories(); + +} // namespace WebKit -} +#endif // PluginSandboxProfile_h |