#ifndef CONTENT_PUBLIC_BROWSER_FILE_SYSTEM_ACCESS_ENTRY_FACTORY_H_
#define CONTENT_PUBLIC_BROWSER_FILE_SYSTEM_ACCESS_ENTRY_FACTORY_H_
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/file_system_access_permission_context.h"
#include "content/public/browser/global_routing_id.h"
#include "ipc/constants.mojom.h"
#include "storage/browser/file_system/file_system_url.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/file_system_access/file_system_access_directory_handle.mojom-forward.h"
#include "third_party/blink/public/mojom/file_system_access/file_system_access_transfer_token.mojom.h"
#include "url/gurl.h"
namespace content {
class CONTENT_EXPORT FileSystemAccessEntryFactory
: public base::RefCountedThreadSafe<FileSystemAccessEntryFactory,
BrowserThread::DeleteOnUIThread> {
public:
using UserAction = FileSystemAccessPermissionContext::UserAction;
struct CONTENT_EXPORT BindingContext {
BindingContext(const blink::StorageKey& storage_key,
const GURL& url,
GlobalRenderFrameHostId frame_id,
bool is_worker = false)
: storage_key(storage_key),
url(url),
frame_id(frame_id),
is_worker(is_worker) {}
BindingContext(const blink::StorageKey& storage_key,
const GURL& url,
int worker_process_id)
: storage_key(storage_key),
url(url),
frame_id(worker_process_id, IPC::mojom::kRoutingIdNone),
is_worker(true) {}
blink::StorageKey storage_key;
GURL url;
GlobalRenderFrameHostId frame_id;
bool is_worker;
int process_id() const { return frame_id.child_id; }
};
virtual blink::mojom::FileSystemAccessEntryPtr CreateFileEntryFromPath(
const BindingContext& binding_context,
const content::PathInfo& path_info,
UserAction user_action) = 0;
virtual blink::mojom::FileSystemAccessEntryPtr CreateDirectoryEntryFromPath(
const BindingContext& binding_context,
const content::PathInfo& path_info,
UserAction user_action) = 0;
using ResolveTransferTokenCallback =
base::OnceCallback<void(std::optional<storage::FileSystemURL>)>;
virtual void ResolveTransferToken(
mojo::PendingRemote<blink::mojom::FileSystemAccessTransferToken>
transfer_token,
ResolveTransferTokenCallback callback) = 0;
protected:
friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
friend class base::DeleteHelper<FileSystemAccessEntryFactory>;
virtual ~FileSystemAccessEntryFactory() {}
};
}
#endif