Index: webkit/glue/plugins/plugin_list.cc |
=================================================================== |
--- webkit/glue/plugins/plugin_list.cc (revision 26533) |
+++ webkit/glue/plugins/plugin_list.cc (working copy) |
@@ -15,6 +15,8 @@ |
#include "webkit/glue/webkit_glue.h" |
#include "googleurl/src/gurl.h" |
+#define kNpGoogleNaClPlugin (FILE_PATH_LITERAL("npgooglenaclplugin")) |
+ |
namespace NPAPI { |
base::LazyInstance<PluginList> g_singleton(base::LINKER_INITIALIZED); |
@@ -113,7 +115,8 @@ |
return true; |
} |
-PluginList::PluginList() : plugins_loaded_(false) { |
+PluginList::PluginList() : plugins_loaded_(false), |
+ use_internal_nacl_(false) { |
PlatformInit(); |
#if defined(OS_WIN) |
@@ -168,6 +171,10 @@ |
LoadPluginsFromDir(directories_to_scan[i], &new_plugins); |
} |
+ if (use_internal_nacl_) { |
+ LoadPlugin(FilePath(kNaClPluginLibraryName), &new_plugins); |
+ } |
+ |
if (webkit_glue::IsDefaultPluginEnabled()) |
LoadPlugin(FilePath(kDefaultPluginLibraryName), &new_plugins); |
@@ -209,6 +216,20 @@ |
plugins->push_back(plugin_info); |
} |
+bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, |
+ std::vector<WebPluginInfo>* plugins) { |
+ FilePath::StringType filename = |
+ StringToLowerASCII(info.path.BaseName().value()); |
+ |
+ // Don't load the external version of NaCl when we need to use |
+ // the internal one. |
+ if (use_internal_nacl_) { |
+ if (std::wstring::npos != filename.find(kNpGoogleNaClPlugin)) |
+ return false; |
+ } |
+ return PlatformShouldLoadPlugin(info, plugins); |
+} |
+ |
bool PluginList::FindPlugin(const std::string& mime_type, |
bool allow_wildcard, |
WebPluginInfo* info) { |
@@ -327,4 +348,24 @@ |
// TODO |
} |
+// static |
+void PluginList::UseInternalNaCl(PluginEntryPoints* entry_points) { |
+ // We access the singleton directly, and not through Singleton(), since |
+ // we don't want LoadPlugins() to be called. |
+ g_singleton.Pointer()->use_internal_nacl_ = true; |
+ |
+ const NPAPI::PluginVersionInfo nacl_plugin_info = { |
+ FilePath(kNaClPluginLibraryName), |
+ L"Native Client", |
+ L"Statically linked NaCl", |
+ L"1, 0, 0, 1", |
+ L"application/x-nacl-srpc", |
+ L"", |
+ L"", |
+ *entry_points |
+ }; |
+ |
+ Singleton()->RegisterInternalPlugin(nacl_plugin_info); |
+} |
+ |
} // namespace NPAPI |