| OLD | NEW |
| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 for (var i = 0; i < tasks.length; i++) { | 80 for (var i = 0; i < tasks.length; i++) { |
| 81 var task = tasks[i]; | 81 var task = tasks[i]; |
| 82 | 82 |
| 83 // Skip Drive App if the file is not on Drive. | 83 // Skip Drive App if the file is not on Drive. |
| 84 if (!is_on_drive && task.driveApp) | 84 if (!is_on_drive && task.driveApp) |
| 85 continue; | 85 continue; |
| 86 | 86 |
| 87 // Tweak images, titles of internal tasks. | 87 // Tweak images, titles of internal tasks. |
| 88 var task_parts = task.taskId.split('|'); | 88 var task_parts = task.taskId.split('|'); |
| 89 if (task_parts[0] == id) { | 89 if (task_parts[0] == id) { |
| 90 if (task_parts[1] == 'play') { | 90 if (task_parts[2] == 'play') { |
| 91 // TODO(serya): This hack needed until task.iconUrl is working | 91 // TODO(serya): This hack needed until task.iconUrl is working |
| 92 // (see GetFileTasksFileBrowserFunction::RunImpl). | 92 // (see GetFileTasksFileBrowserFunction::RunImpl). |
| 93 task.iconType = 'audio'; | 93 task.iconType = 'audio'; |
| 94 task.title = loadTimeData.getString('ACTION_LISTEN'); | 94 task.title = loadTimeData.getString('ACTION_LISTEN'); |
| 95 } else if (task_parts[1] == 'mount-archive') { | 95 } else if (task_parts[2] == 'mount-archive') { |
| 96 task.iconType = 'archive'; | 96 task.iconType = 'archive'; |
| 97 task.title = loadTimeData.getString('MOUNT_ARCHIVE'); | 97 task.title = loadTimeData.getString('MOUNT_ARCHIVE'); |
| 98 } else if (task_parts[1] == 'gallery') { | 98 } else if (task_parts[2] == 'gallery') { |
| 99 task.iconType = 'image'; | 99 task.iconType = 'image'; |
| 100 task.title = loadTimeData.getString('ACTION_OPEN'); | 100 task.title = loadTimeData.getString('ACTION_OPEN'); |
| 101 } else if (task_parts[1] == 'watch') { | 101 } else if (task_parts[2] == 'watch') { |
| 102 task.iconType = 'video'; | 102 task.iconType = 'video'; |
| 103 task.title = loadTimeData.getString('ACTION_WATCH'); | 103 task.title = loadTimeData.getString('ACTION_WATCH'); |
| 104 } else if (task_parts[1] == 'open-hosted') { | 104 } else if (task_parts[2] == 'open-hosted') { |
| 105 if (this.urls_.length > 1) | 105 if (this.urls_.length > 1) |
| 106 task.iconType = 'generic'; | 106 task.iconType = 'generic'; |
| 107 else // Use specific icon. | 107 else // Use specific icon. |
| 108 task.iconType = FileType.getIcon(this.urls_[0]); | 108 task.iconType = FileType.getIcon(this.urls_[0]); |
| 109 task.title = loadTimeData.getString('ACTION_OPEN'); | 109 task.title = loadTimeData.getString('ACTION_OPEN'); |
| 110 } else if (task_parts[1] == 'view-pdf') { | 110 } else if (task_parts[2] == 'view-pdf') { |
| 111 // Do not render this task if disabled. | 111 // Do not render this task if disabled. |
| 112 if (!loadTimeData.getBoolean('PDF_VIEW_ENABLED')) | 112 if (!loadTimeData.getBoolean('PDF_VIEW_ENABLED')) |
| 113 continue; | 113 continue; |
| 114 task.iconType = 'pdf'; | 114 task.iconType = 'pdf'; |
| 115 task.title = loadTimeData.getString('ACTION_VIEW'); | 115 task.title = loadTimeData.getString('ACTION_VIEW'); |
| 116 } else if (task_parts[1] == 'view-in-browser') { | 116 } else if (task_parts[2] == 'view-in-browser') { |
| 117 task.iconType = 'generic'; | 117 task.iconType = 'generic'; |
| 118 task.title = loadTimeData.getString('ACTION_VIEW'); | 118 task.title = loadTimeData.getString('ACTION_VIEW'); |
| 119 } else if (task_parts[1] == 'install-crx') { | 119 } else if (task_parts[2] == 'install-crx') { |
| 120 task.iconType = 'generic'; | 120 task.iconType = 'generic'; |
| 121 task.title = loadTimeData.getString('INSTALL_CRX'); | 121 task.title = loadTimeData.getString('INSTALL_CRX'); |
| 122 } else if (task_parts[1] == 'send-to-drive') { | 122 } else if (task_parts[1] == 'send-to-drive') { |
| 123 if (!this.fileManager_.fileTransferController_ || | 123 if (!this.fileManager_.fileTransferController_ || |
| 124 this.fileManager_.isOnGData()) | 124 this.fileManager_.isOnGData()) |
| 125 continue; | 125 continue; |
| 126 task.iconType = 'drive'; | 126 task.iconType = 'drive'; |
| 127 task.title = loadTimeData.getString('SEND_TO_DRIVE'); | 127 task.title = loadTimeData.getString('SEND_TO_DRIVE'); |
| 128 } | 128 } |
| 129 } | 129 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 FileTasks.prototype.execute_ = function(taskId, opt_urls) { | 184 FileTasks.prototype.execute_ = function(taskId, opt_urls) { |
| 185 var urls = opt_urls || this.urls_; | 185 var urls = opt_urls || this.urls_; |
| 186 this.checkAvailability_(function() { | 186 this.checkAvailability_(function() { |
| 187 chrome.fileBrowserPrivate.executeTask(taskId, urls); | 187 chrome.fileBrowserPrivate.executeTask(taskId, urls); |
| 188 | 188 |
| 189 var task_parts = taskId.split('|'); | 189 var task_parts = taskId.split('|'); |
| 190 if (task_parts[0] == util.getExtensionId()) { | 190 if (task_parts[0] == util.getExtensionId()) { |
| 191 // For internal tasks we do not listen to the event to avoid | 191 // For internal tasks we do not listen to the event to avoid |
| 192 // handling the same task instance from multiple tabs. | 192 // handling the same task instance from multiple tabs. |
| 193 // So, we manually execute the task. | 193 // So, we manually execute the task. |
| 194 this.executeInternalTask_(task_parts[1], urls); | 194 this.executeInternalTask_(task_parts[2], urls); |
| 195 } | 195 } |
| 196 }.bind(this)); | 196 }.bind(this)); |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 /** | 199 /** |
| 200 * Checks whether the remote files are available right now. | 200 * Checks whether the remote files are available right now. |
| 201 * @param {function} callback The callback. | 201 * @param {function} callback The callback. |
| 202 * @private | 202 * @private |
| 203 */ | 203 */ |
| 204 FileTasks.prototype.checkAvailability_ = function(callback) { | 204 FileTasks.prototype.checkAvailability_ = function(callback) { |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 message, | 546 message, |
| 547 items, defaultIdx, | 547 items, defaultIdx, |
| 548 onSuccess); | 548 onSuccess); |
| 549 }; | 549 }; |
| 550 | 550 |
| 551 FileTasks.decorate('display'); | 551 FileTasks.decorate('display'); |
| 552 FileTasks.decorate('updateMenuItem'); | 552 FileTasks.decorate('updateMenuItem'); |
| 553 FileTasks.decorate('execute'); | 553 FileTasks.decorate('execute'); |
| 554 FileTasks.decorate('executeDefault'); | 554 FileTasks.decorate('executeDefault'); |
| 555 | 555 |
| OLD | NEW |