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 247988fe2a40ce58b2417fd6727ce0fcef5d8afd..ce2fb29530345aa9ad078b8dabb148684c0b95ea 100644 |
--- a/chrome/browser/resources/file_manager/js/file_manager.js |
+++ b/chrome/browser/resources/file_manager/js/file_manager.js |
@@ -1429,8 +1429,12 @@ FileManager.prototype = { |
* Respond to the back and forward buttons. |
*/ |
FileManager.prototype.onPopState_ = function(event) { |
- // TODO(serya): We should restore selected items here. |
this.closeFilePopup_(); |
+ // Nothing left to do if the current directory is not changing. This happens |
+ // if we are exiting the Gallery. |
+ if (this.getPathFromUrlOrParams_() == |
+ this.directoryModel_.currentEntry.fullPath) |
+ return; |
this.setupCurrentDirectory_(true /* invokeHandler */); |
}; |
@@ -2817,8 +2821,9 @@ FileManager.prototype = { |
galleryFrame.scrolling = 'no'; |
galleryFrame.setAttribute('webkitallowfullscreen', true); |
+ var singleSelection = urls.length == 1; |
var selectedUrl; |
- if (urls.length == 1 && FileType.isImage(urls[0])) { |
+ if (singleSelection && FileType.isImage(urls[0])) { |
// Single image item selected. Pass to the Gallery as a selected. |
selectedUrl = urls[0]; |
// Pass along every image and video in the directory so that it shows up |
@@ -2849,6 +2854,7 @@ FileManager.prototype = { |
var currentDir = self.directoryModel_.currentEntry; |
var downloadsDir = self.directoryModel_.rootsList.item(0); |
+ var gallerySelection; |
dgozman
2012/04/23 16:22:17
Another approach is to introduce parameter |select
Vladislav Kaznacheev
2012/04/24 08:13:53
I thought about that but it requires at least as m
|
var context = { |
// We show the root label in readonly warning (e.g. archive name). |
readonlyDirName: |
@@ -2861,10 +2867,12 @@ FileManager.prototype = { |
metadataProvider: self.getMetadataProvider(), |
getShareActions: self.getShareActions_.bind(self), |
onNameChange: function(name) { |
- self.document_.title = name; |
+ self.document_.title = gallerySelection = name; |
self.updateLocation_(true /*replace*/, dirPath + '/' + name); |
}, |
onClose: function() { |
+ if (singleSelection) |
+ self.directoryModel_.selectEntry(gallerySelection); |
history.back(1); |
}, |
displayStringFunction: strf |