Index: chrome/browser/resources/file_manager/js/directory_model.js |
diff --git a/chrome/browser/resources/file_manager/js/directory_model.js b/chrome/browser/resources/file_manager/js/directory_model.js |
index ece9580de972159bef3acd4b351341c44bd919e4..c4b6d950d16d03774e243b9560331edd0851625c 100644 |
--- a/chrome/browser/resources/file_manager/js/directory_model.js |
+++ b/chrome/browser/resources/file_manager/js/directory_model.js |
@@ -880,24 +880,24 @@ DirectoryModel.prototype.setupPath = function(path, opt_pathResolveCallback) { |
var INITIAL = true; |
var EXISTS = true; |
- function changeToDefault() { |
+ function changeToDefault(leafName) { |
var def = self.getDefaultDirectory(); |
self.resolveDirectory(def, function(directoryEntry) { |
- resolveCallback(def, '', !EXISTS); |
+ resolveCallback(def, leafName, !EXISTS); |
changeDirectoryEntry(directoryEntry, INITIAL); |
}, function(error) { |
console.error('Failed to resolve default directory: ' + def, error); |
- resolveCallback('/', '', !EXISTS); |
+ resolveCallback('/', leafName, !EXISTS); |
}); |
} |
- function noParentDirectory(error) { |
+ function noParentDirectory(leafName, error) { |
console.log('Can\'t resolve parent directory: ' + path, error); |
- changeToDefault(); |
+ changeToDefault(leafName); |
} |
if (DirectoryModel.isSystemDirectory(path)) { |
- changeToDefault(); |
+ changeToDefault(''); |
return; |
} |
@@ -907,11 +907,12 @@ DirectoryModel.prototype.setupPath = function(path, opt_pathResolveCallback) { |
}, function(error) { |
// Usually, leaf does not exist, because it's just a suggested file name. |
var fileExists = error.code == FileError.TYPE_MISMATCH_ERR; |
+ var nameDelimiter = path.lastIndexOf('/'); |
+ var parentDirectoryPath = path.substr(0, nameDelimiter); |
+ var leafName = path.substr(nameDelimiter + 1); |
if (fileExists || error.code == FileError.NOT_FOUND_ERR) { |
- var nameDelimiter = path.lastIndexOf('/'); |
- var parentDirectoryPath = path.substr(0, nameDelimiter); |
if (DirectoryModel.isSystemDirectory(parentDirectoryPath)) { |
- changeToDefault(); |
+ changeToDefault(leafName); |
return; |
} |
self.resolveDirectory(parentDirectoryPath, |
@@ -926,11 +927,11 @@ DirectoryModel.prototype.setupPath = function(path, opt_pathResolveCallback) { |
// TODO(kaznacheev): Fix history.replaceState for the File Browser and |
// change !INITIAL to INITIAL. Passing |false| makes things |
// less ugly for now. |
- }, noParentDirectory); |
+ }, noParentDirectory.bind(null, leafName)); |
} else { |
// Unexpected errors. |
console.error('Directory resolving error: ', error); |
- changeToDefault(); |
+ changeToDefault(leafName); |
} |
}); |
}; |