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

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

Issue 12560002: Change var blah_blah -> blahBlah. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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 | 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 /** 5 /**
6 * This object encapsulates everything related to tasks execution. 6 * This object encapsulates everything related to tasks execution.
7 * 7 *
8 * @param {FileManager} fileManager FileManager instance. 8 * @param {FileManager} fileManager FileManager instance.
9 * @param {Object=} opt_params File manager load parameters. 9 * @param {Object=} opt_params File manager load parameters.
10 * @constructor 10 * @constructor
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 /** 83 /**
84 * Processes internal tasks. 84 * Processes internal tasks.
85 * 85 *
86 * @param {Array.<Object>} tasks The tasks. 86 * @param {Array.<Object>} tasks The tasks.
87 * @private 87 * @private
88 */ 88 */
89 FileTasks.prototype.processTasks_ = function(tasks) { 89 FileTasks.prototype.processTasks_ = function(tasks) {
90 this.tasks_ = []; 90 this.tasks_ = [];
91 var id = util.platform.getAppId(); 91 var id = util.platform.getAppId();
92 var is_on_drive = false; 92 var isOnDrive = false;
93 for (var index = 0; index < this.urls_.length; ++index) { 93 for (var index = 0; index < this.urls_.length; ++index) {
94 if (FileType.isOnDrive(this.urls_[index])) { 94 if (FileType.isOnDrive(this.urls_[index])) {
95 is_on_drive = true; 95 isOnDrive = true;
96 break; 96 break;
97 } 97 }
98 } 98 }
99 99
100 for (var i = 0; i < tasks.length; i++) { 100 for (var i = 0; i < tasks.length; i++) {
101 var task = tasks[i]; 101 var task = tasks[i];
102 102
103 // Skip Drive App if the file is not on Drive. 103 // Skip Drive App if the file is not on Drive.
104 if (!is_on_drive && task.driveApp) 104 if (!isOnDrive && task.driveApp)
105 continue; 105 continue;
106 106
107 // Tweak images, titles of internal tasks. 107 // Tweak images, titles of internal tasks.
108 var task_parts = task.taskId.split('|'); 108 var taskParts = task.taskId.split('|');
109 if (task_parts[0] == id && task_parts[1] == 'file') { 109 if (taskParts[0] == id && taskParts[1] == 'file') {
110 if (task_parts[2] == 'play') { 110 if (taskParts[2] == 'play') {
111 // TODO(serya): This hack needed until task.iconUrl is working 111 // TODO(serya): This hack needed until task.iconUrl is working
112 // (see GetFileTasksFileBrowserFunction::RunImpl). 112 // (see GetFileTasksFileBrowserFunction::RunImpl).
113 task.iconType = 'audio'; 113 task.iconType = 'audio';
114 task.title = loadTimeData.getString('ACTION_LISTEN'); 114 task.title = loadTimeData.getString('ACTION_LISTEN');
115 } else if (task_parts[2] == 'mount-archive') { 115 } else if (taskParts[2] == 'mount-archive') {
116 task.iconType = 'archive'; 116 task.iconType = 'archive';
117 task.title = loadTimeData.getString('MOUNT_ARCHIVE'); 117 task.title = loadTimeData.getString('MOUNT_ARCHIVE');
118 } else if (task_parts[2] == 'gallery') { 118 } else if (taskParts[2] == 'gallery') {
119 task.iconType = 'image'; 119 task.iconType = 'image';
120 task.title = loadTimeData.getString('ACTION_OPEN'); 120 task.title = loadTimeData.getString('ACTION_OPEN');
121 } else if (task_parts[2] == 'watch') { 121 } else if (taskParts[2] == 'watch') {
122 task.iconType = 'video'; 122 task.iconType = 'video';
123 task.title = loadTimeData.getString('ACTION_WATCH'); 123 task.title = loadTimeData.getString('ACTION_WATCH');
124 } else if (task_parts[2] == 'open-hosted-generic') { 124 } else if (taskParts[2] == 'open-hosted-generic') {
125 if (this.urls_.length > 1) 125 if (this.urls_.length > 1)
126 task.iconType = 'generic'; 126 task.iconType = 'generic';
127 else // Use specific icon. 127 else // Use specific icon.
128 task.iconType = FileType.getIcon(this.urls_[0]); 128 task.iconType = FileType.getIcon(this.urls_[0]);
129 task.title = loadTimeData.getString('ACTION_OPEN'); 129 task.title = loadTimeData.getString('ACTION_OPEN');
130 } else if (task_parts[2] == 'open-hosted-gdoc') { 130 } else if (taskParts[2] == 'open-hosted-gdoc') {
131 task.iconType = 'gdoc'; 131 task.iconType = 'gdoc';
132 task.title = loadTimeData.getString('ACTION_OPEN_GDOC'); 132 task.title = loadTimeData.getString('ACTION_OPEN_GDOC');
133 } else if (task_parts[2] == 'open-hosted-gsheet') { 133 } else if (taskParts[2] == 'open-hosted-gsheet') {
134 task.iconType = 'gsheet'; 134 task.iconType = 'gsheet';
135 task.title = loadTimeData.getString('ACTION_OPEN_GSHEET'); 135 task.title = loadTimeData.getString('ACTION_OPEN_GSHEET');
136 } else if (task_parts[2] == 'open-hosted-gslides') { 136 } else if (taskParts[2] == 'open-hosted-gslides') {
137 task.iconType = 'gslides'; 137 task.iconType = 'gslides';
138 task.title = loadTimeData.getString('ACTION_OPEN_GSLIDES'); 138 task.title = loadTimeData.getString('ACTION_OPEN_GSLIDES');
139 } else if (task_parts[2] == 'view-pdf') { 139 } else if (taskParts[2] == 'view-pdf') {
140 // Do not render this task if disabled. 140 // Do not render this task if disabled.
141 if (!loadTimeData.getBoolean('PDF_VIEW_ENABLED')) 141 if (!loadTimeData.getBoolean('PDF_VIEW_ENABLED'))
142 continue; 142 continue;
143 task.iconType = 'pdf'; 143 task.iconType = 'pdf';
144 task.title = loadTimeData.getString('ACTION_VIEW'); 144 task.title = loadTimeData.getString('ACTION_VIEW');
145 } else if (task_parts[2] == 'view-in-browser') { 145 } else if (taskParts[2] == 'view-in-browser') {
146 task.iconType = 'generic'; 146 task.iconType = 'generic';
147 task.title = loadTimeData.getString('ACTION_VIEW'); 147 task.title = loadTimeData.getString('ACTION_VIEW');
148 } else if (task_parts[2] == 'install-crx') { 148 } else if (taskParts[2] == 'install-crx') {
149 task.iconType = 'generic'; 149 task.iconType = 'generic';
150 task.title = loadTimeData.getString('INSTALL_CRX'); 150 task.title = loadTimeData.getString('INSTALL_CRX');
151 } 151 }
152 } 152 }
153 153
154 if (!task.iconType && task_parts[1] == 'web-intent') { 154 if (!task.iconType && taskParts[1] == 'web-intent') {
155 task.iconType = 'generic'; 155 task.iconType = 'generic';
156 } 156 }
157 157
158 this.tasks_.push(task); 158 this.tasks_.push(task);
159 if (this.defaultTask_ == null && task.isDefault) { 159 if (this.defaultTask_ == null && task.isDefault) {
160 this.defaultTask_ = task; 160 this.defaultTask_ = task;
161 } 161 }
162 } 162 }
163 if (!this.defaultTask_ && this.tasks_.length > 0) { 163 if (!this.defaultTask_ && this.tasks_.length > 0) {
164 // If we haven't picked a default task yet, then just pick the first one. 164 // If we haven't picked a default task yet, then just pick the first one.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 /** 206 /**
207 * Executes a single task. 207 * Executes a single task.
208 * 208 *
209 * @param {string} taskId Task identifier. 209 * @param {string} taskId Task identifier.
210 * @param {Array.<string>=} opt_urls Urls to execute on instead of |this.urls_|. 210 * @param {Array.<string>=} opt_urls Urls to execute on instead of |this.urls_|.
211 * @private 211 * @private
212 */ 212 */
213 FileTasks.prototype.execute_ = function(taskId, opt_urls) { 213 FileTasks.prototype.execute_ = function(taskId, opt_urls) {
214 var urls = opt_urls || this.urls_; 214 var urls = opt_urls || this.urls_;
215 this.checkAvailability_(function() { 215 this.checkAvailability_(function() {
216 var task_parts = taskId.split('|'); 216 var taskParts = taskId.split('|');
217 if (task_parts[0] == util.platform.getAppId() && task_parts[1] == 'file') { 217 if (taskParts[0] == util.platform.getAppId() && taskParts[1] == 'file') {
218 // For internal tasks we do not listen to the event to avoid 218 // For internal tasks we do not listen to the event to avoid
219 // handling the same task instance from multiple tabs. 219 // handling the same task instance from multiple tabs.
220 // So, we manually execute the task. 220 // So, we manually execute the task.
221 this.executeInternalTask_(task_parts[2], urls); 221 this.executeInternalTask_(taskParts[2], urls);
222 } else { 222 } else {
223 chrome.fileBrowserPrivate.executeTask(taskId, urls); 223 chrome.fileBrowserPrivate.executeTask(taskId, urls);
224 } 224 }
225 }.bind(this)); 225 }.bind(this));
226 }; 226 };
227 227
228 /** 228 /**
229 * Checks whether the remote files are available right now. 229 * Checks whether the remote files are available right now.
230 * 230 *
231 * @param {function} callback The callback. 231 * @param {function} callback The callback.
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 title, 601 title,
602 message, 602 message,
603 items, defaultIdx, 603 items, defaultIdx,
604 onSuccess); 604 onSuccess);
605 }; 605 };
606 606
607 FileTasks.decorate('display'); 607 FileTasks.decorate('display');
608 FileTasks.decorate('updateMenuItem'); 608 FileTasks.decorate('updateMenuItem');
609 FileTasks.decorate('execute'); 609 FileTasks.decorate('execute');
610 FileTasks.decorate('executeDefault'); 610 FileTasks.decorate('executeDefault');
OLDNEW
« no previous file with comments | « chrome/browser/resources/extensions/extensions.js ('k') | chrome/browser/resources/file_manager/js/image_editor/image_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698