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

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

Issue 6905143: file manager: respect back/fwd buttons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: set default title shown while initializing Created 9 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/main.html » ('j') | 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 02783f71f220619f5c937fa36b20397da3efcb65..ca37fdbb41dfe01a0689e6e11f4ac2445922f727 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_();
};
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698