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/DOMPluginArray.h"
23 #include "core/frame/LocalFrame.h"
24 #include "core/page/Page.h"
25 #include "platform/plugins/PluginData.h"
26 #include "wtf/Vector.h"
27 #include "wtf/text/AtomicString.h"
31 DOMPluginArray::DOMPluginArray(LocalFrame* frame)
32 : DOMWindowProperty(frame)
34 ScriptWrappable::init(this);
37 DOMPluginArray::~DOMPluginArray()
41 unsigned DOMPluginArray::length() const
43 PluginData* data = pluginData();
46 return data->plugins().size();
49 PassRefPtrWillBeRawPtr<DOMPlugin> DOMPluginArray::item(unsigned index)
51 PluginData* data = pluginData();
54 const Vector<PluginInfo>& plugins = data->plugins();
55 if (index >= plugins.size())
57 return DOMPlugin::create(data, m_frame, index).get();
60 bool DOMPluginArray::canGetItemsForName(const AtomicString& propertyName)
62 PluginData* data = pluginData();
65 const Vector<PluginInfo>& plugins = data->plugins();
66 for (unsigned i = 0; i < plugins.size(); ++i) {
67 if (plugins[i].name == propertyName)
73 PassRefPtrWillBeRawPtr<DOMPlugin> DOMPluginArray::namedItem(const AtomicString& propertyName)
75 PluginData* data = pluginData();
78 const Vector<PluginInfo>& plugins = data->plugins();
79 for (unsigned i = 0; i < plugins.size(); ++i) {
80 if (plugins[i].name == propertyName)
81 return DOMPlugin::create(data, m_frame, i).get();
86 void DOMPluginArray::refresh(bool reload)
88 Page::refreshPlugins(reload);
91 PluginData* DOMPluginArray::pluginData() const
95 Page* page = m_frame->page();
98 return page->pluginData();