Index: chrome/browser/resources/file_manager/js/file_manager.js |
=================================================================== |
--- chrome/browser/resources/file_manager/js/file_manager.js (revision 133184) |
+++ chrome/browser/resources/file_manager/js/file_manager.js (working copy) |
@@ -798,10 +798,11 @@ |
return self.renderRoot_(entry); |
}; |
- this.rootsList_.selectionModel = this.directoryModel_.rootsListSelection; |
+ this.rootsList_.selectionModel = |
+ this.directoryModel_.getRootsListSelectionModel(); |
// TODO(dgozman): add "Add a drive" item. |
- this.rootsList_.dataModel = this.directoryModel_.rootsList; |
+ this.rootsList_.dataModel = this.directoryModel_.getRootsList(); |
this.directoryModel_.updateRoots(function() { |
self.rootsList_.endBatchUpdates(); |
}, false); |
@@ -1221,8 +1222,7 @@ |
return true; |
case 'format': |
- var entry = |
- this.getRootEntry_(this.rootsList_.selectionModel.selectedIndex); |
+ var entry = this.directoryModel_.getCurrentRootDirEntry(); |
return entry && DirectoryModel.getRootType(entry.fullPath) == |
DirectoryModel.RootType.REMOVABLE; |
@@ -1509,16 +1509,11 @@ |
return; |
case 'unmount': |
- var entry = |
- this.getRootEntry_(this.rootsList_.selectionModel.selectedIndex); |
- |
- this.unmountVolume_(entry); |
+ this.unmountVolume_(this.directoryModel_.getCurrentRootDirEntry()); |
return; |
case 'format': |
- var entry = |
- this.getRootEntry_(this.rootsList_.selectionModel.selectedIndex); |
- |
+ var entry = this.directoryModel_.getCurrentRootDirEntry(); |
this.confirm.show(str('FORMATTING_WARNING'), function() { |
chrome.fileBrowserPrivate.formatDevice(entry.toURL()); |
}); |
@@ -1926,7 +1921,7 @@ |
FileManager.prototype.renderRoot_ = function(entry) { |
var li = this.document_.createElement('li'); |
li.className = 'root-item'; |
- li.addEventListener('click', this.onRootClick_.bind(this, entry)); |
+ this.directoryModel_.registerRootClickListener_(li, entry); |
var rootType = DirectoryModel.getRootType(entry.fullPath); |
@@ -1970,18 +1965,6 @@ |
}; |
/** |
- * Handler for root item being clicked. |
- * @param {Entry} entry to navigate to. |
- * @param {Event} event The event. |
- */ |
- FileManager.prototype.onRootClick_ = function(entry, event) { |
- var path = this.directoryModel_.currentEntry.fullPath; |
- if (path.indexOf(entry.fullPath) == 0 && path != entry.fullPath) { |
- this.directoryModel_.changeDirectory(entry.fullPath); |
- } |
- }; |
- |
- /** |
* Unmounts device. |
* @param {string} url The url of removable storage to unmount. |
*/ |
@@ -2457,7 +2440,8 @@ |
FileManager.prototype.isOnGData = function() { |
return this.directoryModel_ && |
- this.directoryModel_.rootPath == '/' + DirectoryModel.GDATA_DIRECTORY; |
+ this.directoryModel_.getCurrentRootPath() == |
+ '/' + DirectoryModel.GDATA_DIRECTORY; |
}; |
FileManager.prototype.getMetadataProvider = function() { |
@@ -2719,7 +2703,7 @@ |
} else if (this.isOnGData() && |
this.directoryModel_.currentEntry.unmounted) { |
// We are currently on an unmounted GData directory, force a rescan. |
- changeDirectoryTo = this.directoryModel_.rootPath; |
+ changeDirectoryTo = this.directoryModel_.getCurrentRootPath(); |
} |
} else { |
this.gdataMounted_ = false; |
@@ -2765,7 +2749,7 @@ |
} |
if (event.status == 'success' && |
- event.mountPath == self.directoryModel_.rootPath) { |
+ event.mountPath == self.directoryModel_.getCurrentRootPath()) { |
if (self.params_.mountTriggered && index == -1) { |
// This device mount was the reason this File Manager instance was |
// created. Now the device is unmounted from another instance |
@@ -2917,7 +2901,7 @@ |
// until we learn to save files directly to GData. |
var readonly = self.isOnReadonlyDirectory() || self.isOnGData(); |
var currentDir = self.directoryModel_.currentEntry; |
- var downloadsDir = self.directoryModel_.rootsList.item(0); |
+ var downloadsDir = self.directoryModel_.getRootsList().item(0); |
var context = { |
// We show the root label in readonly warning (e.g. archive name). |
@@ -2953,7 +2937,7 @@ |
var bc = this.dialogDom_.querySelector('.breadcrumbs'); |
removeChildren(bc); |
- var rootPath = this.directoryModel_.rootPath; |
+ var rootPath = this.directoryModel_.getCurrentRootPath(); |
var relativePath = this.directoryModel_.currentEntry.fullPath. |
substring(rootPath.length).replace(/\/$/, ''); |