diff options
author | cmihail <cmihail@chromium.org> | 2016-02-24 18:15:21 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-25 02:16:28 +0000 |
commit | 20232c23c12a81d98b69d10c9e18c0b4292606cb (patch) | |
tree | 669678e9e8b9e74461c8d963710f64018f04b277 /extensions/common | |
parent | 3d3507bd86994743e974e04ecfc97db4f640a007 (diff) | |
download | chromium_src-20232c23c12a81d98b69d10c9e18c0b4292606cb.zip chromium_src-20232c23c12a81d98b69d10c9e18c0b4292606cb.tar.gz chromium_src-20232c23c12a81d98b69d10c9e18c0b4292606cb.tar.bz2 |
Add directories handling support for apps/extensions.
The change introduces a "include_directories" entry in the manifest
file for file_handlers. In case the value is true, the file handler
becomes a generic handler and adds the given extension to the right
click menu.
BUG=415897
R=mtomasz@chromium.org
Review URL: https://codereview.chromium.org/1407473003
Cr-Commit-Position: refs/heads/master@{#377467}
Diffstat (limited to 'extensions/common')
-rw-r--r-- | extensions/common/api/app_runtime.idl | 6 | ||||
-rw-r--r-- | extensions/common/manifest_constants.cc | 5 | ||||
-rw-r--r-- | extensions/common/manifest_constants.h | 1 | ||||
-rw-r--r-- | extensions/common/manifest_handlers/file_handler_info.cc | 14 | ||||
-rw-r--r-- | extensions/common/manifest_handlers/file_handler_info.h | 3 |
5 files changed, 23 insertions, 6 deletions
diff --git a/extensions/common/api/app_runtime.idl b/extensions/common/api/app_runtime.idl index e3339bd..daf953c 100644 --- a/extensions/common/api/app_runtime.idl +++ b/extensions/common/api/app_runtime.idl @@ -8,11 +8,11 @@ namespace app.runtime { [inline_doc] dictionary LaunchItem { - // FileEntry for the file. - [instanceOf=FileEntry] object entry; + // Entry for the item. + [instanceOf=Entry] object entry; // The MIME type of the file. - DOMString type; + DOMString? type; }; // Enumeration of app launch sources. diff --git a/extensions/common/manifest_constants.cc b/extensions/common/manifest_constants.cc index 7195dda..85775ef 100644 --- a/extensions/common/manifest_constants.cc +++ b/extensions/common/manifest_constants.cc @@ -392,8 +392,11 @@ const char kInvalidFileHandlerExtension[] = "Invalid value for 'file_handlers[*].extensions'."; const char kInvalidFileHandlerExtensionElement[] = "Invalid value for 'file_handlers[*].extensions[*]'."; +const char kInvalidFileHandlerIncludeDirectories[] = + "Invalid value for 'include_directories'."; const char kInvalidFileHandlerNoTypeOrExtension[] = - "'file_handlers[*]' must contain a non-empty 'types' or 'extensions'."; + "'file_handlers[*]' must contain a non-empty 'types', 'extensions' " + "or 'include_directories'."; const char kInvalidFileHandlerType[] = "Invalid value for 'file_handlers[*].types'."; const char kInvalidFileHandlerTypeElement[] = diff --git a/extensions/common/manifest_constants.h b/extensions/common/manifest_constants.h index 9051aa8..81f8fc5 100644 --- a/extensions/common/manifest_constants.h +++ b/extensions/common/manifest_constants.h @@ -318,6 +318,7 @@ extern const char kInvalidFileHandlers[]; extern const char kInvalidFileHandlersTooManyTypesAndExtensions[]; extern const char kInvalidFileHandlerExtension[]; extern const char kInvalidFileHandlerExtensionElement[]; +extern const char kInvalidFileHandlerIncludeDirectories[]; extern const char kInvalidFileHandlerNoTypeOrExtension[]; extern const char kInvalidFileHandlerType[]; extern const char kInvalidFileHandlerTypeElement[]; diff --git a/extensions/common/manifest_handlers/file_handler_info.cc b/extensions/common/manifest_handlers/file_handler_info.cc index 9b0989a..b525c14 100644 --- a/extensions/common/manifest_handlers/file_handler_info.cc +++ b/extensions/common/manifest_handlers/file_handler_info.cc @@ -25,7 +25,7 @@ const int kMaxTypeAndExtensionHandlers = 200; const char kNotRecognized[] = "'%s' is not a recognized file handler property."; } -FileHandlerInfo::FileHandlerInfo() {} +FileHandlerInfo::FileHandlerInfo() : include_directories(false) {} FileHandlerInfo::~FileHandlerInfo() {} FileHandlers::FileHandlers() {} @@ -71,8 +71,18 @@ bool LoadFileHandler(const std::string& handler_id, return false; } + handler.include_directories = false; + if (handler_info.HasKey("include_directories") && + !handler_info.GetBoolean("include_directories", + &handler.include_directories)) { + *error = ErrorUtils::FormatErrorMessageUTF16( + errors::kInvalidFileHandlerIncludeDirectories, handler_id); + return false; + } + if ((!mime_types || mime_types->empty()) && - (!file_extensions || file_extensions->empty())) { + (!file_extensions || file_extensions->empty()) && + !handler.include_directories) { *error = ErrorUtils::FormatErrorMessageUTF16( errors::kInvalidFileHandlerNoTypeOrExtension, handler_id); diff --git a/extensions/common/manifest_handlers/file_handler_info.h b/extensions/common/manifest_handlers/file_handler_info.h index ac458e1..ac9e51d 100644 --- a/extensions/common/manifest_handlers/file_handler_info.h +++ b/extensions/common/manifest_handlers/file_handler_info.h @@ -27,6 +27,9 @@ struct FileHandlerInfo { // MIME types associated with this handler. std::set<std::string> types; + + // True if the handler can manage directories. + bool include_directories; }; typedef std::vector<FileHandlerInfo> FileHandlersInfo; |