| 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" |
| 11 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 11 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/common/extensions/api/plugins/plugins_handler.h" | 14 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
| 15 #include "chrome/common/extensions/manifest_handlers/mime_types_handler.h" | 15 #include "chrome/common/extensions/manifest_handlers/mime_types_handler.h" |
| 16 #include "content/public/browser/plugin_service.h" | 16 #include "content/public/browser/plugin_service.h" |
| 17 #include "content/public/common/pepper_plugin_info.h" | 17 #include "content/public/common/pepper_plugin_info.h" |
| 18 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
| 19 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
| 20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 21 | 21 |
| 22 using content::PluginService; | 22 using content::PluginService; |
| 23 | 23 |
| 24 #if !defined(DISABLE_NACL) |
| 24 static const char kNaClPluginMimeType[] = "application/x-nacl"; | 25 static const char kNaClPluginMimeType[] = "application/x-nacl"; |
| 26 #endif |
| 25 | 27 |
| 26 namespace extensions { | 28 namespace extensions { |
| 27 | 29 |
| 28 PluginManager::PluginManager(content::BrowserContext* context) | 30 PluginManager::PluginManager(content::BrowserContext* context) |
| 29 : profile_(Profile::FromBrowserContext(context)), | 31 : profile_(Profile::FromBrowserContext(context)), |
| 30 extension_registry_observer_(this) { | 32 extension_registry_observer_(this) { |
| 31 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); | 33 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); |
| 32 } | 34 } |
| 33 | 35 |
| 34 PluginManager::~PluginManager() { | 36 PluginManager::~PluginManager() { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 60 if (plugin->is_public) { | 62 if (plugin->is_public) { |
| 61 filter->RestrictPluginToProfileAndOrigin( | 63 filter->RestrictPluginToProfileAndOrigin( |
| 62 plugin->path, profile_, GURL()); | 64 plugin->path, profile_, GURL()); |
| 63 } else { | 65 } else { |
| 64 filter->RestrictPluginToProfileAndOrigin( | 66 filter->RestrictPluginToProfileAndOrigin( |
| 65 plugin->path, profile_, extension->url()); | 67 plugin->path, profile_, extension->url()); |
| 66 } | 68 } |
| 67 } | 69 } |
| 68 } | 70 } |
| 69 | 71 |
| 72 #if !defined(DISABLE_NACL) |
| 70 const NaClModuleInfo::List* nacl_modules = | 73 const NaClModuleInfo::List* nacl_modules = |
| 71 NaClModuleInfo::GetNaClModules(extension); | 74 NaClModuleInfo::GetNaClModules(extension); |
| 72 if (nacl_modules) { | 75 if (nacl_modules) { |
| 73 plugins_or_nacl_changed = true; | 76 plugins_or_nacl_changed = true; |
| 74 for (NaClModuleInfo::List::const_iterator module = nacl_modules->begin(); | 77 for (NaClModuleInfo::List::const_iterator module = nacl_modules->begin(); |
| 75 module != nacl_modules->end(); | 78 module != nacl_modules->end(); |
| 76 ++module) { | 79 ++module) { |
| 77 RegisterNaClModule(*module); | 80 RegisterNaClModule(*module); |
| 78 } | 81 } |
| 79 UpdatePluginListWithNaClModules(); | 82 UpdatePluginListWithNaClModules(); |
| 80 } | 83 } |
| 84 #endif |
| 81 | 85 |
| 82 const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 86 const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
| 83 if (handler && !handler->handler_url().empty()) { | 87 if (handler && !handler->handler_url().empty()) { |
| 84 plugins_or_nacl_changed = true; | 88 plugins_or_nacl_changed = true; |
| 85 | 89 |
| 86 content::WebPluginInfo info; | 90 content::WebPluginInfo info; |
| 87 info.type = content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN; | 91 info.type = content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN; |
| 88 info.name = base::UTF8ToUTF16(handler->extension_id()); | 92 info.name = base::UTF8ToUTF16(handler->extension_id()); |
| 89 info.path = base::FilePath::FromUTF8Unsafe(handler->extension_id()); | 93 info.path = base::FilePath::FromUTF8Unsafe(handler->extension_id()); |
| 90 | 94 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 115 for (PluginInfo::PluginVector::const_iterator plugin = plugins->begin(); | 119 for (PluginInfo::PluginVector::const_iterator plugin = plugins->begin(); |
| 116 plugin != plugins->end(); | 120 plugin != plugins->end(); |
| 117 ++plugin) { | 121 ++plugin) { |
| 118 PluginService::GetInstance()->ForcePluginShutdown(plugin->path); | 122 PluginService::GetInstance()->ForcePluginShutdown(plugin->path); |
| 119 PluginService::GetInstance()->RefreshPlugins(); | 123 PluginService::GetInstance()->RefreshPlugins(); |
| 120 PluginService::GetInstance()->RemoveExtraPluginPath(plugin->path); | 124 PluginService::GetInstance()->RemoveExtraPluginPath(plugin->path); |
| 121 ChromePluginServiceFilter::GetInstance()->UnrestrictPlugin(plugin->path); | 125 ChromePluginServiceFilter::GetInstance()->UnrestrictPlugin(plugin->path); |
| 122 } | 126 } |
| 123 } | 127 } |
| 124 | 128 |
| 129 #if !defined(DISABLE_NACL) |
| 125 const NaClModuleInfo::List* nacl_modules = | 130 const NaClModuleInfo::List* nacl_modules = |
| 126 NaClModuleInfo::GetNaClModules(extension); | 131 NaClModuleInfo::GetNaClModules(extension); |
| 127 if (nacl_modules) { | 132 if (nacl_modules) { |
| 128 plugins_or_nacl_changed = true; | 133 plugins_or_nacl_changed = true; |
| 129 for (NaClModuleInfo::List::const_iterator module = nacl_modules->begin(); | 134 for (NaClModuleInfo::List::const_iterator module = nacl_modules->begin(); |
| 130 module != nacl_modules->end(); | 135 module != nacl_modules->end(); |
| 131 ++module) { | 136 ++module) { |
| 132 UnregisterNaClModule(*module); | 137 UnregisterNaClModule(*module); |
| 133 } | 138 } |
| 134 UpdatePluginListWithNaClModules(); | 139 UpdatePluginListWithNaClModules(); |
| 135 } | 140 } |
| 141 #endif |
| 136 | 142 |
| 137 const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 143 const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
| 138 if (handler && !handler->handler_url().empty()) { | 144 if (handler && !handler->handler_url().empty()) { |
| 139 plugins_or_nacl_changed = true; | 145 plugins_or_nacl_changed = true; |
| 140 base::FilePath path = | 146 base::FilePath path = |
| 141 base::FilePath::FromUTF8Unsafe(handler->extension_id()); | 147 base::FilePath::FromUTF8Unsafe(handler->extension_id()); |
| 142 PluginService::GetInstance()->UnregisterInternalPlugin(path); | 148 PluginService::GetInstance()->UnregisterInternalPlugin(path); |
| 143 PluginService::GetInstance()->ForcePluginShutdown(path); | 149 PluginService::GetInstance()->ForcePluginShutdown(path); |
| 144 PluginService::GetInstance()->RefreshPlugins(); | 150 PluginService::GetInstance()->RefreshPlugins(); |
| 145 } | 151 } |
| 146 | 152 |
| 147 if (plugins_or_nacl_changed) | 153 if (plugins_or_nacl_changed) |
| 148 PluginService::GetInstance()->PurgePluginListCache(profile_, false); | 154 PluginService::GetInstance()->PurgePluginListCache(profile_, false); |
| 149 } | 155 } |
| 150 | 156 |
| 157 #if !defined(DISABLE_NACL) |
| 158 |
| 151 void PluginManager::RegisterNaClModule(const NaClModuleInfo& info) { | 159 void PluginManager::RegisterNaClModule(const NaClModuleInfo& info) { |
| 152 DCHECK(FindNaClModule(info.url) == nacl_module_list_.end()); | 160 DCHECK(FindNaClModule(info.url) == nacl_module_list_.end()); |
| 153 nacl_module_list_.push_front(info); | 161 nacl_module_list_.push_front(info); |
| 154 } | 162 } |
| 155 | 163 |
| 156 void PluginManager::UnregisterNaClModule(const NaClModuleInfo& info) { | 164 void PluginManager::UnregisterNaClModule(const NaClModuleInfo& info) { |
| 157 NaClModuleInfo::List::iterator iter = FindNaClModule(info.url); | 165 NaClModuleInfo::List::iterator iter = FindNaClModule(info.url); |
| 158 DCHECK(iter != nacl_module_list_.end()); | 166 DCHECK(iter != nacl_module_list_.end()); |
| 159 nacl_module_list_.erase(iter); | 167 nacl_module_list_.erase(iter); |
| 160 } | 168 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 217 |
| 210 NaClModuleInfo::List::iterator PluginManager::FindNaClModule(const GURL& url) { | 218 NaClModuleInfo::List::iterator PluginManager::FindNaClModule(const GURL& url) { |
| 211 for (NaClModuleInfo::List::iterator iter = nacl_module_list_.begin(); | 219 for (NaClModuleInfo::List::iterator iter = nacl_module_list_.begin(); |
| 212 iter != nacl_module_list_.end(); ++iter) { | 220 iter != nacl_module_list_.end(); ++iter) { |
| 213 if (iter->url == url) | 221 if (iter->url == url) |
| 214 return iter; | 222 return iter; |
| 215 } | 223 } |
| 216 return nacl_module_list_.end(); | 224 return nacl_module_list_.end(); |
| 217 } | 225 } |
| 218 | 226 |
| 227 #endif // !defined(DISABLE_NACL) |
| 228 |
| 219 } // namespace extensions | 229 } // namespace extensions |
| OLD | NEW |