fix: getAsFileSystemHandle
failure when drag-dropping two directories (#45257)
* fix: drag-dropping two directories Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * fixup! fix: drag-dropping two directories Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5872329 --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
dd82356e25
commit
24d77baeeb
2 changed files with 17 additions and 11 deletions
|
@ -566,7 +566,7 @@ void FileSystemAccessPermissionContext::ConfirmSensitiveEntryAccess(
|
|||
content::GlobalRenderFrameHostId frame_id,
|
||||
base::OnceCallback<void(SensitiveEntryResult)> callback) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
callback_ = std::move(callback);
|
||||
callback_map_.try_emplace(path, std::move(callback));
|
||||
|
||||
auto after_blocklist_check_callback = base::BindOnce(
|
||||
&FileSystemAccessPermissionContext::DidCheckPathAgainstBlocklist,
|
||||
|
@ -610,16 +610,18 @@ void FileSystemAccessPermissionContext::PerformAfterWriteChecks(
|
|||
}
|
||||
|
||||
void FileSystemAccessPermissionContext::RunRestrictedPathCallback(
|
||||
const base::FilePath& file_path,
|
||||
SensitiveEntryResult result) {
|
||||
if (callback_)
|
||||
std::move(callback_).Run(result);
|
||||
if (auto val = callback_map_.extract(file_path))
|
||||
std::move(val.mapped()).Run(result);
|
||||
}
|
||||
|
||||
void FileSystemAccessPermissionContext::OnRestrictedPathResult(
|
||||
const base::FilePath& file_path,
|
||||
gin::Arguments* args) {
|
||||
SensitiveEntryResult result = SensitiveEntryResult::kAbort;
|
||||
args->GetNext(&result);
|
||||
RunRestrictedPathCallback(result);
|
||||
RunRestrictedPathCallback(file_path, result);
|
||||
}
|
||||
|
||||
void FileSystemAccessPermissionContext::DidCheckPathAgainstBlocklist(
|
||||
|
@ -632,8 +634,9 @@ void FileSystemAccessPermissionContext::DidCheckPathAgainstBlocklist(
|
|||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
|
||||
if (user_action == UserAction::kNone) {
|
||||
RunRestrictedPathCallback(should_block ? SensitiveEntryResult::kAbort
|
||||
: SensitiveEntryResult::kAllowed);
|
||||
auto result = should_block ? SensitiveEntryResult::kAbort
|
||||
: SensitiveEntryResult::kAllowed;
|
||||
RunRestrictedPathCallback(path, result);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -652,11 +655,11 @@ void FileSystemAccessPermissionContext::DidCheckPathAgainstBlocklist(
|
|||
"file-system-access-restricted", details,
|
||||
base::BindRepeating(
|
||||
&FileSystemAccessPermissionContext::OnRestrictedPathResult,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
weak_factory_.GetWeakPtr(), path));
|
||||
return;
|
||||
}
|
||||
|
||||
RunRestrictedPathCallback(SensitiveEntryResult::kAllowed);
|
||||
RunRestrictedPathCallback(path, SensitiveEntryResult::kAllowed);
|
||||
}
|
||||
|
||||
void FileSystemAccessPermissionContext::MaybeEvictEntries(
|
||||
|
|
|
@ -143,9 +143,11 @@ class FileSystemAccessPermissionContext
|
|||
content::GlobalRenderFrameHostId frame_id,
|
||||
bool should_block);
|
||||
|
||||
void RunRestrictedPathCallback(SensitiveEntryResult result);
|
||||
void RunRestrictedPathCallback(const base::FilePath& file_path,
|
||||
SensitiveEntryResult result);
|
||||
|
||||
void OnRestrictedPathResult(gin::Arguments* args);
|
||||
void OnRestrictedPathResult(const base::FilePath& file_path,
|
||||
gin::Arguments* args);
|
||||
|
||||
void MaybeEvictEntries(base::Value::Dict& dict);
|
||||
|
||||
|
@ -169,7 +171,8 @@ class FileSystemAccessPermissionContext
|
|||
|
||||
std::map<url::Origin, base::Value::Dict> id_pathinfo_map_;
|
||||
|
||||
base::OnceCallback<void(SensitiveEntryResult)> callback_;
|
||||
std::map<base::FilePath, base::OnceCallback<void(SensitiveEntryResult)>>
|
||||
callback_map_;
|
||||
|
||||
base::WeakPtrFactory<FileSystemAccessPermissionContext> weak_factory_{this};
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue