#ifndef EXTENSIONS_BROWSER_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_
#define EXTENSIONS_BROWSER_API_FILE_HANDLERS_APP_FILE_HANDLER_UTIL_H_
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_handlers/file_handler_info.h"
namespace content {
class BrowserContext;
}
namespace apps {
struct FileHandler;
struct FileHandlerInfo;
FileHandlers;
}
namespace extensions {
struct EntryInfo;
struct FileHandlerMatch;
struct GrantedFileEntry;
namespace app_file_handler_util {
extern const char kInvalidParameters[];
extern const char kSecurityError[];
class WebAppFileHandlerMatch { … };
const apps::FileHandlerInfo* FileHandlerForId(const Extension& app,
const std::string& handler_id);
std::vector<FileHandlerMatch> FindFileHandlerMatchesForEntries(
const Extension& extension,
const std::vector<EntryInfo>& entries);
std::vector<FileHandlerMatch> MatchesFromFileHandlersForEntries(
const FileHandlersInfo& file_handlers,
const std::vector<EntryInfo>& entries);
std::vector<WebAppFileHandlerMatch> MatchesFromWebAppFileHandlersForEntries(
const apps::FileHandlers& file_handlers,
const std::vector<EntryInfo>& entries);
bool FileHandlerCanHandleEntry(const apps::FileHandlerInfo& handler,
const EntryInfo& entry);
bool WebAppFileHandlerCanHandleEntry(const apps::FileHandler& handler,
const EntryInfo& entry);
GrantedFileEntry CreateFileEntryWithPermissions(int renderer_id,
const base::FilePath& path,
bool can_write,
bool can_create,
bool can_delete);
GrantedFileEntry CreateFileEntry(content::BrowserContext* context,
const Extension* extension,
int renderer_id,
const base::FilePath& path,
bool is_directory);
void PrepareFilesForWritableApp(
const std::vector<base::FilePath>& paths,
content::BrowserContext* context,
const std::set<base::FilePath>& directory_paths,
base::OnceClosure on_success,
base::OnceCallback<void(const base::FilePath&)> on_failure);
bool HasFileSystemWritePermission(const Extension* extension);
bool ValidateFileEntryAndGetPath(const std::string& filesystem_name,
const std::string& filesystem_path,
int render_process_id,
base::FilePath* file_path,
std::string* error);
std::vector<extensions::EntryInfo> CreateEntryInfos(
const std::vector<base::FilePath>& entry_paths,
const std::vector<std::string>& mime_types,
const std::set<base::FilePath>& directory_paths);
}
}
#endif