1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file.
4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/files/file_path.h"
6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/lazy_instance.h"
7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/path_service.h"
8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/utf_string_conversions.h"
9f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "chrome/browser/extensions/extension_service.h"
10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/extensions/plugin_manager.h"
11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/profiles/profile.h"
13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/common/chrome_paths.h"
14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/common/extensions/api/plugins/plugins_handler.h"
15f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "chrome/common/extensions/manifest_handlers/mime_types_handler.h"
16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/public/browser/plugin_service.h"
17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/public/common/pepper_plugin_info.h"
180529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "extensions/browser/extension_registry.h"
19f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "extensions/common/extension.h"
207dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "url/gurl.h"
21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
22116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#if !defined(DISABLE_NACL)
2303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "components/nacl/common/nacl_constants.h"
24116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif
25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
2603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)using content::PluginService;
2703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace extensions {
29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)PluginManager::PluginManager(content::BrowserContext* context)
310529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    : profile_(Profile::FromBrowserContext(context)),
320529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      extension_registry_observer_(this) {
330529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)PluginManager::~PluginManager() {
37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)static base::LazyInstance<BrowserContextKeyedAPIFactory<PluginManager> >
40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    g_factory = LAZY_INSTANCE_INITIALIZER;
41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// static
43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)BrowserContextKeyedAPIFactory<PluginManager>*
44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)PluginManager::GetFactoryInstance() {
455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return g_factory.Pointer();
46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
480529e5d033099cbfc42635f6f6183833b09dff6eBen Murdochvoid PluginManager::OnExtensionLoaded(content::BrowserContext* browser_context,
490529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                      const Extension* extension) {
500529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  bool plugins_or_nacl_changed = false;
510529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  if (PluginInfo::HasPlugins(extension)) {
520529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    const PluginInfo::PluginVector* plugins = PluginInfo::GetPlugins(extension);
530529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    CHECK(plugins);
540529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    plugins_or_nacl_changed = true;
550529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    for (PluginInfo::PluginVector::const_iterator plugin = plugins->begin();
560529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch         plugin != plugins->end();
570529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch         ++plugin) {
580529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      PluginService::GetInstance()->RefreshPlugins();
590529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      PluginService::GetInstance()->AddExtraPluginPath(plugin->path);
600529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      ChromePluginServiceFilter* filter =
610529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch          ChromePluginServiceFilter::GetInstance();
620529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      if (plugin->is_public) {
630529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch        filter->RestrictPluginToProfileAndOrigin(
640529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch            plugin->path, profile_, GURL());
650529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      } else {
660529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch        filter->RestrictPluginToProfileAndOrigin(
670529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch            plugin->path, profile_, extension->url());
68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      }
69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    }
700529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  }
71868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
72116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#if !defined(DISABLE_NACL)
730529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  const NaClModuleInfo::List* nacl_modules =
740529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      NaClModuleInfo::GetNaClModules(extension);
750529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  if (nacl_modules) {
760529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    plugins_or_nacl_changed = true;
770529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    for (NaClModuleInfo::List::const_iterator module = nacl_modules->begin();
780529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch         module != nacl_modules->end();
790529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch         ++module) {
800529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      RegisterNaClModule(*module);
81868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    }
820529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    UpdatePluginListWithNaClModules();
830529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  }
84116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif
85868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
86f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
87f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  if (handler && !handler->handler_url().empty()) {
88f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)    plugins_or_nacl_changed = true;
896d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
906d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    content::WebPluginInfo info;
916d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    info.type = content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN;
926d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    info.name = base::UTF8ToUTF16(handler->extension_id());
936d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    info.path = base::FilePath::FromUTF8Unsafe(handler->extension_id());
946d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
956d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    for (std::set<std::string>::const_iterator mime_type =
966d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)         handler->mime_type_set().begin();
976d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)         mime_type != handler->mime_type_set().end(); ++mime_type) {
986d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)      content::WebPluginMimeType mime_type_info;
996d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)      mime_type_info.mime_type = *mime_type;
1006d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)      info.mime_types.push_back(mime_type_info);
1016d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    }
1026d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
1036d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    PluginService::GetInstance()->RefreshPlugins();
1046d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    PluginService::GetInstance()->RegisterInternalPlugin(info, true);
105f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  }
106f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
1070529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  if (plugins_or_nacl_changed)
1080529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    PluginService::GetInstance()->PurgePluginListCache(profile_, false);
1090529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch}
110868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
1110529e5d033099cbfc42635f6f6183833b09dff6eBen Murdochvoid PluginManager::OnExtensionUnloaded(
1120529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    content::BrowserContext* browser_context,
1130529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    const Extension* extension,
1140529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    UnloadedExtensionInfo::Reason reason) {
1150529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  bool plugins_or_nacl_changed = false;
1160529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  if (PluginInfo::HasPlugins(extension)) {
1170529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    const PluginInfo::PluginVector* plugins = PluginInfo::GetPlugins(extension);
1180529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    plugins_or_nacl_changed = true;
1190529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    for (PluginInfo::PluginVector::const_iterator plugin = plugins->begin();
1200529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch         plugin != plugins->end();
1210529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch         ++plugin) {
1220529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      PluginService::GetInstance()->ForcePluginShutdown(plugin->path);
1230529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      PluginService::GetInstance()->RefreshPlugins();
1240529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      PluginService::GetInstance()->RemoveExtraPluginPath(plugin->path);
1250529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      ChromePluginServiceFilter::GetInstance()->UnrestrictPlugin(plugin->path);
126868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    }
1270529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  }
128868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
129116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#if !defined(DISABLE_NACL)
1300529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  const NaClModuleInfo::List* nacl_modules =
1310529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      NaClModuleInfo::GetNaClModules(extension);
1320529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  if (nacl_modules) {
1330529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    plugins_or_nacl_changed = true;
1340529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    for (NaClModuleInfo::List::const_iterator module = nacl_modules->begin();
1350529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch         module != nacl_modules->end();
1360529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch         ++module) {
1370529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      UnregisterNaClModule(*module);
1380529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    }
1390529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    UpdatePluginListWithNaClModules();
140868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
141116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif
1420529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch
143f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
144f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  if (handler && !handler->handler_url().empty()) {
145f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)    plugins_or_nacl_changed = true;
1466d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    base::FilePath path =
1476d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)        base::FilePath::FromUTF8Unsafe(handler->extension_id());
1486d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    PluginService::GetInstance()->UnregisterInternalPlugin(path);
1496d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    PluginService::GetInstance()->ForcePluginShutdown(path);
1506d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    PluginService::GetInstance()->RefreshPlugins();
151f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  }
152f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
1530529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  if (plugins_or_nacl_changed)
1540529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    PluginService::GetInstance()->PurgePluginListCache(profile_, false);
155868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
156868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
157116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#if !defined(DISABLE_NACL)
158116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
159868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void PluginManager::RegisterNaClModule(const NaClModuleInfo& info) {
160868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  DCHECK(FindNaClModule(info.url) == nacl_module_list_.end());
161868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  nacl_module_list_.push_front(info);
162868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
163868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
164868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void PluginManager::UnregisterNaClModule(const NaClModuleInfo& info) {
165868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  NaClModuleInfo::List::iterator iter = FindNaClModule(info.url);
166868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  DCHECK(iter != nacl_module_list_.end());
167868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  nacl_module_list_.erase(iter);
168868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
169868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
170868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void PluginManager::UpdatePluginListWithNaClModules() {
171868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // An extension has been added which has a nacl_module component, which means
172868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // there is a MIME type that module wants to handle, so we need to add that
173868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // MIME type to plugins which handle NaCl modules in order to allow the
174868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // individual modules to handle these types.
175868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  base::FilePath path;
176868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  if (!PathService::Get(chrome::FILE_NACL_PLUGIN, &path))
177868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    return;
178868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  const content::PepperPluginInfo* pepper_info =
179868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      PluginService::GetInstance()->GetRegisteredPpapiPluginInfo(path);
180868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  if (!pepper_info)
181868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    return;
182868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
183ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  std::vector<content::WebPluginMimeType>::const_iterator mime_iter;
184868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Check each MIME type the plugins handle for the NaCl MIME type.
185868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  for (mime_iter = pepper_info->mime_types.begin();
186868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)       mime_iter != pepper_info->mime_types.end(); ++mime_iter) {
18703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    if (mime_iter->mime_type == nacl::kNaClPluginMimeType) {
188868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      // This plugin handles "application/x-nacl".
189868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
190868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      PluginService::GetInstance()->UnregisterInternalPlugin(pepper_info->path);
191868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
192ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      content::WebPluginInfo info = pepper_info->ToWebPluginInfo();
193868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
194868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      for (NaClModuleInfo::List::const_iterator iter =
195868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)               nacl_module_list_.begin();
196868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)           iter != nacl_module_list_.end(); ++iter) {
197868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        // Add the MIME type specified in the extension to this NaCl plugin,
198868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        // With an extra "nacl" argument to specify the location of the NaCl
199868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        // manifest file.
200ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch        content::WebPluginMimeType mime_type_info;
201868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        mime_type_info.mime_type = iter->mime_type;
2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        mime_type_info.additional_param_names.push_back(
2035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            base::UTF8ToUTF16("nacl"));
204868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        mime_type_info.additional_param_values.push_back(
2055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            base::UTF8ToUTF16(iter->url.spec()));
206868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        info.mime_types.push_back(mime_type_info);
207868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      }
208868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
209868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      PluginService::GetInstance()->RefreshPlugins();
210868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      PluginService::GetInstance()->RegisterInternalPlugin(info, true);
211868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      // This plugin has been modified, no need to check the rest of its
212868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      // types, but continue checking other plugins.
213868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      break;
214868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    }
215868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
216868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
217868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
218868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)NaClModuleInfo::List::iterator PluginManager::FindNaClModule(const GURL& url) {
219868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  for (NaClModuleInfo::List::iterator iter = nacl_module_list_.begin();
220868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)       iter != nacl_module_list_.end(); ++iter) {
221868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    if (iter->url == url)
222868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      return iter;
223868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
224868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  return nacl_module_list_.end();
225868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
226868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
227116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif  // !defined(DISABLE_NACL)
228116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
229868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}  // namespace extensions
230