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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 this.selectionHandler_)); | 810 this.selectionHandler_)); |
811 | 811 |
812 this.initTable_(); | 812 this.initTable_(); |
813 this.initGrid_(); | 813 this.initGrid_(); |
814 this.initRootsList_(); | 814 this.initRootsList_(); |
815 | 815 |
816 this.setListType(prefs.listType || FileManager.ListType.DETAIL); | 816 this.setListType(prefs.listType || FileManager.ListType.DETAIL); |
817 | 817 |
818 this.textSearchState_ = {text: '', date: new Date()}; | 818 this.textSearchState_ = {text: '', date: new Date()}; |
819 | 819 |
820 this.closeOnUnmount_ = this.params_.mountTriggered; | 820 this.closeOnUnmount_ = (this.params_.action == 'auto-open'); |
821 | 821 |
822 if (this.closeOnUnmount_) { | 822 if (this.closeOnUnmount_) { |
823 this.volumeManager_.addEventListener('externally-unmounted', | 823 this.volumeManager_.addEventListener('externally-unmounted', |
824 this.onExternallyUnmounted_.bind(this)); | 824 this.onExternallyUnmounted_.bind(this)); |
825 } | 825 } |
826 // Update metadata to change 'Today' and 'Yesterday' dates. | 826 // Update metadata to change 'Today' and 'Yesterday' dates. |
827 var today = new Date(); | 827 var today = new Date(); |
828 today.setHours(0); | 828 today.setHours(0); |
829 today.setMinutes(0); | 829 today.setMinutes(0); |
830 today.setSeconds(0); | 830 today.setSeconds(0); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 if (!path) { | 1265 if (!path) { |
1266 path = this.directoryModel_.getDefaultDirectory(); | 1266 path = this.directoryModel_.getDefaultDirectory(); |
1267 } else if (path.indexOf('/') == -1) { | 1267 } else if (path.indexOf('/') == -1) { |
1268 // Path is a file name. | 1268 // Path is a file name. |
1269 path = this.directoryModel_.getDefaultDirectory() + '/' + path; | 1269 path = this.directoryModel_.getDefaultDirectory() + '/' + path; |
1270 } | 1270 } |
1271 | 1271 |
1272 // In the FULL_PAGE mode if the hash path points to a file we might have | 1272 // In the FULL_PAGE mode if the hash path points to a file we might have |
1273 // to invoke a task after selecting it. | 1273 // to invoke a task after selecting it. |
1274 // If the file path is in params_ we only want to select the file. | 1274 // If the file path is in params_ we only want to select the file. |
1275 var invokeHandlers = pageLoading && !this.params_.selectOnly && | 1275 var invokeHandlers = pageLoading && (this.params_.action != 'select') && |
1276 this.dialogType == DialogType.FULL_PAGE && | 1276 this.dialogType == DialogType.FULL_PAGE; |
1277 !!location.hash; | |
1278 | 1277 |
1279 if (PathUtil.getRootType(path) === RootType.GDATA) { | 1278 if (PathUtil.getRootType(path) === RootType.GDATA) { |
1280 var tracker = this.directoryModel_.createDirectoryChangeTracker(); | 1279 var tracker = this.directoryModel_.createDirectoryChangeTracker(); |
1281 // Expected finish of setupPath to GData. | 1280 // Expected finish of setupPath to GData. |
1282 tracker.exceptInitialChange = true; | 1281 tracker.exceptInitialChange = true; |
1283 tracker.start(); | 1282 tracker.start(); |
1284 if (!this.isGDataEnabled()) { | 1283 if (!this.isGDataEnabled()) { |
1285 if (pageLoading) | 1284 if (pageLoading) |
1286 this.show_(); | 1285 this.show_(); |
1287 this.directoryModel_.setupDefaultPath(); | 1286 this.directoryModel_.setupDefaultPath(); |
(...skipping 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3332 return this.directoryModel_.getFileList(); | 3331 return this.directoryModel_.getFileList(); |
3333 }; | 3332 }; |
3334 | 3333 |
3335 /** | 3334 /** |
3336 * @return {cr.ui.List} Current list object. | 3335 * @return {cr.ui.List} Current list object. |
3337 */ | 3336 */ |
3338 FileManager.prototype.getCurrentList = function() { | 3337 FileManager.prototype.getCurrentList = function() { |
3339 return this.currentList_; | 3338 return this.currentList_; |
3340 }; | 3339 }; |
3341 })(); | 3340 })(); |
OLD | NEW |