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

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: benwells' changes 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 for (var i = 0; i < tasks.length; i++) { 70 for (var i = 0; i < tasks.length; i++) {
71 var task = tasks[i]; 71 var task = tasks[i];
72 72
73 // Skip Drive App if the file is not on Drive. 73 // Skip Drive App if the file is not on Drive.
74 if (!is_on_drive && task.driveApp) 74 if (!is_on_drive && task.driveApp)
75 continue; 75 continue;
76 76
77 // Tweak images, titles of internal tasks. 77 // Tweak images, titles of internal tasks.
78 var task_parts = task.taskId.split('|'); 78 var task_parts = task.taskId.split('|');
79 if (task_parts[0] == id) { 79 if (task_parts[0] == id) {
80 if (task_parts[1] == 'play') { 80 if (task_parts[2] == 'play') {
81 // TODO(serya): This hack needed until task.iconUrl is working 81 // TODO(serya): This hack needed until task.iconUrl is working
82 // (see GetFileTasksFileBrowserFunction::RunImpl). 82 // (see GetFileTasksFileBrowserFunction::RunImpl).
83 task.iconType = 'audio'; 83 task.iconType = 'audio';
84 task.title = loadTimeData.getString('ACTION_LISTEN'); 84 task.title = loadTimeData.getString('ACTION_LISTEN');
85 } else if (task_parts[1] == 'mount-archive') { 85 } else if (task_parts[2] == 'mount-archive') {
86 task.iconType = 'archive'; 86 task.iconType = 'archive';
87 task.title = loadTimeData.getString('MOUNT_ARCHIVE'); 87 task.title = loadTimeData.getString('MOUNT_ARCHIVE');
88 } else if (task_parts[1] == 'gallery') { 88 } else if (task_parts[2] == 'gallery') {
89 task.iconType = 'image'; 89 task.iconType = 'image';
90 task.title = loadTimeData.getString('ACTION_OPEN'); 90 task.title = loadTimeData.getString('ACTION_OPEN');
91 } else if (task_parts[1] == 'watch') { 91 } else if (task_parts[2] == 'watch') {
92 task.iconType = 'video'; 92 task.iconType = 'video';
93 task.title = loadTimeData.getString('ACTION_WATCH'); 93 task.title = loadTimeData.getString('ACTION_WATCH');
94 } else if (task_parts[1] == 'open-hosted') { 94 } else if (task_parts[2] == 'open-hosted') {
95 if (this.urls_.length > 1) 95 if (this.urls_.length > 1)
96 task.iconType = 'generic'; 96 task.iconType = 'generic';
97 else // Use specific icon. 97 else // Use specific icon.
98 task.iconType = FileType.getIcon(this.urls_[0]); 98 task.iconType = FileType.getIcon(this.urls_[0]);
99 task.title = loadTimeData.getString('ACTION_OPEN'); 99 task.title = loadTimeData.getString('ACTION_OPEN');
100 } else if (task_parts[1] == 'view-pdf') { 100 } else if (task_parts[2] == 'view-pdf') {
101 // Do not render this task if disabled. 101 // Do not render this task if disabled.
102 if (!loadTimeData.getBoolean('PDF_VIEW_ENABLED')) 102 if (!loadTimeData.getBoolean('PDF_VIEW_ENABLED'))
103 continue; 103 continue;
104 task.iconType = 'pdf'; 104 task.iconType = 'pdf';
105 task.title = loadTimeData.getString('ACTION_VIEW'); 105 task.title = loadTimeData.getString('ACTION_VIEW');
106 } else if (task_parts[1] == 'view-in-browser') { 106 } else if (task_parts[2] == 'view-in-browser') {
107 task.iconType = 'generic'; 107 task.iconType = 'generic';
108 task.title = loadTimeData.getString('ACTION_VIEW'); 108 task.title = loadTimeData.getString('ACTION_VIEW');
109 } else if (task_parts[1] == 'install-crx') { 109 } else if (task_parts[2] == 'install-crx') {
110 task.iconType = 'generic'; 110 task.iconType = 'generic';
111 task.title = loadTimeData.getString('INSTALL_CRX'); 111 task.title = loadTimeData.getString('INSTALL_CRX');
112 } 112 }
113 } 113 }
114 114
115 this.tasks_.push(task); 115 this.tasks_.push(task);
116 if (this.defaultTask_ == null) { 116 if (this.defaultTask_ == null) {
117 this.defaultTask_ = task; 117 this.defaultTask_ = task;
118 } 118 }
119 } 119 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 FileTasks.prototype.execute_ = function(taskId, opt_urls) { 162 FileTasks.prototype.execute_ = function(taskId, opt_urls) {
163 var urls = opt_urls || this.urls_; 163 var urls = opt_urls || this.urls_;
164 this.checkAvailability_(function() { 164 this.checkAvailability_(function() {
165 chrome.fileBrowserPrivate.executeTask(taskId, urls); 165 chrome.fileBrowserPrivate.executeTask(taskId, urls);
166 166
167 var task_parts = taskId.split('|'); 167 var task_parts = taskId.split('|');
168 if (task_parts[0] == util.getExtensionId()) { 168 if (task_parts[0] == util.getExtensionId()) {
169 // For internal tasks we do not listen to the event to avoid 169 // For internal tasks we do not listen to the event to avoid
170 // handling the same task instance from multiple tabs. 170 // handling the same task instance from multiple tabs.
171 // So, we manually execute the task. 171 // So, we manually execute the task.
172 this.executeInternalTask_(task_parts[1], urls); 172 this.executeInternalTask_(task_parts[2], urls);
173 } 173 }
174 }.bind(this)); 174 }.bind(this));
175 }; 175 };
176 176
177 /** 177 /**
178 * Checks whether the remote files are available right now. 178 * Checks whether the remote files are available right now.
179 * @param {function} callback The callback. 179 * @param {function} callback The callback.
180 * @private 180 * @private
181 */ 181 */
182 FileTasks.prototype.checkAvailability_ = function(callback) { 182 FileTasks.prototype.checkAvailability_ = function(callback) {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 return this; 515 return this;
516 }; 516 };
517 }; 517 };
518 518
519 FileTasks.decorate('display'); 519 FileTasks.decorate('display');
520 FileTasks.decorate('updateMenuItem'); 520 FileTasks.decorate('updateMenuItem');
521 FileTasks.decorate('execute'); 521 FileTasks.decorate('execute');
522 FileTasks.decorate('executeDefault'); 522 FileTasks.decorate('executeDefault');
523 FileTasks.decorate('getExternals'); 523 FileTasks.decorate('getExternals');
524 524
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698