diff options
author | rginda@chromium.org <rginda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-29 23:32:22 +0000 |
---|---|---|
committer | rginda@chromium.org <rginda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-29 23:32:22 +0000 |
commit | 27263dda51daa015b979669e5a8f9c3b7ffbce2a (patch) | |
tree | 44cd17debe32c9ad49db170d6aa6cd0a52f1f34b /chrome | |
parent | 2687f11c2bd2c52231571f2f51ea4c60587a66da (diff) | |
download | chromium_src-27263dda51daa015b979669e5a8f9c3b7ffbce2a.zip chromium_src-27263dda51daa015b979669e5a8f9c3b7ffbce2a.tar.gz chromium_src-27263dda51daa015b979669e5a8f9c3b7ffbce2a.tar.bz2 |
file manager: respect back/fwd buttons
BUG=chromium-os:14666
TEST=manual testing on chromeos-chrome on linux
Review URL: http://codereview.chromium.org/6905143
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83623 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/resources/file_manager/js/file_manager.js | 28 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/main.html | 7 |
2 files changed, 34 insertions, 1 deletions
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js index 02783f7..ca37fdb 100644 --- a/chrome/browser/resources/file_manager/js/file_manager.js +++ b/chrome/browser/resources/file_manager/js/file_manager.js @@ -52,6 +52,7 @@ function FileManager(dialogDom, rootEntries, params) { // DirectoryEntry representing the current directory of the dialog. this.currentDirEntry_ = null; + window.addEventListener('popstate', this.onPopState_.bind(this)); this.addEventListener('directory-changed', this.onDirectoryChanged_.bind(this)); this.addEventListener('selection-summarized', @@ -559,6 +560,16 @@ FileManager.prototype = { 'change', this.onDetailSelectionChanged_.bind(this)); }; + /** + * Respond to the back button. + */ + FileManager.prototype.onPopState_ = function(event) { + this.changeDirectory(event.state, false); + }; + + /** + * Resize details and thumb views to fit the new window size. + */ FileManager.prototype.onResize_ = function() { this.table_.style.height = this.grid_.style.height = this.grid_.parentNode.clientHeight + 'px'; @@ -1154,10 +1165,18 @@ FileManager.prototype = { * changed. * * @param {string} path The absolute path to the new directory. + * @param {bool} opt_saveHistory Save this in the history stack (defaults + * to true). */ - FileManager.prototype.changeDirectory = function(path) { + FileManager.prototype.changeDirectory = function(path, opt_saveHistory) { var self = this; + if (arguments.length == 1) { + opt_saveHistory = true; + } else { + opt_saveHistory = !!opt_saveHistory; + } + function onPathFound(dirEntry) { if (self.currentDirEntry_ && self.currentDirEntry_.fullPath == dirEntry.fullPath) { @@ -1168,6 +1187,7 @@ FileManager.prototype = { var e = new cr.Event('directory-changed'); e.previousDirEntry = self.currentDirEntry_; e.newDirEntry = dirEntry; + e.saveHistory = opt_saveHistory; self.currentDirEntry_ = dirEntry; self.dispatchEvent(e); }; @@ -1309,6 +1329,12 @@ FileManager.prototype = { * @param {cr.Event} event The directory-changed event. */ FileManager.prototype.onDirectoryChanged_ = function(event) { + if (event.saveHistory) { + history.pushState(this.currentDirEntry_.fullPath, + this.currentDirEntry_.fullPath, + location.href); + } + this.document_.title = this.currentDirEntry_.fullPath; this.rescanDirectory_(); }; diff --git a/chrome/browser/resources/file_manager/main.html b/chrome/browser/resources/file_manager/main.html index af84918..08c06db 100644 --- a/chrome/browser/resources/file_manager/main.html +++ b/chrome/browser/resources/file_manager/main.html @@ -70,6 +70,13 @@ <script src="js/util.js"></script> <script src="js/file_manager.js"></script> <script src="js/main.js"></script> + + <!-- We have to set some default title, or chrome will use the page + -- name. As soon as we init and change to a directory, we'll use + -- the directory as the page title. Until then, have a unicode glyph + -- of a tape reel. + --> + <title>✇</title> </head> <body i18n-values=".style.fontFamily:BODY_FONT_FAMILY; .style.fontSize:BODY_FONT_SIZE"> |