Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Unified Diff: chrome/browser/extensions/extension_file_browser_private_api.cc

Issue 7108066: CrOS - Fix crash when pressing Enter in file browser dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, address comments Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_file_browser_private_api.cc
diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc
index 964d44176bb28b5e2634610c112a7a6b7c0b438e..72614070bc142bb7cce49548dfb3c839db1d8cc1 100644
--- a/chrome/browser/extensions/extension_file_browser_private_api.cc
+++ b/chrome/browser/extensions/extension_file_browser_private_api.cc
@@ -909,6 +909,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
@@ -995,6 +1001,7 @@ void SelectFileFunction::GetLocalPathsResponseOnUIThread(
callback.listener()->FileSelected(files[0],
index,
callback.params());
+ RemoveCallback(); // Listeners expect to be invoked exactly once.
}
SendResponse(true);
}
@@ -1089,6 +1096,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);
}
@@ -1098,6 +1106,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;

Powered by Google App Engine
This is Rietveld 408576698