2 * Copyright (C) 2010 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 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.
26 #ifndef PluginInfoStore_h
27 #define PluginInfoStore_h
29 #include "PluginModuleInfo.h"
30 #include <wtf/ThreadingPrimitives.h>
38 class PluginInfoStore {
39 WTF_MAKE_NONCOPYABLE(PluginInfoStore);
44 void setAdditionalPluginsDirectories(const Vector<String>&);
47 Vector<PluginModuleInfo> plugins();
49 // Returns the info for a plug-in that can handle the given MIME type.
50 // If the MIME type is null, the file extension of the given url will be used to infer the
51 // plug-in type. In that case, mimeType will be filled in with the right MIME type.
52 PluginModuleInfo findPlugin(String& mimeType, const WebCore::KURL&);
54 // Returns the info for the plug-in with the given path.
55 PluginModuleInfo infoForPluginWithPath(const String& pluginPath) const;
57 // Return whether this plug-in should be blocked from being instantiated.
58 // Note that the plug-in will still be seen by e.g. navigator.plugins
59 bool shouldBlockPlugin(const PluginModuleInfo&) const;
62 PluginModuleInfo findPluginForMIMEType(const String& mimeType) const;
63 PluginModuleInfo findPluginForExtension(const String& extension, String& mimeType) const;
65 void loadPluginsIfNecessary();
66 static void loadPlugin(Vector<PluginModuleInfo>& plugins, const String& pluginPath);
68 // Platform-specific member functions:
70 // Returns paths to directories that should be searched for plug-ins (via pluginPathsInDirectory).
71 static Vector<String> pluginsDirectories();
73 // Returns paths to all plug-ins in the specified directory.
74 static Vector<String> pluginPathsInDirectory(const String& directory);
76 // Returns paths to individual plug-ins that won't be found via pluginsDirectories/pluginPathsInDirectory.
77 static Vector<String> individualPluginPaths();
79 // Load plug-in info for the plug-in with the specified path.
80 static bool getPluginInfo(const String& pluginPath, PluginModuleInfo&);
82 // Return whether this plug-in should be used (added to the list of plug-ins) or not.
83 static bool shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugins, const PluginModuleInfo&);
85 // Get the MIME type for the given extension.
86 static String getMIMETypeForExtension(const String& extension);
88 Vector<String> m_additionalPluginsDirectories;
89 Vector<PluginModuleInfo> m_plugins;
90 bool m_pluginListIsUpToDate;
92 mutable Mutex m_pluginsLock;
97 #endif // PluginInfoStore_h