| 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 815d2edf73d2f90563f519b04cf298a35f7d2f2e..46108ada221695e9cdde8ce2f8ed056aa437bb83 100644
|
| --- a/chrome/browser/resources/file_manager/js/file_manager.js
|
| +++ b/chrome/browser/resources/file_manager/js/file_manager.js
|
| @@ -1235,8 +1235,25 @@ FileManager.prototype = {
|
| };
|
|
|
| if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) {
|
| + this.taskButtons_.innerHTML = '';
|
| chrome.fileBrowserPrivate.getFileTasks(selection.urls,
|
| this.onTasksFound_.bind(this));
|
| + // Hardcoded Format button
|
| + if (this.currentDirEntry_ && this.currentDirEntry_.fullPath ==
|
| + MEDIA_DIRECTORY && this.selection.totalCount == 1 ) {
|
| + var button = this.document_.createElement('button');
|
| + button.addEventListener('click',this.onFormatButtonClicked_.bind(this));
|
| + button.className = 'task-button';
|
| +
|
| + var img = this.document_.createElement('img');
|
| + img.src = 'images/filetype_generic.png';
|
| +
|
| + button.appendChild(img);
|
| + //TODO(sidor): generic resource
|
| + button.appendChild(this.document_.createTextNode("Format Device"));
|
| +
|
| + this.taskButtons_.appendChild(button);
|
| + }
|
| }
|
|
|
| cacheNextFile();
|
| @@ -1290,7 +1307,6 @@ FileManager.prototype = {
|
| };
|
|
|
| FileManager.prototype.onTasksFound_ = function(tasksList) {
|
| - this.taskButtons_.innerHTML = '';
|
| for (var i = 0; i < tasksList.length; i++) {
|
| var task = tasksList[i];
|
|
|
| @@ -1354,6 +1370,14 @@ FileManager.prototype = {
|
| this.selection.urls);
|
| }
|
|
|
| + FileManager.prototype.onFormatButtonClicked_ = function(event) {
|
| + if(!confirm(str('FORMATTING_WARNING'))) return;
|
| + // Checks already performed by tasks rendering code
|
| + console.log('Formatting device: ' + this.selection.entries[0].fullPath);
|
| + chrome.fileBrowserPrivate.formatDevice(
|
| + this.selection.entries[0].fullPath+'/');
|
| + }
|
| +
|
| /**
|
| * Update the breadcrumb display to reflect the current directory.
|
| */
|
| @@ -1882,12 +1906,17 @@ FileManager.prototype = {
|
| */
|
| FileManager.prototype.onDiskChanged_ = function(event) {
|
| if (event.eventType == 'added') {
|
| + console.log("Disk added, mount path is <" + event.volumeInfo.mountPath +
|
| + ">");
|
| this.changeDirectory(event.volumeInfo.mountPath);
|
| } else if (event.eventType == 'removed') {
|
| - if (this.currentDirEntry_ &&
|
| - isParentPath(event.volumeInfo.mountPath,
|
| - this.currentDirEntry_.fullPath)) {
|
| - this.changeDirectory(getParentPath(event.volumeInfo.mountPath));
|
| + console.log("Disk removed, mount path is <" + event.volumeInfo.mountPath +
|
| + ">");
|
| + if (this.currentDirEntry_ && (isParentPath(event.volumeInfo.mountPath,
|
| + this.currentDirEntry_.fullPath) || this.currentDirEntry_.fullPath ==
|
| + MEDIA_DIRECTORY)) {
|
| + this.changeDirectory(MEDIA_DIRECTORY);
|
| + this.rescanDirectory_(function() {});
|
| }
|
| }
|
| };
|
|
|