#include "config.h"
#include "DOMPlugin.h"
#include "PluginData.h"
#include "Frame.h"
#include <wtf/text/AtomicString.h>
namespace WebCore {
DOMPlugin::DOMPlugin(PluginData* pluginData, Frame* frame, unsigned index)
: FrameDestructionObserver(frame)
, m_pluginData(pluginData)
, m_index(index)
{
}
DOMPlugin::~DOMPlugin()
{
}
String DOMPlugin::name() const
{
return pluginInfo().name;
}
String DOMPlugin::filename() const
{
return pluginInfo().file;
}
String DOMPlugin::description() const
{
return pluginInfo().desc;
}
unsigned DOMPlugin::length() const
{
return pluginInfo().mimes.size();
}
PassRefPtr<DOMMimeType> DOMPlugin::item(unsigned index)
{
if (index >= pluginInfo().mimes.size())
return 0;
const MimeClassInfo& mime = pluginInfo().mimes[index];
const Vector<MimeClassInfo>& mimes = m_pluginData->mimes();
for (unsigned i = 0; i < mimes.size(); ++i) {
if (mimes[i] == mime && m_pluginData->mimePluginIndices()[i] == m_index)
return DOMMimeType::create(m_pluginData.get(), m_frame, i).get();
}
return 0;
}
bool DOMPlugin::canGetItemsForName(const AtomicString& propertyName)
{
const Vector<MimeClassInfo>& mimes = m_pluginData->mimes();
for (unsigned i = 0; i < mimes.size(); ++i)
if (mimes[i].type == propertyName)
return true;
return false;
}
PassRefPtr<DOMMimeType> DOMPlugin::namedItem(const AtomicString& propertyName)
{
const Vector<MimeClassInfo>& mimes = m_pluginData->mimes();
for (unsigned i = 0; i < mimes.size(); ++i)
if (mimes[i].type == propertyName)
return DOMMimeType::create(m_pluginData.get(), m_frame, i).get();
return 0;
}
}