2 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "core/plugins/DOMPlugin.h"
22 #include "platform/plugins/PluginData.h"
23 #include "wtf/text/AtomicString.h"
27 DOMPlugin::DOMPlugin(PluginData* pluginData, LocalFrame* frame, unsigned index)
28 : FrameDestructionObserver(frame)
29 , m_pluginData(pluginData)
34 DOMPlugin::~DOMPlugin()
38 void DOMPlugin::trace(Visitor* visitor)
40 FrameDestructionObserver::trace(visitor);
43 String DOMPlugin::name() const
45 return pluginInfo().name;
48 String DOMPlugin::filename() const
50 return pluginInfo().file;
53 String DOMPlugin::description() const
55 return pluginInfo().desc;
58 unsigned DOMPlugin::length() const
60 return pluginInfo().mimes.size();
63 PassRefPtrWillBeRawPtr<DOMMimeType> DOMPlugin::item(unsigned index)
65 if (index >= pluginInfo().mimes.size())
68 const MimeClassInfo& mime = pluginInfo().mimes[index];
70 const Vector<MimeClassInfo>& mimes = m_pluginData->mimes();
71 for (unsigned i = 0; i < mimes.size(); ++i) {
72 if (mimes[i] == mime && m_pluginData->mimePluginIndices()[i] == m_index)
73 return DOMMimeType::create(m_pluginData.get(), m_frame, i).get();
78 bool DOMPlugin::canGetItemsForName(const AtomicString& propertyName)
80 const Vector<MimeClassInfo>& mimes = m_pluginData->mimes();
81 for (unsigned i = 0; i < mimes.size(); ++i)
82 if (mimes[i].type == propertyName)
87 PassRefPtrWillBeRawPtr<DOMMimeType> DOMPlugin::namedItem(const AtomicString& propertyName)
89 const Vector<MimeClassInfo>& mimes = m_pluginData->mimes();
90 for (unsigned i = 0; i < mimes.size(); ++i)
91 if (mimes[i].type == propertyName)
92 return DOMMimeType::create(m_pluginData.get(), m_frame, i).get();