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

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

Issue 9701063: Fix file manager to better handle missing roots and scan failure (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 // Setting the src of an img to an empty string can crash the browser, so we 5 // Setting the src of an img to an empty string can crash the browser, so we
6 // use an empty 1x1 gif instead. 6 // use an empty 1x1 gif instead.
7 7
8 /** 8 /**
9 * FileManager constructor. 9 * FileManager constructor.
10 * 10 *
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE || 1145 (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE ||
1146 this.dialogType_ == FileManager.DialogType.FULL_PAGE); 1146 this.dialogType_ == FileManager.DialogType.FULL_PAGE);
1147 1147
1148 case 'unmount': 1148 case 'unmount':
1149 return true; 1149 return true;
1150 1150
1151 case 'format': 1151 case 'format':
1152 var entry = 1152 var entry =
1153 this.getRootEntry_(this.rootsList_.selectionModel.selectedIndex); 1153 this.getRootEntry_(this.rootsList_.selectionModel.selectedIndex);
1154 1154
1155 return DirectoryModel.getRootType(entry.fullPath) == 1155 return entry && DirectoryModel.getRootType(entry.fullPath) ==
1156 DirectoryModel.RootType.REMOVABLE; 1156 DirectoryModel.RootType.REMOVABLE;
1157 } 1157 }
1158 }; 1158 };
1159 1159
1160 FileManager.prototype.getRootEntry_ = function(index) { 1160 FileManager.prototype.getRootEntry_ = function(index) {
1161 if (index == -1) 1161 if (index == -1)
1162 return null; 1162 return null;
1163 1163
1164 return this.rootsList_.dataModel.item(index); 1164 return this.rootsList_.dataModel.item(index);
1165 }; 1165 };
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 1466
1467 /** 1467 /**
1468 * Restores current directory and may be a selected item after page load (or 1468 * Restores current directory and may be a selected item after page load (or
1469 * reload) or popping a state (after click on back/forward). If location.hash 1469 * reload) or popping a state (after click on back/forward). If location.hash
1470 * is present it means that the user has navigated somewhere and that place 1470 * is present it means that the user has navigated somewhere and that place
1471 * will be restored. defaultPath primarily is used with save/open dialogs. 1471 * will be restored. defaultPath primarily is used with save/open dialogs.
1472 * Default path may also contain a file name. Freshly opened file manager 1472 * Default path may also contain a file name. Freshly opened file manager
1473 * window has neither. 1473 * window has neither.
1474 */ 1474 */
1475 FileManager.prototype.setupCurrentDirectory_ = function() { 1475 FileManager.prototype.setupCurrentDirectory_ = function() {
1476 // Avoid a bunch of intermediate list redraws while the data model is
1477 // cleared and updated. Note that it may (or may not) be desirable to draw
1478 // partial results as we get them, but today the DirectoryReader API
1479 // generally returns all entries in one chunk so even without this batching
1480 // we wouldn't have incremental updates.
1481 this.table_.startBatchUpdates();
1482 var onLoaded = this.table_.endBatchUpdates.bind(this.table_);
1483 1476
1484 if (location.hash) { 1477 if (location.hash) {
1485 // Location hash has the highest priority. 1478 // Location hash has the highest priority.
1486 var path = decodeURI(location.hash.substr(1)); 1479 var path = decodeURI(location.hash.substr(1));
1487 1480
1488 // In the FULL_PAGE mode if the path points to a file we should invoke 1481 // In the FULL_PAGE mode if the path points to a file we should invoke
1489 // the default action after selecting it. 1482 // the default action after selecting it.
1490 if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) { 1483 if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) {
1491 // To prevent the file list flickering for a moment before the action 1484 // To prevent the file list flickering for a moment before the action
1492 // is executed we hide it under a white div. 1485 // is executed we hide it under a white div.
(...skipping 13 matching lines...) Expand all
1506 removeShade(); 1499 removeShade();
1507 foundLeaf = false; 1500 foundLeaf = false;
1508 } 1501 }
1509 } 1502 }
1510 1503
1511 // TODO(kaznacheev): refactor dispatchDefaultTask to accept an array 1504 // TODO(kaznacheev): refactor dispatchDefaultTask to accept an array
1512 // of urls instead of a selection. This will remove the need to wait 1505 // of urls instead of a selection. This will remove the need to wait
1513 // until the selection is done. 1506 // until the selection is done.
1514 var self = this; 1507 var self = this;
1515 function onLoadedActivateLeaf() { 1508 function onLoadedActivateLeaf() {
1516 onLoaded();
1517 if (foundLeaf) { 1509 if (foundLeaf) {
1518 self.dispatchDefaultTask_(); 1510 self.dispatchDefaultTask_();
1519 setTimeout(removeShade, 1000); 1511 setTimeout(removeShade, 1000);
1520 } 1512 }
1521 } 1513 }
1522 this.directoryModel_.setupPath(path, onLoadedActivateLeaf, onResolve); 1514 this.directoryModel_.setupPath(path, onLoadedActivateLeaf, onResolve);
1523 1515
1524 return; 1516 return;
1525 } 1517 }
1526 1518
1527 this.directoryModel_.setupPath(path, onLoaded); 1519 this.directoryModel_.setupPath(path);
1528 return; 1520 return;
1529 } 1521 }
1530 1522
1531 if (this.params_.defaultPath) { 1523 if (this.params_.defaultPath) {
1532 var path = this.params_.defaultPath; 1524 var path = this.params_.defaultPath;
1533 if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) { 1525 if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) {
1534 this.directoryModel_.setupPath(path, onLoaded, 1526 this.directoryModel_.setupPath(path, undefined,
1535 function(basePath, leafName) { 1527 function(basePath, leafName) {
1536 this.filenameInput_.value = leafName; 1528 this.filenameInput_.value = leafName;
1537 this.selectDefaultPathInFilenameInput_(); 1529 this.selectDefaultPathInFilenameInput_();
1538 }.bind(this)); 1530 }.bind(this));
1539 return; 1531 return;
1540 } 1532 }
1541 1533
1542 this.directoryModel_.setupPath(path, onLoaded); 1534 this.directoryModel_.setupPath(path);
1543 return; 1535 return;
1544 } 1536 }
1545 1537
1546 this.directoryModel_.setupDefaultPath(onLoaded); 1538 this.directoryModel_.setupDefaultPath();
1547 }; 1539 };
1548 1540
1549 /** 1541 /**
1550 * Tweak the UI to become a particular kind of dialog, as determined by the 1542 * Tweak the UI to become a particular kind of dialog, as determined by the
1551 * dialog type parameter passed to the constructor. 1543 * dialog type parameter passed to the constructor.
1552 */ 1544 */
1553 FileManager.prototype.initDialogType_ = function() { 1545 FileManager.prototype.initDialogType_ = function() {
1554 var defaultTitle; 1546 var defaultTitle;
1555 var okLabel = str('OPEN_LABEL'); 1547 var okLabel = str('OPEN_LABEL');
1556 1548
(...skipping 2592 matching lines...) Expand 10 before | Expand all | Expand 10 after
4149 }); 4141 });
4150 }, onError); 4142 }, onError);
4151 4143
4152 function onError(err) { 4144 function onError(err) {
4153 console.log('Error while checking free space: ' + err); 4145 console.log('Error while checking free space: ' + err);
4154 setTimeout(doCheck, 1000 * 60); 4146 setTimeout(doCheck, 1000 * 60);
4155 } 4147 }
4156 } 4148 }
4157 } 4149 }
4158 })(); 4150 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698