OLD | NEW |
---|---|
1 /* | 1 /* |
2 Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 2 Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
3 | 3 |
4 This library is free software; you can redistribute it and/or | 4 This library is free software; you can redistribute it and/or |
5 modify it under the terms of the GNU Library General Public | 5 modify it under the terms of the GNU Library General Public |
6 License as published by the Free Software Foundation; either | 6 License as published by the Free Software Foundation; either |
7 version 2 of the License, or (at your option) any later version. | 7 version 2 of the License, or (at your option) any later version. |
8 | 8 |
9 This library is distributed in the hope that it will be useful, | 9 This library is distributed in the hope that it will be useful, |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 Library General Public License for more details. | 12 Library General Public License for more details. |
13 | 13 |
14 You should have received a copy of the GNU Library General Public License | 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 | 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, | 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 Boston, MA 02110-1301, USA. | 17 Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #ifndef PluginData_h | 20 #ifndef PluginData_h |
21 #define PluginData_h | 21 #define PluginData_h |
22 | 22 |
23 #include "platform/PlatformExport.h" | 23 #include "platform/PlatformExport.h" |
24 #include "platform/heap/Handle.h" | |
24 #include "platform/weborigin/SecurityOrigin.h" | 25 #include "platform/weborigin/SecurityOrigin.h" |
25 #include "platform/wtf/Noncopyable.h" | 26 #include "platform/wtf/Noncopyable.h" |
26 #include "platform/wtf/RefCounted.h" | |
27 #include "platform/wtf/Vector.h" | 27 #include "platform/wtf/Vector.h" |
28 #include "platform/wtf/text/WTFString.h" | 28 #include "platform/wtf/text/WTFString.h" |
29 | 29 |
30 namespace blink { | 30 namespace blink { |
31 | 31 |
32 struct PluginInfo; | 32 class PluginInfo; |
33 | 33 |
34 struct MimeClassInfo { | 34 class PLATFORM_EXPORT MimeClassInfo final |
35 String type; | 35 : public GarbageCollectedFinalized<MimeClassInfo> { |
36 String desc; | 36 public: |
37 Vector<String> extensions; | 37 DECLARE_TRACE(); |
38 | |
39 MimeClassInfo(const String& type, const String& desc, PluginInfo&); | |
40 | |
41 const String& Type() const { return type_; } | |
42 const String& Desc() const { return desc_; } | |
43 const Vector<String>& Extensions() const { return extensions_; } | |
44 const PluginInfo* Plugin() const { return plugin_; } | |
45 | |
46 bool operator==(const MimeClassInfo& info) { | |
jbroman
2017/05/25 15:27:24
Is this operator== needed anymore? It seems like y
lfg
2017/05/25 21:34:42
Removed.
| |
47 return type_ == info.type_ && desc_ == info.desc_ && | |
48 extensions_ == info.extensions_; | |
49 } | |
50 | |
51 private: | |
52 friend class PluginData; | |
53 friend class PluginListBuilder; | |
54 | |
55 String type_; | |
56 String desc_; | |
57 Vector<String> extensions_; | |
58 Member<PluginInfo> plugin_; | |
38 }; | 59 }; |
39 | 60 |
40 inline bool operator==(const MimeClassInfo& a, const MimeClassInfo& b) { | 61 class PLATFORM_EXPORT PluginInfo final |
41 return a.type == b.type && a.desc == b.desc && a.extensions == b.extensions; | 62 : public GarbageCollectedFinalized<PluginInfo> { |
42 } | 63 public: |
64 DECLARE_TRACE(); | |
43 | 65 |
44 struct PluginInfo { | 66 PluginInfo(const String& name, const String& file, const String& desc); |
45 String name; | 67 |
46 String file; | 68 void AddMimeType(MimeClassInfo*); |
47 String desc; | 69 |
48 Vector<MimeClassInfo> mimes; | 70 const MimeClassInfo* GetMimeClassInfo(size_t index) const; |
71 const MimeClassInfo* GetMimeClassInfo(const String& type) const; | |
72 size_t GetMimeClassInfoSize() const; | |
73 | |
74 const String& Name() const { return name_; } | |
75 const String& File() const { return file_; } | |
76 const String& Desc() const { return desc_; } | |
jbroman
2017/05/25 15:27:24
super-nit: while you're touching this, possible to
lfg
2017/05/25 21:34:42
Done.
| |
77 | |
78 private: | |
79 friend class MimeClassInfo; | |
80 friend class PluginData; | |
81 friend class PluginListBuilder; | |
82 | |
83 String name_; | |
84 String file_; | |
85 String desc_; | |
86 HeapVector<Member<MimeClassInfo>> mimes_; | |
49 }; | 87 }; |
50 | 88 |
51 class PLATFORM_EXPORT PluginData : public RefCounted<PluginData> { | 89 class PLATFORM_EXPORT PluginData final |
90 : public GarbageCollectedFinalized<PluginData> { | |
52 WTF_MAKE_NONCOPYABLE(PluginData); | 91 WTF_MAKE_NONCOPYABLE(PluginData); |
53 | 92 |
54 public: | 93 public: |
55 static PassRefPtr<PluginData> Create(SecurityOrigin* main_frame_origin) { | 94 DECLARE_TRACE(); |
56 return AdoptRef(new PluginData(main_frame_origin)); | |
57 } | |
58 | 95 |
59 const Vector<PluginInfo>& Plugins() const { return plugins_; } | 96 static PluginData* Create() { return new PluginData(); } |
60 const Vector<MimeClassInfo>& Mimes() const { return mimes_; } | 97 |
61 const Vector<size_t>& MimePluginIndices() const { | 98 const HeapVector<Member<PluginInfo>>& Plugins() const { return plugins_; } |
62 return mime_plugin_indices_; | 99 const HeapVector<Member<MimeClassInfo>>& Mimes() const { return mimes_; } |
63 } | |
64 const SecurityOrigin* Origin() const { return main_frame_origin_.Get(); } | 100 const SecurityOrigin* Origin() const { return main_frame_origin_.Get(); } |
101 void UpdatePluginList(SecurityOrigin* main_frame_origin); | |
102 void ResetPluginData(); | |
65 | 103 |
66 bool SupportsMimeType(const String& mime_type) const; | 104 bool SupportsMimeType(const String& mime_type) const; |
67 String PluginNameForMimeType(const String& mime_type) const; | 105 String PluginNameForMimeType(const String& mime_type) const; |
68 | 106 |
69 // refreshBrowserSidePluginCache doesn't update existent instances of | 107 // refreshBrowserSidePluginCache doesn't update existent instances of |
70 // PluginData. | 108 // PluginData. |
71 static void RefreshBrowserSidePluginCache(); | 109 static void RefreshBrowserSidePluginCache(); |
72 | 110 |
73 private: | 111 private: |
74 explicit PluginData(SecurityOrigin* main_frame_origin); | 112 PluginData() {} |
75 const PluginInfo* PluginInfoForMimeType(const String& mime_type) const; | 113 const PluginInfo* PluginInfoForMimeType(const String& mime_type) const; |
76 | 114 |
77 Vector<PluginInfo> plugins_; | 115 HeapVector<Member<PluginInfo>> plugins_; |
78 Vector<MimeClassInfo> mimes_; | 116 HeapVector<Member<MimeClassInfo>> mimes_; |
79 Vector<size_t> mime_plugin_indices_; | |
80 RefPtr<SecurityOrigin> main_frame_origin_; | 117 RefPtr<SecurityOrigin> main_frame_origin_; |
tkent
2017/05/25 03:17:30
This member is removable.
lfg
2017/05/25 21:34:42
This is still set in UpdatePluginList, since the p
| |
81 }; | 118 }; |
82 | 119 |
83 } // namespace blink | 120 } // namespace blink |
84 | 121 |
85 #endif | 122 #endif |
OLD | NEW |