summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_file_browser_private_api.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions/extension_file_browser_private_api.cc')
-rw-r--r--chrome/browser/extensions/extension_file_browser_private_api.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc
index 4c85345..d369152 100644
--- a/chrome/browser/extensions/extension_file_browser_private_api.cc
+++ b/chrome/browser/extensions/extension_file_browser_private_api.cc
@@ -816,6 +816,12 @@ const FileDialogFunction::Callback& FileDialogFunction::GetCallback() const {
return Callback::Find(GetTabId());
}
+void FileDialogFunction::RemoveCallback() {
+ // Listeners expect to be invoked exactly once, so we need to remove our
+ // callback objects afterwards.
+ Callback::Remove(GetTabId());
+}
+
// GetFileSystemRootPathOnFileThread can only be called from the file thread,
// so here we are. This function takes a vector of virtual paths, converts
// them to local paths and calls GetLocalPathsResponseOnUIThread with the
@@ -902,6 +908,7 @@ void SelectFileFunction::GetLocalPathsResponseOnUIThread(
callback.listener()->FileSelected(files[0],
index,
callback.params());
+ RemoveCallback(); // Listeners expect to be invoked exactly once.
}
SendResponse(true);
}
@@ -996,6 +1003,7 @@ void SelectFilesFunction::GetLocalPathsResponseOnUIThread(
DCHECK(!callback.IsNull());
if (!callback.IsNull()) {
callback.listener()->MultiFilesSelected(files, callback.params());
+ RemoveCallback(); // Listeners expect to be invoked exactly once.
}
SendResponse(true);
}
@@ -1005,6 +1013,7 @@ bool CancelFileDialogFunction::RunImpl() {
DCHECK(!callback.IsNull());
if (!callback.IsNull()) {
callback.listener()->FileSelectionCanceled(callback.params());
+ RemoveCallback(); // Listeners expect to be invoked exactly once.
}
SendResponse(true);
return true;