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

Side by Side Diff: ui/file_manager/file_manager/foreground/js/task_controller.js

Issue 2513493002: Files App: Update the context menu when installed app is changed. (Closed)
Patch Set: Fixed test. Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 * @param {DialogType} dialogType 6 * @param {DialogType} dialogType
7 * @param {!VolumeManagerWrapper} volumeManager 7 * @param {!VolumeManagerWrapper} volumeManager
8 * @param {!FileManagerUI} ui 8 * @param {!FileManagerUI} ui
9 * @param {!MetadataModel} metadataModel 9 * @param {!MetadataModel} metadataModel
10 * @param {!DirectoryModel} directoryModel 10 * @param {!DirectoryModel} directoryModel
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 */ 90 */
91 this.tasks_ = null; 91 this.tasks_ = null;
92 92
93 ui.taskMenuButton.addEventListener( 93 ui.taskMenuButton.addEventListener(
94 'select', this.onTaskItemClicked_.bind(this)); 94 'select', this.onTaskItemClicked_.bind(this));
95 this.selectionHandler_.addEventListener( 95 this.selectionHandler_.addEventListener(
96 FileSelectionHandler.EventType.CHANGE, 96 FileSelectionHandler.EventType.CHANGE,
97 this.onSelectionChanged_.bind(this)); 97 this.onSelectionChanged_.bind(this));
98 this.selectionHandler_.addEventListener( 98 this.selectionHandler_.addEventListener(
99 FileSelectionHandler.EventType.CHANGE_THROTTLED, 99 FileSelectionHandler.EventType.CHANGE_THROTTLED,
100 this.onSelectionChangeThrottled_.bind(this)); 100 this.updateTasks_.bind(this));
101 chrome.fileManagerPrivate.onAppsUpdated.addListener(
102 this.updateTasks_.bind(this));
101 } 103 }
102 104
103 /** 105 /**
104 * Cached the temporary disabled task item. Used inside 106 * Cached the temporary disabled task item. Used inside
105 * FileSelectionHandler.createTemporaryDisabledTaskItem_(). 107 * FileSelectionHandler.createTemporaryDisabledTaskItem_().
106 * @type {Object} 108 * @type {Object}
107 * @private 109 * @private
108 */ 110 */
109 TaskController.cachedDisabledTaskItem_ = null; 111 TaskController.cachedDisabledTaskItem_ = null;
110 112
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // overridden in this.updateFileSelectionAsync(). 272 // overridden in this.updateFileSelectionAsync().
271 this.updateContextMenuTaskItems_( 273 this.updateContextMenuTaskItems_(
272 [TaskController.createTemporaryDisabledTaskItem_()]); 274 [TaskController.createTemporaryDisabledTaskItem_()]);
273 } else { 275 } else {
274 // Update context menu. 276 // Update context menu.
275 this.updateContextMenuTaskItems_([]); 277 this.updateContextMenuTaskItems_([]);
276 } 278 }
277 }; 279 };
278 280
279 /** 281 /**
280 * Handles change of selection asynchronously and updates context menu. 282 * Updates available tasks opened from context menu or the open button.
281 * @private 283 * @private
282 */ 284 */
283 TaskController.prototype.onSelectionChangeThrottled_ = function() { 285 TaskController.prototype.updateTasks_ = function() {
284 var selection = this.selectionHandler_.selection; 286 var selection = this.selectionHandler_.selection;
285 if (this.dialogType_ === DialogType.FULL_PAGE && 287 if (this.dialogType_ === DialogType.FULL_PAGE &&
286 (selection.directoryCount > 0 || selection.fileCount > 0)) { 288 (selection.directoryCount > 0 || selection.fileCount > 0)) {
287 this.getFileTasks() 289 this.getFileTasks()
288 .then(function(tasks) { 290 .then(function(tasks) {
289 tasks.display(this.ui_.taskMenuButton); 291 tasks.display(this.ui_.taskMenuButton);
290 this.updateContextMenuTaskItems_(tasks.getTaskItems()); 292 this.updateContextMenuTaskItems_(tasks.getTaskItems());
291 }.bind(this)) 293 }.bind(this))
292 .catch(function(error) { 294 .catch(function(error) {
293 if (error) 295 if (error)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 this.metadataModel_.get([entry], ['contentMimeType']).then( 389 this.metadataModel_.get([entry], ['contentMimeType']).then(
388 function(props) { 390 function(props) {
389 FileTasks.create( 391 FileTasks.create(
390 this.volumeManager_, this.metadataModel_, this.directoryModel_, 392 this.volumeManager_, this.metadataModel_, this.directoryModel_,
391 this.ui_, [entry], [props[0].contentMimeType || null]) 393 this.ui_, [entry], [props[0].contentMimeType || null])
392 .then(function(tasks) { 394 .then(function(tasks) {
393 tasks.executeDefault(); 395 tasks.executeDefault();
394 }); 396 });
395 }.bind(this)); 397 }.bind(this));
396 }; 398 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698