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

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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 !fileManager.isRenamingInProgress() && 249 !fileManager.isRenamingInProgress() &&
240 !fileManager.isOnReadonlyDirectory() && 250 !fileManager.isOnReadonlyDirectory() &&
241 selection && 251 selection &&
242 selection.totalCount == 1; 252 selection.totalCount == 1;
243 } 253 }
244 }; 254 };
245 255
246 /** 256 /**
247 * Opens drive help. 257 * Opens drive help.
248 */ 258 */
249 Commands.driveHelpCommand = { 259 Commands.volumeHelpCommand = {
250 execute: function() { 260 execute: function() {
251 window.open(FileManager.GOOGLE_DRIVE_HELP, 'help'); 261 if (fileManager.isOnDrive())
262 window.open(FileManager.GOOGLE_DRIVE_HELP, 'help');
263 else
264 window.open(FileManager.FILES_APP_HELP, 'help');
252 }, 265 },
253 canExecute: CommandUtil.canExecuteOnDriveOnly 266 canExecute: function(event, fileManager) {
267 event.canExecute = true;
268 }
254 }; 269 };
255 270
256 /** 271 /**
257 * Opens drive buy-more-space url. 272 * Opens drive buy-more-space url.
258 */ 273 */
259 Commands.driveBuySpaceCommand = { 274 Commands.driveBuySpaceCommand = {
260 execute: function() { 275 execute: function() {
261 window.open(FileManager.GOOGLE_DRIVE_BUY_STORAGE, 'buy-more-space'); 276 window.open(FileManager.GOOGLE_DRIVE_BUY_STORAGE, 'buy-more-space');
262 }, 277 },
263 canExecute: CommandUtil.canExecuteOnDriveOnly 278 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly
264 }; 279 };
265 280
266 /** 281 /**
267 * Clears drive cache. 282 * Clears drive cache.
268 */ 283 */
269 Commands.driveClearCacheCommand = { 284 Commands.driveClearCacheCommand = {
270 execute: function() { 285 execute: function() {
271 chrome.fileBrowserPrivate.clearDriveCache(); 286 chrome.fileBrowserPrivate.clearDriveCache();
272 }, 287 },
273 canExecute: CommandUtil.canExecuteOnDriveOnly 288 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly
274 }; 289 };
275 290
276 /** 291 /**
277 * Reload the metadata of the file system from the server 292 * Reload the metadata of the file system from the server
278 */ 293 */
279 Commands.driveReloadCommand = { 294 Commands.driveReloadCommand = {
280 execute: function() { 295 execute: function() {
281 chrome.fileBrowserPrivate.reloadDrive(); 296 chrome.fileBrowserPrivate.reloadDrive();
282 }, 297 },
283 canExecute: CommandUtil.canExecuteOnDriveOnly 298 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly
284 }; 299 };
285 300
286 /** 301 /**
287 * Opens drive.google.com. 302 * Opens drive.google.com.
288 */ 303 */
289 Commands.driveGoToDriveCommand = { 304 Commands.driveGoToDriveCommand = {
290 execute: function() { 305 execute: function() {
291 window.open(FileManager.GOOGLE_DRIVE_ROOT, 'drive-root'); 306 window.open(FileManager.GOOGLE_DRIVE_ROOT, 'drive-root');
292 }, 307 },
293 canExecute: CommandUtil.canExecuteOnDriveOnly 308 canExecute: CommandUtil.canExecuteVisibleOnDriveOnly
294 }; 309 };
295 310
296 /** 311 /**
297 * Displays open with dialog for current selection. 312 * Displays open with dialog for current selection.
298 */ 313 */
299 Commands.openWithCommand = { 314 Commands.openWithCommand = {
300 execute: function(event, fileManager) { 315 execute: function(event, fileManager) {
301 var tasks = fileManager.getSelection().tasks; 316 var tasks = fileManager.getSelection().tasks;
302 if (tasks) { 317 if (tasks) {
303 tasks.showTaskPicker(fileManager.defaultTaskPicker, 318 tasks.showTaskPicker(fileManager.defaultTaskPicker,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 * Opens Files App help. 409 * Opens Files App help.
395 */ 410 */
396 Commands.filesAppHelpCommand = { 411 Commands.filesAppHelpCommand = {
397 execute: function() { 412 execute: function() {
398 window.open(FileManager.FILES_APP_HELP, 'help'); 413 window.open(FileManager.FILES_APP_HELP, 'help');
399 }, 414 },
400 canExecute: function(event, fileManager) { 415 canExecute: function(event, fileManager) {
401 event.canExecute = true; 416 event.canExecute = true;
402 } 417 }
403 }; 418 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/file_manager/js/file_manager.js ('k') | chrome/browser/resources/file_manager/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698