| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 6 #include "base/lazy_instance.h" | 6 #include "base/lazy_instance.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/plugin_manager.h" | 10 #include "chrome/browser/extensions/plugin_manager.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 // static | 42 // static |
| 43 BrowserContextKeyedAPIFactory<PluginManager>* | 43 BrowserContextKeyedAPIFactory<PluginManager>* |
| 44 PluginManager::GetFactoryInstance() { | 44 PluginManager::GetFactoryInstance() { |
| 45 return g_factory.Pointer(); | 45 return g_factory.Pointer(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void PluginManager::OnExtensionLoaded(content::BrowserContext* browser_context, | 48 void PluginManager::OnExtensionLoaded(content::BrowserContext* browser_context, |
| 49 const Extension* extension) { | 49 const Extension* extension) { |
| 50 bool plugins_or_nacl_changed = false; | 50 bool plugins_or_nacl_changed = false; |
| 51 if (PluginInfo::HasPlugins(extension)) { | |
| 52 const PluginInfo::PluginVector* plugins = PluginInfo::GetPlugins(extension); | |
| 53 CHECK(plugins); | |
| 54 plugins_or_nacl_changed = true; | |
| 55 for (PluginInfo::PluginVector::const_iterator plugin = plugins->begin(); | |
| 56 plugin != plugins->end(); | |
| 57 ++plugin) { | |
| 58 PluginService::GetInstance()->RefreshPlugins(); | |
| 59 PluginService::GetInstance()->AddExtraPluginPath(plugin->path); | |
| 60 ChromePluginServiceFilter* filter = | |
| 61 ChromePluginServiceFilter::GetInstance(); | |
| 62 if (plugin->is_public) { | |
| 63 filter->RestrictPluginToProfileAndOrigin( | |
| 64 plugin->path, profile_, GURL()); | |
| 65 } else { | |
| 66 filter->RestrictPluginToProfileAndOrigin( | |
| 67 plugin->path, profile_, extension->url()); | |
| 68 } | |
| 69 } | |
| 70 } | |
| 71 | |
| 72 #if !defined(DISABLE_NACL) | 51 #if !defined(DISABLE_NACL) |
| 73 const NaClModuleInfo::List* nacl_modules = | 52 const NaClModuleInfo::List* nacl_modules = |
| 74 NaClModuleInfo::GetNaClModules(extension); | 53 NaClModuleInfo::GetNaClModules(extension); |
| 75 if (nacl_modules) { | 54 if (nacl_modules) { |
| 76 plugins_or_nacl_changed = true; | 55 plugins_or_nacl_changed = true; |
| 77 for (NaClModuleInfo::List::const_iterator module = nacl_modules->begin(); | 56 for (NaClModuleInfo::List::const_iterator module = nacl_modules->begin(); |
| 78 module != nacl_modules->end(); | 57 module != nacl_modules->end(); |
| 79 ++module) { | 58 ++module) { |
| 80 RegisterNaClModule(*module); | 59 RegisterNaClModule(*module); |
| 81 } | 60 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 111 | 90 |
| 112 if (plugins_or_nacl_changed) | 91 if (plugins_or_nacl_changed) |
| 113 PluginService::GetInstance()->PurgePluginListCache(profile_, false); | 92 PluginService::GetInstance()->PurgePluginListCache(profile_, false); |
| 114 } | 93 } |
| 115 | 94 |
| 116 void PluginManager::OnExtensionUnloaded( | 95 void PluginManager::OnExtensionUnloaded( |
| 117 content::BrowserContext* browser_context, | 96 content::BrowserContext* browser_context, |
| 118 const Extension* extension, | 97 const Extension* extension, |
| 119 UnloadedExtensionInfo::Reason reason) { | 98 UnloadedExtensionInfo::Reason reason) { |
| 120 bool plugins_or_nacl_changed = false; | 99 bool plugins_or_nacl_changed = false; |
| 121 if (PluginInfo::HasPlugins(extension)) { | |
| 122 const PluginInfo::PluginVector* plugins = PluginInfo::GetPlugins(extension); | |
| 123 plugins_or_nacl_changed = true; | |
| 124 for (PluginInfo::PluginVector::const_iterator plugin = plugins->begin(); | |
| 125 plugin != plugins->end(); | |
| 126 ++plugin) { | |
| 127 PluginService::GetInstance()->ForcePluginShutdown(plugin->path); | |
| 128 PluginService::GetInstance()->RefreshPlugins(); | |
| 129 PluginService::GetInstance()->RemoveExtraPluginPath(plugin->path); | |
| 130 ChromePluginServiceFilter::GetInstance()->UnrestrictPlugin(plugin->path); | |
| 131 } | |
| 132 } | |
| 133 | |
| 134 #if !defined(DISABLE_NACL) | 100 #if !defined(DISABLE_NACL) |
| 135 const NaClModuleInfo::List* nacl_modules = | 101 const NaClModuleInfo::List* nacl_modules = |
| 136 NaClModuleInfo::GetNaClModules(extension); | 102 NaClModuleInfo::GetNaClModules(extension); |
| 137 if (nacl_modules) { | 103 if (nacl_modules) { |
| 138 plugins_or_nacl_changed = true; | 104 plugins_or_nacl_changed = true; |
| 139 for (NaClModuleInfo::List::const_iterator module = nacl_modules->begin(); | 105 for (NaClModuleInfo::List::const_iterator module = nacl_modules->begin(); |
| 140 module != nacl_modules->end(); | 106 module != nacl_modules->end(); |
| 141 ++module) { | 107 ++module) { |
| 142 UnregisterNaClModule(*module); | 108 UnregisterNaClModule(*module); |
| 143 } | 109 } |
| 144 UpdatePluginListWithNaClModules(); | 110 UpdatePluginListWithNaClModules(); |
| 145 } | 111 } |
| 146 #endif | 112 #endif |
| 147 | 113 |
| 148 const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 114 const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
| 149 if (handler && handler->HasPlugin()) { | 115 if (handler && handler->HasPlugin()) { |
| 150 plugins_or_nacl_changed = true; | 116 plugins_or_nacl_changed = true; |
| 151 base::FilePath path = handler->GetPluginPath(); | 117 base::FilePath path = handler->GetPluginPath(); |
| 152 PluginService::GetInstance()->UnregisterInternalPlugin(path); | 118 PluginService::GetInstance()->UnregisterInternalPlugin(path); |
| 153 PluginService::GetInstance()->ForcePluginShutdown(path); | |
| 154 PluginService::GetInstance()->RefreshPlugins(); | 119 PluginService::GetInstance()->RefreshPlugins(); |
| 155 } | 120 } |
| 156 | 121 |
| 157 if (plugins_or_nacl_changed) | 122 if (plugins_or_nacl_changed) |
| 158 PluginService::GetInstance()->PurgePluginListCache(profile_, false); | 123 PluginService::GetInstance()->PurgePluginListCache(profile_, false); |
| 159 } | 124 } |
| 160 | 125 |
| 161 #if !defined(DISABLE_NACL) | 126 #if !defined(DISABLE_NACL) |
| 162 | 127 |
| 163 void PluginManager::RegisterNaClModule(const NaClModuleInfo& info) { | 128 void PluginManager::RegisterNaClModule(const NaClModuleInfo& info) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 iter != nacl_module_list_.end(); ++iter) { | 189 iter != nacl_module_list_.end(); ++iter) { |
| 225 if (iter->url == url) | 190 if (iter->url == url) |
| 226 return iter; | 191 return iter; |
| 227 } | 192 } |
| 228 return nacl_module_list_.end(); | 193 return nacl_module_list_.end(); |
| 229 } | 194 } |
| 230 | 195 |
| 231 #endif // !defined(DISABLE_NACL) | 196 #endif // !defined(DISABLE_NACL) |
| 232 | 197 |
| 233 } // namespace extensions | 198 } // namespace extensions |
| OLD | NEW |