src/3rdparty/webkit/WebCore/plugins/PluginData.cpp
changeset 0 1918ee327afb
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /*
       
     2     Copyright (C) 2000 Harri Porten (porten@kde.org)
       
     3     Copyright (C) 2000 Daniel Molkentin (molkentin@kde.org)
       
     4     Copyright (C) 2000 Stefan Schimanski (schimmi@kde.org)
       
     5     Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All Rights Reserved.
       
     6     Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
       
     7 
       
     8     This library is free software; you can redistribute it and/or
       
     9     modify it under the terms of the GNU Library General Public
       
    10     License as published by the Free Software Foundation; either
       
    11     version 2 of the License, or (at your option) any later version.
       
    12 
       
    13     This library is distributed in the hope that it will be useful,
       
    14     but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    16     Library General Public License for more details.
       
    17 
       
    18     You should have received a copy of the GNU Library General Public License
       
    19     along with this library; see the file COPYING.LIB.  If not, write to
       
    20     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    21     Boston, MA 02110-1301, USA.
       
    22 */
       
    23 
       
    24 #include "config.h"
       
    25 #include "PluginData.h"
       
    26 
       
    27 namespace WebCore {
       
    28 
       
    29 PluginData::PluginData(const Page* page)
       
    30     : m_page(page)
       
    31 {
       
    32     initPlugins();
       
    33 
       
    34     for (unsigned i = 0; i < m_plugins.size(); ++i) {
       
    35         const PluginInfo* plugin = m_plugins[i];
       
    36         for (unsigned j = 0; j < plugin->mimes.size(); ++j)
       
    37             m_mimes.append(plugin->mimes[j]);
       
    38     }
       
    39 }
       
    40 
       
    41 PluginData::~PluginData()
       
    42 {
       
    43     deleteAllValues(m_plugins);
       
    44     deleteAllValues(m_mimes);
       
    45 }
       
    46 
       
    47 bool PluginData::supportsMimeType(const String& mimeType) const
       
    48 {
       
    49     for (unsigned i = 0; i < m_mimes.size(); ++i)
       
    50         if (m_mimes[i]->type == mimeType)
       
    51             return true;
       
    52     return false;
       
    53 }
       
    54 
       
    55 String PluginData::pluginNameForMimeType(const String& mimeType) const
       
    56 {
       
    57     for (unsigned i = 0; i < m_mimes.size(); ++i)
       
    58         if (m_mimes[i]->type == mimeType)
       
    59             return m_mimes[i]->plugin->name;
       
    60     return String();
       
    61 }
       
    62 
       
    63 }