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

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

Issue 10231010: gdata: Apply correct mount label when mounting archives in GData (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase 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
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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after
2540 FileManager.prototype.onMountCompleted_ = function(event) { 2541 FileManager.prototype.onMountCompleted_ = function(event) {
2541 var changeDirectoryTo = null; 2542 var changeDirectoryTo = null;
2542 2543
2543 if (event && event.mountType == 'gdata') { 2544 if (event && event.mountType == 'gdata') {
2544 metrics.recordInterval('Load.GData'); 2545 metrics.recordInterval('Load.GData');
2545 console.log('GData mounted'); 2546 console.log('GData mounted');
2546 if (event.status == 'success') { 2547 if (event.status == 'success') {
2547 this.gdataMounted_ = true; 2548 this.gdataMounted_ = true;
2548 this.gdataMountInfo_ = { 2549 this.gdataMountInfo_ = {
2549 'mountPath': event.mountPath, 2550 'mountPath': event.mountPath,
2550 'sourceUrl': event.sourceUrl, 2551 'sourcePath': event.sourcePath,
2551 'mountType': event.mountType, 2552 'mountType': event.mountType,
2552 'mountCondition': event.status 2553 'mountCondition': event.status
2553 }; 2554 };
2554 // Not calling clearGDataLoadingTimer_ here because we want to keep 2555 // Not calling clearGDataLoadingTimer_ here because we want to keep
2555 // "Loading Google Docs" message until the directory loads. It is OK if 2556 // "Loading Google Docs" message until the directory loads. It is OK if
2556 // the timer fires after the mount because onDirectoryChanged_ will hide 2557 // the timer fires after the mount because onDirectoryChanged_ will hide
2557 // the unmounted panel. 2558 // the unmounted panel.
2558 if (this.setupCurrentDirectoryPostponed_) { 2559 if (this.setupCurrentDirectoryPostponed_) {
2559 this.setupCurrentDirectoryPostponed_(false /* execute */); 2560 this.setupCurrentDirectoryPostponed_(false /* execute */);
2560 } else if (this.isOnGData() && 2561 } else if (this.isOnGData() &&
(...skipping 13 matching lines...) Expand all
2574 } 2575 }
2575 } 2576 }
2576 } 2577 }
2577 2578
2578 chrome.fileBrowserPrivate.getMountPoints(function(mountPoints) { 2579 chrome.fileBrowserPrivate.getMountPoints(function(mountPoints) {
2579 this.setMountPoints_(mountPoints); 2580 this.setMountPoints_(mountPoints);
2580 2581
2581 if (event.eventType == 'mount') { 2582 if (event.eventType == 'mount') {
2582 // Mount request finished - remove it. 2583 // Mount request finished - remove it.
2583 // Currently we only request mounts for archive files. 2584 // Currently we only request mounts for archive files.
2584 var index = this.mountRequests_.indexOf(event.sourceUrl); 2585 var index = this.mountRequests_.indexOf(event.sourcePath);
2585 if (index != -1) { 2586 if (index != -1) {
2586 this.mountRequests_.splice(index, 1); 2587 this.mountRequests_.splice(index, 1);
2587 if (event.status == 'success') { 2588 if (event.status == 'success') {
2588 // Successful mount requested from this tab, go to the drive root. 2589 // Successful mount requested from this tab, go to the drive root.
2589 changeDirectoryTo = event.mountPath; 2590 changeDirectoryTo = event.mountPath;
2590 } else { 2591 } else {
2591 // Request initiated from this tab failed, report the error. 2592 // Request initiated from this tab failed, report the error.
2592 var fileName = event.sourceUrl.split('/').pop(); 2593 var fileName = event.sourcePath.split('/').pop();
2593 this.alert.show( 2594 this.alert.show(
2594 strf('ARCHIVE_MOUNT_FAILED', fileName, event.status)); 2595 strf('ARCHIVE_MOUNT_FAILED', fileName, event.status));
2595 } 2596 }
2596 } 2597 }
2597 } 2598 }
2598 2599
2599 if (event.eventType == 'unmount') { 2600 if (event.eventType == 'unmount') {
2600 // Unmount request finished - remove it. 2601 // Unmount request finished - remove it.
2601 var index = this.unmountRequests_.indexOf(event.mountPath); 2602 var index = this.unmountRequests_.indexOf(event.mountPath);
2602 if (index != -1) { 2603 if (index != -1) {
2603 this.unmountRequests_.splice(index, 1); 2604 this.unmountRequests_.splice(index, 1);
2604 if (event.status != 'success') 2605 if (event.status != 'success')
2605 this.alert.show(strf('UNMOUNT_FAILED', event.status)); 2606 this.alert.show(strf('UNMOUNT_FAILED', event.status));
2606 } 2607 }
2607 2608
2608 if (event.status == 'success' && 2609 if (event.status == 'success' &&
2609 event.mountPath == this.directoryModel_.getCurrentRootPath()) { 2610 event.mountPath == this.directoryModel_.getCurrentRootPath()) {
2610 if (this.params_.mountTriggered && index == -1) { 2611 if (this.params_.mountTriggered && index == -1) {
2611 // This device mount was the reason this File Manager instance was 2612 // This device mount was the reason this File Manager instance was
2612 // created. Now the device is unmounted from another instance 2613 // created. Now the device is unmounted from another instance
2613 // or the user removed the device manually. Close this instance. 2614 // or the user removed the device manually. Close this instance.
2614 // window.close() sometimes doesn't work. 2615 // window.close() sometimes doesn't work.
2615 chrome.tabs.getCurrent(function(tab) { 2616 chrome.tabs.getCurrent(function(tab) {
2616 chrome.tabs.remove(tab.id); 2617 chrome.tabs.remove(tab.id);
2617 }); 2618 });
2618 return; 2619 return;
2619 } 2620 }
2620 // Current directory just unmounted. Move to the 'Downloads'. 2621 // Current directory just unmounted. Move to the 'Downloads'.
2621 changeDirectoryTo = self.directoryModel_.getDefaultDirectory(); 2622 changeDirectoryTo = this.directoryModel_.getDefaultDirectory();
2622 } 2623 }
2623 } 2624 }
2624 2625
2625 // Even if something failed root list should be rescanned. 2626 // Even if something failed root list should be rescanned.
2626 // Failed mounts can "give" us new devices which might be formatted, 2627 // Failed mounts can "give" us new devices which might be formatted,
2627 // so we have to refresh root list then. 2628 // so we have to refresh root list then.
2628 this.directoryModel_.updateRoots(function() { 2629 this.directoryModel_.updateRoots(function() {
2629 if (changeDirectoryTo) { 2630 if (changeDirectoryTo) {
2630 this.directoryModel_.changeDirectory(changeDirectoryTo); 2631 this.directoryModel_.changeDirectory(changeDirectoryTo);
2631 } 2632 }
(...skipping 15 matching lines...) Expand all
2647 position = urls.indexOf(selectedUrl); 2648 position = urls.indexOf(selectedUrl);
2648 } 2649 }
2649 chrome.mediaPlayerPrivate.play(urls, position); 2650 chrome.mediaPlayerPrivate.play(urls, position);
2650 } else if (id == 'mount-archive') { 2651 } else if (id == 'mount-archive') {
2651 var self = this; 2652 var self = this;
2652 this.resolveSelectResults_(urls, function(urls) { 2653 this.resolveSelectResults_(urls, function(urls) {
2653 for (var index = 0; index < urls.length; ++index) { 2654 for (var index = 0; index < urls.length; ++index) {
2654 // Url in MountCompleted event won't be escaped, so let's make sure 2655 // Url in MountCompleted event won't be escaped, so let's make sure
2655 // we don't use escaped one in mountRequests_. 2656 // we don't use escaped one in mountRequests_.
2656 var unescapedUrl = unescape(urls[index]); 2657 var unescapedUrl = unescape(urls[index]);
2657 self.mountRequests_.push(unescapedUrl); 2658 chrome.fileBrowserPrivate.addMount(unescapedUrl, 'file', {},
2658 chrome.fileBrowserPrivate.addMount(unescapedUrl, 'file', {}); 2659 function(sourcePath) {
2660 self.mountRequests_.push(sourcePath);
2661 });
2659 } 2662 }
2660 }); 2663 });
2661 } else if (id == 'format-device') { 2664 } else if (id == 'format-device') {
2662 this.confirm.show(str('FORMATTING_WARNING'), function() { 2665 this.confirm.show(str('FORMATTING_WARNING'), function() {
2663 chrome.fileBrowserPrivate.formatDevice(urls[0]); 2666 chrome.fileBrowserPrivate.formatDevice(urls[0]);
2664 }); 2667 });
2665 } else if (id == 'gallery') { 2668 } else if (id == 'gallery') {
2666 this.openGallery_(urls); 2669 this.openGallery_(urls);
2667 } else if (id == 'view-pdf' || id == 'view-in-browser' || 2670 } else if (id == 'view-pdf' || id == 'view-in-browser' ||
2668 id == 'install-crx' || id == 'open-hosted') { 2671 id == 'install-crx' || id == 'open-hosted') {
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
4360 } 4363 }
4361 4364
4362 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner); 4365 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner);
4363 4366
4364 var style = this.document_.createElement('link'); 4367 var style = this.document_.createElement('link');
4365 style.rel = 'stylesheet'; 4368 style.rel = 'stylesheet';
4366 style.href = 'css/gdrive_welcome.css'; 4369 style.href = 'css/gdrive_welcome.css';
4367 this.document_.head.appendChild(style); 4370 this.document_.head.appendChild(style);
4368 }; 4371 };
4369 })(); 4372 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698