Commit 32630ce2 authored by serya@chromium.org's avatar serya@chromium.org

Preserving target file name in the save as dialog if target directory doesn't exist.

BUG=151400
TEST=Manual test.


Review URL: https://chromiumcodereview.appspot.com/11411317

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170803 0039d316-1c4b-4281-b951-d872f2087c98
parent 32d162b0
......@@ -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);
}
});
};
......
......@@ -1313,7 +1313,9 @@ DialogType.isModal = function(type) {
if (!this.isGDataEnabled()) {
if (pageLoading)
this.show_();
this.directoryModel_.setupDefaultPath();
var leafName = path.substr(path.indexOf('/') + 1);
path = this.directoryModel_.getDefaultDirectory() + '/' + leafName;
this.finishSetupCurrentDirectory_(path, invokeHandlers);
return;
}
var gdataPath = RootDirectory.GDATA;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment