Commit 1ef3e57d authored by Alex Danilo's avatar Alex Danilo Committed by Commit Bot

Refactor calls to FindFileHandlersForEntries()

Change https://chromium-review.googlesource.com/c/chromium/src/+/1474873
extended the information returned from handler matching for a file
by retaining the reason for the matching (MIME type and/or file
extension).

This CL removes the old method call and replaces it with the
extended method to clean up the code.

Bug: 936296
Tests: Ran all browser and unit tests.
Change-Id: I791c3885298fa480df9363f7e423047cb59ecd0d
Reviewed-on: https://chromium-review.googlesource.com/c/1491063Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Alex Danilo <adanilo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635929}
parent 46b3a0a5
......@@ -268,11 +268,11 @@ class PlatformAppPathLauncher
}
}
} else {
const std::vector<const extensions::FileHandlerInfo*>& handlers =
extensions::app_file_handler_util::FindFileHandlersForEntries(
const std::vector<extensions::FileHandlerMatch> handlers =
extensions::app_file_handler_util::FindFileHandlerMatchesForEntries(
*app, entries_);
if (!handlers.empty())
handler = handlers[0];
handler = handlers[0].handler;
}
// If this app doesn't have a file handler that supports the file, launch
......
......@@ -51,7 +51,6 @@
using extensions::Extension;
using extensions::api::file_manager_private::Verb;
using extensions::app_file_handler_util::FindFileHandlerMatchesForEntries;
using extensions::app_file_handler_util::FindFileHandlersForEntries;
using storage::FileSystemURL;
namespace file_manager {
......
......@@ -266,22 +266,6 @@ std::vector<FileHandlerMatch> FindFileHandlerMatchesForEntries(
return matches;
}
std::vector<const FileHandlerInfo*> FindFileHandlersForEntries(
const Extension& app,
const std::vector<EntryInfo> entries) {
std::vector<const FileHandlerInfo*> handlers;
if (entries.empty())
return handlers;
// Get the matching handlers and extract the handler info from them.
std::vector<FileHandlerMatch> matches =
FindFileHandlerMatchesForEntries(app, entries);
for (const auto& match : matches) {
handlers.push_back(match.handler);
}
return handlers;
}
bool FileHandlerCanHandleEntry(const FileHandlerInfo& handler,
const EntryInfo& entry) {
if (entry.is_directory)
......
......@@ -37,11 +37,6 @@ extern const char kSecurityError[];
const FileHandlerInfo* FileHandlerForId(const Extension& app,
const std::string& handler_id);
// Returns the handlers that can handle all files in |entries|.
std::vector<const FileHandlerInfo*> FindFileHandlersForEntries(
const Extension& extension,
const std::vector<EntryInfo> entries);
// Returns the handlers that can handle all files in |entries|
// along with metadata about how the handler matched (MIME or file extension)
std::vector<FileHandlerMatch> FindFileHandlerMatchesForEntries(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment