Chromium Code Reviews| Index: third_party/WebKit/Source/platform/plugins/PluginData.cpp |
| diff --git a/third_party/WebKit/Source/platform/plugins/PluginData.cpp b/third_party/WebKit/Source/platform/plugins/PluginData.cpp |
| index 4897488b842de7a845c17c668d7a12426384c840..5bf74133de97eb177d0a345f77c148583719b0ab 100644 |
| --- a/third_party/WebKit/Source/platform/plugins/PluginData.cpp |
| +++ b/third_party/WebKit/Source/platform/plugins/PluginData.cpp |
| @@ -25,47 +25,14 @@ |
| #include "platform/plugins/PluginListBuilder.h" |
| #include "public/platform/Platform.h" |
| +#include "public/platform/WebSecurityOrigin.h" |
| namespace blink { |
| - |
| -class PluginCache { |
| -public: |
| - PluginCache() : m_loaded(false), m_refresh(false) { } |
| - ~PluginCache() { reset(false); } |
| - |
| - void reset(bool refresh) |
| - { |
| - m_plugins.clear(); |
| - m_loaded = false; |
| - m_refresh = refresh; |
| - } |
| - |
| - const Vector<PluginInfo>& plugins() |
| - { |
| - if (!m_loaded) { |
| - PluginListBuilder builder(&m_plugins); |
| - Platform::current()->getPluginList(m_refresh, &builder); |
| - m_loaded = true; |
| - m_refresh = false; |
| - } |
| - return m_plugins; |
| - } |
| - |
| -private: |
| - Vector<PluginInfo> m_plugins; |
| - bool m_loaded; |
| - bool m_refresh; |
| -}; |
| - |
| -static PluginCache& pluginCache() |
| +PluginData::PluginData(const WebSecurityOrigin* origin) |
|
alexmos
2016/08/02 22:06:28
nit: empty line before this.
trizzofo
2016/08/03 00:08:37
Done.
|
| { |
| - DEFINE_STATIC_LOCAL(PluginCache, cache, ()); |
| - return cache; |
| -} |
| - |
| -PluginData::PluginData(const Page* page) |
| -{ |
| - initPlugins(page); |
| + PluginListBuilder builder(&m_plugins); |
| + Platform::current()->getPluginList(m_refresh, origin, &builder); |
| + m_refresh = false; |
| for (unsigned i = 0; i < m_plugins.size(); ++i) { |
| const PluginInfo& plugin = m_plugins[i]; |
| @@ -103,22 +70,17 @@ String PluginData::pluginNameForMimeType(const String& mimeType) const |
| return String(); |
| } |
| -void PluginData::initPlugins(const Page*) |
| -{ |
| - const Vector<PluginInfo>& plugins = pluginCache().plugins(); |
| - for (size_t i = 0; i < plugins.size(); ++i) |
| - m_plugins.append(plugins[i]); |
| -} |
| - |
| void PluginData::refresh() |
| { |
| - pluginCache().reset(true); |
| - pluginCache().plugins(); // Force the plugins to be reloaded now. |
| + m_refresh = true; |
| } |
| String getPluginMimeTypeFromExtension(const String& extension) |
| { |
| - const Vector<PluginInfo>& plugins = pluginCache().plugins(); |
| + Vector<PluginInfo> plugins; |
| + PluginListBuilder builder(&plugins); |
| + Platform::current()->getPluginList(PluginData::m_refresh, nullptr, &builder); |
|
alexmos
2016/08/02 22:06:28
Why doesn't this case need the origin? (Or rather
tommycli
2016/08/02 23:03:16
Hi. This is used to fill-in the MIME types of unkn
alexmos
2016/08/04 05:32:02
Sounds reasonable to me.
|
| + PluginData::m_refresh = false; |
| for (size_t i = 0; i < plugins.size(); ++i) { |
| for (size_t j = 0; j < plugins[i].mimes.size(); ++j) { |
| const MimeClassInfo& mime = plugins[i].mimes[j]; |
| @@ -132,4 +94,6 @@ String getPluginMimeTypeFromExtension(const String& extension) |
| return String(); |
| } |
| +bool PluginData::m_refresh = false; |
| + |
| } // namespace blink |