2 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
3 * Copyright (C) 2008 Apple Inc. All rights reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "core/plugins/DOMMimeTypeArray.h"
23 #include "core/frame/Frame.h"
24 #include "core/page/Page.h"
25 #include "platform/plugins/PluginData.h"
26 #include "wtf/text/AtomicString.h"
30 DOMMimeTypeArray::DOMMimeTypeArray(Frame* frame)
31 : DOMWindowProperty(frame)
33 ScriptWrappable::init(this);
36 DOMMimeTypeArray::~DOMMimeTypeArray()
40 unsigned DOMMimeTypeArray::length() const
42 PluginData* data = getPluginData();
45 return data->mimes().size();
48 PassRefPtr<DOMMimeType> DOMMimeTypeArray::item(unsigned index)
50 PluginData* data = getPluginData();
53 const Vector<MimeClassInfo>& mimes = data->mimes();
54 if (index >= mimes.size())
56 return DOMMimeType::create(data, m_frame, index).get();
59 bool DOMMimeTypeArray::canGetItemsForName(const AtomicString& propertyName)
61 PluginData *data = getPluginData();
64 const Vector<MimeClassInfo>& mimes = data->mimes();
65 for (unsigned i = 0; i < mimes.size(); ++i) {
66 if (mimes[i].type == propertyName)
72 PassRefPtr<DOMMimeType> DOMMimeTypeArray::namedItem(const AtomicString& propertyName)
74 PluginData *data = getPluginData();
77 const Vector<MimeClassInfo>& mimes = data->mimes();
78 for (unsigned i = 0; i < mimes.size(); ++i) {
79 if (mimes[i].type == propertyName)
80 return DOMMimeType::create(data, m_frame, i).get();
85 PluginData* DOMMimeTypeArray::getPluginData() const
89 Page* p = m_frame->page();
92 return p->pluginData();
95 } // namespace WebCore