Index: chrome/browser/resources/file_manager/js/file_manager.js |
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js |
index feddb206cb9552ba30adf44726b3cb249528ed22..db0211a43343fdf539a83dd954db0d31cb74f653 100644 |
--- a/chrome/browser/resources/file_manager/js/file_manager.js |
+++ b/chrome/browser/resources/file_manager/js/file_manager.js |
@@ -999,6 +999,8 @@ FileManager.prototype = { |
*/ |
FileManager.prototype.canExecute_ = function(commandId) { |
var readonly = this.isOnReadonlyDirectory(); |
+ var shouldCreate = !util.isSpecialReadonlyDirectory( |
+ this.directoryModel_.getCurrentDirEntry().fullPath); |
SeRya
2012/05/10 08:44:16
I think here should not be difference between loca
tbarzic
2012/05/10 23:28:02
Done.
|
switch (commandId) { |
case 'copy': |
case 'cut': |
@@ -1006,7 +1008,8 @@ FileManager.prototype = { |
case 'paste': |
return !!this.fileTransferController_ && |
- this.fileTransferController_.queryPasteCommandEnabled(); |
+ this.fileTransferController_.queryPasteCommandEnabled() && |
+ shouldCreate; |
case 'rename': |
return (// Initialized to the point where we have a current directory |
@@ -1027,6 +1030,7 @@ FileManager.prototype = { |
case 'newfolder': |
return !readonly && |
+ shouldCreate && |
(this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE || |
this.dialogType_ == FileManager.DialogType.FULL_PAGE); |
@@ -1863,9 +1867,12 @@ FileManager.prototype = { |
var fileName = this.document_.createElement('div'); |
fileName.className = 'filename-label'; |
+ var displayName = |
+ this.directoryModel_.getDisplayName(entry.fullPath, entry.name); |
+ |
fileName.textContent = |
this.directoryModel_.getCurrentDirEntry().name == '' ? |
- this.getRootLabel_(entry.name) : entry.name; |
+ this.getRootLabel_(displayName) : displayName; |
return fileName; |
}; |
@@ -2894,18 +2901,27 @@ FileManager.prototype = { |
var div = doc.createElement('div'); |
div.className = 'breadcrumb-path'; |
- div.textContent = i == 0 ? this.getRootLabel_(path) : pathName; |
+ // We normally shouldn't be updating breadcrumbs for gdata search paths |
+ // (we have to use getDisplayName for these paths), but we have to handle |
+ // the case when user explicitly navigates to |
+ // chrome://files/#/gdata/.search/foo. |
+ div.textContent = i == 0 ? this.getRootLabel_(path) : |
+ this.directoryModel_.getDisplayName(path, |
+ pathName); |
path = path + '/'; |
div.path = path; |
bc.appendChild(div); |
- if (i == pathNames.length - 1) { |
- div.classList.add('breadcrumb-last'); |
+ if (i == pathNames.length - 1 || |
+ path == util.GDATA_SEARCH_ROOT_PATH + '/') { |
+ div.classList.add('breadcrumb-non-clickable'); |
} else { |
div.addEventListener('click', this.onBreadcrumbClick_.bind(this)); |
+ } |
+ if (i != pathNames.length - 1) { |
var spacer = doc.createElement('div'); |
spacer.className = 'separator'; |
bc.appendChild(spacer); |
@@ -3062,7 +3078,9 @@ FileManager.prototype = { |
var self = this; |
var msg; |
if (entries.length == 1) { |
- msg = strf('CONFIRM_DELETE_ONE', entries[0].name); |
+ var entryName = this.directoryModel_.getDisplayName(entries[0].fullPath, |
+ entries[0].name); |
+ msg = strf('CONFIRM_DELETE_ONE', entryName); |
} else { |
msg = strf('CONFIRM_DELETE_SOME', entries.length); |
} |
@@ -3341,6 +3359,7 @@ FileManager.prototype = { |
FileManager.prototype.onDirectoryAction = function(entry) { |
var deviceNumber = this.getDeviceNumber(entry); |
+ // TODO(tbarzic): Is this still used? |
SeRya
2012/05/10 08:44:16
It's obsolete code. Please remove it.
tbarzic
2012/05/10 23:28:02
Yeah, I though so, but wanted to check before I re
|
if (deviceNumber != undefined && |
this.mountPoints_[deviceNumber].mountCondition == |
'unknown_filesystem') { |
@@ -3350,7 +3369,18 @@ FileManager.prototype = { |
'unsupported_filesystem') { |
return this.showButter(str('UNSUPPORTED_FILESYSTEM_WARNING')); |
} else { |
- return this.directoryModel_.changeDirectory(entry.fullPath); |
+ if (!util.isGDataSearchPath(entry.fullPath)) |
+ return this.directoryModel_.changeDirectory(entry.fullPath); |
+ |
+ // If we are under gdata search path, the real entries file path may be |
+ // different from |entry.fullPath|. |
+ var self = this; |
+ chrome.fileBrowserPrivate.getPathForDriveSearchResult(entry.toURL(), |
+ function(path) { |
+ // |path| may be undefined if there was an error. |
+ var changeToPath = path || entry.fullPath; |
+ self.directoryModel_.changeDirectory(changeToPath); |
+ }); |
} |
}; |
@@ -3402,6 +3432,17 @@ FileManager.prototype = { |
}, |
/** |
+ * Updates search box value if needed when directory gets changed. |
+ * @param {Entry} oldDirEntry Dir entry from which directory was changed. |
+ * @param {Entry} newDirEntry Dir entry to which directory was changed. |
+ */ |
+ FileManager.prototype.updateSearchBoxOnDirChange_ = |
+ function(oldDirEntry, newDirEntry) { |
+ if (this.directoryModel_.shouldClearSearch(oldDirEntry, newDirEntry)) |
SeRya
2012/05/10 08:44:16
I think the search box should be cleared unconditi
tbarzic
2012/05/10 23:28:02
Yeah, I found that a bit strange too, but had deci
|
+ this.dialogDom_.querySelector('#search-box').value = ''; |
+ }, |
+ |
+ /** |
* Update the UI when the current directory changes. |
* |
* @param {cr.Event} event The directory-changed event. |
@@ -3411,6 +3452,7 @@ FileManager.prototype = { |
this.updateOkButton_(); |
this.updateBreadcrumbs_(); |
this.updateColumnModel_(); |
+ this.updateSearchBoxOnDirChange_(event.previousDirEntry, event.newDirEntry); |
// Sometimes we rescan the same directory (when mounting GData lazily first, |
// then for real). Do not update the location then. |
@@ -3596,8 +3638,10 @@ FileManager.prototype = { |
return; |
function onError(err) { |
- nameNode.textContent = entry.name; |
- this.alert.show(strf('ERROR_RENAMING', entry.name, |
+ var entryName = |
+ this.directoryModel_.getDisplayName(entry.fullPath, entry.name); |
+ nameNode.textContent = entryName; |
+ this.alert.show(strf('ERROR_RENAMING', entryName, |
getFileErrorString(err.code))); |
} |
@@ -3606,11 +3650,12 @@ FileManager.prototype = { |
// case of success. |
nameNode.textContent = newName; |
- this.directoryModel_.doesExist(newName, function(exists, isFile) { |
+ this.directoryModel_.doesExist(entry, newName, function(exists, isFile) { |
if (!exists) { |
this.directoryModel_.renameEntry(entry, newName, onError.bind(this)); |
} else { |
- nameNode.textContent = entry.name; |
+ nameNode.textContent = |
+ this.directoryModel_.getDisplayName(entry.fullPath, entry.name); |
var message = isFile ? 'FILE_ALREADY_EXISTS' : |
'DIRECTORY_ALREADY_EXISTS'; |
this.alert.show(strf(message, newName)); |
@@ -4296,15 +4341,7 @@ FileManager.prototype = { |
FileManager.prototype.onSearchBoxUpdate_ = function(event) { |
var searchString = this.dialogDom_.querySelector('#search-box').value; |
- if (searchString) { |
- this.directoryModel_.addFilter( |
- 'searchbox', |
- function(e) { |
- return e.name.substr(0, searchString.length) == searchString; |
- }); |
- } else { |
- this.directoryModel_.removeFilter('searchbox'); |
- } |
+ this.directoryModel_.search(searchString); |
}; |
FileManager.prototype.decorateSplitter = function(splitterElement) { |