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

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

Issue 109143005: Files.app: Fix a call of the default task picker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased 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
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager/private_api_tasks.cc ('k') | 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * FileManager constructor. 8 * FileManager constructor.
9 * 9 *
10 * FileManager objects encapsulate the functionality of the file selector 10 * FileManager objects encapsulate the functionality of the file selector
(...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 FileManager.prototype.onTaskItemClicked_ = function(event) { 1744 FileManager.prototype.onTaskItemClicked_ = function(event) {
1745 var selection = this.getSelection(); 1745 var selection = this.getSelection();
1746 if (!selection.tasks) return; 1746 if (!selection.tasks) return;
1747 1747
1748 if (event.item.task) { 1748 if (event.item.task) {
1749 // Task field doesn't exist on change-default dropdown item. 1749 // Task field doesn't exist on change-default dropdown item.
1750 selection.tasks.execute(event.item.task.taskId); 1750 selection.tasks.execute(event.item.task.taskId);
1751 } else { 1751 } else {
1752 var extensions = []; 1752 var extensions = [];
1753 1753
1754 for (var i = 0; i < selection.urls.length; i++) { 1754 for (var i = 0; i < selection.entries.length; i++) {
1755 var match = /\.(\w+)$/g.exec(selection.urls[i]); 1755 var match = /\.(\w+)$/g.exec(selection.entries[i].toURL());
1756 if (match) { 1756 if (match) {
1757 var ext = match[1].toUpperCase(); 1757 var ext = match[1].toUpperCase();
1758 if (extensions.indexOf(ext) == -1) { 1758 if (extensions.indexOf(ext) == -1) {
1759 extensions.push(ext); 1759 extensions.push(ext);
1760 } 1760 }
1761 } 1761 }
1762 } 1762 }
1763 1763
1764 var format = ''; 1764 var format = '';
1765 1765
1766 if (extensions.length == 1) { 1766 if (extensions.length == 1) {
1767 format = extensions[0]; 1767 format = extensions[0];
1768 } 1768 }
1769 1769
1770 // Change default was clicked. We should open "change default" dialog. 1770 // Change default was clicked. We should open "change default" dialog.
1771 selection.tasks.showTaskPicker(this.defaultTaskPicker, 1771 selection.tasks.showTaskPicker(this.defaultTaskPicker,
1772 loadTimeData.getString('CHANGE_DEFAULT_MENU_ITEM'), 1772 loadTimeData.getString('CHANGE_DEFAULT_MENU_ITEM'),
1773 strf('CHANGE_DEFAULT_CAPTION', format), 1773 strf('CHANGE_DEFAULT_CAPTION', format),
1774 this.onDefaultTaskDone_.bind(this)); 1774 this.onDefaultTaskDone_.bind(this));
1775 } 1775 }
1776 }; 1776 };
1777 1777
1778
1779 /** 1778 /**
1780 * Sets the given task as default, when this task is applicable. 1779 * Sets the given task as default, when this task is applicable.
1781 * 1780 *
1782 * @param {Object} task Task to set as default. 1781 * @param {Object} task Task to set as default.
1783 * @private 1782 * @private
1784 */ 1783 */
1785 FileManager.prototype.onDefaultTaskDone_ = function(task) { 1784 FileManager.prototype.onDefaultTaskDone_ = function(task) {
1786 // TODO(dgozman): move this method closer to tasks. 1785 // TODO(dgozman): move this method closer to tasks.
1787 var selection = this.getSelection(); 1786 var selection = this.getSelection();
1788 chrome.fileBrowserPrivate.setDefaultTask(task.taskId, 1787 chrome.fileBrowserPrivate.setDefaultTask(
1789 selection.urls, selection.mimeTypes); 1788 task.taskId,
1789 util.entriesToURLs(selection.entries),
1790 selection.mimeTypes);
1790 selection.tasks = new FileTasks(this); 1791 selection.tasks = new FileTasks(this);
1791 selection.tasks.init(selection.entries, selection.mimeTypes); 1792 selection.tasks.init(selection.entries, selection.mimeTypes);
1792 selection.tasks.display(this.taskItems_); 1793 selection.tasks.display(this.taskItems_);
1793 this.refreshCurrentDirectoryMetadata_(); 1794 this.refreshCurrentDirectoryMetadata_();
1794 this.selectionHandler_.onFileSelectionChanged(); 1795 this.selectionHandler_.onFileSelectionChanged();
1795 }; 1796 };
1796 1797
1797 /** 1798 /**
1798 * @private 1799 * @private
1799 */ 1800 */
(...skipping 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after
3647 callback(this.preferences_); 3648 callback(this.preferences_);
3648 return; 3649 return;
3649 } 3650 }
3650 3651
3651 chrome.fileBrowserPrivate.getPreferences(function(prefs) { 3652 chrome.fileBrowserPrivate.getPreferences(function(prefs) {
3652 this.preferences_ = prefs; 3653 this.preferences_ = prefs;
3653 callback(prefs); 3654 callback(prefs);
3654 }.bind(this)); 3655 }.bind(this));
3655 }; 3656 };
3656 })(); 3657 })();
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager/private_api_tasks.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698