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

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

Issue 11411317: Preserving target file name in the save as dialog if target directory doesn't exist. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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/js/file_manager.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
});
};
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698