chore: call ListenerDestroyed() in FileSelectHelper::RunFileChooserEnd() (#37006)

chore: call ListenerDestroyed() in FileSelectHelper::RunFileChooserEnd()
This commit is contained in:
Shelley Vohr 2023-01-25 15:51:01 +01:00 committed by GitHub
parent 86f99e9cf0
commit afca3ff965
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -180,7 +180,7 @@ void FileSelectHelper::OnListDone(int error) {
std::unique_ptr<ActiveDirectoryEnumeration> entry =
std::move(directory_enumeration_);
if (error) {
FileSelectionCanceled(NULL);
FileSelectionCanceled(nullptr);
return;
}
@ -487,6 +487,11 @@ void FileSelectHelper::RunFileChooserEnd() {
listener_->FileSelectionCanceled();
render_frame_host_ = nullptr;
web_contents_ = nullptr;
// If the dialog was actually opened, dispose of our reference.
if (select_file_dialog_) {
select_file_dialog_->ListenerDestroyed();
select_file_dialog_.reset();
}
Release();
}
@ -525,8 +530,6 @@ void FileSelectHelper::RenderWidgetHostDestroyed(
void FileSelectHelper::RenderFrameHostChanged(
content::RenderFrameHost* old_host,
content::RenderFrameHost* new_host) {
if (!render_frame_host_)
return;
// The |old_host| and its children are now pending deletion. Do not give them
// file access past this point.
for (content::RenderFrameHost* host = render_frame_host_; host;