OLD | NEW |
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 // This variable is checked in SelectFileDialogExtensionBrowserTest. | 5 // This variable is checked in SelectFileDialogExtensionBrowserTest. |
6 var JSErrorCount = 0; | 6 var JSErrorCount = 0; |
7 | 7 |
8 /** | 8 /** |
9 * Count uncaught exceptions. | 9 * Count uncaught exceptions. |
10 */ | 10 */ |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 cr.ui.contextMenuHandler.setContextMenu(this.table_.querySelector('.list'), | 529 cr.ui.contextMenuHandler.setContextMenu(this.table_.querySelector('.list'), |
530 this.fileContextMenu_); | 530 this.fileContextMenu_); |
531 cr.ui.contextMenuHandler.setContextMenu( | 531 cr.ui.contextMenuHandler.setContextMenu( |
532 this.document_.querySelector('.drive-welcome.page'), | 532 this.document_.querySelector('.drive-welcome.page'), |
533 this.fileContextMenu_); | 533 this.fileContextMenu_); |
534 | 534 |
535 this.rootsContextMenu_ = | 535 this.rootsContextMenu_ = |
536 this.dialogDom_.querySelector('#roots-context-menu'); | 536 this.dialogDom_.querySelector('#roots-context-menu'); |
537 cr.ui.Menu.decorate(this.rootsContextMenu_); | 537 cr.ui.Menu.decorate(this.rootsContextMenu_); |
538 | 538 |
539 this.downloadsRootContextMenu_ = | |
540 this.dialogDom_.querySelector('#downloads-root-context-menu'); | |
541 cr.ui.Menu.decorate(this.downloadsRootContextMenu_); | |
542 | |
543 this.textContextMenu_ = | 539 this.textContextMenu_ = |
544 this.dialogDom_.querySelector('#text-context-menu'); | 540 this.dialogDom_.querySelector('#text-context-menu'); |
545 cr.ui.Menu.decorate(this.textContextMenu_); | 541 cr.ui.Menu.decorate(this.textContextMenu_); |
546 | 542 |
547 this.gearButton_ = this.dialogDom_.querySelector('#gear-button'); | 543 this.gearButton_ = this.dialogDom_.querySelector('#gear-button'); |
548 this.gearButton_.addEventListener('menushow', | 544 this.gearButton_.addEventListener('menushow', |
549 this.refreshRemainingSpace_.bind(this, | 545 this.refreshRemainingSpace_.bind(this, |
550 false /* Without loading caption. */)); | 546 false /* Without loading caption. */)); |
551 cr.ui.decorate(this.gearButton_, cr.ui.MenuButton); | 547 cr.ui.decorate(this.gearButton_, cr.ui.MenuButton); |
552 | 548 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 | 596 |
601 CommandUtil.registerCommand(doc, 'drive-clear-local-cache', | 597 CommandUtil.registerCommand(doc, 'drive-clear-local-cache', |
602 Commands.driveClearCacheCommand, this); | 598 Commands.driveClearCacheCommand, this); |
603 | 599 |
604 CommandUtil.registerCommand(doc, 'drive-reload', | 600 CommandUtil.registerCommand(doc, 'drive-reload', |
605 Commands.driveReloadCommand, this); | 601 Commands.driveReloadCommand, this); |
606 | 602 |
607 CommandUtil.registerCommand(doc, 'drive-go-to-drive', | 603 CommandUtil.registerCommand(doc, 'drive-go-to-drive', |
608 Commands.driveGoToDriveCommand, this); | 604 Commands.driveGoToDriveCommand, this); |
609 | 605 |
610 CommandUtil.registerCommand(doc, 'files-app-help', | |
611 Commands.filesAppHelpCommand, this); | |
612 | |
613 CommandUtil.registerCommand(doc, 'paste', | 606 CommandUtil.registerCommand(doc, 'paste', |
614 Commands.pasteFileCommand, doc, this.fileTransferController_); | 607 Commands.pasteFileCommand, doc, this.fileTransferController_); |
615 | 608 |
616 CommandUtil.registerCommand(doc, 'open-with', | 609 CommandUtil.registerCommand(doc, 'open-with', |
617 Commands.openWithCommand, this); | 610 Commands.openWithCommand, this); |
618 | 611 |
619 CommandUtil.registerCommand(doc, 'toggle-pinned', | 612 CommandUtil.registerCommand(doc, 'toggle-pinned', |
620 Commands.togglePinnedCommand, this); | 613 Commands.togglePinnedCommand, this); |
621 | 614 |
622 CommandUtil.registerCommand(doc, 'zip-selection', | 615 CommandUtil.registerCommand(doc, 'zip-selection', |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 // the root before executing it. | 1433 // the root before executing it. |
1441 unmountCommand.canExecuteChange(li); | 1434 unmountCommand.canExecuteChange(li); |
1442 unmountCommand.execute(li); | 1435 unmountCommand.execute(li); |
1443 }.bind(this)); | 1436 }.bind(this)); |
1444 // Block other mouse handlers. | 1437 // Block other mouse handlers. |
1445 eject.addEventListener('mouseup', function(e) { e.stopPropagation() }); | 1438 eject.addEventListener('mouseup', function(e) { e.stopPropagation() }); |
1446 eject.addEventListener('mousedown', function(e) { e.stopPropagation() }); | 1439 eject.addEventListener('mousedown', function(e) { e.stopPropagation() }); |
1447 li.appendChild(eject); | 1440 li.appendChild(eject); |
1448 } | 1441 } |
1449 | 1442 |
1450 // Add a context menu for the root. "Downloads" has a menu item showing the | 1443 if (rootType != RootType.DRIVE && rootType != RootType.DOWNLOADS) |
1451 // remaining space information. | |
1452 if (rootType == RootType.DOWNLOADS) { | |
1453 cr.ui.contextMenuHandler.setContextMenu(li, | |
1454 this.downloadsRootContextMenu_); | |
1455 | |
1456 var downloadsRootContextMenu = this.downloadsRootContextMenu_; | |
1457 var downloadsSpaceInfoLabel = | |
1458 this.dialogDom_.querySelector('#downloads-space-info-label'); | |
1459 | |
1460 var downloadsSpaceInnerBar = | |
1461 this.dialogDom_.querySelector('#downloads-space-info-bar'); | |
1462 var downloadsSpaceOuterBar = | |
1463 this.dialogDom_.querySelector('#downloads-space-info-bar'). | |
1464 parentNode; | |
1465 | |
1466 if (this.downloadsRootContextMenuListener_) { | |
1467 cr.ui.contextMenuHandler.removeEventListener( | |
1468 'show', this.downloadsRootContextMenuListener_); | |
1469 } | |
1470 this.downloadsRootContextMenuListener_ = function(ev) { | |
1471 // Check available space on opening the context menu for Downloads. | |
1472 if (ev.element != li || ev.menu != downloadsRootContextMenu) | |
1473 return; | |
1474 | |
1475 downloadsSpaceInnerBar.setAttribute('pending', ''); | |
1476 spaceInfoLabel.textContent = strf('SPACE_AVAILABLE', sizeStr); | |
1477 | |
1478 chrome.fileBrowserPrivate.getSizeStats( | |
1479 util.makeFilesystemUrl(path), | |
1480 function(sizeStats) { | |
1481 updateSpaceInfo(sizeStats, downloadsSpaceInnerBar, | |
1482 downloadsSpaceInfoLabel, downloadsSpaceOuterBar); | |
1483 }); | |
1484 }; | |
1485 | |
1486 cr.ui.contextMenuHandler.addEventListener( | |
1487 'show', this.downloadsRootContextMenuListener_); | |
1488 } else if (rootType != RootType.DRIVE) { | |
1489 cr.ui.contextMenuHandler.setContextMenu(li, this.rootsContextMenu_); | 1444 cr.ui.contextMenuHandler.setContextMenu(li, this.rootsContextMenu_); |
1490 } | |
1491 | 1445 |
1492 cr.defineProperty(li, 'lead', cr.PropertyKind.BOOL_ATTR); | 1446 cr.defineProperty(li, 'lead', cr.PropertyKind.BOOL_ATTR); |
1493 cr.defineProperty(li, 'selected', cr.PropertyKind.BOOL_ATTR); | 1447 cr.defineProperty(li, 'selected', cr.PropertyKind.BOOL_ATTR); |
1494 | 1448 |
1495 return li; | 1449 return li; |
1496 }; | 1450 }; |
1497 | 1451 |
1498 /** | 1452 /** |
1499 * Unmounts device. | 1453 * Unmounts device. |
1500 * @param {string} path Path to a volume to unmount. | 1454 * @param {string} path Path to a volume to unmount. |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2982 return this.directoryModel_.getFileList(); | 2936 return this.directoryModel_.getFileList(); |
2983 }; | 2937 }; |
2984 | 2938 |
2985 /** | 2939 /** |
2986 * @return {cr.ui.List} Current list object. | 2940 * @return {cr.ui.List} Current list object. |
2987 */ | 2941 */ |
2988 FileManager.prototype.getCurrentList = function() { | 2942 FileManager.prototype.getCurrentList = function() { |
2989 return this.currentList_; | 2943 return this.currentList_; |
2990 }; | 2944 }; |
2991 })(); | 2945 })(); |
OLD | NEW |