Chromium Code Reviews| 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 explicit MimeClassInfo(String, String, PluginInfo*); | |
|
tkent
2017/05/25 00:10:32
Remove |explicit|
Make the first and second argume
lfg
2017/05/25 01:42:40
Done. I agree that the argument names are useful,
lfg
2017/05/25 01:47:39
Actually, never mind, I just realized that the cod
| |
| 40 | |
| 41 void AddExtension(String); | |
| 42 | |
| 43 const String& type() const { return type_; } | |
|
tkent
2017/05/25 00:10:32
This class is not web-exposed. So all member func
lfg
2017/05/25 01:42:40
Done. I think we need to update the blink coding s
tkent
2017/05/25 03:17:30
Yeah, it's outdated. The latest one is https://do
| |
| 44 const String& desc() const { return desc_; } | |
| 45 const Vector<String>& extensions() const { return extensions_; } | |
| 46 const PluginInfo* plugin() const { return plugin_; } | |
| 47 | |
| 48 bool operator==(const MimeClassInfo& info) { | |
| 49 return type_ == info.type_ && desc_ == info.desc_ && | |
| 50 extensions_ == info.extensions_; | |
| 51 } | |
| 52 | |
| 53 private: | |
| 54 friend class PluginData; | |
| 55 friend class PluginListBuilder; | |
| 56 | |
| 57 String type_; | |
| 58 String desc_; | |
| 59 Vector<String> extensions_; | |
| 60 Member<PluginInfo> plugin_; | |
| 38 }; | 61 }; |
| 39 | 62 |
| 40 inline bool operator==(const MimeClassInfo& a, const MimeClassInfo& b) { | 63 class PLATFORM_EXPORT PluginInfo final |
| 41 return a.type == b.type && a.desc == b.desc && a.extensions == b.extensions; | 64 : public GarbageCollectedFinalized<PluginInfo> { |
| 42 } | 65 public: |
| 66 DECLARE_TRACE(); | |
| 43 | 67 |
| 44 struct PluginInfo { | 68 explicit PluginInfo(String, String, String); |
|
tkent
2017/05/25 00:10:32
Remove |explicit|.
Make the all argument |const St
lfg
2017/05/25 01:42:40
Done.
| |
| 45 String name; | 69 |
| 46 String file; | 70 void AddMimeType(MimeClassInfo*); |
| 47 String desc; | 71 |
| 48 Vector<MimeClassInfo> mimes; | 72 const MimeClassInfo* GetMimeClassInfo(size_t index) const; |
| 73 const MimeClassInfo* GetMimeClassInfo(const String& type) const; | |
| 74 size_t GetMimeClassInfoSize() const; | |
| 75 | |
| 76 const String& name() const { return name_; } | |
|
tkent
2017/05/25 00:10:32
Function names should start with a capital letter.
lfg
2017/05/25 01:42:40
Done.
| |
| 77 const String& file() const { return file_; } | |
| 78 const String& desc() const { return desc_; } | |
| 79 | |
| 80 private: | |
| 81 friend class MimeClassInfo; | |
| 82 friend class PluginData; | |
| 83 friend class PluginListBuilder; | |
| 84 | |
| 85 String name_; | |
| 86 String file_; | |
| 87 String desc_; | |
| 88 HeapVector<Member<MimeClassInfo>> mimes_; | |
| 49 }; | 89 }; |
| 50 | 90 |
| 51 class PLATFORM_EXPORT PluginData : public RefCounted<PluginData> { | 91 class PLATFORM_EXPORT PluginData final |
| 92 : public GarbageCollectedFinalized<PluginData> { | |
| 52 WTF_MAKE_NONCOPYABLE(PluginData); | 93 WTF_MAKE_NONCOPYABLE(PluginData); |
| 53 | 94 |
| 54 public: | 95 public: |
| 55 static PassRefPtr<PluginData> Create(SecurityOrigin* main_frame_origin) { | 96 DECLARE_TRACE(); |
| 56 return AdoptRef(new PluginData(main_frame_origin)); | |
| 57 } | |
| 58 | 97 |
| 59 const Vector<PluginInfo>& Plugins() const { return plugins_; } | 98 static PluginData* Create() { return new PluginData(); } |
| 60 const Vector<MimeClassInfo>& Mimes() const { return mimes_; } | 99 |
| 61 const Vector<size_t>& MimePluginIndices() const { | 100 PluginData() {} |
|
tkent
2017/05/25 00:10:32
Do we need both of the factory function and the pu
lfg
2017/05/25 01:42:40
No, moved to private.
| |
| 62 return mime_plugin_indices_; | 101 |
| 63 } | 102 const HeapVector<Member<PluginInfo>>& Plugins() const { return plugins_; } |
| 103 const HeapVector<Member<MimeClassInfo>>& Mimes() const { return mimes_; } | |
| 64 const SecurityOrigin* Origin() const { return main_frame_origin_.Get(); } | 104 const SecurityOrigin* Origin() const { return main_frame_origin_.Get(); } |
| 105 void UpdatePluginList(SecurityOrigin* main_frame_origin); | |
| 106 void ResetPluginData(); | |
| 65 | 107 |
| 66 bool SupportsMimeType(const String& mime_type) const; | 108 bool SupportsMimeType(const String& mime_type) const; |
| 67 String PluginNameForMimeType(const String& mime_type) const; | 109 String PluginNameForMimeType(const String& mime_type) const; |
| 68 | 110 |
| 69 // refreshBrowserSidePluginCache doesn't update existent instances of | 111 // refreshBrowserSidePluginCache doesn't update existent instances of |
| 70 // PluginData. | 112 // PluginData. |
| 71 static void RefreshBrowserSidePluginCache(); | 113 static void RefreshBrowserSidePluginCache(); |
| 72 | 114 |
| 73 private: | 115 private: |
| 74 explicit PluginData(SecurityOrigin* main_frame_origin); | |
| 75 const PluginInfo* PluginInfoForMimeType(const String& mime_type) const; | 116 const PluginInfo* PluginInfoForMimeType(const String& mime_type) const; |
| 76 | 117 |
| 77 Vector<PluginInfo> plugins_; | 118 HeapVector<Member<PluginInfo>> plugins_; |
| 78 Vector<MimeClassInfo> mimes_; | 119 HeapVector<Member<MimeClassInfo>> mimes_; |
| 79 Vector<size_t> mime_plugin_indices_; | |
| 80 RefPtr<SecurityOrigin> main_frame_origin_; | 120 RefPtr<SecurityOrigin> main_frame_origin_; |
| 81 }; | 121 }; |
| 82 | 122 |
| 83 } // namespace blink | 123 } // namespace blink |
| 84 | 124 |
| 85 #endif | 125 #endif |
| OLD | NEW |