Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 var g_slideshow_data = null; | 5 var g_slideshow_data = null; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * FileManager constructor. | 8 * FileManager constructor. |
| 9 * | 9 * |
| 10 * FileManager objects encapsulate the functionality of the file selector | 10 * FileManager objects encapsulate the functionality of the file selector |
| (...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1228 } | 1228 } |
| 1229 | 1229 |
| 1230 if (pendingFiles.length) { | 1230 if (pendingFiles.length) { |
| 1231 cacheEntrySize(pendingFiles.pop(), cacheNextFile); | 1231 cacheEntrySize(pendingFiles.pop(), cacheNextFile); |
| 1232 } else { | 1232 } else { |
| 1233 self.dispatchEvent(new cr.Event('selection-summarized')); | 1233 self.dispatchEvent(new cr.Event('selection-summarized')); |
| 1234 } | 1234 } |
| 1235 }; | 1235 }; |
| 1236 | 1236 |
| 1237 if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) { | 1237 if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) { |
| 1238 this.taskButtons_.innerHTML = ''; | |
| 1238 chrome.fileBrowserPrivate.getFileTasks(selection.urls, | 1239 chrome.fileBrowserPrivate.getFileTasks(selection.urls, |
| 1239 this.onTasksFound_.bind(this)); | 1240 this.onTasksFound_.bind(this)); |
| 1241 // Hardcoded Format button | |
| 1242 if (this.currentDirEntry_ && this.currentDirEntry_.fullPath == | |
| 1243 MEDIA_DIRECTORY && this.selection.totalCount == 1 ) { | |
| 1244 var button = this.document_.createElement('button'); | |
| 1245 button.addEventListener('click',this.onFormatButtonClicked_.bind(this)); | |
| 1246 button.className = 'task-button'; | |
| 1247 | |
| 1248 var img = this.document_.createElement('img'); | |
| 1249 img.src = 'images/filetype_generic.png'; | |
| 1250 | |
| 1251 button.appendChild(img); | |
| 1252 //TODO(sidor): generic resource | |
| 1253 button.appendChild(this.document_.createTextNode("Format Device")); | |
| 1254 | |
| 1255 this.taskButtons_.appendChild(button); | |
| 1256 } | |
| 1240 } | 1257 } |
| 1241 | 1258 |
| 1242 cacheNextFile(); | 1259 cacheNextFile(); |
| 1243 }; | 1260 }; |
| 1244 | 1261 |
| 1245 FileManager.prototype.onMetadataResult_ = function(fileURL, metadata) { | 1262 FileManager.prototype.onMetadataResult_ = function(fileURL, metadata) { |
| 1246 var observers = this.metadataCache_[fileURL]; | 1263 var observers = this.metadataCache_[fileURL]; |
| 1247 if (!observers || !(observers instanceof Array)) { | 1264 if (!observers || !(observers instanceof Array)) { |
| 1248 console.error('Missing or invalid metadata observers: ' + fileURL + ': ' + | 1265 console.error('Missing or invalid metadata observers: ' + fileURL + ': ' + |
| 1249 observers); | 1266 observers); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1283 | 1300 |
| 1284 if (!(methodName in this)) { | 1301 if (!(methodName in this)) { |
| 1285 console.log('Unknown message from metadata reader: ' + data.verb, data); | 1302 console.log('Unknown message from metadata reader: ' + data.verb, data); |
| 1286 return; | 1303 return; |
| 1287 } | 1304 } |
| 1288 | 1305 |
| 1289 this[methodName].apply(this, data.arguments); | 1306 this[methodName].apply(this, data.arguments); |
| 1290 }; | 1307 }; |
| 1291 | 1308 |
| 1292 FileManager.prototype.onTasksFound_ = function(tasksList) { | 1309 FileManager.prototype.onTasksFound_ = function(tasksList) { |
| 1293 this.taskButtons_.innerHTML = ''; | |
| 1294 for (var i = 0; i < tasksList.length; i++) { | 1310 for (var i = 0; i < tasksList.length; i++) { |
| 1295 var task = tasksList[i]; | 1311 var task = tasksList[i]; |
| 1296 | 1312 |
| 1297 // Tweak images, titles of internal tasks. | 1313 // Tweak images, titles of internal tasks. |
| 1298 var task_parts = task.taskId.split('|'); | 1314 var task_parts = task.taskId.split('|'); |
| 1299 if (task_parts[0] == this.getExtensionId_()) { | 1315 if (task_parts[0] == this.getExtensionId_()) { |
| 1300 if (task_parts[1] == 'preview') { | 1316 if (task_parts[1] == 'preview') { |
| 1301 // TODO(serya): This hack needed until task.iconUrl get working | 1317 // TODO(serya): This hack needed until task.iconUrl get working |
| 1302 // (see GetFileTasksFileBrowserFunction::RunImpl). | 1318 // (see GetFileTasksFileBrowserFunction::RunImpl). |
| 1303 task.iconUrl = | 1319 task.iconUrl = |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1347 chrome.fileBrowserPrivate.viewFiles(this.selection.urls, | 1363 chrome.fileBrowserPrivate.viewFiles(this.selection.urls, |
| 1348 event.srcElement.task.taskId); | 1364 event.srcElement.task.taskId); |
| 1349 } | 1365 } |
| 1350 return; | 1366 return; |
| 1351 } | 1367 } |
| 1352 | 1368 |
| 1353 chrome.fileBrowserPrivate.executeTask(event.srcElement.task.taskId, | 1369 chrome.fileBrowserPrivate.executeTask(event.srcElement.task.taskId, |
| 1354 this.selection.urls); | 1370 this.selection.urls); |
| 1355 } | 1371 } |
| 1356 | 1372 |
| 1373 FileManager.prototype.onFormatButtonClicked_ = function(event) { | |
| 1374 if(!confirm(str('FORMATTING_WARNING'))) return; | |
|
tbarzic
2011/07/25 20:43:04
return should go to new line
sidor
2011/07/25 21:40:07
True, and space after if, sorry for that.
| |
| 1375 // Checks already performed by tasks rendering code | |
| 1376 console.log('Formatting device: ' + this.selection.entries[0].fullPath); | |
| 1377 chrome.fileBrowserPrivate.formatDevice( | |
| 1378 this.selection.entries[0].fullPath+'/'); | |
| 1379 } | |
| 1380 | |
| 1357 /** | 1381 /** |
| 1358 * Update the breadcrumb display to reflect the current directory. | 1382 * Update the breadcrumb display to reflect the current directory. |
| 1359 */ | 1383 */ |
| 1360 FileManager.prototype.updateBreadcrumbs_ = function() { | 1384 FileManager.prototype.updateBreadcrumbs_ = function() { |
| 1361 var bc = this.dialogDom_.querySelector('.breadcrumbs'); | 1385 var bc = this.dialogDom_.querySelector('.breadcrumbs'); |
| 1362 bc.innerHTML = ''; | 1386 bc.innerHTML = ''; |
| 1363 | 1387 |
| 1364 var fullPath = this.currentDirEntry_.fullPath.replace(/\/$/, ''); | 1388 var fullPath = this.currentDirEntry_.fullPath.replace(/\/$/, ''); |
| 1365 var pathNames = fullPath.split('/'); | 1389 var pathNames = fullPath.split('/'); |
| 1366 var path = ''; | 1390 var path = ''; |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1875 }); | 1899 }); |
| 1876 }; | 1900 }; |
| 1877 | 1901 |
| 1878 /** | 1902 /** |
| 1879 * Update the UI when a disk is mounted or unmounted. | 1903 * Update the UI when a disk is mounted or unmounted. |
| 1880 * | 1904 * |
| 1881 * @param {string} path The path that has been mounted or unmounted. | 1905 * @param {string} path The path that has been mounted or unmounted. |
| 1882 */ | 1906 */ |
| 1883 FileManager.prototype.onDiskChanged_ = function(event) { | 1907 FileManager.prototype.onDiskChanged_ = function(event) { |
| 1884 if (event.eventType == 'added') { | 1908 if (event.eventType == 'added') { |
| 1909 console.log("Disk added, mount path is <" + event.volumeInfo.mountPath + | |
| 1910 ">"); | |
| 1885 this.changeDirectory(event.volumeInfo.mountPath); | 1911 this.changeDirectory(event.volumeInfo.mountPath); |
| 1886 } else if (event.eventType == 'removed') { | 1912 } else if (event.eventType == 'removed') { |
| 1887 if (this.currentDirEntry_ && | 1913 console.log("Disk removed, mount path is <" + event.volumeInfo.mountPath + |
| 1888 isParentPath(event.volumeInfo.mountPath, | 1914 ">"); |
| 1889 this.currentDirEntry_.fullPath)) { | 1915 if (this.currentDirEntry_ && (isParentPath(event.volumeInfo.mountPath, |
| 1890 this.changeDirectory(getParentPath(event.volumeInfo.mountPath)); | 1916 this.currentDirEntry_.fullPath) || this.currentDirEntry_.fullPath == |
| 1917 MEDIA_DIRECTORY)) { | |
| 1918 this.changeDirectory(MEDIA_DIRECTORY); | |
| 1919 this.rescanDirectory_(function() {}); | |
| 1891 } | 1920 } |
| 1892 } | 1921 } |
| 1893 }; | 1922 }; |
| 1894 | 1923 |
| 1895 /** | 1924 /** |
| 1896 * Rescan the current directory, refreshing the list. | 1925 * Rescan the current directory, refreshing the list. |
| 1897 * | 1926 * |
| 1898 * @param {function()} opt_callback Optional function to invoke when the | 1927 * @param {function()} opt_callback Optional function to invoke when the |
| 1899 * rescan is complete. | 1928 * rescan is complete. |
| 1900 */ | 1929 */ |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2435 window.alert(str('ERROR_RESERVED_NAME')); | 2464 window.alert(str('ERROR_RESERVED_NAME')); |
| 2436 return false; | 2465 return false; |
| 2437 } | 2466 } |
| 2438 if (this.filterFiles_ && name[0] == '.') { | 2467 if (this.filterFiles_ && name[0] == '.') { |
| 2439 window.alert(str('ERROR_HIDDEN_NAME')); | 2468 window.alert(str('ERROR_HIDDEN_NAME')); |
| 2440 return false; | 2469 return false; |
| 2441 } | 2470 } |
| 2442 return true; | 2471 return true; |
| 2443 }; | 2472 }; |
| 2444 })(); | 2473 })(); |
| OLD | NEW |