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) { ...@@ -880,24 +880,24 @@ DirectoryModel.prototype.setupPath = function(path, opt_pathResolveCallback) {
var INITIAL = true; var INITIAL = true;
var EXISTS = true; var EXISTS = true;
function changeToDefault() { function changeToDefault(leafName) {
var def = self.getDefaultDirectory(); var def = self.getDefaultDirectory();
self.resolveDirectory(def, function(directoryEntry) { self.resolveDirectory(def, function(directoryEntry) {
resolveCallback(def, '', !EXISTS); resolveCallback(def, leafName, !EXISTS);
changeDirectoryEntry(directoryEntry, INITIAL); changeDirectoryEntry(directoryEntry, INITIAL);
}, function(error) { }, function(error) {
console.error('Failed to resolve default directory: ' + def, 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); console.log('Can\'t resolve parent directory: ' + path, error);
changeToDefault(); changeToDefault(leafName);
} }
if (DirectoryModel.isSystemDirectory(path)) { if (DirectoryModel.isSystemDirectory(path)) {
changeToDefault(); changeToDefault('');
return; return;
} }
...@@ -907,11 +907,12 @@ DirectoryModel.prototype.setupPath = function(path, opt_pathResolveCallback) { ...@@ -907,11 +907,12 @@ DirectoryModel.prototype.setupPath = function(path, opt_pathResolveCallback) {
}, function(error) { }, function(error) {
// Usually, leaf does not exist, because it's just a suggested file name. // Usually, leaf does not exist, because it's just a suggested file name.
var fileExists = error.code == FileError.TYPE_MISMATCH_ERR; var fileExists = error.code == FileError.TYPE_MISMATCH_ERR;
if (fileExists || error.code == FileError.NOT_FOUND_ERR) {
var nameDelimiter = path.lastIndexOf('/'); var nameDelimiter = path.lastIndexOf('/');
var parentDirectoryPath = path.substr(0, nameDelimiter); var parentDirectoryPath = path.substr(0, nameDelimiter);
var leafName = path.substr(nameDelimiter + 1);
if (fileExists || error.code == FileError.NOT_FOUND_ERR) {
if (DirectoryModel.isSystemDirectory(parentDirectoryPath)) { if (DirectoryModel.isSystemDirectory(parentDirectoryPath)) {
changeToDefault(); changeToDefault(leafName);
return; return;
} }
self.resolveDirectory(parentDirectoryPath, self.resolveDirectory(parentDirectoryPath,
...@@ -926,11 +927,11 @@ DirectoryModel.prototype.setupPath = function(path, opt_pathResolveCallback) { ...@@ -926,11 +927,11 @@ DirectoryModel.prototype.setupPath = function(path, opt_pathResolveCallback) {
// TODO(kaznacheev): Fix history.replaceState for the File Browser and // TODO(kaznacheev): Fix history.replaceState for the File Browser and
// change !INITIAL to INITIAL. Passing |false| makes things // change !INITIAL to INITIAL. Passing |false| makes things
// less ugly for now. // less ugly for now.
}, noParentDirectory); }, noParentDirectory.bind(null, leafName));
} else { } else {
// Unexpected errors. // Unexpected errors.
console.error('Directory resolving error: ', error); console.error('Directory resolving error: ', error);
changeToDefault(); changeToDefault(leafName);
} }
}); });
}; };
......
...@@ -1313,7 +1313,9 @@ DialogType.isModal = function(type) { ...@@ -1313,7 +1313,9 @@ DialogType.isModal = function(type) {
if (!this.isGDataEnabled()) { if (!this.isGDataEnabled()) {
if (pageLoading) if (pageLoading)
this.show_(); this.show_();
this.directoryModel_.setupDefaultPath(); var leafName = path.substr(path.indexOf('/') + 1);
path = this.directoryModel_.getDefaultDirectory() + '/' + leafName;
this.finishSetupCurrentDirectory_(path, invokeHandlers);
return; return;
} }
var gdataPath = RootDirectory.GDATA; 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