| 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 /** | 5 /** |
| 6 * FileManager constructor. | 6 * FileManager constructor. |
| 7 * | 7 * |
| 8 * FileManager objects encapsulate the functionality of the file selector | 8 * FileManager objects encapsulate the functionality of the file selector |
| 9 * dialogs, as well as the full screen file manager application (though the | 9 * dialogs, as well as the full screen file manager application (though the |
| 10 * latter is not yet implemented). | 10 * latter is not yet implemented). |
| 11 * | 11 * |
| 12 * @constructor | 12 * @constructor |
| 13 * @param {HTMLElement} dialogDom The DOM node containing the prototypical | 13 * @param {HTMLElement} dialogDom The DOM node containing the prototypical |
| 14 * dialog UI. | 14 * dialog UI. |
| 15 */ | 15 */ |
| 16 function FileManager(dialogDom) { | 16 function FileManager(dialogDom) { |
| 17 this.dialogDom_ = dialogDom; | 17 this.dialogDom_ = dialogDom; |
| 18 this.filesystem_ = null; | 18 this.filesystem_ = null; |
| 19 this.params_ = location.search ? | 19 this.params_ = location.search ? |
| 20 JSON.parse(decodeURIComponent(location.search.substr(1))) : | 20 JSON.parse(decodeURIComponent(location.search.substr(1))) : |
| 21 {}; | 21 window.launchData || {}; |
| 22 this.listType_ = null; | 22 this.listType_ = null; |
| 23 this.showDelayTimeout_ = null; | 23 this.showDelayTimeout_ = null; |
| 24 | 24 |
| 25 this.filesystemObserverId_ = null; | 25 this.filesystemObserverId_ = null; |
| 26 this.gdataObserverId_ = null; | 26 this.gdataObserverId_ = null; |
| 27 | 27 |
| 28 this.document_ = dialogDom.ownerDocument; | 28 this.document_ = dialogDom.ownerDocument; |
| 29 this.dialogType = this.params_.type || DialogType.FULL_PAGE; | 29 this.dialogType = this.params_.type || DialogType.FULL_PAGE; |
| 30 this.startupPrefName_ = 'file-manager-' + this.dialogType; | 30 this.startupPrefName_ = 'file-manager-' + this.dialogType; |
| 31 | 31 |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 this.selectionHandler_)); | 811 this.selectionHandler_)); |
| 812 | 812 |
| 813 this.initTable_(); | 813 this.initTable_(); |
| 814 this.initGrid_(); | 814 this.initGrid_(); |
| 815 this.initRootsList_(); | 815 this.initRootsList_(); |
| 816 | 816 |
| 817 this.setListType(prefs.listType || FileManager.ListType.DETAIL); | 817 this.setListType(prefs.listType || FileManager.ListType.DETAIL); |
| 818 | 818 |
| 819 this.textSearchState_ = {text: '', date: new Date()}; | 819 this.textSearchState_ = {text: '', date: new Date()}; |
| 820 | 820 |
| 821 this.closeOnUnmount_ = this.params_.mountTriggered; | 821 this.closeOnUnmount_ = (this.params_.action == 'auto-open'); |
| 822 | 822 |
| 823 if (this.closeOnUnmount_) { | 823 if (this.closeOnUnmount_) { |
| 824 this.volumeManager_.addEventListener('externally-unmounted', | 824 this.volumeManager_.addEventListener('externally-unmounted', |
| 825 this.onExternallyUnmounted_.bind(this)); | 825 this.onExternallyUnmounted_.bind(this)); |
| 826 } | 826 } |
| 827 // Update metadata to change 'Today' and 'Yesterday' dates. | 827 // Update metadata to change 'Today' and 'Yesterday' dates. |
| 828 var today = new Date(); | 828 var today = new Date(); |
| 829 today.setHours(0); | 829 today.setHours(0); |
| 830 today.setMinutes(0); | 830 today.setMinutes(0); |
| 831 today.setSeconds(0); | 831 today.setSeconds(0); |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 if (!path) { | 1266 if (!path) { |
| 1267 path = this.directoryModel_.getDefaultDirectory(); | 1267 path = this.directoryModel_.getDefaultDirectory(); |
| 1268 } else if (path.indexOf('/') == -1) { | 1268 } else if (path.indexOf('/') == -1) { |
| 1269 // Path is a file name. | 1269 // Path is a file name. |
| 1270 path = this.directoryModel_.getDefaultDirectory() + '/' + path; | 1270 path = this.directoryModel_.getDefaultDirectory() + '/' + path; |
| 1271 } | 1271 } |
| 1272 | 1272 |
| 1273 // In the FULL_PAGE mode if the hash path points to a file we might have | 1273 // In the FULL_PAGE mode if the hash path points to a file we might have |
| 1274 // to invoke a task after selecting it. | 1274 // to invoke a task after selecting it. |
| 1275 // If the file path is in params_ we only want to select the file. | 1275 // If the file path is in params_ we only want to select the file. |
| 1276 var invokeHandlers = pageLoading && !this.params_.selectOnly && | 1276 var invokeHandlers = pageLoading && (this.params_.action != 'select') && |
| 1277 this.dialogType == DialogType.FULL_PAGE && | 1277 this.dialogType == DialogType.FULL_PAGE; |
| 1278 !!location.hash; | |
| 1279 | 1278 |
| 1280 if (PathUtil.getRootType(path) === RootType.GDATA) { | 1279 if (PathUtil.getRootType(path) === RootType.GDATA) { |
| 1281 var tracker = this.directoryModel_.createDirectoryChangeTracker(); | 1280 var tracker = this.directoryModel_.createDirectoryChangeTracker(); |
| 1282 // Expected finish of setupPath to GData. | 1281 // Expected finish of setupPath to GData. |
| 1283 tracker.exceptInitialChange = true; | 1282 tracker.exceptInitialChange = true; |
| 1284 tracker.start(); | 1283 tracker.start(); |
| 1285 if (!this.isGDataEnabled()) { | 1284 if (!this.isGDataEnabled()) { |
| 1286 if (pageLoading) | 1285 if (pageLoading) |
| 1287 this.show_(); | 1286 this.show_(); |
| 1288 this.directoryModel_.setupDefaultPath(); | 1287 this.directoryModel_.setupDefaultPath(); |
| (...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3340 return this.directoryModel_.getFileList(); | 3339 return this.directoryModel_.getFileList(); |
| 3341 }; | 3340 }; |
| 3342 | 3341 |
| 3343 /** | 3342 /** |
| 3344 * @return {cr.ui.List} Current list object. | 3343 * @return {cr.ui.List} Current list object. |
| 3345 */ | 3344 */ |
| 3346 FileManager.prototype.getCurrentList = function() { | 3345 FileManager.prototype.getCurrentList = function() { |
| 3347 return this.currentList_; | 3346 return this.currentList_; |
| 3348 }; | 3347 }; |
| 3349 })(); | 3348 })(); |
| OLD | NEW |