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 19 #include "config.h" 20 #include "MimeType.h" 21 22 #include "Frame.h" 23 #include "Page.h" 24 #include "Plugin.h" 25 #include "PluginData.h" 26 #include "Settings.h" 27 28 namespace WebCore { 29 30 MimeType::MimeType(PassRefPtr<PluginData> pluginData, unsigned index) 31 : m_pluginData(pluginData) 32 , m_index(index) 33 { 34 } 35 36 MimeType::~MimeType() 37 { 38 } 39 40 const String &MimeType::type() const 41 { 42 return m_pluginData->mimes()[m_index]->type; 43 } 44 45 const String &MimeType::suffixes() const 46 { 47 return m_pluginData->mimes()[m_index]->suffixes; 48 } 49 50 const String &MimeType::description() const 51 { 52 return m_pluginData->mimes()[m_index]->desc; 53 } 54 55 PassRefPtr<Plugin> MimeType::enabledPlugin() const 56 { 57 const Page* p = m_pluginData->page(); 58 if (!p || !p->settings()->arePluginsEnabled()) 59 return 0; 60 61 const PluginInfo *info = m_pluginData->mimes()[m_index]->plugin; 62 const Vector<PluginInfo*>& plugins = m_pluginData->plugins(); 63 for (size_t i = 0; i < plugins.size(); ++i) { 64 if (plugins[i] == info) 65 return Plugin::create(m_pluginData.get(), i); 66 } 67 return 0; 68 } 69 70 } // namespace WebCore 71