Commit 0112caf9 authored by mtomasz@chromium.org's avatar mtomasz@chromium.org

Remove getCurrentDirectoryURL and getCurrentDirPath from directory_model.js.

This CL removes two methods which rely on URL and full paths, what is deprecated.

TEST=Tested manually.
BUG=328252

Review URL: https://codereview.chromium.org/101243003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243077 0039d316-1c4b-4281-b951-d872f2087c98
parent 9ea7aea3
...@@ -200,27 +200,6 @@ DirectoryModel.prototype.getCurrentDirEntry = function() { ...@@ -200,27 +200,6 @@ DirectoryModel.prototype.getCurrentDirEntry = function() {
return this.currentDirContents_.getDirectoryEntry(); return this.currentDirContents_.getDirectoryEntry();
}; };
/**
* TODO(hirono): Remove the method.
* @return {string} URL of the current directory. or null if unavailable.
*/
DirectoryModel.prototype.getCurrentDirectoryURL = function() {
var entry = this.currentDirContents_.getDirectoryEntry();
if (!entry)
return null;
return util.isFakeEntry(entry) ?
util.makeFilesystemUrl(entry.fullPath) : entry.toURL();
};
/**
* @return {string} Path for the current directory, or empty string if the
* current directory is not yet set.
*/
DirectoryModel.prototype.getCurrentDirPath = function() {
var entry = this.currentDirContents_.getDirectoryEntry();
return entry ? entry.fullPath : '';
};
/** /**
* @return {Array.<string>} File paths of selected files. * @return {Array.<string>} File paths of selected files.
* @private * @private
...@@ -912,8 +891,8 @@ DirectoryModel.prototype.onVolumeInfoListUpdated_ = function(event) { ...@@ -912,8 +891,8 @@ DirectoryModel.prototype.onVolumeInfoListUpdated_ = function(event) {
// since the current directory is initializing now. // since the current directory is initializing now.
// TODO(mtomasz): DEFAULT_MOUNT_POINT is deprecated. Use VolumeManager:: // TODO(mtomasz): DEFAULT_MOUNT_POINT is deprecated. Use VolumeManager::
// getDefaultVolume() after it is implemented. // getDefaultVolume() after it is implemented.
if (this.getCurrentDirPath() && if (this.getCurrentDirEntry() &&
!this.volumeManager_.getVolumeInfo(this.getCurrentDirPath())) !this.volumeManager_.getVolumeInfo(this.getCurrentDirEntry()))
this.changeDirectory(PathUtil.DEFAULT_MOUNT_POINT); this.changeDirectory(PathUtil.DEFAULT_MOUNT_POINT);
}; };
......
...@@ -374,8 +374,11 @@ DirectoryItem.prototype.doDropTargetAction = function() { ...@@ -374,8 +374,11 @@ DirectoryItem.prototype.doDropTargetAction = function() {
* Executes the assigned action. DirectoryItem performs changeDirectory. * Executes the assigned action. DirectoryItem performs changeDirectory.
*/ */
DirectoryItem.prototype.doAction = function() { DirectoryItem.prototype.doAction = function() {
if (this.fullPath !== this.directoryModel_.getCurrentDirPath()) // TODO(mtomasz, yoshiki): Do not use fullPaths here, but Entry instead.
if (!this.directoryModel_.getCurrentDirEntry() ||
this.fullPath !== this.directoryModel_.getCurrentDirEntry().fullPath) {
this.directoryModel_.changeDirectory(this.fullPath); this.directoryModel_.changeDirectory(this.fullPath);
}
}; };
/** /**
......
...@@ -1931,23 +1931,6 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -1931,23 +1931,6 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
this.grid_.focus(); this.grid_.focus();
}; };
/**
* Return full path of the current directory or null.
* @return {?string} The full path of the current directory.
*/
FileManager.prototype.getCurrentDirectory = function() {
return this.directoryModel_ && this.directoryModel_.getCurrentDirPath();
};
/**
* Return URL of the current directory or null.
* @return {string} URL representing the current directory.
*/
FileManager.prototype.getCurrentDirectoryURL = function() {
return this.directoryModel_ &&
this.directoryModel_.getCurrentDirectoryURL();
};
/** /**
* Return DirectoryEntry of the current directory or null. * Return DirectoryEntry of the current directory or null.
* @return {DirectoryEntry} DirectoryEntry of the current directory. Returns * @return {DirectoryEntry} DirectoryEntry of the current directory. Returns
...@@ -2199,7 +2182,8 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -2199,7 +2182,8 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
if (this.dialogType != DialogType.FULL_PAGE) if (this.dialogType != DialogType.FULL_PAGE)
return; return;
var path = this.getCurrentDirectory(); // TODO(mtomasz): Use VolumeInfo.root instead.
var path = this.getCurrentDirectoryEntry().fullPath;
var rootPath = PathUtil.getRootPath(path); var rootPath = PathUtil.getRootPath(path);
this.document_.title = PathUtil.getRootLabel(rootPath) + this.document_.title = PathUtil.getRootLabel(rootPath) +
path.substring(rootPath.length); path.substring(rootPath.length);
...@@ -2271,7 +2255,10 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -2271,7 +2255,10 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
FileManager.prototype.onDirectoryChanged_ = function(event) { FileManager.prototype.onDirectoryChanged_ = function(event) {
this.selectionHandler_.onFileSelectionChanged(); this.selectionHandler_.onFileSelectionChanged();
this.ui_.searchBox.clear(); this.ui_.searchBox.clear();
util.updateAppState(this.getCurrentDirectory()); // TODO(mtomasz): Use Entry.toURL() instead of fullPath.
util.updateAppState(
this.getCurrentDirectoryEntry() &&
this.getCurrentDirectoryEntry().fullPath);
// If the current directory is moved from the device's volume, do not // If the current directory is moved from the device's volume, do not
// automatically close the window on device removal. // automatically close the window on device removal.
...@@ -2485,10 +2472,10 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -2485,10 +2472,10 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
}.bind(this)); }.bind(this));
}; };
// TODO(haruki): this.getCurrentDirectoryURL() might not return the actual // TODO(haruki): this.getCurrentDirectoryEntry() might not return the actual
// parent if the directory content is a search result. Fix it to do proper // parent if the directory content is a search result. Fix it to do proper
// validation. // validation.
this.validateFileName_(this.getCurrentDirectoryURL(), this.validateFileName_(this.getCurrentDirectoryEntry(),
newName, newName,
validationDone.bind(this)); validationDone.bind(this));
}; };
...@@ -2833,7 +2820,10 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -2833,7 +2820,10 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
switch (util.getKeyModifiers(event) + event.keyCode) { switch (util.getKeyModifiers(event) + event.keyCode) {
case '8': // Backspace => Up one directory. case '8': // Backspace => Up one directory.
event.preventDefault(); event.preventDefault();
var path = this.getCurrentDirectory(); // TODO(mtomasz): Use Entry.getParent() instead.
if (!this.getCurrentDirectoryEntry())
break;
var path = this.getCurrentDirectoryEntry().fullPath;
if (path && !PathUtil.isRootPath(path)) { if (path && !PathUtil.isRootPath(path)) {
var path = path.replace(/\/[^\/]+$/, ''); var path = path.replace(/\/[^\/]+$/, '');
this.directoryModel_.changeDirectory(path); this.directoryModel_.changeDirectory(path);
...@@ -3124,10 +3114,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -3124,10 +3114,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
throw new Error('Missing filename!'); throw new Error('Missing filename!');
var directory = this.getCurrentDirectoryEntry(); var directory = this.getCurrentDirectoryEntry();
var currentDirUrl = directory.toURL(); this.validateFileName_(directory, filename, function(isValid) {
if (currentDirUrl.charAt(currentDirUrl.length - 1) != '/')
currentDirUrl += '/';
this.validateFileName_(currentDirUrl, filename, function(isValid) {
if (!isValid) if (!isValid)
return; return;
...@@ -3137,6 +3124,11 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -3137,6 +3124,11 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
} }
var selectFileAndClose = function() { var selectFileAndClose = function() {
// TODO(mtomasz): Clean this up by avoiding constructing a URL
// via string concatenation.
var currentDirUrl = directory.toURL();
if (currentDirUrl.charAt(currentDirUrl.length - 1) != '/')
currentDirUrl += '/';
this.selectFilesAndClose_({ this.selectFilesAndClose_({
urls: [currentDirUrl + encodeURIComponent(filename)], urls: [currentDirUrl + encodeURIComponent(filename)],
multiple: false, multiple: false,
...@@ -3178,7 +3170,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -3178,7 +3170,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
if (DialogType.isFolderDialog(this.dialogType) && if (DialogType.isFolderDialog(this.dialogType) &&
selectedIndexes.length == 0) { selectedIndexes.length == 0) {
var url = this.getCurrentDirectoryURL(); var url = this.getCurrentDirectoryEntry().toURL();
var singleSelection = { var singleSelection = {
urls: [url], urls: [url],
multiple: false, multiple: false,
...@@ -3247,14 +3239,15 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -3247,14 +3239,15 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
* *
* It also verifies if the name length is in the limit of the filesystem. * It also verifies if the name length is in the limit of the filesystem.
* *
* @param {string} parentUrl The URL of the parent directory entry. * @param {DirectoryEntry} parentEntry The URL of the parent directory entry.
* @param {string} name New file or folder name. * @param {string} name New file or folder name.
* @param {function} onDone Function to invoke when user closes the * @param {function} onDone Function to invoke when user closes the
* warning box or immediatelly if file name is correct. If the name was * warning box or immediatelly if file name is correct. If the name was
* valid it is passed true, and false otherwise. * valid it is passed true, and false otherwise.
* @private * @private
*/ */
FileManager.prototype.validateFileName_ = function(parentUrl, name, onDone) { FileManager.prototype.validateFileName_ = function(
parentEntry, name, onDone) {
var msg; var msg;
var testResult = /[\/\\\<\>\:\?\*\"\|]/.exec(name); var testResult = /[\/\\\<\>\:\?\*\"\|]/.exec(name);
if (testResult) { if (testResult) {
...@@ -3276,7 +3269,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -3276,7 +3269,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
var self = this; var self = this;
chrome.fileBrowserPrivate.validatePathNameLength( chrome.fileBrowserPrivate.validatePathNameLength(
parentUrl, name, function(valid) { parentEntry.toURL(), name, function(valid) {
if (!valid) { if (!valid) {
self.alert.show(str('ERROR_LONG_NAME'), self.alert.show(str('ERROR_LONG_NAME'),
function() { onDone(false); }); function() { onDone(false); });
......
...@@ -451,8 +451,10 @@ CommandHandler.COMMANDS_['new-folder'] = { ...@@ -451,8 +451,10 @@ CommandHandler.COMMANDS_['new-folder'] = {
*/ */
CommandHandler.COMMANDS_['new-window'] = { CommandHandler.COMMANDS_['new-window'] = {
execute: function(event, fileManager) { execute: function(event, fileManager) {
// TODO(mtomasz): Use Entry.toURL() instead of fullPath.
fileManager.backgroundPage.launchFileManager({ fileManager.backgroundPage.launchFileManager({
defaultPath: fileManager.getCurrentDirectory() defaultPath: fileManager.getCurrentDirectoryEntry() &&
fileManager.getCurrentDirectoryEntry().fullPath
}); });
}, },
canExecute: function(event, fileManager) { canExecute: function(event, fileManager) {
......
...@@ -217,8 +217,11 @@ NavigationList.prototype.renderRoot_ = function(modelItem) { ...@@ -217,8 +217,11 @@ NavigationList.prototype.renderRoot_ = function(modelItem) {
item.setModelItem(modelItem, volumeInfo && volumeInfo.deviceType); item.setModelItem(modelItem, volumeInfo && volumeInfo.deviceType);
var handleClick = function() { var handleClick = function() {
// TODO(mtomasz, yoshiki): Do not use fullPath here, but Entry.
if (item.selected && if (item.selected &&
modelItem.path !== this.directoryModel_.getCurrentDirPath()) { (!this.directoryModel_.getCurrentDirEntry() ||
modelItem.path !==
this.directoryModel_.getCurrentDirEntry().fullPath)) {
metrics.recordUserAction('FolderShortcut.Navigate'); metrics.recordUserAction('FolderShortcut.Navigate');
this.changeDirectory_(modelItem); this.changeDirectory_(modelItem);
} }
......
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