| 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 * Copyright (C) 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Lesser General Public | 6 * modify it under the terms of the GNU Lesser General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "core/frame/LocalFrame.h" | 22 #include "core/frame/LocalFrame.h" |
| 23 #include "core/page/Page.h" | 23 #include "core/page/Page.h" |
| 24 #include "platform/plugins/PluginData.h" | 24 #include "platform/plugins/PluginData.h" |
| 25 #include "wtf/Vector.h" | 25 #include "wtf/Vector.h" |
| 26 #include "wtf/text/AtomicString.h" | 26 #include "wtf/text/AtomicString.h" |
| 27 | 27 |
| 28 namespace blink { | 28 namespace blink { |
| 29 | 29 |
| 30 DOMPluginArray::DOMPluginArray(LocalFrame* frame) | 30 DOMPluginArray::DOMPluginArray(LocalFrame* frame) |
| 31 : DOMWindowProperty(frame) | 31 : DOMWindowProperty(frame) |
| 32 , m_modified(0) |
| 32 { | 33 { |
| 33 } | 34 } |
| 34 | 35 |
| 35 DEFINE_TRACE(DOMPluginArray) | 36 DEFINE_TRACE(DOMPluginArray) |
| 36 { | 37 { |
| 37 DOMWindowProperty::trace(visitor); | 38 DOMWindowProperty::trace(visitor); |
| 39 visitor->trace(m_plugins); |
| 38 } | 40 } |
| 39 | 41 |
| 40 unsigned DOMPluginArray::length() const | 42 unsigned DOMPluginArray::length() const |
| 41 { | 43 { |
| 42 PluginData* data = pluginData(); | 44 PluginData* data = pluginData(); |
| 43 if (!data) | 45 if (!data) |
| 44 return 0; | 46 return 0; |
| 45 return data->plugins().size(); | 47 return data->plugins().size(); |
| 46 } | 48 } |
| 47 | 49 |
| 50 DOMPlugin* DOMPluginArray::getPlugin(unsigned index) |
| 51 { |
| 52 PluginData* data = pluginData(); |
| 53 if (!data) |
| 54 return nullptr; |
| 55 if (data->modified() != m_modified) { |
| 56 m_plugins.clear(); |
| 57 m_modified = data->modified(); |
| 58 } |
| 59 if (m_plugins.find(index) == m_plugins.end()) |
| 60 m_plugins.add(index, DOMPlugin::create(data, m_frame, index)); |
| 61 return m_plugins.get(index); |
| 62 } |
| 63 |
| 48 DOMPlugin* DOMPluginArray::item(unsigned index) | 64 DOMPlugin* DOMPluginArray::item(unsigned index) |
| 49 { | 65 { |
| 50 PluginData* data = pluginData(); | 66 PluginData* data = pluginData(); |
| 51 if (!data) | 67 if (!data) |
| 52 return nullptr; | 68 return nullptr; |
| 53 const Vector<PluginInfo>& plugins = data->plugins(); | 69 const Vector<PluginInfo>& plugins = data->plugins(); |
| 54 if (index >= plugins.size()) | 70 if (index >= plugins.size()) |
| 55 return nullptr; | 71 return nullptr; |
| 56 return DOMPlugin::create(data, m_frame, index); | 72 return getPlugin(index); |
| 57 } | 73 } |
| 58 | 74 |
| 59 DOMPlugin* DOMPluginArray::namedItem(const AtomicString& propertyName) | 75 DOMPlugin* DOMPluginArray::namedItem(const AtomicString& propertyName) |
| 60 { | 76 { |
| 61 PluginData* data = pluginData(); | 77 PluginData* data = pluginData(); |
| 62 if (!data) | 78 if (!data) |
| 63 return nullptr; | 79 return nullptr; |
| 64 const Vector<PluginInfo>& plugins = data->plugins(); | 80 const Vector<PluginInfo>& plugins = data->plugins(); |
| 65 for (unsigned i = 0; i < plugins.size(); ++i) { | 81 for (unsigned i = 0; i < plugins.size(); ++i) { |
| 66 if (plugins[i].name == propertyName) | 82 if (plugins[i].name == propertyName) |
| 67 return DOMPlugin::create(data, m_frame, i); | 83 return getPlugin(i); |
| 68 } | 84 } |
| 69 return nullptr; | 85 return nullptr; |
| 70 } | 86 } |
| 71 | 87 |
| 72 void DOMPluginArray::refresh(bool reload) | 88 void DOMPluginArray::refresh(bool reload) |
| 73 { | 89 { |
| 74 if (!m_frame) | 90 if (!m_frame) |
| 75 return; | 91 return; |
| 76 Page::refreshPlugins(); | 92 Page::refreshPlugins(); |
| 77 if (reload) | 93 if (reload) |
| 78 m_frame->reload(FrameLoadTypeReload, ClientRedirectPolicy::ClientRedirec
t); | 94 m_frame->reload(FrameLoadTypeReload, ClientRedirectPolicy::ClientRedirec
t); |
| 79 } | 95 } |
| 80 | 96 |
| 81 PluginData* DOMPluginArray::pluginData() const | 97 PluginData* DOMPluginArray::pluginData() const |
| 82 { | 98 { |
| 83 if (!m_frame) | 99 if (!m_frame) |
| 84 return nullptr; | 100 return nullptr; |
| 85 return m_frame->pluginData(); | 101 return m_frame->pluginData(); |
| 86 } | 102 } |
| 87 | 103 |
| 88 } // namespace blink | 104 } // namespace blink |
| OLD | NEW |