OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 2 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Lesser General Public | 5 * modify it under the terms of the GNU Lesser General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Lesser General Public License for more details. | 12 * Lesser General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Lesser General Public | 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 | 15 * License along with this library; if not, write to the Free Software |
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
17 * MA 02110-1301 USA | 17 * MA 02110-1301 USA |
18 */ | 18 */ |
19 | 19 |
20 #include "modules/plugins/DOMPlugin.h" | 20 #include "modules/plugins/DOMPlugin.h" |
21 | 21 |
22 #include "platform/plugins/PluginData.h" | 22 #include "platform/plugins/PluginData.h" |
23 #include "platform/wtf/text/AtomicString.h" | 23 #include "platform/wtf/text/AtomicString.h" |
24 | 24 |
25 namespace blink { | 25 namespace blink { |
26 | 26 |
27 DOMPlugin::DOMPlugin(PluginData* plugin_data, LocalFrame* frame, unsigned index) | 27 DOMPlugin::DOMPlugin(LocalFrame* frame, const PluginInfo& plugin_info) |
28 : ContextClient(frame), plugin_data_(plugin_data), index_(index) {} | 28 : ContextClient(frame), plugin_info_(&plugin_info) {} |
29 | 29 |
30 DOMPlugin::~DOMPlugin() {} | 30 DOMPlugin::~DOMPlugin() {} |
31 | 31 |
32 DEFINE_TRACE(DOMPlugin) { | 32 DEFINE_TRACE(DOMPlugin) { |
33 ContextClient::Trace(visitor); | 33 ContextClient::Trace(visitor); |
| 34 visitor->Trace(plugin_info_); |
34 } | 35 } |
35 | 36 |
36 String DOMPlugin::name() const { | 37 String DOMPlugin::name() const { |
37 return GetPluginInfo().name; | 38 return plugin_info_->Name(); |
38 } | 39 } |
39 | 40 |
40 String DOMPlugin::filename() const { | 41 String DOMPlugin::filename() const { |
41 return GetPluginInfo().file; | 42 return plugin_info_->Filename(); |
42 } | 43 } |
43 | 44 |
44 String DOMPlugin::description() const { | 45 String DOMPlugin::description() const { |
45 return GetPluginInfo().desc; | 46 return plugin_info_->Description(); |
46 } | 47 } |
47 | 48 |
48 unsigned DOMPlugin::length() const { | 49 unsigned DOMPlugin::length() const { |
49 return GetPluginInfo().mimes.size(); | 50 return plugin_info_->GetMimeClassInfoSize(); |
50 } | 51 } |
51 | 52 |
52 DOMMimeType* DOMPlugin::item(unsigned index) { | 53 DOMMimeType* DOMPlugin::item(unsigned index) { |
53 if (index >= GetPluginInfo().mimes.size()) | 54 const MimeClassInfo* mime = plugin_info_->GetMimeClassInfo(index); |
| 55 |
| 56 if (!mime) |
54 return nullptr; | 57 return nullptr; |
55 | 58 |
56 const MimeClassInfo& mime = GetPluginInfo().mimes[index]; | 59 return DOMMimeType::Create(GetFrame(), *mime); |
57 | |
58 const Vector<MimeClassInfo>& mimes = plugin_data_->Mimes(); | |
59 for (unsigned i = 0; i < mimes.size(); ++i) { | |
60 if (mimes[i] == mime && plugin_data_->MimePluginIndices()[i] == index_) | |
61 return DOMMimeType::Create(plugin_data_.Get(), GetFrame(), i); | |
62 } | |
63 return nullptr; | |
64 } | 60 } |
65 | 61 |
66 DOMMimeType* DOMPlugin::namedItem(const AtomicString& property_name) { | 62 DOMMimeType* DOMPlugin::namedItem(const AtomicString& property_name) { |
67 const Vector<MimeClassInfo>& mimes = plugin_data_->Mimes(); | 63 const MimeClassInfo* mime = plugin_info_->GetMimeClassInfo(property_name); |
68 for (unsigned i = 0; i < mimes.size(); ++i) { | 64 |
69 if (mimes[i].type == property_name) | 65 if (!mime) |
70 return DOMMimeType::Create(plugin_data_.Get(), GetFrame(), i); | 66 return nullptr; |
71 } | 67 |
72 return nullptr; | 68 return DOMMimeType::Create(GetFrame(), *mime); |
73 } | 69 } |
74 | 70 |
75 } // namespace blink | 71 } // namespace blink |
OLD | NEW |