• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2009, The Android Open Source Project
3     Copyright (C) 2008 Trolltech ASA
4     Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
5 
6     This library is free software; you can redistribute it and/or
7     modify it under the terms of the GNU Library General Public
8     License as published by the Free Software Foundation; either
9     version 2 of the License, or (at your option) any later version.
10 
11     This library is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14     Library General Public License for more details.
15 
16     You should have received a copy of the GNU Library General Public License
17     along with this library; see the file COPYING.LIB.  If not, write to
18     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19     Boston, MA 02110-1301, USA.
20 */
21 
22 #include "config.h"
23 #include "PluginData.h"
24 
25 #include "PluginDatabase.h"
26 #include "PluginPackage.h"
27 
28 namespace WebCore {
29 
initPlugins()30 void PluginData::initPlugins()
31 {
32     PluginDatabase *db = PluginDatabase::installedPlugins();
33     const Vector<PluginPackage*> &plugins = db->plugins();
34 
35     for (unsigned int i = 0; i < plugins.size(); ++i) {
36         PluginInfo* info = new PluginInfo;
37         PluginPackage* package = plugins[i];
38 
39         info->name = package->name();
40         info->file = package->fileName();
41         info->desc = package->description();
42 
43         const MIMEToDescriptionsMap& mimeToDescriptions = package->mimeToDescriptions();
44         MIMEToDescriptionsMap::const_iterator end = mimeToDescriptions.end();
45         for (MIMEToDescriptionsMap::const_iterator it = mimeToDescriptions.begin(); it != end; ++it) {
46             MimeClassInfo* mime = new MimeClassInfo;
47             info->mimes.append(mime);
48 
49             mime->type = it->first;
50             mime->desc = it->second;
51             mime->plugin = info;
52 
53             Vector<String> extensions = package->mimeToExtensions().get(mime->type);
54 
55             for (unsigned i = 0; i < extensions.size(); i++) {
56                 if (i > 0)
57                     mime->suffixes += ",";
58 
59                 mime->suffixes += extensions[i];
60             }
61         }
62 
63         m_plugins.append(info);
64     }
65 }
66 
refresh()67 void PluginData::refresh()
68 {
69     PluginDatabase *db = PluginDatabase::installedPlugins();
70     db->refresh();
71 }
72 
73 };
74