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

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: some fixes, haven't approached JS yet 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
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-generic') { 104 } else if (task_parts[2] == 'open-hosted-generic') {
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] == 'open-hosted-gdoc') { 110 } else if (task_parts[2] == 'open-hosted-gdoc') {
111 task.iconType = 'gdoc'; 111 task.iconType = 'gdoc';
112 task.title = loadTimeData.getString('ACTION_OPEN_GDOC'); 112 task.title = loadTimeData.getString('ACTION_OPEN_GDOC');
113 } else if (task_parts[1] == 'open-hosted-gsheet') { 113 } else if (task_parts[2] == 'open-hosted-gsheet') {
114 task.iconType = 'gsheet'; 114 task.iconType = 'gsheet';
115 task.title = loadTimeData.getString('ACTION_OPEN_GSHEET'); 115 task.title = loadTimeData.getString('ACTION_OPEN_GSHEET');
116 } else if (task_parts[1] == 'open-hosted-gslides') { 116 } else if (task_parts[2] == 'open-hosted-gslides') {
117 task.iconType = 'gslides'; 117 task.iconType = 'gslides';
118 task.title = loadTimeData.getString('ACTION_OPEN_GSLIDES'); 118 task.title = loadTimeData.getString('ACTION_OPEN_GSLIDES');
119 } else if (task_parts[1] == 'view-pdf') { 119 } else if (task_parts[2] == 'view-pdf') {
120 // Do not render this task if disabled. 120 // Do not render this task if disabled.
121 if (!loadTimeData.getBoolean('PDF_VIEW_ENABLED')) 121 if (!loadTimeData.getBoolean('PDF_VIEW_ENABLED'))
122 continue; 122 continue;
123 task.iconType = 'pdf'; 123 task.iconType = 'pdf';
124 task.title = loadTimeData.getString('ACTION_VIEW'); 124 task.title = loadTimeData.getString('ACTION_VIEW');
125 } else if (task_parts[1] == 'view-in-browser') { 125 } else if (task_parts[2] == 'view-in-browser') {
126 task.iconType = 'generic'; 126 task.iconType = 'generic';
127 task.title = loadTimeData.getString('ACTION_VIEW'); 127 task.title = loadTimeData.getString('ACTION_VIEW');
128 } else if (task_parts[1] == 'install-crx') { 128 } else if (task_parts[2] == 'install-crx') {
129 task.iconType = 'generic'; 129 task.iconType = 'generic';
130 task.title = loadTimeData.getString('INSTALL_CRX'); 130 task.title = loadTimeData.getString('INSTALL_CRX');
131 } 131 }
132 } 132 }
133 133
134 this.tasks_.push(task); 134 this.tasks_.push(task);
135 if (this.defaultTask_ == null && task.isDefault) { 135 if (this.defaultTask_ == null && task.isDefault) {
136 this.defaultTask_ = task; 136 this.defaultTask_ = task;
137 } 137 }
138 } 138 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 FileTasks.prototype.execute_ = function(taskId, opt_urls) { 187 FileTasks.prototype.execute_ = function(taskId, opt_urls) {
188 var urls = opt_urls || this.urls_; 188 var urls = opt_urls || this.urls_;
189 this.checkAvailability_(function() { 189 this.checkAvailability_(function() {
190 chrome.fileBrowserPrivate.executeTask(taskId, urls); 190 chrome.fileBrowserPrivate.executeTask(taskId, urls);
191 191
192 var task_parts = taskId.split('|'); 192 var task_parts = taskId.split('|');
193 if (task_parts[0] == util.getExtensionId()) { 193 if (task_parts[0] == util.getExtensionId()) {
194 // For internal tasks we do not listen to the event to avoid 194 // For internal tasks we do not listen to the event to avoid
195 // handling the same task instance from multiple tabs. 195 // handling the same task instance from multiple tabs.
196 // So, we manually execute the task. 196 // So, we manually execute the task.
197 this.executeInternalTask_(task_parts[1], urls); 197 this.executeInternalTask_(task_parts[2], urls);
198 } 198 }
199 }.bind(this)); 199 }.bind(this));
200 }; 200 };
201 201
202 /** 202 /**
203 * Checks whether the remote files are available right now. 203 * Checks whether the remote files are available right now.
204 * @param {function} callback The callback. 204 * @param {function} callback The callback.
205 * @private 205 * @private
206 */ 206 */
207 FileTasks.prototype.checkAvailability_ = function(callback) { 207 FileTasks.prototype.checkAvailability_ = function(callback) {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 message, 536 message,
537 items, defaultIdx, 537 items, defaultIdx,
538 onSuccess); 538 onSuccess);
539 }; 539 };
540 540
541 FileTasks.decorate('display'); 541 FileTasks.decorate('display');
542 FileTasks.decorate('updateMenuItem'); 542 FileTasks.decorate('updateMenuItem');
543 FileTasks.decorate('execute'); 543 FileTasks.decorate('execute');
544 FileTasks.decorate('executeDefault'); 544 FileTasks.decorate('executeDefault');
545 545
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698