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 DEFINE_GC_INFO(DOMMimeTypeArray);
32 DOMMimeTypeArray::DOMMimeTypeArray(Frame* frame)
33 : DOMWindowProperty(frame)
35 ScriptWrappable::init(this);
38 DOMMimeTypeArray::~DOMMimeTypeArray()
42 unsigned DOMMimeTypeArray::length() const
44 PluginData* data = getPluginData();
47 return data->mimes().size();
50 PassRefPtrWillBeRawPtr<DOMMimeType> DOMMimeTypeArray::item(unsigned index)
52 PluginData* data = getPluginData();
55 const Vector<MimeClassInfo>& mimes = data->mimes();
56 if (index >= mimes.size())
58 return DOMMimeType::create(data, m_frame, index).get();
61 bool DOMMimeTypeArray::canGetItemsForName(const AtomicString& propertyName)
63 PluginData *data = getPluginData();
66 const Vector<MimeClassInfo>& mimes = data->mimes();
67 for (unsigned i = 0; i < mimes.size(); ++i) {
68 if (mimes[i].type == propertyName)
74 PassRefPtrWillBeRawPtr<DOMMimeType> DOMMimeTypeArray::namedItem(const AtomicString& propertyName)
76 PluginData *data = getPluginData();
79 const Vector<MimeClassInfo>& mimes = data->mimes();
80 for (unsigned i = 0; i < mimes.size(); ++i) {
81 if (mimes[i].type == propertyName)
82 return DOMMimeType::create(data, m_frame, i).get();
87 PluginData* DOMMimeTypeArray::getPluginData() const
91 Page* p = m_frame->page();
94 return p->pluginData();
97 } // namespace WebCore