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

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

Issue 10834383: Chrome OS "open with" picker allowing Web Intents (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: tiny 80 chars fix Created 8 years, 3 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 * This object encapsulates everything related to tasks execution. 6 * This object encapsulates everything related to tasks execution.
7 * @param {FileManager} fileManager FileManager instance. 7 * @param {FileManager} fileManager FileManager instance.
8 * @param {Array.<string>} urls List of file urls. 8 * @param {Array.<string>} urls List of file urls.
9 * @param {Array.<string>=} opt_mimeTypes List of MIME types for each 9 * @param {Array.<string>=} opt_mimeTypes List of MIME types for each
10 * of the files. 10 * of the files.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 for (var i = 0; i < tasks.length; i++) { 78 for (var i = 0; i < tasks.length; i++) {
79 var task = tasks[i]; 79 var task = tasks[i];
80 80
81 // Skip Drive App if the file is not on Drive. 81 // Skip Drive App if the file is not on Drive.
82 if (!is_on_drive && task.driveApp) 82 if (!is_on_drive && task.driveApp)
83 continue; 83 continue;
84 84
85 // Tweak images, titles of internal tasks. 85 // Tweak images, titles of internal tasks.
86 var task_parts = task.taskId.split('|'); 86 var task_parts = task.taskId.split('|');
87 if (task_parts[0] == id) { 87 if (task_parts[0] == id) {
88 if (task_parts[1] == 'play') { 88 if (task_parts[2] == 'play') {
89 // TODO(serya): This hack needed until task.iconUrl is working 89 // TODO(serya): This hack needed until task.iconUrl is working
90 // (see GetFileTasksFileBrowserFunction::RunImpl). 90 // (see GetFileTasksFileBrowserFunction::RunImpl).
91 task.iconType = 'audio'; 91 task.iconType = 'audio';
92 task.title = loadTimeData.getString('ACTION_LISTEN'); 92 task.title = loadTimeData.getString('ACTION_LISTEN');
93 } else if (task_parts[1] == 'mount-archive') { 93 } else if (task_parts[2] == 'mount-archive') {
94 task.iconType = 'archive'; 94 task.iconType = 'archive';
95 task.title = loadTimeData.getString('MOUNT_ARCHIVE'); 95 task.title = loadTimeData.getString('MOUNT_ARCHIVE');
96 } else if (task_parts[1] == 'gallery') { 96 } else if (task_parts[2] == 'gallery') {
97 task.iconType = 'image'; 97 task.iconType = 'image';
98 task.title = loadTimeData.getString('ACTION_OPEN'); 98 task.title = loadTimeData.getString('ACTION_OPEN');
99 } else if (task_parts[1] == 'watch') { 99 } else if (task_parts[2] == 'watch') {
100 task.iconType = 'video'; 100 task.iconType = 'video';
101 task.title = loadTimeData.getString('ACTION_WATCH'); 101 task.title = loadTimeData.getString('ACTION_WATCH');
102 } else if (task_parts[1] == 'open-hosted') { 102 } else if (task_parts[2] == 'open-hosted') {
103 if (this.urls_.length > 1) 103 if (this.urls_.length > 1)
104 task.iconType = 'generic'; 104 task.iconType = 'generic';
105 else // Use specific icon. 105 else // Use specific icon.
106 task.iconType = FileType.getIcon(this.urls_[0]); 106 task.iconType = FileType.getIcon(this.urls_[0]);
107 task.title = loadTimeData.getString('ACTION_OPEN'); 107 task.title = loadTimeData.getString('ACTION_OPEN');
108 } else if (task_parts[1] == 'view-pdf') { 108 } else if (task_parts[2] == 'view-pdf') {
109 // Do not render this task if disabled. 109 // Do not render this task if disabled.
110 if (!loadTimeData.getBoolean('PDF_VIEW_ENABLED')) 110 if (!loadTimeData.getBoolean('PDF_VIEW_ENABLED'))
111 continue; 111 continue;
112 task.iconType = 'pdf'; 112 task.iconType = 'pdf';
113 task.title = loadTimeData.getString('ACTION_VIEW'); 113 task.title = loadTimeData.getString('ACTION_VIEW');
114 } else if (task_parts[1] == 'view-in-browser') { 114 } else if (task_parts[2] == 'view-in-browser') {
115 task.iconType = 'generic'; 115 task.iconType = 'generic';
116 task.title = loadTimeData.getString('ACTION_VIEW'); 116 task.title = loadTimeData.getString('ACTION_VIEW');
117 } else if (task_parts[1] == 'install-crx') { 117 } else if (task_parts[2] == 'install-crx') {
118 task.iconType = 'generic'; 118 task.iconType = 'generic';
119 task.title = loadTimeData.getString('INSTALL_CRX'); 119 task.title = loadTimeData.getString('INSTALL_CRX');
120 } else if (task_parts[1] == 'send-to-drive') { 120 } else if (task_parts[1] == 'send-to-drive') {
121 if (!this.fileManager_.fileTransferController_ || 121 if (!this.fileManager_.fileTransferController_ ||
122 this.fileManager_.isOnGData()) 122 this.fileManager_.isOnGData())
123 continue; 123 continue;
124 task.iconType = 'drive'; 124 task.iconType = 'drive';
125 task.title = loadTimeData.getString('SEND_TO_DRIVE'); 125 task.title = loadTimeData.getString('SEND_TO_DRIVE');
126 } 126 }
127 } 127 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 FileTasks.prototype.execute_ = function(taskId, opt_urls) { 182 FileTasks.prototype.execute_ = function(taskId, opt_urls) {
183 var urls = opt_urls || this.urls_; 183 var urls = opt_urls || this.urls_;
184 this.checkAvailability_(function() { 184 this.checkAvailability_(function() {
185 chrome.fileBrowserPrivate.executeTask(taskId, urls); 185 chrome.fileBrowserPrivate.executeTask(taskId, urls);
186 186
187 var task_parts = taskId.split('|'); 187 var task_parts = taskId.split('|');
188 if (task_parts[0] == util.getExtensionId()) { 188 if (task_parts[0] == util.getExtensionId()) {
189 // For internal tasks we do not listen to the event to avoid 189 // For internal tasks we do not listen to the event to avoid
190 // handling the same task instance from multiple tabs. 190 // handling the same task instance from multiple tabs.
191 // So, we manually execute the task. 191 // So, we manually execute the task.
192 this.executeInternalTask_(task_parts[1], urls); 192 this.executeInternalTask_(task_parts[2], urls);
193 } 193 }
194 }.bind(this)); 194 }.bind(this));
195 }; 195 };
196 196
197 /** 197 /**
198 * Checks whether the remote files are available right now. 198 * Checks whether the remote files are available right now.
199 * @param {function} callback The callback. 199 * @param {function} callback The callback.
200 * @private 200 * @private
201 */ 201 */
202 FileTasks.prototype.checkAvailability_ = function(callback) { 202 FileTasks.prototype.checkAvailability_ = function(callback) {
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 items, defaultIdx, 583 items, defaultIdx,
584 onSuccess); 584 onSuccess);
585 }; 585 };
586 586
587 FileTasks.decorate('display'); 587 FileTasks.decorate('display');
588 FileTasks.decorate('updateMenuItem'); 588 FileTasks.decorate('updateMenuItem');
589 FileTasks.decorate('execute'); 589 FileTasks.decorate('execute');
590 FileTasks.decorate('executeDefault'); 590 FileTasks.decorate('executeDefault');
591 FileTasks.decorate('getExternals'); 591 FileTasks.decorate('getExternals');
592 592
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698