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

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

Issue 10342010: Add gdata content search to file_manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: some fixes Created 8 years, 8 months 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
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 5a90e85a21a05b2c4340b3c36a55064155c6746b..10b9ec45cddf9c8584aa13aac050d7d6fb760b07 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -978,6 +978,8 @@ FileManager.prototype = {
*/
FileManager.prototype.canExecute_ = function(commandId) {
var readonly = this.isOnReadonlyDirectory();
+ var shouldCreate = util.shouldCreateOnGDataPath(
dgozman 2012/05/03 11:21:47 This is not very intuitive: you ask for something
tbarzic 2012/05/03 19:16:02 Done.
+ this.directoryModel_.getCurrentDirEntry().fullPath);
switch (commandId) {
case 'copy':
case 'cut':
@@ -985,7 +987,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
@@ -1006,6 +1009,7 @@ FileManager.prototype = {
case 'newfolder':
return !readonly &&
+ shouldCreate &&
(this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE ||
this.dialogType_ == FileManager.DialogType.FULL_PAGE);
@@ -1830,9 +1834,16 @@ FileManager.prototype = {
var fileName = this.document_.createElement('div');
fileName.className = 'filename-label';
+ // If the entry is gdata search result, we should calculate name to use
+ // instead of using |entry.name|.
+ var gdataSearchResult =
+ util.getFileAndDisplayNameForGDataSearchResult(entry.fullPath);
+ var displayName = gdataSearchResult ? gdataSearchResult.displayName :
+ entry.name;
+
fileName.textContent =
this.directoryModel_.getCurrentDirEntry().name == '' ?
- this.getRootLabel_(entry.name) : entry.name;
+ this.getRootLabel_(displayName) : displayName;
return fileName;
};
@@ -2870,7 +2881,12 @@ FileManager.prototype = {
if (i == pathNames.length - 1) {
div.classList.add('breadcrumb-last');
} else {
- div.addEventListener('click', this.onBreadcrumbClick_.bind(this));
+ // This is virtual, inaccessible directory.
+ if (i == 1 && pathNames[0] == 'gdata' && pathNames[1] == '.search') {
dgozman 2012/05/03 11:21:47 |path == util.getGDataSearchRoot()| ?
tbarzic 2012/05/03 19:16:02 Yep, you're right, I haven't read the method caref
+ div.classList.add('breadcrumb-last');
+ } else {
+ div.addEventListener('click', this.onBreadcrumbClick_.bind(this));
+ }
var spacer = doc.createElement('div');
spacer.className = 'separator';
@@ -3540,7 +3556,17 @@ FileManager.prototype = {
FileManager.prototype.commitRename_ = function() {
var input = this.renameInput_;
var entry = input.currentEntry;
- var newName = input.value;
+ var newNameInput = input.value;
+
+ // If we are renaming gdata search result, we'll have to format newName we
+ // use in file system operations like: <resource_id>.<file_name>.
+ var searchResultName =
+ util.getFileAndDisplayNameForGDataSearchResult(entry.fullPath);
+
+ var newName =
+ searchResultName ? searchResultName.resourceId + '.' + newNameInput :
+ newNameInput;
+ var oldName = searchResultName ? searchResultName.displayName : entry.name;
if (newName == entry.name) {
this.cancelRename_();
@@ -3558,7 +3584,7 @@ FileManager.prototype = {
this.cancelRename_();
}
- if (!this.validateFileName_(newName, validationDone.bind(this)))
+ if (!this.validateFileName_(newNameInput, validationDone.bind(this)))
return;
function onError(err) {
@@ -3570,16 +3596,16 @@ FileManager.prototype = {
this.cancelRename_();
// Optimistically apply new name immediately to avoid flickering in
// case of success.
- nameNode.textContent = newName;
+ nameNode.textContent = newNameInput;
this.directoryModel_.doesExist(newName, function(exists, isFile) {
if (!exists) {
this.directoryModel_.renameEntry(entry, newName, onError.bind(this));
} else {
- nameNode.textContent = entry.name;
+ nameNode.textContent = oldName;
var message = isFile ? 'FILE_ALREADY_EXISTS' :
'DIRECTORY_ALREADY_EXISTS';
- this.alert.show(strf(message, newName));
+ this.alert.show(strf(message, newNameInput));
}
}.bind(this));
};
@@ -4263,13 +4289,22 @@ 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;
- });
+ if (!this.isOnGData()) {
+ this.directoryModel_.addFilter(
+ 'searchbox',
+ function(e) {
+ return e.name.substr(0, searchString.length) == searchString;
+ });
+ } else {
+ this.directoryModel_.changeDirectory(
+ util.createGDataSearchPath(searchString));
+ }
} else {
- this.directoryModel_.removeFilter('searchbox');
+ if (!this.isOnGData()) {
+ this.directoryModel_.removeFilter('searchbox');
+ } else {
+ this.directoryModel_.changeDirectory('/gdata/');
dgozman 2012/05/03 11:21:47 1. Use |'/' + DirectoryModel.GDATA_DIRECTORY| 2. I
tbarzic 2012/05/03 19:16:02 Done.
+ }
}
};

Powered by Google App Engine
This is Rietveld 408576698