summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/extensions/api/streams_private/streams_private_api.cc2
-rw-r--r--chrome/browser/extensions/plugin_manager.cc9
-rw-r--r--extensions/common/manifest_handlers/mime_types_handler.cc12
-rw-r--r--extensions/common/manifest_handlers/mime_types_handler.h9
4 files changed, 26 insertions, 6 deletions
diff --git a/chrome/browser/extensions/api/streams_private/streams_private_api.cc b/chrome/browser/extensions/api/streams_private/streams_private_api.cc
index 277afb2..57ebe6d 100644
--- a/chrome/browser/extensions/api/streams_private/streams_private_api.cc
+++ b/chrome/browser/extensions/api/streams_private/streams_private_api.cc
@@ -79,7 +79,7 @@ void StreamsPrivateAPI::ExecuteMimeTypeHandler(
// If the mime handler uses MimeHandlerViewGuest, the MimeHandlerViewGuest
// will take ownership of the stream. Otherwise, store the stream handle in
// |streams_| and fire an event notifying the extension.
- if (!handler->handler_url().empty()) {
+ if (handler->HasPlugin()) {
GURL handler_url(Extension::GetBaseURLFromExtensionId(extension_id).spec() +
handler->handler_url());
auto tab_id = ExtensionTabUtil::GetTabId(web_contents);
diff --git a/chrome/browser/extensions/plugin_manager.cc b/chrome/browser/extensions/plugin_manager.cc
index 2384d71..e86fcb8 100644
--- a/chrome/browser/extensions/plugin_manager.cc
+++ b/chrome/browser/extensions/plugin_manager.cc
@@ -84,13 +84,13 @@ void PluginManager::OnExtensionLoaded(content::BrowserContext* browser_context,
#endif
const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
- if (handler && !handler->handler_url().empty()) {
+ if (handler && handler->HasPlugin()) {
plugins_or_nacl_changed = true;
content::WebPluginInfo info;
info.type = content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN;
info.name = base::UTF8ToUTF16(extension->name());
- info.path = base::FilePath::FromUTF8Unsafe(extension->url().spec());
+ info.path = handler->GetPluginPath();
for (std::set<std::string>::const_iterator mime_type =
handler->mime_type_set().begin();
@@ -146,10 +146,9 @@ void PluginManager::OnExtensionUnloaded(
#endif
const MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
- if (handler && !handler->handler_url().empty()) {
+ if (handler && handler->HasPlugin()) {
plugins_or_nacl_changed = true;
- base::FilePath path =
- base::FilePath::FromUTF8Unsafe(extension->url().spec());
+ base::FilePath path = handler->GetPluginPath();
PluginService::GetInstance()->UnregisterInternalPlugin(path);
PluginService::GetInstance()->ForcePluginShutdown(path);
PluginService::GetInstance()->RefreshPlugins();
diff --git a/extensions/common/manifest_handlers/mime_types_handler.cc b/extensions/common/manifest_handlers/mime_types_handler.cc
index 7c4f034..61e1342 100644
--- a/extensions/common/manifest_handlers/mime_types_handler.cc
+++ b/extensions/common/manifest_handlers/mime_types_handler.cc
@@ -63,6 +63,18 @@ bool MimeTypesHandler::CanHandleMIMEType(const std::string& mime_type) const {
return mime_type_set_.find(mime_type) != mime_type_set_.end();
}
+bool MimeTypesHandler::HasPlugin() const {
+ return !handler_url_.empty();
+}
+
+base::FilePath MimeTypesHandler::GetPluginPath() const {
+ // TODO(raymes): Storing the extension URL in a base::FilePath is really
+ // nasty. We should probably just use the extension ID as the placeholder path
+ // instead.
+ return base::FilePath::FromUTF8Unsafe(
+ std::string(extensions::kExtensionScheme) + "://" + extension_id_ + "/");
+}
+
// static
MimeTypesHandler* MimeTypesHandler::GetHandler(
const extensions::Extension* extension) {
diff --git a/extensions/common/manifest_handlers/mime_types_handler.h b/extensions/common/manifest_handlers/mime_types_handler.h
index 887e379..30f46a4 100644
--- a/extensions/common/manifest_handlers/mime_types_handler.h
+++ b/extensions/common/manifest_handlers/mime_types_handler.h
@@ -43,6 +43,15 @@ class MimeTypesHandler {
const std::set<std::string>& mime_type_set() const { return mime_type_set_; }
+ // Returns true if this MimeTypesHandler has a plugin associated with it (for
+ // the mimeHandlerPrivate API). Returns false if the MimeTypesHandler is for
+ // the streamsPrivate API.
+ bool HasPlugin() const;
+
+ // If HasPlugin() returns true, this will return the plugin path for the
+ // plugin associated with this MimeTypesHandler.
+ base::FilePath GetPluginPath() const;
+
private:
// The id for the extension this action belongs to (as defined in the
// extension manifest).