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

Side by Side Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 10914075: [filemanager] Implementing undo delete functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * FileManager constructor. 6 * FileManager constructor.
7 * 7 *
8 * FileManager objects encapsulate the functionality of the file selector 8 * FileManager objects encapsulate the functionality of the file selector
9 * dialogs, as well as the full screen file manager application (though the 9 * dialogs, as well as the full screen file manager application (though the
10 * latter is not yet implemented). 10 * latter is not yet implemented).
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 fileManager.volumeManager_); 203 fileManager.volumeManager_);
204 this.metadataCache_ = fileManager.metadataCache_; 204 this.metadataCache_ = fileManager.metadataCache_;
205 205
206 this.filesystemChangeHandler_ = 206 this.filesystemChangeHandler_ =
207 fileManager.updateMetadataInUI_.bind(fileManager, 'filesystem'); 207 fileManager.updateMetadataInUI_.bind(fileManager, 'filesystem');
208 this.thumbnailChangeHandler_ = 208 this.thumbnailChangeHandler_ =
209 fileManager.updateMetadataInUI_.bind(fileManager, 'thumbnail'); 209 fileManager.updateMetadataInUI_.bind(fileManager, 'thumbnail');
210 this.gdataChangeHandler_ = 210 this.gdataChangeHandler_ =
211 fileManager.updateMetadataInUI_.bind(fileManager, 'gdata'); 211 fileManager.updateMetadataInUI_.bind(fileManager, 'gdata');
212 212
213 var dm = fileManager.directoryModel_;
214 this.internalChangeHandler_ = dm.rescan.bind(dm);
215
213 this.filesystemObserverId_ = null; 216 this.filesystemObserverId_ = null;
214 this.thumbnailObserverId_ = null; 217 this.thumbnailObserverId_ = null;
215 this.gdataObserverId_ = null; 218 this.gdataObserverId_ = null;
219 this.internalObserverId_ = null;
216 220
217 // Holds the directories known to contain files with stale metadata 221 // Holds the directories known to contain files with stale metadata
218 // as URL to bool map. 222 // as URL to bool map.
219 this.directoriesWithStaleMetadata_ = {}; 223 this.directoriesWithStaleMetadata_ = {};
220 }; 224 };
221 225
222 FileManager.MetadataFileWatcher.prototype.__proto__ = FileWatcher.prototype; 226 FileManager.MetadataFileWatcher.prototype.__proto__ = FileWatcher.prototype;
223 227
224 /** 228 /**
225 * Changed metadata observers for the new directory. 229 * Changed metadata observers for the new directory.
226 * @override 230 * @override
227 * @param {DirectoryEntryi?} entry New watched directory entry. 231 * @param {DirectoryEntryi?} entry New watched directory entry.
228 * @override 232 * @override
229 */ 233 */
230 FileManager.MetadataFileWatcher.prototype.changeWatchedEntry = 234 FileManager.MetadataFileWatcher.prototype.changeWatchedEntry = function(
231 function(entry) { 235 entry) {
232 FileWatcher.prototype.changeWatchedEntry.call(this, entry); 236 FileWatcher.prototype.changeWatchedEntry.call(this, entry);
233 237
234 if (this.filesystemObserverId_) 238 if (this.filesystemObserverId_)
235 this.metadataCache_.removeObserver(this.filesystemObserverId_); 239 this.metadataCache_.removeObserver(this.filesystemObserverId_);
236 if (this.thumbnailObserverId_) 240 if (this.thumbnailObserverId_)
237 this.metadataCache_.removeObserver(this.thumbnailObserverId_); 241 this.metadataCache_.removeObserver(this.thumbnailObserverId_);
238 if (this.gdataObserverId_) 242 if (this.gdataObserverId_)
239 this.metadataCache_.removeObserver(this.gdataObserverId_); 243 this.metadataCache_.removeObserver(this.gdataObserverId_);
240 this.filesystemObserverId_ = null; 244 this.filesystemObserverId_ = null;
241 this.gdataObserverId_ = null; 245 this.gdataObserverId_ = null;
246 this.internalObserverId_ = null;
242 if (!entry) 247 if (!entry)
243 return; 248 return;
244 249
245 this.filesystemObserverId_ = this.metadataCache_.addObserver( 250 this.filesystemObserverId_ = this.metadataCache_.addObserver(
246 entry, 251 entry,
247 MetadataCache.CHILDREN, 252 MetadataCache.CHILDREN,
248 'filesystem', 253 'filesystem',
249 this.filesystemChangeHandler_); 254 this.filesystemChangeHandler_);
250 255
251 this.thumbnailObserverId_ = this.metadataCache_.addObserver( 256 this.thumbnailObserverId_ = this.metadataCache_.addObserver(
252 entry, 257 entry,
253 MetadataCache.CHILDREN, 258 MetadataCache.CHILDREN,
254 'thumbnail', 259 'thumbnail',
255 this.thumbnailChangeHandler_); 260 this.thumbnailChangeHandler_);
256 261
257 if (PathUtil.getRootType(entry.fullPath) === RootType.GDATA) { 262 if (PathUtil.getRootType(entry.fullPath) === RootType.GDATA) {
258 this.gdataObserverId_ = this.metadataCache_.addObserver( 263 this.gdataObserverId_ = this.metadataCache_.addObserver(
259 entry, 264 entry,
260 MetadataCache.CHILDREN, 265 MetadataCache.CHILDREN,
261 'gdata', 266 'gdata',
262 this.gdataChangeHandler_); 267 this.gdataChangeHandler_);
263 } 268 }
269
270 this.internalObserverId_ = this.metadataCache_.addObserver(
271 entry,
272 MetadataCache.CHILDREN,
273 'internal',
274 this.internalChangeHandler_);
264 }; 275 };
265 276
266 /** 277 /**
267 * @override 278 * @override
268 */ 279 */
269 FileManager.MetadataFileWatcher.prototype.onFileInWatchedDirectoryChanged = 280 FileManager.MetadataFileWatcher.prototype.onFileInWatchedDirectoryChanged =
270 function() { 281 function() {
271 FileWatcher.prototype.onFileInWatchedDirectoryChanged.apply(this); 282 FileWatcher.prototype.onFileInWatchedDirectoryChanged.apply(this);
272 delete this.directoriesWithStaleMetadata_[ 283 delete this.directoriesWithStaleMetadata_[
273 this.getWatchedDirectoryEntry().toURL()]; 284 this.getWatchedDirectoryEntry().toURL()];
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 }; 476 };
466 477
467 FileManager.prototype.initDataTransferOperations_ = function() { 478 FileManager.prototype.initDataTransferOperations_ = function() {
468 this.copyManager_ = new FileCopyManagerWrapper.getInstance( 479 this.copyManager_ = new FileCopyManagerWrapper.getInstance(
469 this.filesystem_.root); 480 this.filesystem_.root);
470 this.copyManager_.addEventListener('copy-progress', 481 this.copyManager_.addEventListener('copy-progress',
471 this.onCopyProgress_.bind(this)); 482 this.onCopyProgress_.bind(this));
472 this.copyManager_.addEventListener('copy-operation-complete', 483 this.copyManager_.addEventListener('copy-operation-complete',
473 this.onCopyManagerOperationComplete_.bind(this)); 484 this.onCopyManagerOperationComplete_.bind(this));
474 485
475 this.butterBar_ = new ButterBar(this.dialogDom_, this.copyManager_); 486 this.butterBar_ = new ButterBar(this.dialogDom_, this.copyManager_,
487 this.metadataCache_);
476 488
477 var controller = this.fileTransferController_ = new FileTransferController( 489 var controller = this.fileTransferController_ = new FileTransferController(
478 GridItem.bind(null, this, false /* no checkbox */), 490 GridItem.bind(null, this, false /* no checkbox */),
479 this.copyManager_, 491 this.copyManager_,
480 this.directoryModel_); 492 this.directoryModel_);
481 controller.attachDragSource(this.table_.list); 493 controller.attachDragSource(this.table_.list);
482 controller.attachDropTarget(this.table_.list); 494 controller.attachDropTarget(this.table_.list);
483 controller.attachDragSource(this.grid_); 495 controller.attachDragSource(this.grid_);
484 controller.attachDropTarget(this.grid_); 496 controller.attachDropTarget(this.grid_);
485 controller.attachDropTarget(this.rootsList_, true); 497 controller.attachDropTarget(this.rootsList_, true);
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 return; 1285 return;
1274 1286
1275 case 'rename': 1287 case 'rename':
1276 this.initiateRename_(); 1288 this.initiateRename_();
1277 return; 1289 return;
1278 1290
1279 case 'delete': 1291 case 'delete':
1280 if (this.isRenamingInProgress()) 1292 if (this.isRenamingInProgress())
1281 document.execCommand('delete'); 1293 document.execCommand('delete');
1282 else 1294 else
1283 this.deleteEntries(this.selection.entries); 1295 this.deleteSelection();
1284 1296
1285 return; 1297 return;
1286 1298
1287 case 'newfolder': 1299 case 'newfolder':
1288 this.onNewFolderCommand_(event); 1300 this.onNewFolderCommand_(event);
1289 return; 1301 return;
1290 1302
1291 case 'unmount': 1303 case 'unmount':
1292 this.unmountVolume_(this.directoryModel_.getCurrentRootPath()); 1304 this.unmountVolume_(this.directoryModel_.getCurrentRootPath());
1293 return; 1305 return;
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 }; 2638 };
2627 2639
2628 /** 2640 /**
2629 * Return URL of the current directory or null. 2641 * Return URL of the current directory or null.
2630 */ 2642 */
2631 FileManager.prototype.getCurrentDirectoryURL = function() { 2643 FileManager.prototype.getCurrentDirectoryURL = function() {
2632 return this.directoryModel_ && 2644 return this.directoryModel_ &&
2633 this.directoryModel_.getCurrentDirEntry().toURL(); 2645 this.directoryModel_.getCurrentDirEntry().toURL();
2634 }; 2646 };
2635 2647
2636 FileManager.prototype.deleteEntries = function(entries, force, opt_callback) { 2648 FileManager.prototype.deleteSelection = function(entries) {
2637 if (!force) { 2649 /* if (!force) {
Vladislav Kaznacheev 2012/09/04 14:50:38 Commented code
dgozman 2012/09/07 11:05:10 Done.
2638 var self = this; 2650 var self = this;
2639 var msg; 2651 var msg;
2640 if (entries.length == 1) { 2652 if (entries.length == 1) {
2641 msg = strf('CONFIRM_DELETE_ONE', entries[0].name); 2653 msg = strf('CONFIRM_DELETE_ONE', entries[0].name);
2642 } else { 2654 } else {
2643 msg = strf('CONFIRM_DELETE_SOME', entries.length); 2655 msg = strf('CONFIRM_DELETE_SOME', entries.length);
2644 } 2656 }
2645 2657
2646 this.confirm.show(msg, this.deleteEntries.bind( 2658 this.confirm.show(msg, this.deleteEntries.bind(
2647 this, entries, true, opt_callback)); 2659 this, entries, true, opt_callback));
2648 return; 2660 return;
2649 } 2661 }
2662 this.directoryModel_.deleteEntries(entries);*/
2650 2663
2651 this.directoryModel_.deleteEntries(entries, opt_callback); 2664 this.butterBar_.initiateDelete(this.selection.entries);
2652 }; 2665 };
2653 2666
2654 FileManager.prototype.onDeleteButtonClick_ = function(event) { 2667 FileManager.prototype.onDeleteButtonClick_ = function(event) {
2655 this.deleteEntries(this.selection.entries); 2668 this.deleteSelection();
2656 event.preventDefault(); 2669 event.preventDefault();
2657 event.stopPropagation(); 2670 event.stopPropagation();
2658 }; 2671 };
2659 2672
2660 FileManager.prototype.onDeleteButtonKeyPress_ = function(event) { 2673 FileManager.prototype.onDeleteButtonKeyPress_ = function(event) {
2661 switch (util.getKeyModifiers(event) + event.keyCode) { 2674 switch (util.getKeyModifiers(event) + event.keyCode) {
2662 case '13': // Enter 2675 case '13': // Enter
2663 case '32': // Space 2676 case '32': // Space
2664 this.deleteEntries(this.selection.entries); 2677 this.deleteSelection();
2665 event.preventDefault(); 2678 event.preventDefault();
2666 event.stopPropagation(); 2679 event.stopPropagation();
2667 break; 2680 break;
2668 } 2681 }
2669 }; 2682 };
2670 2683
2671 FileManager.prototype.blinkSelection = function() { 2684 FileManager.prototype.blinkSelection = function() {
2672 if (!this.selection || this.selection.totalCount == 0) 2685 if (!this.selection || this.selection.totalCount == 0)
2673 return; 2686 return;
2674 2687
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
4227 this.dialogDom_.querySelector('#default-action-separator'); 4240 this.dialogDom_.querySelector('#default-action-separator');
4228 4241
4229 // TODO(dzvorygin): Here we use this hack, since 'hidden' is standard 4242 // TODO(dzvorygin): Here we use this hack, since 'hidden' is standard
4230 // attribute and we can't use it's setter as usual. 4243 // attribute and we can't use it's setter as usual.
4231 this.openWithCommand_.__lookupSetter__('hidden'). 4244 this.openWithCommand_.__lookupSetter__('hidden').
4232 call(this.openWithCommand_, !(defaultItem && isMultiple)); 4245 call(this.openWithCommand_, !(defaultItem && isMultiple));
4233 this.defaultActionMenuItem_.hidden = !defaultItem; 4246 this.defaultActionMenuItem_.hidden = !defaultItem;
4234 defaultActionSeparator.hidden = !defaultItem; 4247 defaultActionSeparator.hidden = !defaultItem;
4235 }; 4248 };
4236 })(); 4249 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698