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

Unified Diff: chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc

Issue 14790018: ChromeOS: Use file extensions in Files app to decide which apps to use. (Closed) Base URL: http://git.chromium.org/chromium/src.git@file-handler-extensions2
Patch Set: Created 7 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: chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc
diff --git a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc
index a66298d501f8985ec75913720ba886876f6b6ce3..04089fcd542e9850bcc34cf34928a4543d733cbf 100644
--- a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc
+++ b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc
@@ -43,6 +43,17 @@ bool FileHandlerCanHandleFileWithExtension(
return false;
}
+bool FileHandlerCanHandleFileWithMimeType(
+ const FileHandlerInfo& handler,
+ const std::string& mime_type) {
+ for (std::set<std::string>::const_iterator type = handler.types.begin();
+ type != handler.types.end(); ++type) {
+ if (net::MatchesMimeType(*type, mime_type))
+ return true;
+ }
+ return false;
+}
+
} // namespace
typedef std::vector<FileHandlerInfo> FileHandlerList;
@@ -77,10 +88,10 @@ const FileHandlerInfo* FirstFileHandlerForFile(
return NULL;
}
-std::vector<const FileHandlerInfo*> FindFileHandlersForMimeTypes(
- const Extension& app, const std::set<std::string>& mime_types) {
+std::vector<const FileHandlerInfo*> FindFileHandlersForFiles(
+ const Extension& app, const PathAndMimeTypeSet& files) {
std::vector<const FileHandlerInfo*> handlers;
- if (mime_types.empty())
+ if (files.empty())
return handlers;
// Look for file handlers which can handle all the MIME types specified.
@@ -91,9 +102,9 @@ std::vector<const FileHandlerInfo*> FindFileHandlersForMimeTypes(
for (FileHandlerList::const_iterator data = file_handlers->begin();
data != file_handlers->end(); ++data) {
bool handles_all_types = true;
- for (std::set<std::string>::const_iterator type_iter = mime_types.begin();
- type_iter != mime_types.end(); ++type_iter) {
- if (!FileHandlerCanHandleFileWithMimeType(*data, *type_iter)) {
+ for (PathAndMimeTypeSet::const_iterator it = files.begin();
+ it != files.end(); ++it) {
+ if (!FileHandlerCanHandleFile(*data, it->second, it->first)) {
handles_all_types = false;
break;
}
@@ -112,17 +123,6 @@ bool FileHandlerCanHandleFile(
FileHandlerCanHandleFileWithExtension(handler, path);
}
-bool FileHandlerCanHandleFileWithMimeType(
- const FileHandlerInfo& handler,
- const std::string& mime_type) {
- for (std::set<std::string>::const_iterator type = handler.types.begin();
- type != handler.types.end(); ++type) {
- if (net::MatchesMimeType(*type, mime_type))
- return true;
- }
- return false;
-}
-
GrantedFileEntry CreateFileEntry(
Profile* profile,
const std::string& extension_id,

Powered by Google App Engine
This is Rietveld 408576698