1/* 2 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef NetscapePluginModule_h 27#define NetscapePluginModule_h 28 29#if ENABLE(NETSCAPE_PLUGIN_API) 30 31#include "Module.h" 32#include "PluginModuleInfo.h" 33#include "PluginQuirks.h" 34#include <WebCore/npruntime_internal.h> 35#include <wtf/RefCounted.h> 36#include <wtf/text/WTFString.h> 37 38namespace WebCore { 39struct MimeClassInfo; 40} 41 42namespace WebKit { 43 44struct RawPluginMetaData; 45 46class NetscapePluginModule : public RefCounted<NetscapePluginModule> { 47public: 48 static PassRefPtr<NetscapePluginModule> getOrCreate(const String& pluginPath); 49 ~NetscapePluginModule(); 50 51 const NPPluginFuncs& pluginFuncs() const { return m_pluginFuncs; } 52 53 void incrementLoadCount(); 54 void decrementLoadCount(); 55 56 static bool getPluginInfo(const String& pluginPath, PluginModuleInfo&); 57 58 const PluginQuirks& pluginQuirks() const { return m_pluginQuirks; } 59 60 // Return a list of domains for which the plug-in has data stored. 61 Vector<String> sitesWithData(); 62 63 // Request that the plug-in clear the site data. 64 bool clearSiteData(const String& site, uint64_t flags, uint64_t maxAge); 65 66 Module* module() const { return m_module.get(); } 67 68#if PLUGIN_ARCHITECTURE(MAC) 69 static bool createPluginMIMETypesPreferences(const String& pluginPath); 70#endif 71 72#if PLUGIN_ARCHITECTURE(X11) 73 static bool scanPlugin(const String& pluginPath); 74 static void parseMIMEDescription(const String& mimeDescription, Vector<WebCore::MimeClassInfo>& result); 75 static String buildMIMEDescription(const Vector<WebCore::MimeClassInfo>&); 76#endif 77 78private: 79 explicit NetscapePluginModule(const String& pluginPath); 80 81 void determineQuirks(); 82 83#if PLUGIN_ARCHITECTURE(X11) 84 bool getPluginInfoForLoadedPlugin(RawPluginMetaData&); 85#endif 86 87 bool tryGetSitesWithData(Vector<String>&); 88 bool tryClearSiteData(const String& site, uint64_t flags, uint64_t maxAge); 89 90 bool tryLoad(); 91 bool load(); 92 void unload(); 93 94 void shutdown(); 95 96 String m_pluginPath; 97 bool m_isInitialized; 98 unsigned m_loadCount; 99 100 PluginQuirks m_pluginQuirks; 101 102 NPP_ShutdownProcPtr m_shutdownProcPtr; 103 NPPluginFuncs m_pluginFuncs; 104 105 std::unique_ptr<Module> m_module; 106}; 107 108} // namespace WebKit 109 110#endif // ENABLE(NETSCAPE_PLUGIN_API) 111 112#endif // NetscapePluginModule_h 113