| 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& Description() const { return description_; } |
| 43 const Vector<String>& Extensions() const { return extensions_; } |
| 44 const PluginInfo* Plugin() const { return plugin_; } |
| 45 |
| 46 private: |
| 47 friend class PluginData; |
| 48 friend class PluginListBuilder; |
| 49 |
| 50 String type_; |
| 51 String description_; |
| 52 Vector<String> extensions_; |
| 53 Member<PluginInfo> plugin_; |
| 38 }; | 54 }; |
| 39 | 55 |
| 40 inline bool operator==(const MimeClassInfo& a, const MimeClassInfo& b) { | 56 class PLATFORM_EXPORT PluginInfo final |
| 41 return a.type == b.type && a.desc == b.desc && a.extensions == b.extensions; | 57 : public GarbageCollectedFinalized<PluginInfo> { |
| 42 } | 58 public: |
| 59 DECLARE_TRACE(); |
| 43 | 60 |
| 44 struct PluginInfo { | 61 PluginInfo(const String& name, const String& filename, const String& desc); |
| 45 String name; | 62 |
| 46 String file; | 63 void AddMimeType(MimeClassInfo*); |
| 47 String desc; | 64 |
| 48 Vector<MimeClassInfo> mimes; | 65 const MimeClassInfo* GetMimeClassInfo(size_t index) const; |
| 66 const MimeClassInfo* GetMimeClassInfo(const String& type) const; |
| 67 size_t GetMimeClassInfoSize() const; |
| 68 |
| 69 const String& Name() const { return name_; } |
| 70 const String& Filename() const { return filename_; } |
| 71 const String& Description() const { return description_; } |
| 72 |
| 73 private: |
| 74 friend class MimeClassInfo; |
| 75 friend class PluginData; |
| 76 friend class PluginListBuilder; |
| 77 |
| 78 String name_; |
| 79 String filename_; |
| 80 String description_; |
| 81 HeapVector<Member<MimeClassInfo>> mimes_; |
| 49 }; | 82 }; |
| 50 | 83 |
| 51 class PLATFORM_EXPORT PluginData : public RefCounted<PluginData> { | 84 class PLATFORM_EXPORT PluginData final |
| 85 : public GarbageCollectedFinalized<PluginData> { |
| 52 WTF_MAKE_NONCOPYABLE(PluginData); | 86 WTF_MAKE_NONCOPYABLE(PluginData); |
| 53 | 87 |
| 54 public: | 88 public: |
| 55 static PassRefPtr<PluginData> Create(SecurityOrigin* main_frame_origin) { | 89 DECLARE_TRACE(); |
| 56 return AdoptRef(new PluginData(main_frame_origin)); | |
| 57 } | |
| 58 | 90 |
| 59 const Vector<PluginInfo>& Plugins() const { return plugins_; } | 91 static PluginData* Create() { return new PluginData(); } |
| 60 const Vector<MimeClassInfo>& Mimes() const { return mimes_; } | 92 |
| 61 const Vector<size_t>& MimePluginIndices() const { | 93 const HeapVector<Member<PluginInfo>>& Plugins() const { return plugins_; } |
| 62 return mime_plugin_indices_; | 94 const HeapVector<Member<MimeClassInfo>>& Mimes() const { return mimes_; } |
| 63 } | |
| 64 const SecurityOrigin* Origin() const { return main_frame_origin_.Get(); } | 95 const SecurityOrigin* Origin() const { return main_frame_origin_.Get(); } |
| 96 void UpdatePluginList(SecurityOrigin* main_frame_origin); |
| 97 void ResetPluginData(); |
| 65 | 98 |
| 66 bool SupportsMimeType(const String& mime_type) const; | 99 bool SupportsMimeType(const String& mime_type) const; |
| 67 String PluginNameForMimeType(const String& mime_type) const; | 100 String PluginNameForMimeType(const String& mime_type) const; |
| 68 | 101 |
| 69 // refreshBrowserSidePluginCache doesn't update existent instances of | 102 // refreshBrowserSidePluginCache doesn't update existent instances of |
| 70 // PluginData. | 103 // PluginData. |
| 71 static void RefreshBrowserSidePluginCache(); | 104 static void RefreshBrowserSidePluginCache(); |
| 72 | 105 |
| 73 private: | 106 private: |
| 74 explicit PluginData(SecurityOrigin* main_frame_origin); | 107 PluginData() {} |
| 75 const PluginInfo* PluginInfoForMimeType(const String& mime_type) const; | |
| 76 | 108 |
| 77 Vector<PluginInfo> plugins_; | 109 HeapVector<Member<PluginInfo>> plugins_; |
| 78 Vector<MimeClassInfo> mimes_; | 110 HeapVector<Member<MimeClassInfo>> mimes_; |
| 79 Vector<size_t> mime_plugin_indices_; | |
| 80 RefPtr<SecurityOrigin> main_frame_origin_; | 111 RefPtr<SecurityOrigin> main_frame_origin_; |
| 81 }; | 112 }; |
| 82 | 113 |
| 83 } // namespace blink | 114 } // namespace blink |
| 84 | 115 |
| 85 #endif | 116 #endif |
| OLD | NEW |