2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef PluginPackageWin_H
27 #define PluginPackageWin_H
33 #include "StringHash.h"
34 #include "PlatformString.h"
35 #include "npfunctions.h"
36 #include <wtf/HashMap.h>
37 #include <wtf/RefCounted.h>
40 typedef HashMap<String, String> MIMEToDescriptionsMap;
41 typedef HashMap<String, Vector<String> > MIMEToExtensionsMap;
43 class PluginPackageWin : public RefCounted<PluginPackageWin> {
46 static PluginPackageWin* createPackage(const String& path, const FILETIME& lastModified);
48 String name() const { return m_name; }
49 String description() const { return m_description; }
50 String fileName() const { return m_fileName; }
51 String parentDirectory() const { return m_parentDirectory; }
52 void getFileVersion(DWORD& mostSignificant, DWORD& leastSignificant) const;
54 const MIMEToDescriptionsMap& mimeToDescriptions() const { return m_mimeToDescriptions; }
55 const MIMEToExtensionsMap& mimeToExtensions() const { return m_mimeToExtensions; }
57 unsigned PluginPackageWin::hash() const;
58 static bool equal(const PluginPackageWin& a, const PluginPackageWin& b);
62 void unloadWithoutShutdown();
64 const NPPluginFuncs* pluginFuncs() const { return &m_pluginFuncs; }
66 PluginPackageWin(const String& path, const FILETIME& lastModified);
68 void storeFileVersion(LPVOID versionInfoData);
73 DWORD m_fileVersionMS;
74 DWORD m_fileVersionLS;
80 String m_parentDirectory;
82 MIMEToDescriptionsMap m_mimeToDescriptions;
83 MIMEToExtensionsMap m_mimeToExtensions;
86 FILETIME m_lastModified;
88 NPP_ShutdownProcPtr m_NPP_Shutdown;
89 NPPluginFuncs m_pluginFuncs;
90 NPNetscapeFuncs m_browserFuncs;
92 void freeLibrarySoon();
93 void freeLibraryTimerFired(Timer<PluginPackageWin>*);
94 Timer<PluginPackageWin> m_freeLibraryTimer;
97 struct PluginPackageWinHash {
98 static unsigned hash(const int key) { return reinterpret_cast<PluginPackageWin*>(key)->hash(); }
99 static unsigned hash(const RefPtr<PluginPackageWin>& key) { return key->hash(); }
101 static bool equal(const int a, const int b) { return equal(reinterpret_cast<PluginPackageWin*>(a), reinterpret_cast<PluginPackageWin*>(b)); }
102 static bool equal(const RefPtr<PluginPackageWin>& a, const RefPtr<PluginPackageWin>& b) { return PluginPackageWin::equal(*a.get(), *b.get()); }
103 static const bool safeToCompareToEmptyOrDeleted = false;
106 } // namespace WebCore
108 // FIXME: This is a workaround for a bug in WTF, where it's impossible to use a custom Hash function but with default traits.
109 // It should be possible to do this without a StorageTraits specialization.
111 template<> struct HashKeyStorageTraits<WebCore::PluginPackageWinHash, HashTraits<RefPtr<WebCore::PluginPackageWin> > > {
112 typedef IntTypes<sizeof(RefPtr<WebCore::PluginPackageWin>)>::SignedType IntType;
113 typedef WebCore::PluginPackageWinHash Hash;
114 typedef HashTraits<IntType> Traits;