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 "public/platform/WebSecurityOrigin.h" | |
| 24 #include "wtf/Noncopyable.h" | 25 #include "wtf/Noncopyable.h" | 
| 25 #include "wtf/RefCounted.h" | 26 #include "wtf/RefCounted.h" | 
| 26 #include "wtf/Vector.h" | 27 #include "wtf/Vector.h" | 
| 27 #include "wtf/text/WTFString.h" | 28 #include "wtf/text/WTFString.h" | 
| 28 | 29 | 
| 29 namespace blink { | 30 namespace blink { | 
| 30 | 31 | 
| 31 class Page; | |
| 32 struct PluginInfo; | 32 struct PluginInfo; | 
| 33 | 33 | 
| 34 struct MimeClassInfo { | 34 struct MimeClassInfo { | 
| 35 String type; | 35 String type; | 
| 36 String desc; | 36 String desc; | 
| 37 Vector<String> extensions; | 37 Vector<String> extensions; | 
| 38 }; | 38 }; | 
| 39 | 39 | 
| 40 inline bool operator==(const MimeClassInfo& a, const MimeClassInfo& b) | 40 inline bool operator==(const MimeClassInfo& a, const MimeClassInfo& b) | 
| 41 { | 41 { | 
| 42 return a.type == b.type && a.desc == b.desc && a.extensions == b.extensions; | 42 return a.type == b.type && a.desc == b.desc && a.extensions == b.extensions; | 
| 43 } | 43 } | 
| 44 | 44 | 
| 45 struct PluginInfo { | 45 struct PluginInfo { | 
| 46 String name; | 46 String name; | 
| 47 String file; | 47 String file; | 
| 48 String desc; | 48 String desc; | 
| 49 Vector<MimeClassInfo> mimes; | 49 Vector<MimeClassInfo> mimes; | 
| 50 }; | 50 }; | 
| 51 | 51 | 
| 52 class PLATFORM_EXPORT PluginData : public RefCounted<PluginData> { | 52 class PLATFORM_EXPORT PluginData : public RefCounted<PluginData> { | 
| 53 WTF_MAKE_NONCOPYABLE(PluginData); | 53 WTF_MAKE_NONCOPYABLE(PluginData); | 
| 54 public: | 54 public: | 
| 55 static PassRefPtr<PluginData> create(const Page* page) { return adoptRef(new PluginData(page)); } | 55 static PassRefPtr<PluginData> create(const WebSecurityOrigin& origin) { retu rn adoptRef(new PluginData(origin)); } | 
| 56 | 56 | 
| 57 const Vector<PluginInfo>& plugins() const { return m_plugins; } | 57 const Vector<PluginInfo>& plugins() const { return m_plugins; } | 
| 58 const Vector<MimeClassInfo>& mimes() const { return m_mimes; } | 58 const Vector<MimeClassInfo>& mimes() const { return m_mimes; } | 
| 59 const Vector<size_t>& mimePluginIndices() const { return m_mimePluginIndices ; } | 59 const Vector<size_t>& mimePluginIndices() const { return m_mimePluginIndices ; } | 
| 60 | 60 | 
| 61 bool supportsMimeType(const String& mimeType) const; | 61 bool supportsMimeType(const String& mimeType) const; | 
| 62 String pluginNameForMimeType(const String& mimeType) const; | 62 String pluginNameForMimeType(const String& mimeType) const; | 
| 63 void checkOriginChange(const WebSecurityOrigin&); | |
| 63 | 64 | 
| 64 static void refresh(); | 65 static void refresh(); | 
| 66 static bool m_refresh; | |
| 65 | 67 | 
| 66 private: | 68 private: | 
| 67 explicit PluginData(const Page*); | 69 explicit PluginData(const WebSecurityOrigin&); | 
| 68 void initPlugins(const Page*); | 70 void initPlugins(const WebSecurityOrigin&); | 
| 69 const PluginInfo* pluginInfoForMimeType(const String& mimeType) const; | 71 const PluginInfo* pluginInfoForMimeType(const String& mimeType) const; | 
| 70 | 72 | 
| 71 Vector<PluginInfo> m_plugins; | 73 Vector<PluginInfo> m_plugins; | 
| 72 Vector<MimeClassInfo> m_mimes; | 74 Vector<MimeClassInfo> m_mimes; | 
| 73 Vector<size_t> m_mimePluginIndices; | 75 Vector<size_t> m_mimePluginIndices; | 
| 76 WebSecurityOrigin m_origin; | |
| 
 
tommycli
2016/07/29 23:38:19
my suggestion: Don't save m_origin here. Save it o
 
trizzofo
2016/08/01 23:36:14
Done.
 
 | |
| 74 }; | 77 }; | 
| 75 | 78 | 
| 76 // Checks if any of the plugins handle this extension, and if so returns the | 79 // Checks if any of the plugins handle this extension, and if so returns the | 
| 77 // plugin's mime type for this extension. Otherwise returns an empty string. | 80 // plugin's mime type for this extension. Otherwise returns an empty string. | 
| 78 PLATFORM_EXPORT String getPluginMimeTypeFromExtension(const String& extension); | 81 PLATFORM_EXPORT String getPluginMimeTypeFromExtension(const String& extension); | 
| 79 | 82 | 
| 80 } // namespace blink | 83 } // namespace blink | 
| 81 | 84 | 
| 82 #endif | 85 #endif | 
| OLD | NEW |