Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: extensions/common/manifest_handlers/file_handler_info.cc

Issue 1872223002: Add verbs API to file handlers. Modify the Chrome OS UI so that it displayes the internationalized … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keep only Verb enum in file_manager_private.js. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/common/manifest_handlers/file_handler_info.cc
diff --git a/extensions/common/manifest_handlers/file_handler_info.cc b/extensions/common/manifest_handlers/file_handler_info.cc
index 68ef8322fc6a3e8178d644032a867512ca0bac4c..5c5daba7beac6bc4ecb731f1550b569a253e4929 100644
--- a/extensions/common/manifest_handlers/file_handler_info.cc
+++ b/extensions/common/manifest_handlers/file_handler_info.cc
@@ -21,12 +21,29 @@ namespace extensions {
namespace keys = manifest_keys;
namespace errors = manifest_errors;
+namespace file_handler_verbs {
+
+const char kOpenWith[] = "open with";
Devlin 2016/05/20 21:08:16 https://codereview.chromium.org/1872223002/diff/12
cmihail 2016/05/23 02:46:13 Done.
+const char kAddTo[] = "add to";
+const char kPackWith[] = "pack with";
+
+} // namespace file_handler_verbs
+
namespace {
+
const int kMaxTypeAndExtensionHandlers = 200;
const char kNotRecognized[] = "'%s' is not a recognized file handler property.";
+
+bool IsSupportedVerb(const std::string& verb) {
+ return verb == file_handler_verbs::kOpenWith ||
+ verb == file_handler_verbs::kAddTo ||
+ verb == file_handler_verbs::kPackWith;
}
-FileHandlerInfo::FileHandlerInfo() : include_directories(false) {}
+} // namespace
+
+FileHandlerInfo::FileHandlerInfo()
+ : include_directories(false), verb(file_handler_verbs::kOpenWith) {}
FileHandlerInfo::FileHandlerInfo(const FileHandlerInfo& other) = default;
FileHandlerInfo::~FileHandlerInfo() {}
@@ -82,6 +99,15 @@ bool LoadFileHandler(const std::string& handler_id,
return false;
}
+ handler.verb = file_handler_verbs::kOpenWith;
+ if (handler_info.HasKey(keys::kFileHandlerVerb) &&
+ !handler_info.GetString(keys::kFileHandlerVerb, &handler.verb) &&
Devlin 2016/05/20 21:08:16 This is wrong - it should be an || on this line, r
cmihail 2016/05/23 02:46:13 Done.
+ !IsSupportedVerb(handler.verb)) {
+ *error = ErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidFileHandlerVerb, handler_id);
+ return false;
+ }
+
if ((!mime_types || mime_types->empty()) &&
(!file_extensions || file_extensions->empty()) &&
!handler.include_directories) {

Powered by Google App Engine
This is Rietveld 408576698