• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
PluginData(const Page * page)34 PluginData::PluginData(const Page* page)
35 {
36     initPlugins(page);
37 
38     for (unsigned i = 0; i < m_plugins.size(); ++i) {
39         const PluginInfo& plugin = m_plugins[i];
40         for (unsigned j = 0; j < plugin.mimes.size(); ++j) {
41             m_mimes.append(plugin.mimes[j]);
42             m_mimePluginIndices.append(i);
43         }
44     }
45 }
46 
supportsMimeType(const String & mimeType) const47 bool PluginData::supportsMimeType(const String& mimeType) const
48 {
49     for (unsigned i = 0; i < m_mimes.size(); ++i)
50         if (m_mimes[i].type == mimeType)
51             return true;
52     return false;
53 }
54 
pluginNameForMimeType(const String & mimeType) const55 String PluginData::pluginNameForMimeType(const String& mimeType) const
56 {
57     for (unsigned i = 0; i < m_mimes.size(); ++i) {
58         const MimeClassInfo& info = m_mimes[i];
59 
60         if (info.type == mimeType)
61             return m_plugins[m_mimePluginIndices[i]].name;
62     }
63 
64     return String();
65 }
66 
67 #if USE(PLATFORM_STRATEGIES)
refresh()68 void PluginData::refresh()
69 {
70     platformStrategies()->pluginStrategy()->refreshPlugins();
71 }
72 
initPlugins(const Page * page)73 void PluginData::initPlugins(const Page* page)
74 {
75     ASSERT(m_plugins.isEmpty());
76 
77     platformStrategies()->pluginStrategy()->getPluginInfo(page, m_plugins);
78 }
79 #endif
80 
81 }
82