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

Unified Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 8602009: CrOS: Fix file_watchers_ DCHECK in SelectFileDialogExtensionBrowserTest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/file_manager.js
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index 69c6c381f9776d13f0617b96f48539cd69fc7c32..c41b1c393f84514275b57ee777e85086be71912f 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -3166,9 +3166,15 @@ FileManager.prototype = {
}
};
- FileManager.prototype.onUnload_ = function(event) {
+ /**
+ * Unload handler for the page. May be called manually for the file picker
+ * dialog, because it closes by calling extension API functions that do not
+ * return.
+ */
+ FileManager.prototype.onUnload_ = function() {
if (this.subscribedOnDirectoryChanges_) {
- chrome.fileBrowserPrivate.removeFileWatch(event.previousDirEntry.toURL(),
+ this.subscribedOnDirectoryChanges_ = false;
+ chrome.fileBrowserPrivate.removeFileWatch(this.currentDirEntry_.toURL(),
function(result) {
if (!result) {
console.log('Failed to remove file watch');
@@ -3575,16 +3581,43 @@ FileManager.prototype = {
};
/**
- * Handle a click of the cancel button. Closes the window.
+ * Handle a click of the cancel button. Closes the window. Does not return.
+ * TODO(jamescook): Make unload handler work automatically, crbug.com/104811
*
* @param {Event} event The click event.
*/
FileManager.prototype.onCancel_ = function(event) {
+ this.onUnload_();
// Closes the window and does not return.
chrome.fileBrowserPrivate.cancelDialog();
};
/**
+ * Selects a file. Closes the window. Does not return.
+ * TODO(jamescook): Make unload handler work automatically, crbug.com/104811
+ *
+ * @param {string} fileUrl The filename as a URL.
+ * @param {number} filterIndex The integer file filter index.
+ */
+ FileManager.prototype.selectFile_ = function(fileUrl, filterIndex) {
+ this.onUnload_();
+ // Closes the window and does not return.
+ chrome.fileBrowserPrivate.selectFile(fileUrl, filterIndex);
+ };
+
+ /**
+ * Selects multiple files. Closes the window. Does not return.
+ * TODO(jamescook): Make unload handler work automatically, crbug.com/104811
+ *
+ * @param {Array.<string>} fileUrls Array of filename URLs.
+ */
+ FileManager.prototype.selectFiles_ = function(fileUrls) {
+ this.onUnload_();
+ // Closes the window and does not return.
+ chrome.fileBrowserPrivate.selectFiles(fileUrls);
+ };
+
+ /**
* Handle a click of the ok button.
*
* The ok button has different UI labels depending on the type of dialog, but
@@ -3610,9 +3643,8 @@ FileManager.prototype = {
var self = this;
function resolveCallback(victim) {
if (victim instanceof FileError) {
- // File does not exist. (NB: selectFile Closes the window and does
- // not return.)
- chrome.fileBrowserPrivate.selectFile(
+ // File does not exist. Closes the window and does not return.
+ self.selectFile_(
currentDirUrl + encodeURIComponent(filename),
self.getSelectedFilterIndex_(filename));
}
@@ -3624,7 +3656,7 @@ FileManager.prototype = {
self.confirm.show(strf('CONFIRM_OVERWRITE_FILE', filename),
function() {
// User selected Ok from the confirm dialog.
- chrome.fileBrowserPrivate.selectFile(
+ self.selectFile_(
currentDirUrl + encodeURIComponent(filename),
self.getSelectedFilterIndex_(filename));
});
@@ -3659,7 +3691,7 @@ FileManager.prototype = {
// Multi-file selection has no other restrictions.
if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_MULTI_FILE) {
// Closes the window and does not return.
- chrome.fileBrowserPrivate.selectFiles(ary);
+ this.selectFiles_(ary);
return;
}
@@ -3698,8 +3730,7 @@ FileManager.prototype = {
}
// Closes the window and does not return.
- chrome.fileBrowserPrivate.selectFile(
- ary[0], this.getSelectedFilterIndex_(ary[0]));
+ this.selectFile_(ary[0], this.getSelectedFilterIndex_(ary[0]));
};
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698