Chromium Code Reviews| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 module != nacl_modules->end(); | 75 module != nacl_modules->end(); |
| 76 ++module) { | 76 ++module) { |
| 77 RegisterNaClModule(*module); | 77 RegisterNaClModule(*module); |
| 78 } | 78 } |
| 79 UpdatePluginListWithNaClModules(); | 79 UpdatePluginListWithNaClModules(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 82 const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
| 83 if (handler && !handler->handler_url().empty()) { | 83 if (handler && !handler->handler_url().empty()) { |
| 84 plugins_or_nacl_changed = true; | 84 plugins_or_nacl_changed = true; |
| 85 RegisterMimeTypeHandler(handler->extension_id()); | 85 mime_type_handler_extension_ids_.insert(handler->extension_id()); |
|
Yoyo Zhou
2014/06/19 01:50:39
It doesn't look like we ever erase IDs from this.
Zachary Kuznia
2014/06/19 18:02:24
This set is no longer needed. Removed.
| |
| 86 UpdatePluginListWithNaClModules(); | 86 |
| 87 content::WebPluginInfo info; | |
| 88 info.type = content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN; | |
| 89 info.name = base::UTF8ToUTF16(handler->extension_id()); | |
| 90 info.path = base::FilePath::FromUTF8Unsafe(handler->extension_id()); | |
| 91 | |
| 92 for (std::set<std::string>::const_iterator mime_type = | |
| 93 handler->mime_type_set().begin(); | |
| 94 mime_type != handler->mime_type_set().end(); ++mime_type) { | |
| 95 content::WebPluginMimeType mime_type_info; | |
| 96 mime_type_info.mime_type = *mime_type; | |
| 97 info.mime_types.push_back(mime_type_info); | |
| 98 } | |
| 99 | |
| 100 PluginService::GetInstance()->RefreshPlugins(); | |
| 101 PluginService::GetInstance()->RegisterInternalPlugin(info, true); | |
| 87 } | 102 } |
| 88 | 103 |
| 89 if (plugins_or_nacl_changed) | 104 if (plugins_or_nacl_changed) |
| 90 PluginService::GetInstance()->PurgePluginListCache(profile_, false); | 105 PluginService::GetInstance()->PurgePluginListCache(profile_, false); |
| 91 } | 106 } |
| 92 | 107 |
| 93 void PluginManager::OnExtensionUnloaded( | 108 void PluginManager::OnExtensionUnloaded( |
| 94 content::BrowserContext* browser_context, | 109 content::BrowserContext* browser_context, |
| 95 const Extension* extension, | 110 const Extension* extension, |
| 96 UnloadedExtensionInfo::Reason reason) { | 111 UnloadedExtensionInfo::Reason reason) { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 115 for (NaClModuleInfo::List::const_iterator module = nacl_modules->begin(); | 130 for (NaClModuleInfo::List::const_iterator module = nacl_modules->begin(); |
| 116 module != nacl_modules->end(); | 131 module != nacl_modules->end(); |
| 117 ++module) { | 132 ++module) { |
| 118 UnregisterNaClModule(*module); | 133 UnregisterNaClModule(*module); |
| 119 } | 134 } |
| 120 UpdatePluginListWithNaClModules(); | 135 UpdatePluginListWithNaClModules(); |
| 121 } | 136 } |
| 122 | 137 |
| 123 const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 138 const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
| 124 if (handler && !handler->handler_url().empty()) { | 139 if (handler && !handler->handler_url().empty()) { |
| 125 plugins_or_nacl_changed = true; | 140 PluginService::GetInstance()->UnregisterInternalPlugin( |
|
Yoyo Zhou
2014/06/19 01:50:39
Why is this no longer?
Zachary Kuznia
2014/06/19 18:02:24
It looks like I was missing another call as well.
| |
| 126 UnregisterMimeTypeHandler(handler->extension_id()); | 141 base::FilePath::FromUTF8Unsafe(handler->extension_id())); |
| 127 } | 142 } |
| 128 | 143 |
| 129 if (plugins_or_nacl_changed) | 144 if (plugins_or_nacl_changed) |
| 130 PluginService::GetInstance()->PurgePluginListCache(profile_, false); | 145 PluginService::GetInstance()->PurgePluginListCache(profile_, false); |
| 131 } | 146 } |
| 132 | 147 |
| 133 void PluginManager::RegisterNaClModule(const NaClModuleInfo& info) { | 148 void PluginManager::RegisterNaClModule(const NaClModuleInfo& info) { |
| 134 DCHECK(FindNaClModule(info.url) == nacl_module_list_.end()); | 149 DCHECK(FindNaClModule(info.url) == nacl_module_list_.end()); |
| 135 nacl_module_list_.push_front(info); | 150 nacl_module_list_.push_front(info); |
| 136 } | 151 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 info.mime_types.push_back(mime_type_info); | 195 info.mime_types.push_back(mime_type_info); |
| 181 } | 196 } |
| 182 | 197 |
| 183 PluginService::GetInstance()->RefreshPlugins(); | 198 PluginService::GetInstance()->RefreshPlugins(); |
| 184 PluginService::GetInstance()->RegisterInternalPlugin(info, true); | 199 PluginService::GetInstance()->RegisterInternalPlugin(info, true); |
| 185 // This plugin has been modified, no need to check the rest of its | 200 // This plugin has been modified, no need to check the rest of its |
| 186 // types, but continue checking other plugins. | 201 // types, but continue checking other plugins. |
| 187 break; | 202 break; |
| 188 } | 203 } |
| 189 } | 204 } |
| 190 | |
| 191 for (std::set<std::string>::iterator ix = | |
| 192 mime_type_handler_extension_ids_.begin(); | |
| 193 ix != mime_type_handler_extension_ids_.end(); ++ix) { | |
| 194 const std::string& extension_id = *ix; | |
| 195 const Extension* extension = | |
| 196 profile_->GetExtensionService()->GetExtensionById(extension_id, false); | |
| 197 const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | |
| 198 if (handler && !handler->handler_url().empty()) { | |
| 199 PluginService::GetInstance()->UnregisterInternalPlugin( | |
| 200 base::FilePath::FromUTF8Unsafe(extension_id)); | |
| 201 | |
| 202 content::WebPluginInfo info; | |
| 203 info.type = content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN; | |
| 204 info.name = base::UTF8ToUTF16(extension_id); | |
| 205 info.path = base::FilePath::FromUTF8Unsafe(extension_id); | |
| 206 | |
| 207 for (std::set<std::string>::const_iterator mime_type = | |
| 208 handler->mime_type_set().begin(); | |
| 209 mime_type != handler->mime_type_set().end(); ++mime_type) { | |
| 210 content::WebPluginMimeType mime_type_info; | |
| 211 mime_type_info.mime_type = *mime_type; | |
| 212 info.mime_types.push_back(mime_type_info); | |
| 213 } | |
| 214 | |
| 215 PluginService::GetInstance()->RefreshPlugins(); | |
| 216 PluginService::GetInstance()->RegisterInternalPlugin(info, true); | |
| 217 } | |
| 218 } | |
| 219 } | 205 } |
| 220 | 206 |
| 221 void PluginManager::RegisterMimeTypeHandler(const std::string& extension_id) { | |
| 222 mime_type_handler_extension_ids_.insert(extension_id); | |
| 223 } | |
| 224 | |
| 225 void PluginManager::UnregisterMimeTypeHandler(const std::string& extension_id) { | |
| 226 mime_type_handler_extension_ids_.erase(extension_id); | |
| 227 PluginService::GetInstance()->UnregisterInternalPlugin( | |
| 228 base::FilePath::FromUTF8Unsafe(extension_id)); | |
| 229 } | |
| 230 | |
| 231 NaClModuleInfo::List::iterator PluginManager::FindNaClModule(const GURL& url) { | 207 NaClModuleInfo::List::iterator PluginManager::FindNaClModule(const GURL& url) { |
| 232 for (NaClModuleInfo::List::iterator iter = nacl_module_list_.begin(); | 208 for (NaClModuleInfo::List::iterator iter = nacl_module_list_.begin(); |
| 233 iter != nacl_module_list_.end(); ++iter) { | 209 iter != nacl_module_list_.end(); ++iter) { |
| 234 if (iter->url == url) | 210 if (iter->url == url) |
| 235 return iter; | 211 return iter; |
| 236 } | 212 } |
| 237 return nacl_module_list_.end(); | 213 return nacl_module_list_.end(); |
| 238 } | 214 } |
| 239 | 215 |
| 240 } // namespace extensions | 216 } // namespace extensions |
| OLD | NEW |