DOMPlugin.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  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
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "config.h"
  19. #include "DOMPlugin.h"
  20. #include "PluginData.h"
  21. #include "Frame.h"
  22. #include <wtf/text/AtomicString.h>
  23. namespace WebCore {
  24. DOMPlugin::DOMPlugin(PluginData* pluginData, Frame* frame, unsigned index)
  25. : FrameDestructionObserver(frame)
  26. , m_pluginData(pluginData)
  27. , m_index(index)
  28. {
  29. }
  30. DOMPlugin::~DOMPlugin()
  31. {
  32. }
  33. String DOMPlugin::name() const
  34. {
  35. return pluginInfo().name;
  36. }
  37. String DOMPlugin::filename() const
  38. {
  39. return pluginInfo().file;
  40. }
  41. String DOMPlugin::description() const
  42. {
  43. return pluginInfo().desc;
  44. }
  45. unsigned DOMPlugin::length() const
  46. {
  47. return pluginInfo().mimes.size();
  48. }
  49. PassRefPtr<DOMMimeType> DOMPlugin::item(unsigned index)
  50. {
  51. if (index >= pluginInfo().mimes.size())
  52. return 0;
  53. const MimeClassInfo& mime = pluginInfo().mimes[index];
  54. const Vector<MimeClassInfo>& mimes = m_pluginData->mimes();
  55. for (unsigned i = 0; i < mimes.size(); ++i) {
  56. if (mimes[i] == mime && m_pluginData->mimePluginIndices()[i] == m_index)
  57. return DOMMimeType::create(m_pluginData.get(), m_frame, i).get();
  58. }
  59. return 0;
  60. }
  61. bool DOMPlugin::canGetItemsForName(const AtomicString& propertyName)
  62. {
  63. const Vector<MimeClassInfo>& mimes = m_pluginData->mimes();
  64. for (unsigned i = 0; i < mimes.size(); ++i)
  65. if (mimes[i].type == propertyName)
  66. return true;
  67. return false;
  68. }
  69. PassRefPtr<DOMMimeType> DOMPlugin::namedItem(const AtomicString& propertyName)
  70. {
  71. const Vector<MimeClassInfo>& mimes = m_pluginData->mimes();
  72. for (unsigned i = 0; i < mimes.size(); ++i)
  73. if (mimes[i].type == propertyName)
  74. return DOMMimeType::create(m_pluginData.get(), m_frame, i).get();
  75. return 0;
  76. }
  77. } // namespace WebCore