Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 10252005: [File Manager] Fixed an exception when ejecting a removable drive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2525 matching lines...) Expand 10 before | Expand all | Expand 10 after
2536 }; 2536 };
2537 2537
2538 FileManager.prototype.isOnReadonlyDirectory = function() { 2538 FileManager.prototype.isOnReadonlyDirectory = function() {
2539 return this.directoryModel_.isReadOnly(); 2539 return this.directoryModel_.isReadOnly();
2540 }; 2540 };
2541 2541
2542 /** 2542 /**
2543 * Event handler called when some volume was mounted or unmouted. 2543 * Event handler called when some volume was mounted or unmouted.
2544 */ 2544 */
2545 FileManager.prototype.onMountCompleted_ = function(event) { 2545 FileManager.prototype.onMountCompleted_ = function(event) {
2546 var self = this;
2547
2548 var changeDirectoryTo = null; 2546 var changeDirectoryTo = null;
2549 2547
2550 if (event && event.mountType == 'gdata') { 2548 if (event && event.mountType == 'gdata') {
2551 metrics.recordInterval('Load.GData'); 2549 metrics.recordInterval('Load.GData');
2552 console.log('GData mounted'); 2550 console.log('GData mounted');
2553 if (event.status == 'success') { 2551 if (event.status == 'success') {
2554 this.gdataMounted_ = true; 2552 this.gdataMounted_ = true;
2555 this.gdataMountInfo_ = { 2553 this.gdataMountInfo_ = {
2556 'mountPath': event.mountPath, 2554 'mountPath': event.mountPath,
2557 'sourceUrl': event.sourceUrl, 2555 'sourceUrl': event.sourceUrl,
(...skipping 18 matching lines...) Expand all
2576 this.onGDataUnreachable_('GData mount failed: ' + event.status); 2574 this.onGDataUnreachable_('GData mount failed: ' + event.status);
2577 if (this.setupCurrentDirectoryPostponed_) { 2575 if (this.setupCurrentDirectoryPostponed_) {
2578 this.setupCurrentDirectoryPostponed_(true /* cancel */); 2576 this.setupCurrentDirectoryPostponed_(true /* cancel */);
2579 // Change to unmounted GData root. 2577 // Change to unmounted GData root.
2580 changeDirectoryTo = '/' + DirectoryModel.GDATA_DIRECTORY; 2578 changeDirectoryTo = '/' + DirectoryModel.GDATA_DIRECTORY;
2581 } 2579 }
2582 } 2580 }
2583 } 2581 }
2584 2582
2585 chrome.fileBrowserPrivate.getMountPoints(function(mountPoints) { 2583 chrome.fileBrowserPrivate.getMountPoints(function(mountPoints) {
2586 self.setMountPoints_(mountPoints); 2584 this.setMountPoints_(mountPoints);
2587 2585
2588 if (event.eventType == 'mount') { 2586 if (event.eventType == 'mount') {
2589 // Mount request finished - remove it. 2587 // Mount request finished - remove it.
2590 // Currently we only request mounts for archive files. 2588 // Currently we only request mounts for archive files.
2591 var index = self.mountRequests_.indexOf(event.sourceUrl); 2589 var index = this.mountRequests_.indexOf(event.sourceUrl);
2592 if (index != -1) { 2590 if (index != -1) {
2593 self.mountRequests_.splice(index, 1); 2591 this.mountRequests_.splice(index, 1);
2594 if (event.status == 'success') { 2592 if (event.status == 'success') {
2595 // Successful mount requested from this tab, go to the drive root. 2593 // Successful mount requested from this tab, go to the drive root.
2596 changeDirectoryTo = event.mountPath; 2594 changeDirectoryTo = event.mountPath;
2597 } else { 2595 } else {
2598 // Request initiated from this tab failed, report the error. 2596 // Request initiated from this tab failed, report the error.
2599 var fileName = event.sourceUrl.split('/').pop(); 2597 var fileName = event.sourceUrl.split('/').pop();
2600 self.alert.show( 2598 this.alert.show(
2601 strf('ARCHIVE_MOUNT_FAILED', fileName, event.status)); 2599 strf('ARCHIVE_MOUNT_FAILED', fileName, event.status));
2602 } 2600 }
2603 } 2601 }
2604 } 2602 }
2605 2603
2606 if (event.eventType == 'unmount') { 2604 if (event.eventType == 'unmount') {
2607 // Unmount request finished - remove it. 2605 // Unmount request finished - remove it.
2608 var index = self.unmountRequests_.indexOf(event.mountPath); 2606 var index = this.unmountRequests_.indexOf(event.mountPath);
2609 if (index != -1) { 2607 if (index != -1) {
2610 self.unmountRequests_.splice(index, 1); 2608 this.unmountRequests_.splice(index, 1);
2611 if (event.status != 'success') 2609 if (event.status != 'success')
2612 self.alert.show(strf('UNMOUNT_FAILED', event.status)); 2610 this.alert.show(strf('UNMOUNT_FAILED', event.status));
2613 } 2611 }
2614 2612
2615 if (event.status == 'success' && 2613 if (event.status == 'success' &&
2616 event.mountPath == self.directoryModel_.getCurrentRootPath()) { 2614 event.mountPath == this.directoryModel_.getCurrentRootPath()) {
2617 if (self.params_.mountTriggered && index == -1) { 2615 if (this.params_.mountTriggered && index == -1) {
2618 // This device mount was the reason this File Manager instance was 2616 // This device mount was the reason this File Manager instance was
2619 // created. Now the device is unmounted from another instance 2617 // created. Now the device is unmounted from another instance
2620 // or the user removed the device manually. Close this instance. 2618 // or the user removed the device manually. Close this instance.
2621 // window.close() sometimes doesn't work. 2619 // window.close() sometimes doesn't work.
2622 chrome.tabs.getCurrent(function(tab) { 2620 chrome.tabs.getCurrent(function(tab) {
2623 chrome.tabs.remove(tab.id); 2621 chrome.tabs.remove(tab.id);
2624 }); 2622 });
2625 return; 2623 return;
2626 } 2624 }
2627 // Current directory just unmounted. Move to the 'Downloads'. 2625 // Current directory just unmounted. Move to the 'Downloads'.
2628 changeDirectoryTo = this.directoryModel_.getDefaultDirectory(); 2626 changeDirectoryTo = this.directoryModel_.getDefaultDirectory();
2629 } 2627 }
2630 } 2628 }
2631 2629
2632 // Even if something failed root list should be rescanned. 2630 // Even if something failed root list should be rescanned.
2633 // Failed mounts can "give" us new devices which might be formatted, 2631 // Failed mounts can "give" us new devices which might be formatted,
2634 // so we have to refresh root list then. 2632 // so we have to refresh root list then.
2635 self.directoryModel_.updateRoots(function() { 2633 this.directoryModel_.updateRoots(function() {
2636 if (changeDirectoryTo) { 2634 if (changeDirectoryTo) {
2637 self.directoryModel_.changeDirectory(changeDirectoryTo); 2635 this.directoryModel_.changeDirectory(changeDirectoryTo);
2638 } 2636 }
2639 }, self.gdataMounted_); 2637 }.bind(this), this.gdataMounted_);
2640 }); 2638 }.bind(this));
2641 }; 2639 };
2642 2640
2643 /** 2641 /**
2644 * Event handler called when some internal task should be executed. 2642 * Event handler called when some internal task should be executed.
2645 */ 2643 */
2646 FileManager.prototype.onFileTaskExecute_ = function(id, urls) { 2644 FileManager.prototype.onFileTaskExecute_ = function(id, urls) {
2647 if (id == 'play') { 2645 if (id == 'play') {
2648 var position = 0; 2646 var position = 0;
2649 if (urls.length == 1) { 2647 if (urls.length == 1) {
2650 // If just a single audio file is selected pass along every audio file 2648 // If just a single audio file is selected pass along every audio file
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
4366 4364
4367 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner); 4365 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner);
4368 this.directoryModel_.addEventListener('rescan-completed', maybeShowBanner); 4366 this.directoryModel_.addEventListener('rescan-completed', maybeShowBanner);
4369 4367
4370 var style = this.document_.createElement('link'); 4368 var style = this.document_.createElement('link');
4371 style.rel = 'stylesheet'; 4369 style.rel = 'stylesheet';
4372 style.href = 'css/gdrive_welcome.css'; 4370 style.href = 'css/gdrive_welcome.css';
4373 this.document_.head.appendChild(style); 4371 this.document_.head.appendChild(style);
4374 }; 4372 };
4375 })(); 4373 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698