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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 var CommandUtil = {}; | 7 var CommandUtil = {}; |
8 | 8 |
9 /** | 9 /** |
10 * Extracts root on which command event was dispatched. | 10 * Extracts root on which command event was dispatched. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 * Checks if command should be visible on drive. | 46 * Checks if command should be visible on drive. |
47 * @param {Event} event Command event to mark. | 47 * @param {Event} event Command event to mark. |
48 * @param {FileManager} fileManager FileManager to use. | 48 * @param {FileManager} fileManager FileManager to use. |
49 */ | 49 */ |
50 CommandUtil.canExecuteVisibleOnDriveOnly = function(event, fileManager) { | 50 CommandUtil.canExecuteVisibleOnDriveOnly = function(event, fileManager) { |
51 event.canExecute = fileManager.isOnDrive(); | 51 event.canExecute = fileManager.isOnDrive(); |
52 event.command.setHidden(!fileManager.isOnDrive()); | 52 event.command.setHidden(!fileManager.isOnDrive()); |
53 }; | 53 }; |
54 | 54 |
55 /** | 55 /** |
| 56 * Checks if command should be visible on drive with pressing ctrl key. |
| 57 * @param {Event} event Command event to mark. |
| 58 * @param {FileManager} fileManager FileManager to use. |
| 59 */ |
| 60 CommandUtil.canExecuteVisibleOnDriveWithCtrlKeyOnly = |
| 61 function(event, fileManager) { |
| 62 event.canExecute = fileManager.isOnDrive() && fileManager.isCtrlKeyPressed(); |
| 63 event.command.setHidden(!event.canExecute); |
| 64 }; |
| 65 |
| 66 /** |
56 * Returns a single selected/passed entry or null. | 67 * Returns a single selected/passed entry or null. |
57 * @param {Event} event Command event. | 68 * @param {Event} event Command event. |
58 * @param {FileManager} fileManager FileManager to use. | 69 * @param {FileManager} fileManager FileManager to use. |
59 * @return {FileEntry} The entry or null. | 70 * @return {FileEntry} The entry or null. |
60 */ | 71 */ |
61 CommandUtil.getSingleEntry = function(event, fileManager) { | 72 CommandUtil.getSingleEntry = function(event, fileManager) { |
62 if (event.target.entry) { | 73 if (event.target.entry) { |
63 return event.target.entry; | 74 return event.target.entry; |
64 } | 75 } |
65 var selection = fileManager.getSelection(); | 76 var selection = fileManager.getSelection(); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly | 334 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly |
324 }; | 335 }; |
325 | 336 |
326 /** | 337 /** |
327 * Clears drive cache. | 338 * Clears drive cache. |
328 */ | 339 */ |
329 Commands.driveClearCacheCommand = { | 340 Commands.driveClearCacheCommand = { |
330 execute: function() { | 341 execute: function() { |
331 chrome.fileBrowserPrivate.clearDriveCache(); | 342 chrome.fileBrowserPrivate.clearDriveCache(); |
332 }, | 343 }, |
333 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly | 344 canExecute: CommandUtil.canExecuteVisibleOnDriveWithCtrlKeyOnly |
334 }; | 345 }; |
335 | 346 |
336 /** | 347 /** |
337 * Reload the metadata of the file system from the server | 348 * Reload the metadata of the file system from the server |
338 */ | 349 */ |
339 Commands.driveReloadCommand = { | 350 Commands.driveReloadCommand = { |
340 execute: function() { | 351 execute: function() { |
341 chrome.fileBrowserPrivate.reloadDrive(); | 352 chrome.fileBrowserPrivate.reloadDrive(); |
342 }, | 353 }, |
343 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly | 354 canExecute: CommandUtil.canExecuteVisibleOnDriveWithCtrlKeyOnly |
344 }; | 355 }; |
345 | 356 |
346 /** | 357 /** |
347 * Opens drive.google.com. | 358 * Opens drive.google.com. |
348 */ | 359 */ |
349 Commands.driveGoToDriveCommand = { | 360 Commands.driveGoToDriveCommand = { |
350 execute: function() { | 361 execute: function() { |
351 window.open(FileManager.GOOGLE_DRIVE_ROOT, 'drive-root'); | 362 window.open(FileManager.GOOGLE_DRIVE_ROOT, 'drive-root'); |
352 }, | 363 }, |
353 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly | 364 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 fileManager.copyManager_.zipSelection(dirEntry, fileManager.isOnDrive(), | 453 fileManager.copyManager_.zipSelection(dirEntry, fileManager.isOnDrive(), |
443 selectionEntries); | 454 selectionEntries); |
444 }, | 455 }, |
445 canExecute: function(event, fileManager) { | 456 canExecute: function(event, fileManager) { |
446 var selection = fileManager.getSelection(); | 457 var selection = fileManager.getSelection(); |
447 event.canExecute = !fileManager.isOnReadonlyDirectory() && | 458 event.canExecute = !fileManager.isOnReadonlyDirectory() && |
448 !fileManager.isOnDrive() && | 459 !fileManager.isOnDrive() && |
449 selection && selection.totalCount > 0; | 460 selection && selection.totalCount > 0; |
450 } | 461 } |
451 }; | 462 }; |
OLD | NEW |