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

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

Issue 12221082: Add gear menu to /downloads and /external_storage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. Created 7 years, 10 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 var CommandUtil = {}; 5 var CommandUtil = {};
6 6
7 /** 7 /**
8 * Extracts root on which command event was dispatched. 8 * Extracts root on which command event was dispatched.
9 * 9 *
10 * @param {Event} event Command event for which to retrieve root to operate on. 10 * @param {Event} event Command event for which to retrieve root to operate on.
(...skipping 17 matching lines...) Expand all
28 var root = CommandUtil.getCommandRoot(event, rootsList); 28 var root = CommandUtil.getCommandRoot(event, rootsList);
29 29
30 return root && PathUtil.getRootType(root.fullPath); 30 return root && PathUtil.getRootType(root.fullPath);
31 }; 31 };
32 32
33 /** 33 /**
34 * Checks if command can be executed on drive. 34 * Checks if command can be executed on drive.
35 * @param {Event} event Command event to mark. 35 * @param {Event} event Command event to mark.
36 * @param {FileManager} fileManager FileManager to use. 36 * @param {FileManager} fileManager FileManager to use.
37 */ 37 */
38 CommandUtil.canExecuteOnDriveOnly = function(event, fileManager) { 38 CommandUtil.canExecuteEnabledOnDriveOnly = function(event, fileManager) {
39 event.canExecute = fileManager.isOnDrive(); 39 event.canExecute = fileManager.isOnDrive();
40 }; 40 };
41 41
42 /** 42 /**
43 * Checks if command should be visible on drive.
44 * @param {Event} event Command event to mark.
45 * @param {FileManager} fileManager FileManager to use.
46 */
47 CommandUtil.canExecuteVisibleOnDriveOnly = function(event, fileManager) {
48 event.canExecute = fileManager.isOnDrive();
49 event.command.setHidden(!fileManager.isOnDrive());
50 };
51
52 /**
43 * Returns a single selected/passed entry or null. 53 * Returns a single selected/passed entry or null.
44 * @param {Event} event Command event. 54 * @param {Event} event Command event.
45 * @param {FileManager} fileManager FileManager to use. 55 * @param {FileManager} fileManager FileManager to use.
46 * @return {FileEntry} The entry or null. 56 * @return {FileEntry} The entry or null.
47 */ 57 */
48 CommandUtil.getSingleEntry = function(event, fileManager) { 58 CommandUtil.getSingleEntry = function(event, fileManager) {
49 if (event.target.entry) { 59 if (event.target.entry) {
50 return event.target.entry; 60 return event.target.entry;
51 } 61 }
52 var selection = fileManager.getSelection(); 62 var selection = fileManager.getSelection();
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 253 }
244 }; 254 };
245 255
246 /** 256 /**
247 * Opens drive help. 257 * Opens drive help.
248 */ 258 */
249 Commands.driveHelpCommand = { 259 Commands.driveHelpCommand = {
250 execute: function() { 260 execute: function() {
251 window.open(FileManager.GOOGLE_DRIVE_HELP, 'help'); 261 window.open(FileManager.GOOGLE_DRIVE_HELP, 'help');
252 }, 262 },
253 canExecute: CommandUtil.canExecuteOnDriveOnly 263 canExecute: function(event, fileManager) {
264 event.canExecute = true;
265 }
254 }; 266 };
255 267
256 /** 268 /**
257 * Opens drive buy-more-space url. 269 * Opens drive buy-more-space url.
258 */ 270 */
259 Commands.driveBuySpaceCommand = { 271 Commands.driveBuySpaceCommand = {
260 execute: function() { 272 execute: function() {
261 window.open(FileManager.GOOGLE_DRIVE_BUY_STORAGE, 'buy-more-space'); 273 window.open(FileManager.GOOGLE_DRIVE_BUY_STORAGE, 'buy-more-space');
262 }, 274 },
263 canExecute: CommandUtil.canExecuteOnDriveOnly 275 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly
264 }; 276 };
265 277
266 /** 278 /**
267 * Clears drive cache. 279 * Clears drive cache.
268 */ 280 */
269 Commands.driveClearCacheCommand = { 281 Commands.driveClearCacheCommand = {
270 execute: function() { 282 execute: function() {
271 chrome.fileBrowserPrivate.clearDriveCache(); 283 chrome.fileBrowserPrivate.clearDriveCache();
272 }, 284 },
273 canExecute: CommandUtil.canExecuteOnDriveOnly 285 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly
274 }; 286 };
275 287
276 /** 288 /**
277 * Reload the metadata of the file system from the server 289 * Reload the metadata of the file system from the server
278 */ 290 */
279 Commands.driveReloadCommand = { 291 Commands.driveReloadCommand = {
280 execute: function() { 292 execute: function() {
281 chrome.fileBrowserPrivate.reloadDrive(); 293 chrome.fileBrowserPrivate.reloadDrive();
282 }, 294 },
283 canExecute: CommandUtil.canExecuteOnDriveOnly 295 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly
284 }; 296 };
285 297
286 /** 298 /**
287 * Opens drive.google.com. 299 * Opens drive.google.com.
288 */ 300 */
289 Commands.driveGoToDriveCommand = { 301 Commands.driveGoToDriveCommand = {
290 execute: function() { 302 execute: function() {
291 window.open(FileManager.GOOGLE_DRIVE_ROOT, 'drive-root'); 303 window.open(FileManager.GOOGLE_DRIVE_ROOT, 'drive-root');
292 }, 304 },
293 canExecute: CommandUtil.canExecuteOnDriveOnly 305 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly
294 }; 306 };
295 307
296 /** 308 /**
297 * Displays open with dialog for current selection. 309 * Displays open with dialog for current selection.
298 */ 310 */
299 Commands.openWithCommand = { 311 Commands.openWithCommand = {
300 execute: function(event, fileManager) { 312 execute: function(event, fileManager) {
301 var tasks = fileManager.getSelection().tasks; 313 var tasks = fileManager.getSelection().tasks;
302 if (tasks) { 314 if (tasks) {
303 tasks.showTaskPicker(fileManager.defaultTaskPicker, 315 tasks.showTaskPicker(fileManager.defaultTaskPicker,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 * Opens Files App help. 406 * Opens Files App help.
395 */ 407 */
396 Commands.filesAppHelpCommand = { 408 Commands.filesAppHelpCommand = {
397 execute: function() { 409 execute: function() {
398 window.open(FileManager.FILES_APP_HELP, 'help'); 410 window.open(FileManager.FILES_APP_HELP, 'help');
399 }, 411 },
400 canExecute: function(event, fileManager) { 412 canExecute: function(event, fileManager) {
401 event.canExecute = true; 413 event.canExecute = true;
402 } 414 }
403 }; 415 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698