~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/plugins/PluginData.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 Library 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
    Library General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU Library General Public License
 
15
    along with this library; see the file COPYING.LIB.  If not, write to
 
16
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
    Boston, MA 02110-1301, USA.
 
18
*/
 
19
 
 
20
#ifndef PluginData_h
 
21
#define PluginData_h
 
22
 
 
23
#include <wtf/RefCounted.h>
 
24
#include <wtf/Vector.h>
 
25
#include <wtf/text/WTFString.h>
 
26
 
 
27
namespace WebCore {
 
28
 
 
29
class Page;
 
30
struct PluginInfo;
 
31
 
 
32
struct MimeClassInfo {
 
33
    String type;
 
34
    String desc;
 
35
    Vector<String> extensions;
 
36
 
 
37
    MimeClassInfo isolatedCopy() const
 
38
    {
 
39
        MimeClassInfo clone;
 
40
        clone.type = type.isolatedCopy();
 
41
        clone.desc = desc.isolatedCopy();
 
42
        for (unsigned i = 0; i < extensions.size(); ++i)
 
43
            clone.extensions.append(extensions[i].isolatedCopy());
 
44
        return clone;
 
45
    }
 
46
};
 
47
 
 
48
inline bool operator==(const MimeClassInfo& a, const MimeClassInfo& b)
 
49
{
 
50
    return a.type == b.type && a.desc == b.desc && a.extensions == b.extensions;
 
51
}
 
52
 
 
53
struct PluginInfo {
 
54
    String name;
 
55
    String file;
 
56
    String desc;
 
57
    Vector<MimeClassInfo> mimes;
 
58
 
 
59
    PluginInfo isolatedCopy() const
 
60
    {
 
61
        PluginInfo clone;
 
62
        clone.name = name.isolatedCopy();
 
63
        clone.file = file.isolatedCopy();
 
64
        clone.desc = desc.isolatedCopy();
 
65
        for (unsigned i = 0; i < mimes.size(); ++i)
 
66
            clone.mimes.append(mimes[i].isolatedCopy());
 
67
        return clone;
 
68
    }
 
69
};
 
70
 
 
71
// FIXME: merge with PluginDatabase in the future
 
72
class PluginData : public RefCounted<PluginData> {
 
73
public:
 
74
    static PassRefPtr<PluginData> create(const Page* page) { return adoptRef(new PluginData(page)); }
 
75
 
 
76
    const Vector<PluginInfo>& plugins() const { return m_plugins; }
 
77
    const Vector<MimeClassInfo>& mimes() const { return m_mimes; }
 
78
    const Vector<size_t>& mimePluginIndices() const { return m_mimePluginIndices; }
 
79
    
 
80
    bool supportsMimeType(const String& mimeType) const;
 
81
    String pluginNameForMimeType(const String& mimeType) const;
 
82
    String pluginFileForMimeType(const String& mimeType) const;
 
83
 
 
84
    static void refresh();
 
85
 
 
86
private:
 
87
    explicit PluginData(const Page*);
 
88
    void initPlugins(const Page*);
 
89
    const PluginInfo* pluginInfoForMimeType(const String& mimeType) const;
 
90
 
 
91
    Vector<PluginInfo> m_plugins;
 
92
    Vector<MimeClassInfo> m_mimes;
 
93
    Vector<size_t> m_mimePluginIndices;
 
94
};
 
95
 
 
96
}
 
97
 
 
98
#endif