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

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: Fix C++ side bug. 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 * 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 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 FileManager.prototype.onTaskItemClicked_ = function(event) { 1686 FileManager.prototype.onTaskItemClicked_ = function(event) {
1687 var selection = this.getSelection(); 1687 var selection = this.getSelection();
1688 if (!selection.tasks) return; 1688 if (!selection.tasks) return;
1689 1689
1690 if (event.item.task) { 1690 if (event.item.task) {
1691 // Task field doesn't exist on change-default dropdown item. 1691 // Task field doesn't exist on change-default dropdown item.
1692 selection.tasks.execute(event.item.task.taskId); 1692 selection.tasks.execute(event.item.task.taskId);
1693 } else { 1693 } else {
1694 var extensions = []; 1694 var extensions = [];
1695 1695
1696 for (var i = 0; i < selection.urls.length; i++) { 1696 for (var i = 0; i < selection.entries.length; i++) {
1697 var match = /\.(\w+)$/g.exec(selection.urls[i]); 1697 var match = /\.(\w+)$/g.exec(selection.entries[i].toURL());
1698 if (match) { 1698 if (match) {
1699 var ext = match[1].toUpperCase(); 1699 var ext = match[1].toUpperCase();
1700 if (extensions.indexOf(ext) == -1) { 1700 if (extensions.indexOf(ext) == -1) {
1701 extensions.push(ext); 1701 extensions.push(ext);
1702 } 1702 }
1703 } 1703 }
1704 } 1704 }
1705 1705
1706 var format = ''; 1706 var format = '';
1707 1707
1708 if (extensions.length == 1) { 1708 if (extensions.length == 1) {
1709 format = extensions[0]; 1709 format = extensions[0];
1710 } 1710 }
1711 1711
1712 // Change default was clicked. We should open "change default" dialog. 1712 // Change default was clicked. We should open "change default" dialog.
1713 selection.tasks.showTaskPicker(this.defaultTaskPicker, 1713 selection.tasks.showTaskPicker(this.defaultTaskPicker,
1714 loadTimeData.getString('CHANGE_DEFAULT_MENU_ITEM'), 1714 loadTimeData.getString('CHANGE_DEFAULT_MENU_ITEM'),
1715 strf('CHANGE_DEFAULT_CAPTION', format), 1715 strf('CHANGE_DEFAULT_CAPTION', format),
1716 this.onDefaultTaskDone_.bind(this)); 1716 this.onDefaultTaskDone_.bind(this));
1717 } 1717 }
1718 }; 1718 };
1719 1719
1720
1721 /** 1720 /**
1722 * Sets the given task as default, when this task is applicable. 1721 * Sets the given task as default, when this task is applicable.
1723 * 1722 *
1724 * @param {Object} task Task to set as default. 1723 * @param {Object} task Task to set as default.
1725 * @private 1724 * @private
1726 */ 1725 */
1727 FileManager.prototype.onDefaultTaskDone_ = function(task) { 1726 FileManager.prototype.onDefaultTaskDone_ = function(task) {
1728 // TODO(dgozman): move this method closer to tasks. 1727 // TODO(dgozman): move this method closer to tasks.
1729 var selection = this.getSelection(); 1728 var selection = this.getSelection();
1730 chrome.fileBrowserPrivate.setDefaultTask(task.taskId, 1729 chrome.fileBrowserPrivate.setDefaultTask(
1731 selection.urls, selection.mimeTypes); 1730 task.taskId,
1731 util.entriesToURLs(selection.entries),
1732 selection.mimeTypes);
1732 selection.tasks = new FileTasks(this); 1733 selection.tasks = new FileTasks(this);
1733 selection.tasks.init(selection.entries, selection.mimeTypes); 1734 selection.tasks.init(selection.entries, selection.mimeTypes);
1734 selection.tasks.display(this.taskItems_); 1735 selection.tasks.display(this.taskItems_);
1735 this.refreshCurrentDirectoryMetadata_(); 1736 this.refreshCurrentDirectoryMetadata_();
1736 this.selectionHandler_.onFileSelectionChanged(); 1737 this.selectionHandler_.onFileSelectionChanged();
1737 }; 1738 };
1738 1739
1739 /** 1740 /**
1740 * @private 1741 * @private
1741 */ 1742 */
(...skipping 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after
3589 callback(this.preferences_); 3590 callback(this.preferences_);
3590 return; 3591 return;
3591 } 3592 }
3592 3593
3593 chrome.fileBrowserPrivate.getPreferences(function(prefs) { 3594 chrome.fileBrowserPrivate.getPreferences(function(prefs) {
3594 this.preferences_ = prefs; 3595 this.preferences_ = prefs;
3595 callback(prefs); 3596 callback(prefs);
3596 }.bind(this)); 3597 }.bind(this));
3597 }; 3598 };
3598 })(); 3599 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698