Chromium Code Reviews| 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 /** | 5 /** |
| 6 * TODO(dzvorygin): Here we use this hack, since 'hidden' is standard | 6 * TODO(dzvorygin): Here we use this hack, since 'hidden' is standard |
| 7 * attribute and we can't use it's setter as usual. | 7 * attribute and we can't use it's setter as usual. |
| 8 * @param {boolean} value New value of hidden property. | 8 * @param {boolean} value New value of hidden property. |
| 9 */ | 9 */ |
| 10 cr.ui.Command.prototype.setHidden = function(value) { | 10 cr.ui.Command.prototype.setHidden = function(value) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 if (event.command.id === commandId) | 174 if (event.command.id === commandId) |
| 175 event.canExecute = document.queryCommandEnabled(event.command.id); | 175 event.canExecute = document.queryCommandEnabled(event.command.id); |
| 176 }); | 176 }); |
| 177 }; | 177 }; |
| 178 | 178 |
| 179 /** | 179 /** |
| 180 * Default command. | 180 * Default command. |
| 181 * @type {Command} | 181 * @type {Command} |
| 182 */ | 182 */ |
| 183 CommandUtil.defaultCommand = /** @type {Command} */ ({ | 183 CommandUtil.defaultCommand = /** @type {Command} */ ({ |
| 184 /** | |
| 185 * @param {Event} event Command event. | |
|
fukino
2014/10/31 07:04:21
Could you make these parameter type non-nullable?
hirono
2014/10/31 07:47:29
Done.
| |
| 186 * @param {FileManager} fileManager FileManager to use. | |
| 187 */ | |
| 184 execute: function(event, fileManager) { | 188 execute: function(event, fileManager) { |
| 185 fileManager.document.execCommand(event.command.id); | 189 fileManager.document.execCommand(event.command.id); |
| 186 }, | 190 }, |
| 191 /** | |
| 192 * @param {Event} event Command event. | |
| 193 * @param {FileManager} fileManager FileManager to use. | |
| 194 */ | |
| 187 canExecute: function(event, fileManager) { | 195 canExecute: function(event, fileManager) { |
| 188 event.canExecute = fileManager.document.queryCommandEnabled( | 196 event.canExecute = fileManager.document.queryCommandEnabled( |
| 189 event.command.id); | 197 event.command.id); |
| 190 } | 198 } |
| 191 }); | 199 }); |
| 192 | 200 |
| 193 /** | 201 /** |
| 194 * Creates the volume switch command with index. | 202 * Creates the volume switch command with index. |
| 195 * @param {number} index Volume index from 1 to 9. | 203 * @param {number} index Volume index from 1 to 9. |
| 196 * @return {Command} Volume switch command. | 204 * @return {Command} Volume switch command. |
| 197 */ | 205 */ |
| 198 CommandUtil.createVolumeSwitchCommand = function(index) { | 206 CommandUtil.createVolumeSwitchCommand = function(index) { |
| 199 return /** @type {Command} */ ({ | 207 return /** @type {Command} */ ({ |
| 208 /** | |
| 209 * @param {Event} event Command event. | |
| 210 * @param {FileManager} fileManager FileManager to use. | |
| 211 */ | |
| 200 execute: function(event, fileManager) { | 212 execute: function(event, fileManager) { |
| 201 fileManager.directoryTree.selectByIndex(index - 1); | 213 fileManager.directoryTree.selectByIndex(index - 1); |
| 202 }, | 214 }, |
| 215 /** | |
| 216 * @param {Event} event Command event. | |
| 217 * @param {FileManager} fileManager FileManager to use. | |
| 218 */ | |
| 203 canExecute: function(event, fileManager) { | 219 canExecute: function(event, fileManager) { |
| 204 event.canExecute = index > 0 && | 220 event.canExecute = index > 0 && |
| 205 index <= fileManager.directoryTree.items.length; | 221 index <= fileManager.directoryTree.items.length; |
| 206 } | 222 } |
| 207 }); | 223 }); |
| 208 }; | 224 }; |
| 209 | 225 |
| 210 /** | 226 /** |
| 211 * Returns a directory entry when only one entry is selected and it is | 227 * Returns a directory entry when only one entry is selected and it is |
| 212 * directory. Otherwise, returns null. | 228 * directory. Otherwise, returns null. |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 event.canExecute = removable && !isReadOnly; | 434 event.canExecute = removable && !isReadOnly; |
| 419 event.command.setHidden(!removable); | 435 event.command.setHidden(!removable); |
| 420 } | 436 } |
| 421 }); | 437 }); |
| 422 | 438 |
| 423 /** | 439 /** |
| 424 * Initiates new folder creation. | 440 * Initiates new folder creation. |
| 425 * @type {Command} | 441 * @type {Command} |
| 426 */ | 442 */ |
| 427 CommandHandler.COMMANDS_['new-folder'] = /** @type {Command} */ ({ | 443 CommandHandler.COMMANDS_['new-folder'] = /** @type {Command} */ ({ |
| 444 /** | |
| 445 * @param {Event} event Command event. | |
| 446 * @param {FileManager} fileManager FileManager to use. | |
| 447 */ | |
| 428 execute: function(event, fileManager) { | 448 execute: function(event, fileManager) { |
| 429 fileManager.createNewFolder(); | 449 fileManager.createNewFolder(); |
| 430 }, | 450 }, |
| 451 /** | |
| 452 * @param {Event} event Command event. | |
| 453 * @param {FileManager} fileManager FileManager to use. | |
| 454 */ | |
| 431 canExecute: function(event, fileManager) { | 455 canExecute: function(event, fileManager) { |
| 432 var directoryModel = fileManager.directoryModel; | 456 var directoryModel = fileManager.directoryModel; |
| 433 event.canExecute = !fileManager.isOnReadonlyDirectory() && | 457 event.canExecute = !fileManager.isOnReadonlyDirectory() && |
| 434 !fileManager.isRenamingInProgress() && | 458 !fileManager.isRenamingInProgress() && |
| 435 !directoryModel.isSearching() && | 459 !directoryModel.isSearching() && |
| 436 !directoryModel.isScanning(); | 460 !directoryModel.isScanning(); |
| 437 } | 461 } |
| 438 }); | 462 }); |
| 439 | 463 |
| 440 /** | 464 /** |
| 441 * Initiates new window creation. | 465 * Initiates new window creation. |
| 442 * @type {Command} | 466 * @type {Command} |
| 443 */ | 467 */ |
| 444 CommandHandler.COMMANDS_['new-window'] = /** @type {Command} */ ({ | 468 CommandHandler.COMMANDS_['new-window'] = /** @type {Command} */ ({ |
| 469 /** | |
| 470 * @param {Event} event Command event. | |
| 471 * @param {FileManager} fileManager FileManager to use. | |
| 472 */ | |
| 445 execute: function(event, fileManager) { | 473 execute: function(event, fileManager) { |
| 446 chrome.fileManagerPrivate.getProfiles( | 474 chrome.fileManagerPrivate.getProfiles( |
| 447 function(profiles, currentId, displayedId) { | 475 function(profiles, currentId, displayedId) { |
| 448 fileManager.backgroundPage.launchFileManager({ | 476 fileManager.backgroundPage.launchFileManager({ |
| 449 currentDirectoryURL: fileManager.getCurrentDirectoryEntry() && | 477 currentDirectoryURL: fileManager.getCurrentDirectoryEntry() && |
| 450 fileManager.getCurrentDirectoryEntry().toURL(), | 478 fileManager.getCurrentDirectoryEntry().toURL(), |
| 451 displayedId: currentId !== displayedId ? displayedId : undefined | 479 displayedId: currentId !== displayedId ? displayedId : undefined |
| 452 }); | 480 }); |
| 453 }); | 481 }); |
| 454 }, | 482 }, |
| 483 /** | |
| 484 * @param {Event} event Command event. | |
| 485 * @param {FileManager} fileManager FileManager to use. | |
| 486 */ | |
| 455 canExecute: function(event, fileManager) { | 487 canExecute: function(event, fileManager) { |
| 456 event.canExecute = | 488 event.canExecute = |
| 457 fileManager.getCurrentDirectoryEntry() && | 489 fileManager.getCurrentDirectoryEntry() && |
| 458 (fileManager.dialogType === DialogType.FULL_PAGE); | 490 (fileManager.dialogType === DialogType.FULL_PAGE); |
| 459 } | 491 } |
| 460 }); | 492 }); |
| 461 | 493 |
| 462 /** | 494 /** |
| 463 * Toggles drive sync settings. | 495 * Toggles drive sync settings. |
| 464 * @type {Command} | 496 * @type {Command} |
| 465 */ | 497 */ |
| 466 CommandHandler.COMMANDS_['drive-sync-settings'] = /** @type {Command} */ ({ | 498 CommandHandler.COMMANDS_['drive-sync-settings'] = /** @type {Command} */ ({ |
| 499 /** | |
| 500 * @param {Event} event Command event. | |
| 501 * @param {FileManager} fileManager FileManager to use. | |
| 502 */ | |
| 467 execute: function(event, fileManager) { | 503 execute: function(event, fileManager) { |
| 468 fileManager.toggleDriveSyncSettings(); | 504 fileManager.toggleDriveSyncSettings(); |
| 469 }, | 505 }, |
| 506 /** | |
| 507 * @param {Event} event Command event. | |
| 508 * @param {FileManager} fileManager FileManager to use. | |
| 509 */ | |
| 470 canExecute: function(event, fileManager) { | 510 canExecute: function(event, fileManager) { |
| 471 event.canExecute = fileManager.shouldShowDriveSettings(); | 511 event.canExecute = fileManager.shouldShowDriveSettings(); |
| 472 event.command.setHidden(!event.canExecute); | 512 event.command.setHidden(!event.canExecute); |
| 473 } | 513 } |
| 474 }); | 514 }); |
| 475 | 515 |
| 476 /** | 516 /** |
| 477 * Toggles drive hosted settings. | 517 * Toggles drive hosted settings. |
| 478 * @type {Command} | 518 * @type {Command} |
| 479 */ | 519 */ |
| 480 CommandHandler.COMMANDS_['drive-hosted-settings'] = /** @type {Command} */ ({ | 520 CommandHandler.COMMANDS_['drive-hosted-settings'] = /** @type {Command} */ ({ |
| 521 /** | |
| 522 * @param {Event} event Command event. | |
| 523 * @param {FileManager} fileManager FileManager to use. | |
| 524 */ | |
| 481 execute: function(event, fileManager) { | 525 execute: function(event, fileManager) { |
| 482 fileManager.toggleDriveHostedSettings(); | 526 fileManager.toggleDriveHostedSettings(); |
| 483 }, | 527 }, |
| 528 /** | |
| 529 * @param {Event} event Command event. | |
| 530 * @param {FileManager} fileManager FileManager to use. | |
| 531 */ | |
| 484 canExecute: function(event, fileManager) { | 532 canExecute: function(event, fileManager) { |
| 485 event.canExecute = fileManager.shouldShowDriveSettings(); | 533 event.canExecute = fileManager.shouldShowDriveSettings(); |
| 486 event.command.setHidden(!event.canExecute); | 534 event.command.setHidden(!event.canExecute); |
| 487 } | 535 } |
| 488 }); | 536 }); |
| 489 | 537 |
| 490 /** | 538 /** |
| 491 * Deletes selected files. | 539 * Deletes selected files. |
| 492 * @type {Command} | 540 * @type {Command} |
| 493 */ | 541 */ |
| 494 CommandHandler.COMMANDS_['delete'] = /** @type {Command} */ ({ | 542 CommandHandler.COMMANDS_['delete'] = /** @type {Command} */ ({ |
| 543 /** | |
| 544 * @param {Event} event Command event. | |
| 545 * @param {FileManager} fileManager FileManager to use. | |
| 546 */ | |
| 495 execute: function(event, fileManager) { | 547 execute: function(event, fileManager) { |
| 496 var entries = fileManager.getSelection().entries; | 548 var entries = fileManager.getSelection().entries; |
| 497 var message = entries.length == 1 ? | 549 var message = entries.length == 1 ? |
| 498 strf('GALLERY_CONFIRM_DELETE_ONE', entries[0].name) : | 550 strf('GALLERY_CONFIRM_DELETE_ONE', entries[0].name) : |
| 499 strf('GALLERY_CONFIRM_DELETE_SOME', entries.length); | 551 strf('GALLERY_CONFIRM_DELETE_SOME', entries.length); |
| 500 fileManager.ui.deleteConfirmDialog.show(message, function() { | 552 fileManager.ui.deleteConfirmDialog.show(message, function() { |
| 501 fileManager.fileOperationManager.deleteEntries(entries); | 553 fileManager.fileOperationManager.deleteEntries(entries); |
| 502 }); | 554 }); |
| 503 }, | 555 }, |
| 556 /** | |
| 557 * @param {Event} event Command event. | |
| 558 * @param {FileManager} fileManager FileManager to use. | |
| 559 */ | |
| 504 canExecute: function(event, fileManager) { | 560 canExecute: function(event, fileManager) { |
| 505 var selection = fileManager.getSelection(); | 561 var selection = fileManager.getSelection(); |
| 506 event.canExecute = !fileManager.isOnReadonlyDirectory() && | 562 event.canExecute = !fileManager.isOnReadonlyDirectory() && |
| 507 selection && | 563 selection && |
| 508 selection.totalCount > 0; | 564 selection.totalCount > 0; |
| 509 } | 565 } |
| 510 }); | 566 }); |
| 511 | 567 |
| 512 /** | 568 /** |
| 513 * Pastes files from clipboard. | 569 * Pastes files from clipboard. |
| 514 * @type {Command} | 570 * @type {Command} |
| 515 */ | 571 */ |
| 516 CommandHandler.COMMANDS_['paste'] = /** @type {Command} */ ({ | 572 CommandHandler.COMMANDS_['paste'] = /** @type {Command} */ ({ |
| 573 /** | |
| 574 * @param {Event} event Command event. | |
| 575 * @param {FileManager} fileManager FileManager to use. | |
| 576 */ | |
| 517 execute: function(event, fileManager) { | 577 execute: function(event, fileManager) { |
| 518 fileManager.document.execCommand(event.command.id); | 578 fileManager.document.execCommand(event.command.id); |
| 519 }, | 579 }, |
| 580 /** | |
| 581 * @param {Event} event Command event. | |
| 582 * @param {FileManager} fileManager FileManager to use. | |
| 583 */ | |
| 520 canExecute: function(event, fileManager) { | 584 canExecute: function(event, fileManager) { |
| 521 var fileTransferController = fileManager.fileTransferController; | 585 var fileTransferController = fileManager.fileTransferController; |
| 522 event.canExecute = (fileTransferController && | 586 event.canExecute = (fileTransferController && |
| 523 fileTransferController.queryPasteCommandEnabled()); | 587 fileTransferController.queryPasteCommandEnabled()); |
| 524 // Hide this command if only one folder is selected. | 588 // Hide this command if only one folder is selected. |
| 525 event.command.setHidden(!!CommandUtil.getOnlyOneSelectedDirectory( | 589 event.command.setHidden(!!CommandUtil.getOnlyOneSelectedDirectory( |
| 526 fileManager.getSelection())); | 590 fileManager.getSelection())); |
| 527 } | 591 } |
| 528 }); | 592 }); |
| 529 | 593 |
| 530 /** | 594 /** |
| 531 * Pastes files from clipboard into the selected folder. | 595 * Pastes files from clipboard into the selected folder. |
| 532 * @type {Command} | 596 * @type {Command} |
| 533 */ | 597 */ |
| 534 CommandHandler.COMMANDS_['paste-into-folder'] = /** @type {Command} */ ({ | 598 CommandHandler.COMMANDS_['paste-into-folder'] = /** @type {Command} */ ({ |
| 599 /** | |
| 600 * @param {Event} event Command event. | |
| 601 * @param {FileManager} fileManager FileManager to use. | |
| 602 */ | |
| 535 execute: function(event, fileManager) { | 603 execute: function(event, fileManager) { |
| 536 var selection = fileManager.getSelection(); | 604 var selection = fileManager.getSelection(); |
| 537 var dest = CommandUtil.getOnlyOneSelectedDirectory(selection); | 605 var dest = CommandUtil.getOnlyOneSelectedDirectory(selection); |
| 538 if (!dest) return; | 606 if (!dest) return; |
| 539 | 607 |
| 540 // This handler tweaks the Event object for 'paste' event so that | 608 // This handler tweaks the Event object for 'paste' event so that |
| 541 // the FileTransferController can distinguish this 'paste-into-folder' | 609 // the FileTransferController can distinguish this 'paste-into-folder' |
| 542 // command and know the destination directory. | 610 // command and know the destination directory. |
| 543 var handler = function(inEvent) { | 611 var handler = function(inEvent) { |
| 544 inEvent.destDirectory = dest; | 612 inEvent.destDirectory = dest; |
| 545 }; | 613 }; |
| 546 fileManager.document.addEventListener('paste', handler, true); | 614 fileManager.document.addEventListener('paste', handler, true); |
| 547 fileManager.document.execCommand('paste'); | 615 fileManager.document.execCommand('paste'); |
| 548 fileManager.document.removeEventListener('paste', handler, true); | 616 fileManager.document.removeEventListener('paste', handler, true); |
| 549 }, | 617 }, |
| 618 /** | |
| 619 * @param {Event} event Command event. | |
| 620 * @param {FileManager} fileManager FileManager to use. | |
| 621 */ | |
| 550 canExecute: function(event, fileManager) { | 622 canExecute: function(event, fileManager) { |
| 551 var fileTransferController = fileManager.fileTransferController; | 623 var fileTransferController = fileManager.fileTransferController; |
| 552 event.canExecute = (fileTransferController && | 624 event.canExecute = (fileTransferController && |
| 553 fileTransferController.queryPasteCommandEnabled()); | 625 fileTransferController.queryPasteCommandEnabled()); |
| 554 // Hide this command unless only one folder is selected. | 626 // Hide this command unless only one folder is selected. |
| 555 event.command.setHidden(!CommandUtil.getOnlyOneSelectedDirectory( | 627 event.command.setHidden(!CommandUtil.getOnlyOneSelectedDirectory( |
| 556 fileManager.getSelection())); | 628 fileManager.getSelection())); |
| 557 } | 629 } |
| 558 }); | 630 }); |
| 559 | 631 |
| 560 CommandHandler.COMMANDS_['cut'] = CommandUtil.defaultCommand; | 632 CommandHandler.COMMANDS_['cut'] = CommandUtil.defaultCommand; |
| 561 CommandHandler.COMMANDS_['copy'] = CommandUtil.defaultCommand; | 633 CommandHandler.COMMANDS_['copy'] = CommandUtil.defaultCommand; |
| 562 | 634 |
| 563 /** | 635 /** |
| 564 * Initiates file renaming. | 636 * Initiates file renaming. |
| 565 * @type {Command} | 637 * @type {Command} |
| 566 */ | 638 */ |
| 567 CommandHandler.COMMANDS_['rename'] = /** @type {Command} */ ({ | 639 CommandHandler.COMMANDS_['rename'] = /** @type {Command} */ ({ |
| 640 /** | |
| 641 * @param {Event} event Command event. | |
| 642 * @param {FileManager} fileManager FileManager to use. | |
| 643 */ | |
| 568 execute: function(event, fileManager) { | 644 execute: function(event, fileManager) { |
| 569 fileManager.initiateRename(); | 645 fileManager.initiateRename(); |
| 570 }, | 646 }, |
| 647 /** | |
| 648 * @param {Event} event Command event. | |
| 649 * @param {FileManager} fileManager FileManager to use. | |
| 650 */ | |
| 571 canExecute: function(event, fileManager) { | 651 canExecute: function(event, fileManager) { |
| 572 var selection = fileManager.getSelection(); | 652 var selection = fileManager.getSelection(); |
| 573 event.canExecute = !fileManager.isRenamingInProgress() && | 653 event.canExecute = !fileManager.isRenamingInProgress() && |
| 574 !fileManager.isOnReadonlyDirectory() && | 654 !fileManager.isOnReadonlyDirectory() && |
| 575 selection && | 655 selection && |
| 576 selection.totalCount == 1; | 656 selection.totalCount == 1; |
| 577 } | 657 } |
| 578 }); | 658 }); |
| 579 | 659 |
| 580 /** | 660 /** |
| 581 * Opens drive help. | 661 * Opens drive help. |
| 582 * @type {Command} | 662 * @type {Command} |
| 583 */ | 663 */ |
| 584 CommandHandler.COMMANDS_['volume-help'] = /** @type {Command} */ ({ | 664 CommandHandler.COMMANDS_['volume-help'] = /** @type {Command} */ ({ |
| 665 /** | |
| 666 * @param {Event} event Command event. | |
| 667 * @param {FileManager} fileManager FileManager to use. | |
| 668 */ | |
| 585 execute: function(event, fileManager) { | 669 execute: function(event, fileManager) { |
| 586 if (fileManager.isOnDrive()) | 670 if (fileManager.isOnDrive()) |
| 587 util.visitURL(str('GOOGLE_DRIVE_HELP_URL')); | 671 util.visitURL(str('GOOGLE_DRIVE_HELP_URL')); |
| 588 else | 672 else |
| 589 util.visitURL(str('FILES_APP_HELP_URL')); | 673 util.visitURL(str('FILES_APP_HELP_URL')); |
| 590 }, | 674 }, |
| 675 /** | |
| 676 * @param {Event} event Command event. | |
| 677 * @param {FileManager} fileManager FileManager to use. | |
| 678 */ | |
| 591 canExecute: function(event, fileManager) { | 679 canExecute: function(event, fileManager) { |
| 592 // Hides the help menu in modal dialog mode. It does not make much sense | 680 // Hides the help menu in modal dialog mode. It does not make much sense |
| 593 // because after all, users cannot view the help without closing, and | 681 // because after all, users cannot view the help without closing, and |
| 594 // besides that the help page is about Files.app as an app, not about the | 682 // besides that the help page is about Files.app as an app, not about the |
| 595 // dialog mode itself. It can also lead to hard-to-fix bug crbug.com/339089. | 683 // dialog mode itself. It can also lead to hard-to-fix bug crbug.com/339089. |
| 596 var hideHelp = DialogType.isModal(fileManager.dialogType); | 684 var hideHelp = DialogType.isModal(fileManager.dialogType); |
| 597 event.canExecute = !hideHelp; | 685 event.canExecute = !hideHelp; |
| 598 event.command.setHidden(hideHelp); | 686 event.command.setHidden(hideHelp); |
| 599 fileManager.document_.getElementById('help-separator').hidden = hideHelp; | 687 fileManager.document_.getElementById('help-separator').hidden = hideHelp; |
| 600 } | 688 } |
| 601 }); | 689 }); |
| 602 | 690 |
| 603 /** | 691 /** |
| 604 * Opens drive buy-more-space url. | 692 * Opens drive buy-more-space url. |
| 605 * @type {Command} | 693 * @type {Command} |
| 606 */ | 694 */ |
| 607 CommandHandler.COMMANDS_['drive-buy-more-space'] = /** @type {Command} */ ({ | 695 CommandHandler.COMMANDS_['drive-buy-more-space'] = /** @type {Command} */ ({ |
| 696 /** | |
| 697 * @param {Event} event Command event. | |
| 698 * @param {FileManager} fileManager FileManager to use. | |
| 699 */ | |
| 608 execute: function(event, fileManager) { | 700 execute: function(event, fileManager) { |
| 609 util.visitURL(str('GOOGLE_DRIVE_BUY_STORAGE_URL')); | 701 util.visitURL(str('GOOGLE_DRIVE_BUY_STORAGE_URL')); |
| 610 }, | 702 }, |
| 611 canExecute: CommandUtil.canExecuteVisibleOnDriveInNormalAppModeOnly | 703 canExecute: CommandUtil.canExecuteVisibleOnDriveInNormalAppModeOnly |
| 612 }); | 704 }); |
| 613 | 705 |
| 614 /** | 706 /** |
| 615 * Opens drive.google.com. | 707 * Opens drive.google.com. |
| 616 * @type {Command} | 708 * @type {Command} |
| 617 */ | 709 */ |
| 618 CommandHandler.COMMANDS_['drive-go-to-drive'] = /** @type {Command} */ ({ | 710 CommandHandler.COMMANDS_['drive-go-to-drive'] = /** @type {Command} */ ({ |
| 711 /** | |
| 712 * @param {Event} event Command event. | |
| 713 * @param {FileManager} fileManager FileManager to use. | |
| 714 */ | |
| 619 execute: function(event, fileManager) { | 715 execute: function(event, fileManager) { |
| 620 util.visitURL(str('GOOGLE_DRIVE_ROOT_URL')); | 716 util.visitURL(str('GOOGLE_DRIVE_ROOT_URL')); |
| 621 }, | 717 }, |
| 622 canExecute: CommandUtil.canExecuteVisibleOnDriveInNormalAppModeOnly | 718 canExecute: CommandUtil.canExecuteVisibleOnDriveInNormalAppModeOnly |
| 623 }); | 719 }); |
| 624 | 720 |
| 625 /** | 721 /** |
| 626 * Displays open with dialog for current selection. | 722 * Displays open with dialog for current selection. |
| 627 * @type {Command} | 723 * @type {Command} |
| 628 */ | 724 */ |
| 629 CommandHandler.COMMANDS_['open-with'] = /** @type {Command} */ ({ | 725 CommandHandler.COMMANDS_['open-with'] = /** @type {Command} */ ({ |
| 726 /** | |
| 727 * @param {Event} event Command event. | |
| 728 * @param {FileManager} fileManager FileManager to use. | |
| 729 */ | |
| 630 execute: function(event, fileManager) { | 730 execute: function(event, fileManager) { |
| 631 var tasks = fileManager.getSelection().tasks; | 731 var tasks = fileManager.getSelection().tasks; |
| 632 if (tasks) { | 732 if (tasks) { |
| 633 tasks.showTaskPicker(fileManager.defaultTaskPicker, | 733 tasks.showTaskPicker(fileManager.defaultTaskPicker, |
| 634 str('OPEN_WITH_BUTTON_LABEL'), | 734 str('OPEN_WITH_BUTTON_LABEL'), |
| 635 '', | 735 '', |
| 636 function(task) { | 736 function(task) { |
| 637 tasks.execute(task.taskId); | 737 tasks.execute(task.taskId); |
| 638 }); | 738 }); |
| 639 } | 739 } |
| 640 }, | 740 }, |
| 741 /** | |
| 742 * @param {Event} event Command event. | |
| 743 * @param {FileManager} fileManager FileManager to use. | |
| 744 */ | |
| 641 canExecute: function(event, fileManager) { | 745 canExecute: function(event, fileManager) { |
| 642 var tasks = fileManager.getSelection().tasks; | 746 var tasks = fileManager.getSelection().tasks; |
| 643 event.canExecute = tasks && tasks.size() > 1; | 747 event.canExecute = tasks && tasks.size() > 1; |
| 644 } | 748 } |
| 645 }); | 749 }); |
| 646 | 750 |
| 647 /** | 751 /** |
| 648 * Focuses search input box. | 752 * Focuses search input box. |
| 649 * @type {Command} | 753 * @type {Command} |
| 650 */ | 754 */ |
| 651 CommandHandler.COMMANDS_['search'] = /** @type {Command} */ ({ | 755 CommandHandler.COMMANDS_['search'] = /** @type {Command} */ ({ |
| 756 /** | |
| 757 * @param {Event} event Command event. | |
| 758 * @param {FileManager} fileManager FileManager to use. | |
| 759 */ | |
| 652 execute: function(event, fileManager) { | 760 execute: function(event, fileManager) { |
| 653 var element = fileManager.document.querySelector('#search-box input'); | 761 var element = fileManager.document.querySelector('#search-box input'); |
| 654 element.focus(); | 762 element.focus(); |
| 655 element.select(); | 763 element.select(); |
| 656 }, | 764 }, |
| 765 /** | |
| 766 * @param {Event} event Command event. | |
| 767 * @param {FileManager} fileManager FileManager to use. | |
| 768 */ | |
| 657 canExecute: function(event, fileManager) { | 769 canExecute: function(event, fileManager) { |
| 658 event.canExecute = !fileManager.isRenamingInProgress(); | 770 event.canExecute = !fileManager.isRenamingInProgress(); |
| 659 } | 771 } |
| 660 }); | 772 }); |
| 661 | 773 |
| 662 /** | 774 /** |
| 663 * Activates the n-th volume. | 775 * Activates the n-th volume. |
| 664 * @type {Command} | 776 * @type {Command} |
| 665 */ | 777 */ |
| 666 CommandHandler.COMMANDS_['volume-switch-1'] = | 778 CommandHandler.COMMANDS_['volume-switch-1'] = |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 } | 853 } |
| 742 }; | 854 }; |
| 743 steps.start(); | 855 steps.start(); |
| 744 | 856 |
| 745 var driveSyncHandler = | 857 var driveSyncHandler = |
| 746 fileManager.backgroundPage.background.driveSyncHandler; | 858 fileManager.backgroundPage.background.driveSyncHandler; |
| 747 if (pin && driveSyncHandler.isSyncSuppressed()) | 859 if (pin && driveSyncHandler.isSyncSuppressed()) |
| 748 driveSyncHandler.showDisabledMobileSyncNotification(); | 860 driveSyncHandler.showDisabledMobileSyncNotification(); |
| 749 }, | 861 }, |
| 750 | 862 |
| 863 /** | |
| 864 * @param {Event} event Command event. | |
| 865 * @param {FileManager} fileManager FileManager to use. | |
| 866 */ | |
| 751 canExecute: function(event, fileManager) { | 867 canExecute: function(event, fileManager) { |
| 752 var entries = CommandUtil.getPinTargetEntries(); | 868 var entries = CommandUtil.getPinTargetEntries(); |
| 753 var checked = true; | 869 var checked = true; |
| 754 for (var i = 0; i < entries.length; i++) { | 870 for (var i = 0; i < entries.length; i++) { |
| 755 checked = checked && entries[i].pinned; | 871 checked = checked && entries[i].pinned; |
| 756 } | 872 } |
| 757 if (entries.length > 0) { | 873 if (entries.length > 0) { |
| 758 event.canExecute = true; | 874 event.canExecute = true; |
| 759 event.command.setHidden(false); | 875 event.command.setHidden(false); |
| 760 event.command.checked = checked; | 876 event.command.checked = checked; |
| 761 } else { | 877 } else { |
| 762 event.canExecute = false; | 878 event.canExecute = false; |
| 763 event.command.setHidden(true); | 879 event.command.setHidden(true); |
| 764 } | 880 } |
| 765 } | 881 } |
| 766 }); | 882 }); |
| 767 | 883 |
| 768 /** | 884 /** |
| 769 * Creates zip file for current selection. | 885 * Creates zip file for current selection. |
| 770 * @type {Command} | 886 * @type {Command} |
| 771 */ | 887 */ |
| 772 CommandHandler.COMMANDS_['zip-selection'] = /** @type {Command} */ ({ | 888 CommandHandler.COMMANDS_['zip-selection'] = /** @type {Command} */ ({ |
| 889 /** | |
| 890 * @param {Event} event Command event. | |
| 891 * @param {FileManager} fileManager FileManager to use. | |
| 892 */ | |
| 773 execute: function(event, fileManager) { | 893 execute: function(event, fileManager) { |
| 774 var dirEntry = fileManager.getCurrentDirectoryEntry(); | 894 var dirEntry = fileManager.getCurrentDirectoryEntry(); |
| 895 if (!dirEntry) | |
| 896 return; | |
| 775 var selectionEntries = fileManager.getSelection().entries; | 897 var selectionEntries = fileManager.getSelection().entries; |
| 776 fileManager.fileOperationManager_.zipSelection(dirEntry, selectionEntries); | 898 fileManager.fileOperationManager_.zipSelection( |
| 899 dirEntry, selectionEntries); | |
| 777 }, | 900 }, |
| 901 /** | |
| 902 * @param {Event} event Command event. | |
| 903 * @param {FileManager} fileManager FileManager to use. | |
| 904 */ | |
| 778 canExecute: function(event, fileManager) { | 905 canExecute: function(event, fileManager) { |
| 779 var dirEntry = fileManager.getCurrentDirectoryEntry(); | 906 var dirEntry = fileManager.getCurrentDirectoryEntry(); |
| 780 var selection = fileManager.getSelection(); | 907 var selection = fileManager.getSelection(); |
| 781 event.canExecute = | 908 event.canExecute = |
| 782 dirEntry && | 909 dirEntry && |
| 783 !fileManager.isOnReadonlyDirectory() && | 910 !fileManager.isOnReadonlyDirectory() && |
| 784 !fileManager.isOnDrive() && | 911 !fileManager.isOnDrive() && |
| 785 selection && selection.totalCount > 0; | 912 selection && selection.totalCount > 0; |
| 786 } | 913 } |
| 787 }); | 914 }); |
| 788 | 915 |
| 789 /** | 916 /** |
| 790 * Shows the share dialog for the current selection (single only). | 917 * Shows the share dialog for the current selection (single only). |
| 791 * @type {Command} | 918 * @type {Command} |
| 792 */ | 919 */ |
| 793 CommandHandler.COMMANDS_['share'] = /** @type {Command} */ ({ | 920 CommandHandler.COMMANDS_['share'] = /** @type {Command} */ ({ |
| 921 /** | |
| 922 * @param {Event} event Command event. | |
| 923 * @param {FileManager} fileManager FileManager to use. | |
| 924 */ | |
| 794 execute: function(event, fileManager) { | 925 execute: function(event, fileManager) { |
| 795 fileManager.shareSelection(); | 926 fileManager.shareSelection(); |
| 796 }, | 927 }, |
| 928 /** | |
| 929 * @param {Event} event Command event. | |
| 930 * @param {FileManager} fileManager FileManager to use. | |
| 931 */ | |
| 797 canExecute: function(event, fileManager) { | 932 canExecute: function(event, fileManager) { |
| 798 var selection = fileManager.getSelection(); | 933 var selection = fileManager.getSelection(); |
| 799 var isDriveOffline = | 934 var isDriveOffline = |
| 800 fileManager.volumeManager.getDriveConnectionState().type === | 935 fileManager.volumeManager.getDriveConnectionState().type === |
| 801 VolumeManagerCommon.DriveConnectionType.OFFLINE; | 936 VolumeManagerCommon.DriveConnectionType.OFFLINE; |
| 802 event.canExecute = fileManager.isOnDrive() && | 937 event.canExecute = fileManager.isOnDrive() && |
| 803 !isDriveOffline && | 938 !isDriveOffline && |
| 804 selection && selection.totalCount == 1; | 939 selection && selection.totalCount == 1; |
| 805 event.command.setHidden(!fileManager.isOnDrive()); | 940 event.command.setHidden(!fileManager.isOnDrive()); |
| 806 } | 941 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 882 event.canExecute = isShortcut && eligible; | 1017 event.canExecute = isShortcut && eligible; |
| 883 event.command.setHidden(!event.canExecute); | 1018 event.command.setHidden(!event.canExecute); |
| 884 } | 1019 } |
| 885 }); | 1020 }); |
| 886 | 1021 |
| 887 /** | 1022 /** |
| 888 * Zoom in to the Files.app. | 1023 * Zoom in to the Files.app. |
| 889 * @type {Command} | 1024 * @type {Command} |
| 890 */ | 1025 */ |
| 891 CommandHandler.COMMANDS_['zoom-in'] = /** @type {Command} */ ({ | 1026 CommandHandler.COMMANDS_['zoom-in'] = /** @type {Command} */ ({ |
| 1027 /** | |
| 1028 * @param {Event} event Command event. | |
| 1029 * @param {FileManager} fileManager FileManager to use. | |
| 1030 */ | |
| 892 execute: function(event, fileManager) { | 1031 execute: function(event, fileManager) { |
| 893 chrome.fileManagerPrivate.zoom('in'); | 1032 chrome.fileManagerPrivate.zoom('in'); |
| 894 }, | 1033 }, |
| 895 canExecute: CommandUtil.canExecuteAlways | 1034 canExecute: CommandUtil.canExecuteAlways |
| 896 }); | 1035 }); |
| 897 | 1036 |
| 898 /** | 1037 /** |
| 899 * Zoom out from the Files.app. | 1038 * Zoom out from the Files.app. |
| 900 * @type {Command} | 1039 * @type {Command} |
| 901 */ | 1040 */ |
| 902 CommandHandler.COMMANDS_['zoom-out'] = /** @type {Command} */ ({ | 1041 CommandHandler.COMMANDS_['zoom-out'] = /** @type {Command} */ ({ |
| 1042 /** | |
| 1043 * @param {Event} event Command event. | |
| 1044 * @param {FileManager} fileManager FileManager to use. | |
| 1045 */ | |
| 903 execute: function(event, fileManager) { | 1046 execute: function(event, fileManager) { |
| 904 chrome.fileManagerPrivate.zoom('out'); | 1047 chrome.fileManagerPrivate.zoom('out'); |
| 905 }, | 1048 }, |
| 906 canExecute: CommandUtil.canExecuteAlways | 1049 canExecute: CommandUtil.canExecuteAlways |
| 907 }); | 1050 }); |
| 908 | 1051 |
| 909 /** | 1052 /** |
| 910 * Reset the zoom factor. | 1053 * Reset the zoom factor. |
| 911 * @type {Command} | 1054 * @type {Command} |
| 912 */ | 1055 */ |
| 913 CommandHandler.COMMANDS_['zoom-reset'] = /** @type {Command} */ ({ | 1056 CommandHandler.COMMANDS_['zoom-reset'] = /** @type {Command} */ ({ |
| 1057 /** | |
| 1058 * @param {Event} event Command event. | |
| 1059 * @param {FileManager} fileManager FileManager to use. | |
| 1060 */ | |
| 914 execute: function(event, fileManager) { | 1061 execute: function(event, fileManager) { |
| 915 chrome.fileManagerPrivate.zoom('reset'); | 1062 chrome.fileManagerPrivate.zoom('reset'); |
| 916 }, | 1063 }, |
| 917 canExecute: CommandUtil.canExecuteAlways | 1064 canExecute: CommandUtil.canExecuteAlways |
| 918 }); | 1065 }); |
| 919 | 1066 |
| 920 /** | 1067 /** |
| 921 * Open inspector for foreground page. | 1068 * Open inspector for foreground page. |
| 922 * @type {Command} | 1069 * @type {Command} |
| 923 */ | 1070 */ |
| 924 CommandHandler.COMMANDS_['inspect-normal'] = /** @type {Command} */ ({ | 1071 CommandHandler.COMMANDS_['inspect-normal'] = /** @type {Command} */ ({ |
| 1072 /** | |
| 1073 * @param {Event} event Command event. | |
| 1074 * @param {FileManager} fileManager FileManager to use. | |
| 1075 */ | |
| 925 execute: function(event, fileManager) { | 1076 execute: function(event, fileManager) { |
| 926 chrome.fileManagerPrivate.openInspector('normal'); | 1077 chrome.fileManagerPrivate.openInspector('normal'); |
| 927 }, | 1078 }, |
| 928 canExecute: CommandUtil.canExecuteAlways | 1079 canExecute: CommandUtil.canExecuteAlways |
| 929 }); | 1080 }); |
| 930 | 1081 |
| 931 /** | 1082 /** |
| 932 * Open inspector for foreground page and bring focus to the console. | 1083 * Open inspector for foreground page and bring focus to the console. |
| 933 * @type {Command} | 1084 * @type {Command} |
| 934 */ | 1085 */ |
| 935 CommandHandler.COMMANDS_['inspect-console'] = /** @type {Command} */ ({ | 1086 CommandHandler.COMMANDS_['inspect-console'] = /** @type {Command} */ ({ |
| 1087 /** | |
| 1088 * @param {Event} event Command event. | |
| 1089 * @param {FileManager} fileManager FileManager to use. | |
| 1090 */ | |
| 936 execute: function(event, fileManager) { | 1091 execute: function(event, fileManager) { |
| 937 chrome.fileManagerPrivate.openInspector('console'); | 1092 chrome.fileManagerPrivate.openInspector('console'); |
| 938 }, | 1093 }, |
| 939 canExecute: CommandUtil.canExecuteAlways | 1094 canExecute: CommandUtil.canExecuteAlways |
| 940 }); | 1095 }); |
| 941 | 1096 |
| 942 /** | 1097 /** |
| 943 * Open inspector for foreground page in inspect element mode. | 1098 * Open inspector for foreground page in inspect element mode. |
| 944 * @type {Command} | 1099 * @type {Command} |
| 945 */ | 1100 */ |
| 946 CommandHandler.COMMANDS_['inspect-element'] = /** @type {Command} */ ({ | 1101 CommandHandler.COMMANDS_['inspect-element'] = /** @type {Command} */ ({ |
| 1102 /** | |
| 1103 * @param {Event} event Command event. | |
| 1104 * @param {FileManager} fileManager FileManager to use. | |
| 1105 */ | |
| 947 execute: function(event, fileManager) { | 1106 execute: function(event, fileManager) { |
| 948 chrome.fileManagerPrivate.openInspector('element'); | 1107 chrome.fileManagerPrivate.openInspector('element'); |
| 949 }, | 1108 }, |
| 950 canExecute: CommandUtil.canExecuteAlways | 1109 canExecute: CommandUtil.canExecuteAlways |
| 951 }); | 1110 }); |
| 952 | 1111 |
| 953 /** | 1112 /** |
| 954 * Open inspector for background page. | 1113 * Open inspector for background page. |
| 955 * @type {Command} | 1114 * @type {Command} |
| 956 */ | 1115 */ |
| 957 CommandHandler.COMMANDS_['inspect-background'] = /** @type {Command} */ ({ | 1116 CommandHandler.COMMANDS_['inspect-background'] = /** @type {Command} */ ({ |
| 1117 /** | |
| 1118 * @param {Event} event Command event. | |
| 1119 * @param {FileManager} fileManager FileManager to use. | |
| 1120 */ | |
| 958 execute: function(event, fileManager) { | 1121 execute: function(event, fileManager) { |
| 959 chrome.fileManagerPrivate.openInspector('background'); | 1122 chrome.fileManagerPrivate.openInspector('background'); |
| 960 }, | 1123 }, |
| 961 canExecute: CommandUtil.canExecuteAlways | 1124 canExecute: CommandUtil.canExecuteAlways |
| 962 }); | 1125 }); |
| OLD | NEW |