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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 this.unmountedPanel_.setAttribute('loading', true); | 687 this.unmountedPanel_.setAttribute('loading', true); |
688 } | 688 } |
689 | 689 |
690 // If the user changed to another directory and then back to GData we | 690 // If the user changed to another directory and then back to GData we |
691 // re-enter this method while the timer is still active. In this case | 691 // re-enter this method while the timer is still active. In this case |
692 // we only update the UI but do not request the mount again. | 692 // we only update the UI but do not request the mount again. |
693 if (this.gdataLoadingTimer_) | 693 if (this.gdataLoadingTimer_) |
694 return; | 694 return; |
695 | 695 |
696 metrics.startInterval('Load.GData'); | 696 metrics.startInterval('Load.GData'); |
697 chrome.fileBrowserPrivate.addMount('', 'gdata', {}); | 697 chrome.fileBrowserPrivate.addMount('', 'gdata', {}, |
| 698 function(sourcePath) {}); |
698 | 699 |
699 // This timer could fire before the mount succeeds. We will silently | 700 // This timer could fire before the mount succeeds. We will silently |
700 // replace the error message with the correct directory contents. | 701 // replace the error message with the correct directory contents. |
701 this.gdataLoadingTimer_ = setTimeout(function() { | 702 this.gdataLoadingTimer_ = setTimeout(function() { |
702 this.gdataLoadingTimer_ = null; | 703 this.gdataLoadingTimer_ = null; |
703 this.onGDataUnreachable_('GData load timeout'); | 704 this.onGDataUnreachable_('GData load timeout'); |
704 }.bind(this), | 705 }.bind(this), |
705 15 * 60 * 1000); | 706 15 * 60 * 1000); |
706 }; | 707 }; |
707 | 708 |
(...skipping 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2543 | 2544 |
2544 var changeDirectoryTo = null; | 2545 var changeDirectoryTo = null; |
2545 | 2546 |
2546 if (event && event.mountType == 'gdata') { | 2547 if (event && event.mountType == 'gdata') { |
2547 metrics.recordInterval('Load.GData'); | 2548 metrics.recordInterval('Load.GData'); |
2548 console.log('GData mounted'); | 2549 console.log('GData mounted'); |
2549 if (event.status == 'success') { | 2550 if (event.status == 'success') { |
2550 this.gdataMounted_ = true; | 2551 this.gdataMounted_ = true; |
2551 this.gdataMountInfo_ = { | 2552 this.gdataMountInfo_ = { |
2552 'mountPath': event.mountPath, | 2553 'mountPath': event.mountPath, |
2553 'sourceUrl': event.sourceUrl, | 2554 'sourcePath': event.sourcePath, |
2554 'mountType': event.mountType, | 2555 'mountType': event.mountType, |
2555 'mountCondition': event.status | 2556 'mountCondition': event.status |
2556 }; | 2557 }; |
2557 // Not calling clearGDataLoadingTimer_ here because we want to keep | 2558 // Not calling clearGDataLoadingTimer_ here because we want to keep |
2558 // "Loading Google Docs" message until the directory loads. It is OK if | 2559 // "Loading Google Docs" message until the directory loads. It is OK if |
2559 // the timer fires after the mount because onDirectoryChanged_ will hide | 2560 // the timer fires after the mount because onDirectoryChanged_ will hide |
2560 // the unmounted panel. | 2561 // the unmounted panel. |
2561 if (this.setupCurrentDirectoryPostponed_) { | 2562 if (this.setupCurrentDirectoryPostponed_) { |
2562 this.setupCurrentDirectoryPostponed_(false /* execute */); | 2563 this.setupCurrentDirectoryPostponed_(false /* execute */); |
2563 } else if (this.isOnGData() && | 2564 } else if (this.isOnGData() && |
(...skipping 13 matching lines...) Expand all Loading... |
2577 } | 2578 } |
2578 } | 2579 } |
2579 } | 2580 } |
2580 | 2581 |
2581 chrome.fileBrowserPrivate.getMountPoints(function(mountPoints) { | 2582 chrome.fileBrowserPrivate.getMountPoints(function(mountPoints) { |
2582 self.setMountPoints_(mountPoints); | 2583 self.setMountPoints_(mountPoints); |
2583 | 2584 |
2584 if (event.eventType == 'mount') { | 2585 if (event.eventType == 'mount') { |
2585 // Mount request finished - remove it. | 2586 // Mount request finished - remove it. |
2586 // Currently we only request mounts for archive files. | 2587 // Currently we only request mounts for archive files. |
2587 var index = self.mountRequests_.indexOf(event.sourceUrl); | 2588 var index = self.mountRequests_.indexOf(event.sourcePath); |
2588 if (index != -1) { | 2589 if (index != -1) { |
2589 self.mountRequests_.splice(index, 1); | 2590 self.mountRequests_.splice(index, 1); |
2590 if (event.status == 'success') { | 2591 if (event.status == 'success') { |
2591 // Successful mount requested from this tab, go to the drive root. | 2592 // Successful mount requested from this tab, go to the drive root. |
2592 changeDirectoryTo = event.mountPath; | 2593 changeDirectoryTo = event.mountPath; |
2593 } else { | 2594 } else { |
2594 // Request initiated from this tab failed, report the error. | 2595 // Request initiated from this tab failed, report the error. |
2595 var fileName = event.sourceUrl.split('/').pop(); | 2596 var fileName = event.sourcePath.split('/').pop(); |
2596 self.alert.show( | 2597 self.alert.show( |
2597 strf('ARCHIVE_MOUNT_FAILED', fileName, event.status)); | 2598 strf('ARCHIVE_MOUNT_FAILED', fileName, event.status)); |
2598 } | 2599 } |
2599 } | 2600 } |
2600 } | 2601 } |
2601 | 2602 |
2602 if (event.eventType == 'unmount') { | 2603 if (event.eventType == 'unmount') { |
2603 // Unmount request finished - remove it. | 2604 // Unmount request finished - remove it. |
2604 var index = self.unmountRequests_.indexOf(event.mountPath); | 2605 var index = self.unmountRequests_.indexOf(event.mountPath); |
2605 if (index != -1) { | 2606 if (index != -1) { |
2606 self.unmountRequests_.splice(index, 1); | 2607 self.unmountRequests_.splice(index, 1); |
2607 if (event.status != 'success') | 2608 if (event.status != 'success') |
2608 self.alert.show(strf('UNMOUNT_FAILED', event.status)); | 2609 self.alert.show(strf('UNMOUNT_FAILED', event.status)); |
2609 } | 2610 } |
2610 | 2611 |
2611 if (event.status == 'success' && | 2612 if (event.status == 'success' && |
2612 event.mountPath == self.directoryModel_.getCurrentRootPath()) { | 2613 event.mountPath == self.directoryModel_.getCurrentRootPath()) { |
2613 if (self.params_.mountTriggered && index == -1) { | 2614 if (self.params_.mountTriggered && index == -1) { |
2614 // This device mount was the reason this File Manager instance was | 2615 // This device mount was the reason this File Manager instance was |
2615 // created. Now the device is unmounted from another instance | 2616 // created. Now the device is unmounted from another instance |
2616 // or the user removed the device manually. Close this instance. | 2617 // or the user removed the device manually. Close this instance. |
2617 // window.close() sometimes doesn't work. | 2618 // window.close() sometimes doesn't work. |
2618 chrome.tabs.getCurrent(function(tab) { | 2619 chrome.tabs.getCurrent(function(tab) { |
2619 chrome.tabs.remove(tab.id); | 2620 chrome.tabs.remove(tab.id); |
2620 }); | 2621 }); |
2621 return; | 2622 return; |
2622 } | 2623 } |
2623 // Current directory just unmounted. Move to the 'Downloads'. | 2624 // Current directory just unmounted. Move to the 'Downloads'. |
2624 changeDirectoryTo = this.directoryModel_.getDefaultDirectory(); | 2625 changeDirectoryTo = self.directoryModel_.getDefaultDirectory(); |
2625 } | 2626 } |
2626 } | 2627 } |
2627 | 2628 |
2628 // Even if something failed root list should be rescanned. | 2629 // Even if something failed root list should be rescanned. |
2629 // Failed mounts can "give" us new devices which might be formatted, | 2630 // Failed mounts can "give" us new devices which might be formatted, |
2630 // so we have to refresh root list then. | 2631 // so we have to refresh root list then. |
2631 self.directoryModel_.updateRoots(function() { | 2632 self.directoryModel_.updateRoots(function() { |
2632 if (changeDirectoryTo) { | 2633 if (changeDirectoryTo) { |
2633 self.directoryModel_.changeDirectory(changeDirectoryTo); | 2634 self.directoryModel_.changeDirectory(changeDirectoryTo); |
2634 } | 2635 } |
(...skipping 15 matching lines...) Expand all Loading... |
2650 position = urls.indexOf(selectedUrl); | 2651 position = urls.indexOf(selectedUrl); |
2651 } | 2652 } |
2652 chrome.mediaPlayerPrivate.play(urls, position); | 2653 chrome.mediaPlayerPrivate.play(urls, position); |
2653 } else if (id == 'mount-archive') { | 2654 } else if (id == 'mount-archive') { |
2654 var self = this; | 2655 var self = this; |
2655 this.resolveSelectResults_(urls, function(urls) { | 2656 this.resolveSelectResults_(urls, function(urls) { |
2656 for (var index = 0; index < urls.length; ++index) { | 2657 for (var index = 0; index < urls.length; ++index) { |
2657 // Url in MountCompleted event won't be escaped, so let's make sure | 2658 // Url in MountCompleted event won't be escaped, so let's make sure |
2658 // we don't use escaped one in mountRequests_. | 2659 // we don't use escaped one in mountRequests_. |
2659 var unescapedUrl = unescape(urls[index]); | 2660 var unescapedUrl = unescape(urls[index]); |
2660 self.mountRequests_.push(unescapedUrl); | 2661 chrome.fileBrowserPrivate.addMount(unescapedUrl, 'file', {}, |
2661 chrome.fileBrowserPrivate.addMount(unescapedUrl, 'file', {}); | 2662 function(sourcePath) { |
| 2663 self.mountRequests_.push(sourcePath); |
| 2664 }); |
2662 } | 2665 } |
2663 }); | 2666 }); |
2664 } else if (id == 'format-device') { | 2667 } else if (id == 'format-device') { |
2665 this.confirm.show(str('FORMATTING_WARNING'), function() { | 2668 this.confirm.show(str('FORMATTING_WARNING'), function() { |
2666 chrome.fileBrowserPrivate.formatDevice(urls[0]); | 2669 chrome.fileBrowserPrivate.formatDevice(urls[0]); |
2667 }); | 2670 }); |
2668 } else if (id == 'gallery') { | 2671 } else if (id == 'gallery') { |
2669 this.openGallery_(urls); | 2672 this.openGallery_(urls); |
2670 } else if (id == 'view-pdf' || id == 'view-in-browser' || | 2673 } else if (id == 'view-pdf' || id == 'view-in-browser' || |
2671 id == 'install-crx' || id == 'open-hosted') { | 2674 id == 'install-crx' || id == 'open-hosted') { |
(...skipping 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4362 | 4365 |
4363 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner); | 4366 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner); |
4364 this.directoryModel_.addEventListener('rescan-completed', maybeShowBanner); | 4367 this.directoryModel_.addEventListener('rescan-completed', maybeShowBanner); |
4365 | 4368 |
4366 var style = this.document_.createElement('link'); | 4369 var style = this.document_.createElement('link'); |
4367 style.rel = 'stylesheet'; | 4370 style.rel = 'stylesheet'; |
4368 style.href = 'css/gdrive_welcome.css'; | 4371 style.href = 'css/gdrive_welcome.css'; |
4369 this.document_.head.appendChild(style); | 4372 this.document_.head.appendChild(style); |
4370 }; | 4373 }; |
4371 })(); | 4374 })(); |
OLD | NEW |