Index: ui/file_manager/file_manager/foreground/js/directory_model.js |
diff --git a/ui/file_manager/file_manager/foreground/js/directory_model.js b/ui/file_manager/file_manager/foreground/js/directory_model.js |
index cc93910caba83c040e3734a8b97c77da33c1f37e..810a12706b2273bb31ef6388f71004d72f55ed50 100644 |
--- a/ui/file_manager/file_manager/foreground/js/directory_model.js |
+++ b/ui/file_manager/file_manager/foreground/js/directory_model.js |
@@ -647,12 +647,16 @@ DirectoryModel.prototype.createDirectory = function(name, |
}; |
/** |
- * Change the current directory to the directory represented by |
+ * Changes the current directory to the directory represented by |
* a DirectoryEntry or a fake entry. |
* |
* Dispatches the 'directory-changed' event when the directory is successfully |
* changed. |
* |
+ * Note : if this is called from UI, please consider to use DirectoryModel. |
+ * activateDirectoryEntry instead of this, which is higher-level function and |
+ * cares about the selection. |
+ * |
* @param {DirectoryEntry|Object} dirEntry The entry of the new directory to |
* be opened. |
* @param {function()=} opt_callback Executed if the directory loads |
@@ -695,6 +699,31 @@ DirectoryModel.prototype.changeDirectoryEntry = function( |
}; |
/** |
+ * Activates the given directry. |
+ * This method: |
+ * - Changes the current directory, if the given directory is the current |
+ * directory. |
+ * - Clears the selection, if the given directory is the current directory. |
+ * |
+ * @param {DirectoryEntry|Object} dirEntry The entry of the new directory to |
+ * be opened. |
+ * @param {function()=} opt_callback Executed if the directory loads |
+ * successfully. |
+ */ |
+DirectoryModel.prototype.activateDirectoryEntry = function( |
+ dirEntry, opt_callback) { |
+ var currentDirectoryEntry = this.getCurrentDirEntry(); |
+ if (currentDirectoryEntry && |
+ util.isSameEntry(dirEntry, currentDirectoryEntry)) { |
+ // On activating the current directory, clear the selection on the filelist. |
+ this.clearSelection(); |
+ } else { |
+ // Otherwise, changes the current directory. |
+ this.changeDirectoryEntry(dirEntry, opt_callback); |
+ } |
+}; |
+ |
+/** |
* Clears the selection in the file list. |
*/ |
DirectoryModel.prototype.clearSelection = function() { |