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

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

Issue 7069029: file manager: disable "Save" and "New Folder" buttons in the media/ directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // WK Bug 55728 is fixed on the chrome 12 branch but not on the trunk. 5 // WK Bug 55728 is fixed on the chrome 12 branch but not on the trunk.
6 // TODO(rginda): Enable this everywhere once we have a trunk-worthy fix. 6 // TODO(rginda): Enable this everywhere once we have a trunk-worthy fix.
7 const ENABLE_EXIF_READER = navigator.userAgent.match(/chrome\/12\.0/i); 7 const ENABLE_EXIF_READER = navigator.userAgent.match(/chrome\/12\.0/i);
8 8
9 // Thumbnail view is painful without the exif reader. 9 // Thumbnail view is painful without the exif reader.
10 const ENABLE_THUMBNAIL_VIEW = ENABLE_EXIF_READER; 10 const ENABLE_THUMBNAIL_VIEW = ENABLE_EXIF_READER;
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 selectable = (this.selection.directoryCount == 0 && 1479 selectable = (this.selection.directoryCount == 0 &&
1480 this.selection.fileCount == 1); 1480 this.selection.fileCount == 1);
1481 } else if (this.dialogType_ == 1481 } else if (this.dialogType_ ==
1482 FileManager.DialogType.SELECT_OPEN_MULTI_FILE) { 1482 FileManager.DialogType.SELECT_OPEN_MULTI_FILE) {
1483 selectable = (this.selection.directoryCount == 0 && 1483 selectable = (this.selection.directoryCount == 0 &&
1484 this.selection.fileCount >= 1); 1484 this.selection.fileCount >= 1);
1485 } else if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) { 1485 } else if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) {
1486 if (this.selection.leadEntry && this.selection.leadEntry.isFile) 1486 if (this.selection.leadEntry && this.selection.leadEntry.isFile)
1487 this.filenameInput_.value = this.selection.leadEntry.name; 1487 this.filenameInput_.value = this.selection.leadEntry.name;
1488 1488
1489 selectable = !!this.filenameInput_.value; 1489 if (this.currentDirEntry_.fullPath == '/' ||
1490 this.currentDirEntry_.fullPath == MEDIA_DIRECTORY) {
1491 // Nothing can be saved in to the root or media/ directories.
1492 selectable = false;
1493 } else {
1494 selectable = !!this.filenameInput_.value;
1495 }
1490 } else if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) { 1496 } else if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) {
1491 // No "select" buttons on the full page UI. 1497 // No "select" buttons on the full page UI.
1492 selectable = true; 1498 selectable = true;
1493 } else { 1499 } else {
1494 throw new Error('Unknown dialog type'); 1500 throw new Error('Unknown dialog type');
1495 } 1501 }
1496 1502
1497 this.okButton_.disabled = !selectable; 1503 this.okButton_.disabled = !selectable;
1498 this.updatePreview_(); 1504 this.updatePreview_();
1499 }; 1505 };
(...skipping 25 matching lines...) Expand all
1525 * 1531 *
1526 * @param {cr.Event} event The directory-changed event. 1532 * @param {cr.Event} event The directory-changed event.
1527 */ 1533 */
1528 FileManager.prototype.onDirectoryChanged_ = function(event) { 1534 FileManager.prototype.onDirectoryChanged_ = function(event) {
1529 if (event.saveHistory) { 1535 if (event.saveHistory) {
1530 history.pushState(this.currentDirEntry_.fullPath, 1536 history.pushState(this.currentDirEntry_.fullPath,
1531 this.currentDirEntry_.fullPath, 1537 this.currentDirEntry_.fullPath,
1532 location.href); 1538 location.href);
1533 } 1539 }
1534 1540
1535 // New folder should never be enabled in the root directory. 1541 // New folder should never be enabled in the root or media/ directories.
1536 this.newFolderButton_.disabled = this.currentDirEntry_.fullPath == '/'; 1542 this.newFolderButton_.disabled =
1543 (this.currentDirEntry_.fullPath == '/' ||
1544 this.currentDirEntry_.fullPath == MEDIA_DIRECTORY);
1537 1545
1538 this.document_.title = this.currentDirEntry_.fullPath; 1546 this.document_.title = this.currentDirEntry_.fullPath;
1539 this.rescanDirectory_(); 1547 this.rescanDirectory_();
1540 }; 1548 };
1541 1549
1542 /** 1550 /**
1543 * Update the UI when a disk is mounted or unmounted. 1551 * Update the UI when a disk is mounted or unmounted.
1544 * 1552 *
1545 * @param {string} path The path that has been mounted or unmounted. 1553 * @param {string} path The path that has been mounted or unmounted.
1546 */ 1554 */
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { 2004 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) {
1997 if (!this.selection.leadEntry.isFile) 2005 if (!this.selection.leadEntry.isFile)
1998 throw new Error('Selected entry is not a file!'); 2006 throw new Error('Selected entry is not a file!');
1999 } 2007 }
2000 2008
2001 chrome.fileBrowserPrivate.selectFile(ary[0], 0); 2009 chrome.fileBrowserPrivate.selectFile(ary[0], 0);
2002 window.close(); 2010 window.close();
2003 }; 2011 };
2004 2012
2005 })(); 2013 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698