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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 this.grid_.endBatchUpdates(); | 532 this.grid_.endBatchUpdates(); |
533 | 533 |
534 // Show the page now unless it's already delayed. | 534 // Show the page now unless it's already delayed. |
535 this.delayShow_(0); | 535 this.delayShow_(0); |
536 | 536 |
537 metrics.recordInterval('Load.DOM'); | 537 metrics.recordInterval('Load.DOM'); |
538 metrics.recordInterval('Load.Total'); | 538 metrics.recordInterval('Load.Total'); |
539 }; | 539 }; |
540 | 540 |
541 FileManager.prototype.initDataTransferOperations_ = function() { | 541 FileManager.prototype.initDataTransferOperations_ = function() { |
542 this.copyManager_ = new FileCopyManager(this.filesystem_.root); | 542 this.copyManager_ = FileCopyManagerWrapper.getInstance( |
543 this.filesystem_.root); | |
543 this.copyManager_.addEventListener('copy-progress', | 544 this.copyManager_.addEventListener('copy-progress', |
544 this.onCopyProgress_.bind(this)); | 545 this.onCopyProgress_.bind(this)); |
545 this.copyManager_.addEventListener('copy-operation-complete', | 546 this.copyManager_.addEventListener('copy-operation-complete', |
546 this.onCopyManagerOperationComplete_.bind(this)); | 547 this.onCopyManagerOperationComplete_.bind(this)); |
547 | 548 |
548 var controller = this.fileTransferController_ = new FileTransferController( | 549 var controller = this.fileTransferController_ = new FileTransferController( |
549 GridItem.bind(null, this, false /* no checkbox */), | 550 GridItem.bind(null, this, false /* no checkbox */), |
550 this.copyManager_, | 551 this.copyManager_, |
551 this.directoryModel_); | 552 this.directoryModel_); |
552 controller.attachDragSource(this.table_.list); | 553 controller.attachDragSource(this.table_.list); |
(...skipping 4083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4636 this.gdataSpaceInfoBar_.style.width = | 4637 this.gdataSpaceInfoBar_.style.width = |
4637 (100 * usedSpace / result.totalSizeKB) + '%'; | 4638 (100 * usedSpace / result.totalSizeKB) + '%'; |
4638 } else { | 4639 } else { |
4639 this.gdataSpaceInfoBar_.style.display = 'none'; | 4640 this.gdataSpaceInfoBar_.style.display = 'none'; |
4640 this.gdataSpaceInfoLabel_.textContent = | 4641 this.gdataSpaceInfoLabel_.textContent = |
4641 str('GDATA_FAILED_SPACE_INFO'); | 4642 str('GDATA_FAILED_SPACE_INFO'); |
4642 } | 4643 } |
4643 }.bind(this)); | 4644 }.bind(this)); |
4644 } | 4645 } |
4645 })(); | 4646 })(); |
4647 | |
4648 var fileCopyManagerWrapper = null; | |
4649 | |
4650 /** | |
4651 * @constructor | |
4652 * @param {DirectoryEntry} root Root directory entry. | |
4653 */ | |
4654 function FileCopyManagerWrapper(root) { | |
4655 var copyManagerPrototype = | |
4656 chrome.extension.getBackgroundPage().FileCopyManager.prototype; | |
4657 | |
4658 for (var property in copyManagerPrototype) { | |
4659 if (this[property] === undefined && | |
4660 typeof copyManagerPrototype[property] === 'function') { | |
4661 this[property] = (function(p) { | |
4662 return function() { | |
4663 var cmInstance = | |
4664 chrome.extension.getBackgroundPage().FileCopyManager.getInstance( | |
4665 root); | |
4666 return cmInstance[p].apply(cmInstance, arguments); | |
4667 } | |
4668 })(property); | |
4669 } | |
4670 } | |
4671 } | |
4672 | |
4673 /** | |
4674 * Extending cr.EventTarget | |
dgozman
2012/07/17 16:10:53
full stop
Oleg Eterevsky
2012/07/17 16:44:13
Done.
| |
4675 */ | |
4676 FileCopyManagerWrapper.prototype.__proto__ = cr.EventTarget.prototype; | |
4677 | |
4678 /** | |
4679 * Create a new instance or get existing instance of FCMW. | |
4680 * @param {DirectoryEntry} root Root directory entry. | |
4681 * @return {FileCopyManagerWrapper} A FileCopyManagerWrapper instance. | |
4682 */ | |
4683 FileCopyManagerWrapper.getInstance = function(root) { | |
4684 if (fileCopyManagerWrapper === null) { | |
4685 fileCopyManagerWrapper = new FileCopyManagerWrapper(root); | |
4686 } | |
4687 return fileCopyManagerWrapper; | |
4688 }; | |
4689 | |
4690 /** | |
4691 * Called be FileCopyManager to raise an event in this instance of FileManager. | |
4692 * @param {string} eventName Event name. | |
4693 * @param {Object} eventArgs Arbitratry field written to event object. | |
4694 */ | |
4695 FileCopyManagerWrapper.prototype.onEvent = function(eventName, eventArgs) { | |
4696 var event = new cr.Event(eventName); | |
4697 for (var arg in eventArgs) | |
4698 if (eventArgs.hasOwnProperty(arg)) | |
4699 event[arg] = eventArgs[arg]; | |
4700 | |
4701 this.dispatchEvent(event); | |
4702 }; | |
4703 | |
OLD | NEW |