|
1 /* |
|
2 Copyright (C) 2000 Harri Porten (porten@kde.org) |
|
3 Copyright (C) 2000 Daniel Molkentin (molkentin@kde.org) |
|
4 Copyright (C) 2000 Stefan Schimanski (schimmi@kde.org) |
|
5 Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All Rights Reserved. |
|
6 Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
|
7 |
|
8 This library is free software; you can redistribute it and/or |
|
9 modify it under the terms of the GNU Library General Public |
|
10 License as published by the Free Software Foundation; either |
|
11 version 2 of the License, or (at your option) any later version. |
|
12 |
|
13 This library is distributed in the hope that it will be useful, |
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 Library General Public License for more details. |
|
17 |
|
18 You should have received a copy of the GNU Library General Public License |
|
19 along with this library; see the file COPYING.LIB. If not, write to |
|
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
21 Boston, MA 02110-1301, USA. |
|
22 */ |
|
23 |
|
24 #include "config.h" |
|
25 #include "PluginData.h" |
|
26 |
|
27 #if USE(PLATFORM_STRATEGIES) |
|
28 #include "PlatformStrategies.h" |
|
29 #include "PluginStrategy.h" |
|
30 #endif |
|
31 |
|
32 namespace WebCore { |
|
33 |
|
34 PluginData::PluginData(const Page* page) |
|
35 : m_page(page) |
|
36 { |
|
37 initPlugins(); |
|
38 |
|
39 for (unsigned i = 0; i < m_plugins.size(); ++i) { |
|
40 const PluginInfo& plugin = m_plugins[i]; |
|
41 for (unsigned j = 0; j < plugin.mimes.size(); ++j) { |
|
42 m_mimes.append(plugin.mimes[j]); |
|
43 m_mimePluginIndices.append(i); |
|
44 } |
|
45 } |
|
46 } |
|
47 |
|
48 bool PluginData::supportsMimeType(const String& mimeType) const |
|
49 { |
|
50 for (unsigned i = 0; i < m_mimes.size(); ++i) |
|
51 if (m_mimes[i].type == mimeType) |
|
52 return true; |
|
53 return false; |
|
54 } |
|
55 |
|
56 String PluginData::pluginNameForMimeType(const String& mimeType) const |
|
57 { |
|
58 for (unsigned i = 0; i < m_mimes.size(); ++i) { |
|
59 const MimeClassInfo& info = m_mimes[i]; |
|
60 |
|
61 if (info.type == mimeType) |
|
62 return m_plugins[m_mimePluginIndices[i]].name; |
|
63 } |
|
64 |
|
65 return String(); |
|
66 } |
|
67 |
|
68 #if USE(PLATFORM_STRATEGIES) |
|
69 void PluginData::refresh() |
|
70 { |
|
71 platformStrategies()->pluginStrategy()->refreshPlugins(); |
|
72 } |
|
73 |
|
74 void PluginData::initPlugins() |
|
75 { |
|
76 ASSERT(m_plugins.isEmpty()); |
|
77 |
|
78 platformStrategies()->pluginStrategy()->getPluginInfo(m_plugins); |
|
79 } |
|
80 #endif |
|
81 |
|
82 } |