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

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: Move back to "open-with" for the id of the more actions dialog, as it breaks some browsers tests, a… 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..5cc615edaf6b4949ea910e015ca8f195f10cfb24 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";
+const char kAddTo[] = "add_to";
+const char kPackWith[] = "pack_with";
+const char kShareWith[] = "share_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 ||
+ verb == file_handler_verbs::kShareWith;
}
-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) {
@@ -123,7 +151,8 @@ bool LoadFileHandler(const std::string& handler_id,
for (base::DictionaryValue::Iterator it(handler_info); !it.IsAtEnd();
it.Advance()) {
if (it.key() != keys::kFileHandlerExtensions &&
- it.key() != keys::kFileHandlerTypes) {
+ it.key() != keys::kFileHandlerTypes &&
+ it.key() != keys::kFileHandlerVerb) {
install_warnings->push_back(
InstallWarning(base::StringPrintf(kNotRecognized, it.key().c_str()),
keys::kFileHandlers,

Powered by Google App Engine
This is Rietveld 408576698