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

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: Remove restriction to have uppercase verbs in manifest file. 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..c263e426eac932411782247c1d711bea8a9877f5 100644
--- a/extensions/common/manifest_handlers/file_handler_info.cc
+++ b/extensions/common/manifest_handlers/file_handler_info.cc
@@ -21,12 +21,31 @@ namespace extensions {
namespace keys = manifest_keys;
namespace errors = manifest_errors;
+namespace file_handler_verbs {
+
+const char kOpenWith[] = "Open with";
Devlin 2016/05/16 16:17:32 manifest constants are almost always all_lowercase
cmihail 2016/05/18 02:35:31 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) {
+ std::set<std::string> supported_verbs;
+ supported_verbs.emplace(file_handler_verbs::kOpenWith);
+ supported_verbs.emplace(file_handler_verbs::kAddTo);
+ supported_verbs.emplace(file_handler_verbs::kPackWith);
+ return supported_verbs.find(verb) != supported_verbs.end();
Devlin 2016/05/16 16:17:32 This results in the construction of a set and thre
cmihail 2016/05/18 02:35:31 Done.
}
-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 +101,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) &&
+ !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