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). |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // -------------------------------------------------------------------------- | 244 // -------------------------------------------------------------------------- |
245 // Miscellaneous FileManager's states. | 245 // Miscellaneous FileManager's states. |
246 | 246 |
247 /** | 247 /** |
248 * Queue for ordering FileManager's initialization process. | 248 * Queue for ordering FileManager's initialization process. |
249 * @type {!AsyncUtil.Group} | 249 * @type {!AsyncUtil.Group} |
250 * @private | 250 * @private |
251 */ | 251 */ |
252 this.initializeQueue_ = new AsyncUtil.Group(); | 252 this.initializeQueue_ = new AsyncUtil.Group(); |
253 | 253 |
| 254 /** |
| 255 * Indicates whether cloud import is enabled. This is initialized in |
| 256 * #initSettings. |
| 257 * @private {?boolean} |
| 258 */ |
| 259 this.importEnabled_ = null; |
| 260 |
254 // Object.seal() has big performance/memory overhead for now, so we use | 261 // Object.seal() has big performance/memory overhead for now, so we use |
255 // Object.preventExtensions() here. crbug.com/412239. | 262 // Object.preventExtensions() here. crbug.com/412239. |
256 Object.preventExtensions(this); | 263 Object.preventExtensions(this); |
257 } | 264 } |
258 | 265 |
259 FileManager.prototype = /** @struct */ { | 266 FileManager.prototype = /** @struct */ { |
260 __proto__: cr.EventTarget.prototype, | 267 __proto__: cr.EventTarget.prototype, |
261 /** | 268 /** |
262 * @return {DirectoryModel} | 269 * @return {DirectoryModel} |
263 */ | 270 */ |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 */ | 354 */ |
348 get ui() { | 355 get ui() { |
349 return this.ui_; | 356 return this.ui_; |
350 } | 357 } |
351 }; | 358 }; |
352 | 359 |
353 // Anonymous "namespace". | 360 // Anonymous "namespace". |
354 (function() { | 361 (function() { |
355 FileManager.prototype.initSettings_ = function(callback) { | 362 FileManager.prototype.initSettings_ = function(callback) { |
356 this.appStateController_ = new AppStateController(this.dialogType); | 363 this.appStateController_ = new AppStateController(this.dialogType); |
357 this.appStateController_.loadInitialViewOptions().then(callback); | 364 var whenViewOptionsLoaded = |
| 365 this.appStateController_.loadInitialViewOptions(); |
| 366 var whenImportFlagLoaded = importer.importEnabled().then( |
| 367 function(enabled) { |
| 368 this.importEnabled_ = enabled; |
| 369 }.bind(this)); |
| 370 |
| 371 Promise.all([ |
| 372 whenViewOptionsLoaded, |
| 373 whenImportFlagLoaded |
| 374 ]).then(callback); |
358 }; | 375 }; |
359 | 376 |
360 /** | 377 /** |
361 * One time initialization for the file system and related things. | 378 * One time initialization for the file system and related things. |
362 * | 379 * |
363 * @param {function()} callback Completion callback. | 380 * @param {function()} callback Completion callback. |
364 * @private | 381 * @private |
365 */ | 382 */ |
366 FileManager.prototype.initFileSystemUI_ = function(callback) { | 383 FileManager.prototype.initFileSystemUI_ = function(callback) { |
367 this.ui_.listContainer.startBatchUpdates(); | 384 this.ui_.listContainer.startBatchUpdates(); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 assert(this.dialogDom_); | 727 assert(this.dialogDom_); |
711 | 728 |
712 // Cache nodes we'll be manipulating. | 729 // Cache nodes we'll be manipulating. |
713 var dom = this.dialogDom_; | 730 var dom = this.dialogDom_; |
714 assert(dom); | 731 assert(dom); |
715 | 732 |
716 // Initialize the dialog. | 733 // Initialize the dialog. |
717 FileManagerDialogBase.setFileManager(this); | 734 FileManagerDialogBase.setFileManager(this); |
718 | 735 |
719 var table = queryRequiredElement(dom, '.detail-table'); | 736 var table = queryRequiredElement(dom, '.detail-table'); |
720 // TODO(smckay): Work out the cloud import UI when in list view. | 737 table.importEnabled = this.importEnabled_; |
721 FileTable.decorate( | 738 FileTable.decorate( |
722 table, | 739 table, |
723 this.metadataCache_, | 740 this.metadataCache_, |
724 this.volumeManager_, | 741 this.volumeManager_, |
| 742 this.historyLoader_, |
725 this.dialogType == DialogType.FULL_PAGE); | 743 this.dialogType == DialogType.FULL_PAGE); |
726 var grid = queryRequiredElement(dom, '.thumbnail-grid'); | 744 var grid = queryRequiredElement(dom, '.thumbnail-grid'); |
727 FileGrid.decorate( | 745 FileGrid.decorate( |
728 grid, | 746 grid, |
729 this.metadataCache_, | 747 this.metadataCache_, |
730 this.volumeManager_, | 748 this.volumeManager_, |
731 this.historyLoader_); | 749 this.historyLoader_); |
732 | 750 |
733 this.addHistoryObserver_(); | 751 this.addHistoryObserver_(); |
734 | 752 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 // Ignore any entry that isn't an immediate child of the | 814 // Ignore any entry that isn't an immediate child of the |
797 // current directory. | 815 // current directory. |
798 util.isChildEntry(event.entry, this.getCurrentDirectoryEntry()) | 816 util.isChildEntry(event.entry, this.getCurrentDirectoryEntry()) |
799 .then( | 817 .then( |
800 /** | 818 /** |
801 * @param {boolean} isChild | 819 * @param {boolean} isChild |
802 * @this {FileManager} | 820 * @this {FileManager} |
803 */ | 821 */ |
804 function(isChild) { | 822 function(isChild) { |
805 if (isChild) { | 823 if (isChild) { |
806 // TODO(smckay): Update listview when that view is visible. | |
807 this.ui_.listContainer.grid.updateListItemsMetadata( | 824 this.ui_.listContainer.grid.updateListItemsMetadata( |
808 'import-history', | 825 'import-history', |
809 [event.entry]); | 826 [event.entry]); |
| 827 this.ui_.listContainer.table.updateListItemsMetadata( |
| 828 'import-history', |
| 829 [event.entry]); |
810 } | 830 } |
811 }.bind(this)); | 831 }.bind(this)); |
812 }; | 832 }; |
813 | 833 |
814 /** | 834 /** |
815 * Constructs table and grid (heavy operation). | 835 * Constructs table and grid (heavy operation). |
816 * @private | 836 * @private |
817 **/ | 837 **/ |
818 FileManager.prototype.initFileList_ = function() { | 838 FileManager.prototype.initFileList_ = function() { |
819 var singleSelection = | 839 var singleSelection = |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 out += this.initializeQueue_.pendingTasks[key].toString() + '\n'; | 1291 out += this.initializeQueue_.pendingTasks[key].toString() + '\n'; |
1272 }.bind(this)); | 1292 }.bind(this)); |
1273 | 1293 |
1274 out += '2. VolumeManagerWrapper\n' + | 1294 out += '2. VolumeManagerWrapper\n' + |
1275 this.volumeManager_.toString() + '\n'; | 1295 this.volumeManager_.toString() + '\n'; |
1276 | 1296 |
1277 out += 'End of debug information.'; | 1297 out += 'End of debug information.'; |
1278 console.log(out); | 1298 console.log(out); |
1279 }; | 1299 }; |
1280 })(); | 1300 })(); |
OLD | NEW |