#include "content/browser/file_system_access/file_system_access_safe_move_helper.h"
#include "base/feature_list.h"
#include "base/files/file.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/thread_annotations.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/services/quarantine/quarantine.h"
#include "content/browser/file_system_access/features.h"
#include "content/browser/file_system_access/file_system_access_error.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/content_client.h"
#include "crypto/secure_hash.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "storage/browser/file_system/copy_or_move_hook_delegate.h"
#include "storage/browser/file_system/file_stream_reader.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/file_system/file_system_context.h"
#include "storage/browser/file_system/file_system_operation.h"
#include "storage/browser/file_system/file_system_operation_runner.h"
#include "storage/common/file_system/file_system_util.h"
namespace content {
namespace {
class HashCalculator : public base::RefCounted<HashCalculator> { … };
}
FileSystemAccessSafeMoveHelper::FileSystemAccessSafeMoveHelper(
base::WeakPtr<FileSystemAccessManagerImpl> manager,
const FileSystemAccessManagerImpl::BindingContext& context,
const storage::FileSystemURL& source_url,
const storage::FileSystemURL& dest_url,
storage::FileSystemOperation::CopyOrMoveOptionSet options,
download::QuarantineConnectionCallback quarantine_connection_callback,
bool has_transient_user_activation)
: … { … }
FileSystemAccessSafeMoveHelper::~FileSystemAccessSafeMoveHelper() = default;
void FileSystemAccessSafeMoveHelper::Start(
FileSystemAccessSafeMoveHelperCallback callback) { … }
void FileSystemAccessSafeMoveHelper::ComputeHashForSourceFile(
HashCallback callback) { … }
bool FileSystemAccessSafeMoveHelper::RequireAfterWriteChecks() const { … }
bool FileSystemAccessSafeMoveHelper::RequireQuarantine() const { … }
void FileSystemAccessSafeMoveHelper::DoAfterWriteCheck(
base::File::Error hash_result,
const std::string& hash,
int64_t size) { … }
void FileSystemAccessSafeMoveHelper::DidAfterWriteCheck(
FileSystemAccessPermissionContext::AfterWriteCheckResult result) { … }
void FileSystemAccessSafeMoveHelper::DidFileSkipQuarantine(
base::File::Error result) { … }
void FileSystemAccessSafeMoveHelper::DidFileDoQuarantine(
const storage::FileSystemURL& target_url,
const GURL& referrer_url,
mojo::Remote<quarantine::mojom::Quarantine> quarantine_remote,
base::File::Error result) { … }
void FileSystemAccessSafeMoveHelper::DidAnnotateFile(
mojo::Remote<quarantine::mojom::Quarantine> quarantine_remote,
quarantine::mojom::QuarantineFileResult result) { … }
}