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

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

Issue 109973002: Migrate from URLs to Entries in the Files App's gallery. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 7 years 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
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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * This object encapsulates everything related to tasks execution. 8 * This object encapsulates everything related to tasks execution.
9 * 9 *
10 * @param {FileManager} fileManager FileManager instance. 10 * @param {FileManager} fileManager FileManager instance.
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 559
560 /** 560 /**
561 * The core implementation of mounts archives. 561 * The core implementation of mounts archives.
562 * 562 *
563 * @param {Array.<Entry>} entries Mount file entries list. 563 * @param {Array.<Entry>} entries Mount file entries list.
564 * @private 564 * @private
565 */ 565 */
566 FileTasks.prototype.mountArchivesInternal_ = function(entries) { 566 FileTasks.prototype.mountArchivesInternal_ = function(entries) {
567 var fm = this.fileManager_; 567 var fm = this.fileManager_;
568 568
569 var tracker = fm.directoryModel_.createDirectoryChangeTracker(); 569 var tracker = fm.directoryModel.createDirectoryChangeTracker();
570 tracker.start(); 570 tracker.start();
571 571
572 // TODO(mtomasz): Pass Entries instead of URLs. 572 // TODO(mtomasz): Pass Entries instead of URLs.
573 var urls = util.entriesToURLs(entries); 573 var urls = util.entriesToURLs(entries);
574 fm.resolveSelectResults_(urls, function(resolvedURLs) { 574 fm.resolveSelectResults_(urls, function(resolvedURLs) {
575 for (var index = 0; index < resolvedURLs.length; ++index) { 575 for (var index = 0; index < resolvedURLs.length; ++index) {
576 // TODO(mtomasz): Pass Entry instead of URL. 576 // TODO(mtomasz): Pass Entry instead of URL.
577 fm.volumeManager_.mountArchive(resolvedURLs[index], 577 fm.volumeManager.mountArchive(resolvedURLs[index],
578 function(mountPath) { 578 function(mountPath) {
579 tracker.stop(); 579 tracker.stop();
580 if (!tracker.hasChanged) 580 if (!tracker.hasChanged)
581 fm.directoryModel_.changeDirectory(mountPath); 581 fm.directoryModel.changeDirectory(mountPath);
582 }, function(url, error) { 582 }, function(url, error) {
583 tracker.stop(); 583 tracker.stop();
584 var path = util.extractFilePath(url); 584 var path = util.extractFilePath(url);
585 var namePos = path.lastIndexOf('/'); 585 var namePos = path.lastIndexOf('/');
586 fm.alert.show(strf('ARCHIVE_MOUNT_FAILED', 586 fm.alert.show(strf('ARCHIVE_MOUNT_FAILED',
587 path.substr(namePos + 1), error)); 587 path.substr(namePos + 1), error));
588 }.bind(null, resolvedURLs[index])); 588 }.bind(null, resolvedURLs[index]));
589 } 589 }
590 }); 590 });
591 }; 591 };
(...skipping 30 matching lines...) Expand all
622 util.updateAppState(null /* keep path */, '' /* remove search. */); 622 util.updateAppState(null /* keep path */, '' /* remove search. */);
623 } 623 }
624 624
625 var savedAppState = window.appState; 625 var savedAppState = window.appState;
626 var savedTitle = document.title; 626 var savedTitle = document.title;
627 627
628 // Push a temporary state which will be replaced every time the selection 628 // Push a temporary state which will be replaced every time the selection
629 // changes in the Gallery and popped when the Gallery is closed. 629 // changes in the Gallery and popped when the Gallery is closed.
630 util.updateAppState(); 630 util.updateAppState();
631 631
632 // TODO(mtomasz): Pass entries instead of urls. 632 var onBack = function(selectedEntries) {
633 var onBack = function(selectedUrls) { 633 fm.directoryModel.selectEntries(selectedEntries);
634 fm.directoryModel_.selectUrls(selectedUrls);
635 fm.closeFilePopup(); // Will call Gallery.unload. 634 fm.closeFilePopup(); // Will call Gallery.unload.
636 window.appState = savedAppState; 635 window.appState = savedAppState;
637 util.saveAppState(); 636 util.saveAppState();
638 document.title = savedTitle; 637 document.title = savedTitle;
639 }; 638 };
640 639
641 var onClose = function() { 640 var onClose = function() {
642 fm.onClose(); 641 fm.onClose();
643 }; 642 };
644 643
645 var onMaximize = function() { 644 var onMaximize = function() {
646 fm.onMaximize(); 645 fm.onMaximize();
647 }; 646 };
648 647
649 var onAppRegionChanged = function(visible) { 648 var onAppRegionChanged = function(visible) {
650 fm.onFilePopupAppRegionChanged(visible); 649 fm.onFilePopupAppRegionChanged(visible);
651 }; 650 };
652 651
653 galleryFrame.onload = function() { 652 galleryFrame.onload = function() {
654 galleryFrame.contentWindow.ImageUtil.metrics = metrics; 653 galleryFrame.contentWindow.ImageUtil.metrics = metrics;
655 654
656 // TODO(haruki): isOnReadonlyDirectory() only checks the permission for the 655 // TODO(haruki): isOnReadonlyDirectory() only checks the permission for the
657 // root. We should check more granular permission to know whether the file 656 // root. We should check more granular permission to know whether the file
658 // is writable or not. 657 // is writable or not.
659 var readonly = fm.isOnReadonlyDirectory(); 658 var readonly = fm.isOnReadonlyDirectory();
660 var currentDir = fm.getCurrentDirectoryEntry(); 659 var currentDir = fm.getCurrentDirectoryEntry();
661 var downloadsVolume = 660 var downloadsVolume =
662 fm.volumeManager_.getCurrentProfileVolumeInfo(RootType.DOWNLOADS); 661 fm.volumeManager.getCurrentProfileVolumeInfo(RootType.DOWNLOADS);
663 var downloadsDir = downloadsVolume && downloadsVolume.root; 662 var downloadsDir = downloadsVolume && downloadsVolume.root;
664 var readonlyDirName = null; 663 var readonlyDirName = null;
665 if (readonly && currentDir) { 664 if (readonly && currentDir) {
666 var rootPath = PathUtil.getRootPath(currentDir.fullPath); 665 var rootPath = PathUtil.getRootPath(currentDir.fullPath);
667 readonlyDirName = fm.isOnDrive() ? 666 readonlyDirName = fm.isOnDrive() ?
668 PathUtil.getRootLabel(rootPath) : 667 PathUtil.getRootLabel(rootPath) :
669 PathUtil.basename(rootPath); 668 PathUtil.basename(rootPath);
670 } 669 }
671 670
672 var context = { 671 var context = {
673 // We show the root label in readonly warning (e.g. archive name). 672 // We show the root label in readonly warning (e.g. archive name).
674 readonlyDirName: readonlyDirName, 673 readonlyDirName: readonlyDirName,
675 curDirEntry: currentDir, 674 curDirEntry: currentDir,
676 saveDirEntry: readonly ? downloadsDir : null, 675 saveDirEntry: readonly ? downloadsDir : null,
677 searchResults: fm.directoryModel_.isSearching(), 676 searchResults: fm.directoryModel.isSearching(),
678 metadataCache: fm.metadataCache_, 677 metadataCache: fm.metadataCache_,
679 pageState: this.params_, 678 pageState: this.params_,
680 appWindow: chrome.app.window.current(), 679 appWindow: chrome.app.window.current(),
681 onBack: onBack, 680 onBack: onBack,
682 onClose: onClose, 681 onClose: onClose,
683 onMaximize: onMaximize, 682 onMaximize: onMaximize,
684 onAppRegionChanged: onAppRegionChanged, 683 onAppRegionChanged: onAppRegionChanged,
685 displayStringFunction: strf 684 displayStringFunction: strf
686 }; 685 };
687 // TODO(mtomasz): Pass entries instead.
688 var allUrls = util.entriesToURLs(allEntries);
689 var urls = util.entriesToURLs(entries);
690 galleryFrame.contentWindow.Gallery.open( 686 galleryFrame.contentWindow.Gallery.open(
691 context, fm.volumeManager_, allUrls, urls); 687 context, fm.volumeManager, allEntries, entries);
692 }.bind(this); 688 }.bind(this);
693 689
694 galleryFrame.src = 'gallery.html'; 690 galleryFrame.src = 'gallery.html';
695 fm.openFilePopup(galleryFrame, fm.updateTitle_.bind(fm)); 691 fm.openFilePopup(galleryFrame, fm.updateTitle_.bind(fm));
696 }; 692 };
697 693
698 /** 694 /**
699 * Displays the list of tasks in a task picker combobutton. 695 * Displays the list of tasks in a task picker combobutton.
700 * 696 *
701 * @param {cr.ui.ComboButton} combobutton The task picker element. 697 * @param {cr.ui.ComboButton} combobutton The task picker element.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 items, defaultIdx, 825 items, defaultIdx,
830 function(item) { 826 function(item) {
831 onSuccess(item.task); 827 onSuccess(item.task);
832 }); 828 });
833 }; 829 };
834 830
835 FileTasks.decorate('display'); 831 FileTasks.decorate('display');
836 FileTasks.decorate('updateMenuItem'); 832 FileTasks.decorate('updateMenuItem');
837 FileTasks.decorate('execute'); 833 FileTasks.decorate('execute');
838 FileTasks.decorate('executeDefault'); 834 FileTasks.decorate('executeDefault');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698