Commit 1b5cd520 authored by zork@chromium.org's avatar zork@chromium.org

Fix some DCHECKS when using BrowserPlugin for extension mime type handlers

BUG=368514

Review URL: https://codereview.chromium.org/340953006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278647 0039d316-1c4b-4281-b951-d872f2087c98
parent 4cf2dc61
...@@ -82,8 +82,22 @@ void PluginManager::OnExtensionLoaded(content::BrowserContext* browser_context, ...@@ -82,8 +82,22 @@ void PluginManager::OnExtensionLoaded(content::BrowserContext* browser_context,
const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
if (handler && !handler->handler_url().empty()) { if (handler && !handler->handler_url().empty()) {
plugins_or_nacl_changed = true; plugins_or_nacl_changed = true;
RegisterMimeTypeHandler(handler->extension_id());
UpdatePluginListWithNaClModules(); content::WebPluginInfo info;
info.type = content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN;
info.name = base::UTF8ToUTF16(handler->extension_id());
info.path = base::FilePath::FromUTF8Unsafe(handler->extension_id());
for (std::set<std::string>::const_iterator mime_type =
handler->mime_type_set().begin();
mime_type != handler->mime_type_set().end(); ++mime_type) {
content::WebPluginMimeType mime_type_info;
mime_type_info.mime_type = *mime_type;
info.mime_types.push_back(mime_type_info);
}
PluginService::GetInstance()->RefreshPlugins();
PluginService::GetInstance()->RegisterInternalPlugin(info, true);
} }
if (plugins_or_nacl_changed) if (plugins_or_nacl_changed)
...@@ -123,7 +137,11 @@ void PluginManager::OnExtensionUnloaded( ...@@ -123,7 +137,11 @@ void PluginManager::OnExtensionUnloaded(
const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
if (handler && !handler->handler_url().empty()) { if (handler && !handler->handler_url().empty()) {
plugins_or_nacl_changed = true; plugins_or_nacl_changed = true;
UnregisterMimeTypeHandler(handler->extension_id()); base::FilePath path =
base::FilePath::FromUTF8Unsafe(handler->extension_id());
PluginService::GetInstance()->UnregisterInternalPlugin(path);
PluginService::GetInstance()->ForcePluginShutdown(path);
PluginService::GetInstance()->RefreshPlugins();
} }
if (plugins_or_nacl_changed) if (plugins_or_nacl_changed)
...@@ -187,45 +205,6 @@ void PluginManager::UpdatePluginListWithNaClModules() { ...@@ -187,45 +205,6 @@ void PluginManager::UpdatePluginListWithNaClModules() {
break; break;
} }
} }
for (std::set<std::string>::iterator ix =
mime_type_handler_extension_ids_.begin();
ix != mime_type_handler_extension_ids_.end(); ++ix) {
const std::string& extension_id = *ix;
const Extension* extension =
profile_->GetExtensionService()->GetExtensionById(extension_id, false);
const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
if (handler && !handler->handler_url().empty()) {
PluginService::GetInstance()->UnregisterInternalPlugin(
base::FilePath::FromUTF8Unsafe(extension_id));
content::WebPluginInfo info;
info.type = content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN;
info.name = base::UTF8ToUTF16(extension_id);
info.path = base::FilePath::FromUTF8Unsafe(extension_id);
for (std::set<std::string>::const_iterator mime_type =
handler->mime_type_set().begin();
mime_type != handler->mime_type_set().end(); ++mime_type) {
content::WebPluginMimeType mime_type_info;
mime_type_info.mime_type = *mime_type;
info.mime_types.push_back(mime_type_info);
}
PluginService::GetInstance()->RefreshPlugins();
PluginService::GetInstance()->RegisterInternalPlugin(info, true);
}
}
}
void PluginManager::RegisterMimeTypeHandler(const std::string& extension_id) {
mime_type_handler_extension_ids_.insert(extension_id);
}
void PluginManager::UnregisterMimeTypeHandler(const std::string& extension_id) {
mime_type_handler_extension_ids_.erase(extension_id);
PluginService::GetInstance()->UnregisterInternalPlugin(
base::FilePath::FromUTF8Unsafe(extension_id));
} }
NaClModuleInfo::List::iterator PluginManager::FindNaClModule(const GURL& url) { NaClModuleInfo::List::iterator PluginManager::FindNaClModule(const GURL& url) {
......
...@@ -44,9 +44,6 @@ class PluginManager : public BrowserContextKeyedAPI, ...@@ -44,9 +44,6 @@ class PluginManager : public BrowserContextKeyedAPI,
void RegisterNaClModule(const NaClModuleInfo& info); void RegisterNaClModule(const NaClModuleInfo& info);
void UnregisterNaClModule(const NaClModuleInfo& info); void UnregisterNaClModule(const NaClModuleInfo& info);
void RegisterMimeTypeHandler(const std::string& extension_id);
void UnregisterMimeTypeHandler(const std::string& extension_id);
// Call UpdatePluginListWithNaClModules() after registering or unregistering // Call UpdatePluginListWithNaClModules() after registering or unregistering
// a NaCl module to see those changes reflected in the PluginList. // a NaCl module to see those changes reflected in the PluginList.
void UpdatePluginListWithNaClModules(); void UpdatePluginListWithNaClModules();
...@@ -67,10 +64,6 @@ class PluginManager : public BrowserContextKeyedAPI, ...@@ -67,10 +64,6 @@ class PluginManager : public BrowserContextKeyedAPI,
extensions::NaClModuleInfo::List nacl_module_list_; extensions::NaClModuleInfo::List nacl_module_list_;
// The set of extensions that are registered as the handler for at least one
// MIME type.
std::set<std::string> mime_type_handler_extension_ids_;
Profile* profile_; Profile* profile_;
// Listen to extension load, unloaded notifications. // Listen to extension load, unloaded notifications.
......
...@@ -386,7 +386,7 @@ bool BufferedResourceHandler::UseAlternateNextHandler( ...@@ -386,7 +386,7 @@ bool BufferedResourceHandler::UseAlternateNextHandler(
scoped_refptr<net::IOBuffer> buf; scoped_refptr<net::IOBuffer> buf;
int size = 0; int size = 0;
next_handler_->OnWillRead(&buf, &size, payload_for_old_handler.length()); next_handler_->OnWillRead(&buf, &size, -1);
CHECK_GE(size, static_cast<int>(payload_for_old_handler.length())); CHECK_GE(size, static_cast<int>(payload_for_old_handler.length()));
memcpy(buf->data(), payload_for_old_handler.c_str(), memcpy(buf->data(), payload_for_old_handler.c_str(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment