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 /** | 7 /** |
8 * FileManager constructor. | 8 * FileManager constructor. |
9 * | 9 * |
10 * FileManager objects encapsulate the functionality of the file selector | 10 * FileManager objects encapsulate the functionality of the file selector |
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 }.bind(this)); | 1585 }.bind(this)); |
1586 } | 1586 } |
1587 | 1587 |
1588 if (this.dialogType === DialogType.FULL_PAGE) { | 1588 if (this.dialogType === DialogType.FULL_PAGE) { |
1589 // In the FULL_PAGE mode if the restored path points to a file we might | 1589 // In the FULL_PAGE mode if the restored path points to a file we might |
1590 // have to invoke a task after selecting it. | 1590 // have to invoke a task after selecting it. |
1591 if (this.params_.action === 'select') | 1591 if (this.params_.action === 'select') |
1592 return; | 1592 return; |
1593 | 1593 |
1594 var task = null; | 1594 var task = null; |
1595 if (opt_suggestedName) { | 1595 // Handle restoring after crash. |
1596 // Non-existent file or a directory. | 1596 if (this.params_.gallery) { |
1597 if (this.params_.gallery) { | 1597 if (!opt_selectionEntry) { |
| 1598 // Non-existent file or a directory. |
1598 // Reloading while the Gallery is open with empty or multiple | 1599 // Reloading while the Gallery is open with empty or multiple |
1599 // selection. Open the Gallery when the directory is scanned. | 1600 // selection. Open the Gallery when the directory is scanned. |
1600 task = function() { | 1601 task = function() { |
1601 new FileTasks(this, this.params_).openGallery([]); | 1602 new FileTasks(this, this.params_).openGallery([]); |
1602 }.bind(this); | 1603 }.bind(this); |
1603 } | 1604 } else { |
1604 } else if (opt_selectionEntry) { | 1605 // The file or the directory exists. |
1605 // There is a file to be selected. It means, that we are recovering | |
1606 // the Files app. | |
1607 // We call the appropriate methods of FileTasks directly as we do | |
1608 // not need any of the preparations that |execute| method does. | |
1609 // TODO(mtomasz): Change Entry.fullPath to Entry. | |
1610 var mediaType = FileType.getMediaType(opt_selectionEntry); | |
1611 if (mediaType === 'image' || mediaType === 'video') { | |
1612 task = function() { | 1606 task = function() { |
1613 // TODO(mtomasz): Replace the url with an entry. | 1607 // TODO(mtomasz): Replace the url with an entry. |
1614 new FileTasks(this, this.params_).openGallery([opt_selectionEntry]); | 1608 new FileTasks(this, this.params_).openGallery([opt_selectionEntry]); |
1615 }.bind(this); | 1609 }.bind(this); |
1616 } else if (mediaType === 'archive') { | |
1617 task = function() { | |
1618 new FileTasks(this, this.params_).mountArchives( | |
1619 [opt_selectionEntry]); | |
1620 }.bind(this); | |
1621 } | 1610 } |
| 1611 } else { |
| 1612 // TODO(mtomasz): Implement remounting archives after crash. |
| 1613 // See: crbug.com/333139 |
1622 } | 1614 } |
1623 | 1615 |
1624 // If there is a task to be run, run it after the scan is completed. | 1616 // If there is a task to be run, run it after the scan is completed. |
1625 if (task) { | 1617 if (task) { |
1626 var listener = function() { | 1618 var listener = function() { |
1627 this.directoryModel_.removeEventListener( | 1619 this.directoryModel_.removeEventListener( |
1628 'scan-completed', listener); | 1620 'scan-completed', listener); |
1629 task(); | 1621 task(); |
1630 }.bind(this); | 1622 }.bind(this); |
1631 this.directoryModel_.addEventListener('scan-completed', listener); | 1623 this.directoryModel_.addEventListener('scan-completed', listener); |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2272 * | 2264 * |
2273 * @param {Event} event The directory-changed event. | 2265 * @param {Event} event The directory-changed event. |
2274 * @private | 2266 * @private |
2275 */ | 2267 */ |
2276 FileManager.prototype.onDirectoryChanged_ = function(event) { | 2268 FileManager.prototype.onDirectoryChanged_ = function(event) { |
2277 this.selectionHandler_.onFileSelectionChanged(); | 2269 this.selectionHandler_.onFileSelectionChanged(); |
2278 this.ui_.searchBox.clear(); | 2270 this.ui_.searchBox.clear(); |
2279 // TODO(mtomasz): Use Entry.toURL() instead of fullPath. | 2271 // TODO(mtomasz): Use Entry.toURL() instead of fullPath. |
2280 util.updateAppState( | 2272 util.updateAppState( |
2281 this.getCurrentDirectoryEntry() && | 2273 this.getCurrentDirectoryEntry() && |
2282 this.getCurrentDirectoryEntry().fullPath); | 2274 this.getCurrentDirectoryEntry().fullPath, '' /* opt_param */); |
2283 | 2275 |
2284 // If the current directory is moved from the device's volume, do not | 2276 // If the current directory is moved from the device's volume, do not |
2285 // automatically close the window on device removal. | 2277 // automatically close the window on device removal. |
2286 if (event.previousDirEntry && | 2278 if (event.previousDirEntry && |
2287 PathUtil.getRootPath(event.previousDirEntry.fullPath) != | 2279 PathUtil.getRootPath(event.previousDirEntry.fullPath) != |
2288 PathUtil.getRootPath(event.newDirEntry.fullPath)) | 2280 PathUtil.getRootPath(event.newDirEntry.fullPath)) |
2289 this.closeOnUnmount_ = false; | 2281 this.closeOnUnmount_ = false; |
2290 | 2282 |
2291 if (this.commandHandler) | 2283 if (this.commandHandler) |
2292 this.commandHandler.updateAvailability(); | 2284 this.commandHandler.updateAvailability(); |
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3656 callback(this.preferences_); | 3648 callback(this.preferences_); |
3657 return; | 3649 return; |
3658 } | 3650 } |
3659 | 3651 |
3660 chrome.fileBrowserPrivate.getPreferences(function(prefs) { | 3652 chrome.fileBrowserPrivate.getPreferences(function(prefs) { |
3661 this.preferences_ = prefs; | 3653 this.preferences_ = prefs; |
3662 callback(prefs); | 3654 callback(prefs); |
3663 }.bind(this)); | 3655 }.bind(this)); |
3664 }; | 3656 }; |
3665 })(); | 3657 })(); |
OLD | NEW |