| Index: chrome/browser/resources/file_manager/js/file_manager.js
|
| diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
|
| index f3f490c84969ee016d510aee70dce34fd0bf2908..9069d7d04edf918d7c7da65bbff3da5443f5f604 100644
|
| --- a/chrome/browser/resources/file_manager/js/file_manager.js
|
| +++ b/chrome/browser/resources/file_manager/js/file_manager.js
|
| @@ -1471,10 +1471,14 @@ FileManager.prototype = {
|
| if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) {
|
| // Since unmount task cannot be defined in terms of file patterns,
|
| // we manually include it here, if all selected items are mount points.
|
| + this.taskButtons_.innerHTML = '';
|
| chrome.fileBrowserPrivate.getFileTasks(
|
| selection.urls,
|
| this.onTasksFound_.bind(this,
|
| this.shouldShowUnmount_(selection.urls)));
|
| + // This needs to be done in sparate function, as check requires
|
| + // asynchronous function calls.
|
| + this.DisplayFormattingTask1_(selection.entries);
|
| }
|
|
|
| cacheNextFile();
|
| @@ -1549,8 +1553,6 @@ FileManager.prototype = {
|
| title: ''
|
| });
|
| }
|
| -
|
| - this.taskButtons_.innerHTML = '';
|
| for (var i = 0; i < tasksList.length; i++) {
|
| var task = tasksList[i];
|
|
|
| @@ -1586,19 +1588,65 @@ FileManager.prototype = {
|
| task.title = str('UNMOUNT_ARCHIVE');
|
| }
|
| }
|
| + this.renderTaskButton_(task);
|
| + }
|
| + };
|
|
|
| - var button = this.document_.createElement('button');
|
| - button.addEventListener('click', this.onTaskButtonClicked_.bind(this));
|
| - button.className = 'task-button';
|
| - button.task = task;
|
| + FileManager.prototype.renderTaskButton_ = function(task) {
|
| + var button = this.document_.createElement('button');
|
| + button.addEventListener('click', this.onTaskButtonClicked_.bind(this));
|
| + button.className = 'task-button';
|
| + button.task = task;
|
|
|
| - var img = this.document_.createElement('img');
|
| - img.src = task.iconUrl;
|
| + var img = this.document_.createElement('img');
|
| + img.src = task.iconUrl;
|
|
|
| - button.appendChild(img);
|
| - button.appendChild(this.document_.createTextNode(task.title));
|
| + button.appendChild(img);
|
| + button.appendChild(this.document_.createTextNode(task.title));
|
|
|
| - this.taskButtons_.appendChild(button);
|
| + this.taskButtons_.appendChild(button);
|
| + };
|
| +
|
| + /**
|
| + * Checks whether formatting task should be displayed and if the answer is
|
| + * affirmative renders it. Includes asynchronous calls, so it's splitted into
|
| + * three parts.
|
| + */
|
| + FileManager.prototype.DisplayFormattingTask1_ = function(entries) {
|
| + if (entries.length != 1)
|
| + return;
|
| + var self = this;
|
| + chrome.fileBrowserPrivate.getMountPoints(
|
| + this.DisplayFormattingTask2_.bind(this, entries[0].fullPath));
|
| + };
|
| +
|
| + FileManager.prototype.DisplayFormattingTask2_ = function(mountPath,
|
| + mountPoints) {
|
| + var normalize = function(x) {
|
| + if(x[0] != '/')
|
| + return '/' + x;
|
| + else
|
| + return x;
|
| + }
|
| + this.mountPoints_ = mountPoints;
|
| + for (var i = 0; i < mountPoints.length; ++i) {
|
| + if (mountPoints[i].mountType == "device" &&
|
| + normalize(mountPoints[i].mountPath) == normalize(mountPath)) {
|
| + chrome.fileBrowserPrivate.getVolumeMetadata(mountPoints[i].sourceUrl,
|
| + this.DisplayFormattingTask3_.bind(this));
|
| + return;
|
| + }
|
| + }
|
| + };
|
| +
|
| + FileManager.prototype.DisplayFormattingTask3_ = function(volumeMetadata) {
|
| + if (volumeMetadata.deviceType == "flash") {
|
| + var task = {
|
| + taskId: this.getExtensionId_() + '|format-device',
|
| + iconUrl: chrome.extension.getURL('images/filetype_generic.png'),
|
| + title: str('FORMAT_DEVICE')
|
| + };
|
| + this.renderTaskButton_(task);
|
| }
|
| };
|
|
|
| @@ -1666,6 +1714,10 @@ FileManager.prototype = {
|
| for (var index = 0; index < urls.length; ++index) {
|
| chrome.fileBrowserPrivate.removeMount(urls[index]);
|
| }
|
| + } else if (id == 'format-device') {
|
| + if (!confirm(str('FORMATTING_WARNING')))
|
| + return;
|
| + chrome.fileBrowserPrivate.formatDevice(urls[0]);
|
| }
|
| };
|
|
|
|
|