diff options
author | raymes <raymes@chromium.org> | 2015-07-16 16:38:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-16 23:39:33 +0000 |
commit | 83dbc5011d9c708003457b38cbfd33ae563b4ff5 (patch) | |
tree | 5ff28f5509d54de51851ea7ebfeb7b7f5b8a7b47 /extensions/common/manifest_handlers | |
parent | c13bdd545cd70260f86341c3d5a17ec756975f11 (diff) | |
download | chromium_src-83dbc5011d9c708003457b38cbfd33ae563b4ff5.zip chromium_src-83dbc5011d9c708003457b38cbfd33ae563b4ff5.tar.gz chromium_src-83dbc5011d9c708003457b38cbfd33ae563b4ff5.tar.bz2 |
Factor out logic to determine whether a MimeTypesHandler has a plugin and its path
This CL adds functions to MimeTypesHandler which return:
1) HasPlugin(): Whether the handler has a plugin associated with it (that is, it's a
mimeHandlerPrivate API handler). If not, it's a handler for the streamsPrivate API.
2) GetPluiginPath(): If it does have a plugin, this returns the path of the associated
plugin.
BUG=443466
Review URL: https://codereview.chromium.org/1219903003
Cr-Commit-Position: refs/heads/master@{#339168}
Diffstat (limited to 'extensions/common/manifest_handlers')
-rw-r--r-- | extensions/common/manifest_handlers/mime_types_handler.cc | 12 | ||||
-rw-r--r-- | extensions/common/manifest_handlers/mime_types_handler.h | 9 |
2 files changed, 21 insertions, 0 deletions
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). |