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 // Setting the src of an img to an empty string can crash the browser, so we | 5 // Setting the src of an img to an empty string can crash the browser, so we |
6 // use an empty 1x1 gif instead. | 6 // use an empty 1x1 gif instead. |
7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' | 7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' |
8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; | 8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; |
9 | 9 |
10 var g_slideshow_data = null; | 10 var g_slideshow_data = null; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 this.onFileTaskExecute_.bind(this)); | 132 this.onFileTaskExecute_.bind(this)); |
133 | 133 |
134 this.initCommands_(); | 134 this.initCommands_(); |
135 this.initDom_(); | 135 this.initDom_(); |
136 this.initDialogType_(); | 136 this.initDialogType_(); |
137 this.setupCurrentDirectory_(); | 137 this.setupCurrentDirectory_(); |
138 | 138 |
139 this.summarizeSelection_(); | 139 this.summarizeSelection_(); |
140 this.updatePreview_(); | 140 this.updatePreview_(); |
141 | 141 |
142 chrome.fileBrowserPrivate.onDiskChanged.addListener( | |
143 this.onDiskChanged_.bind(this)); | |
144 | |
145 this.refocus(); | 142 this.refocus(); |
146 | 143 |
147 // Pass all URLs to the metadata reader until we have a correct filter. | 144 // Pass all URLs to the metadata reader until we have a correct filter. |
148 this.metadataUrlFilter_ = /.*/; | 145 this.metadataUrlFilter_ = /.*/; |
149 | 146 |
150 this.metadataReader_ = new Worker('js/metadata_dispatcher.js'); | 147 this.metadataReader_ = new Worker('js/metadata_dispatcher.js'); |
151 this.metadataReader_.onmessage = this.onMetadataMessage_.bind(this); | 148 this.metadataReader_.onmessage = this.onMetadataMessage_.bind(this); |
152 this.metadataReader_.postMessage({verb: 'init'}); | 149 this.metadataReader_.postMessage({verb: 'init'}); |
153 // Initialization is not complete until the Worker sends back the | 150 // Initialization is not complete until the Worker sends back the |
154 // 'initialized' message. See below. | 151 // 'initialized' message. See below. |
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 var fileName = event.sourceUrl.substr( | 1675 var fileName = event.sourceUrl.substr( |
1679 event.sourceUrl.lastIndexOf('/') + 1); | 1676 event.sourceUrl.lastIndexOf('/') + 1); |
1680 self.alert.show(strf('ARCHIVE_MOUNT_FAILED', fileName, | 1677 self.alert.show(strf('ARCHIVE_MOUNT_FAILED', fileName, |
1681 event.status)); | 1678 event.status)); |
1682 } | 1679 } |
1683 } | 1680 } |
1684 return; | 1681 return; |
1685 } | 1682 } |
1686 } | 1683 } |
1687 } | 1684 } |
| 1685 |
| 1686 if (event.eventType == 'unmount' && event.status == 'success' && |
| 1687 self.currentDirEntry_ && |
| 1688 isParentPath(event.mountPath, self.currentDirEntry_.fullPath)) { |
| 1689 self.changeDirectory(getParentPath(event.mountPath)); |
| 1690 return; |
| 1691 } |
| 1692 |
1688 // TODO(dgozman): rescan directory, only if it contains mounted points, | 1693 // TODO(dgozman): rescan directory, only if it contains mounted points, |
1689 // when mounts location will be decided. | 1694 // when mounts location will be decided. |
1690 this.rescanDirectory_(); | 1695 if (event.status == 'success') |
| 1696 self.rescanDirectory_(); |
1691 }); | 1697 }); |
1692 }; | 1698 }; |
1693 | 1699 |
1694 /** | 1700 /** |
1695 * Event handler called when some internal task should be executed. | 1701 * Event handler called when some internal task should be executed. |
1696 */ | 1702 */ |
1697 FileManager.prototype.onFileTaskExecute_ = function(id, details) { | 1703 FileManager.prototype.onFileTaskExecute_ = function(id, details) { |
1698 var urls = details.entries.map(function(entry) { | 1704 var urls = details.entries.map(function(entry) { |
1699 return entry.toURL(); | 1705 return entry.toURL(); |
1700 }); | 1706 }); |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2434 this.rescanDirectory_(function() { | 2440 this.rescanDirectory_(function() { |
2435 if (event.selectedEntry) | 2441 if (event.selectedEntry) |
2436 self.selectEntry(event.selectedEntry); | 2442 self.selectEntry(event.selectedEntry); |
2437 // For tests that open the dialog to empty directories, everything | 2443 // For tests that open the dialog to empty directories, everything |
2438 // is loaded at this point. | 2444 // is loaded at this point. |
2439 chrome.test.sendMessage('directory-change-complete'); | 2445 chrome.test.sendMessage('directory-change-complete'); |
2440 }); | 2446 }); |
2441 }; | 2447 }; |
2442 | 2448 |
2443 /** | 2449 /** |
2444 * Update the UI when a disk is mounted or unmounted. | |
2445 * | |
2446 * @param {string} path The path that has been mounted or unmounted. | |
2447 */ | |
2448 FileManager.prototype.onDiskChanged_ = function(event) { | |
2449 if (event.eventType == 'added') { | |
2450 this.changeDirectory(event.volumeInfo.mountPath); | |
2451 } else if (event.eventType == 'removed') { | |
2452 if (this.currentDirEntry_ && | |
2453 isParentPath(event.volumeInfo.mountPath, | |
2454 this.currentDirEntry_.fullPath)) { | |
2455 this.changeDirectory(getParentPath(event.volumeInfo.mountPath)); | |
2456 } | |
2457 } | |
2458 }; | |
2459 | |
2460 /** | |
2461 * Rescan the current directory, refreshing the list. | 2450 * Rescan the current directory, refreshing the list. |
2462 * | 2451 * |
2463 * @param {function()} opt_callback Optional function to invoke when the | 2452 * @param {function()} opt_callback Optional function to invoke when the |
2464 * rescan is complete. | 2453 * rescan is complete. |
2465 */ | 2454 */ |
2466 FileManager.prototype.rescanDirectory_ = function(opt_callback) { | 2455 FileManager.prototype.rescanDirectory_ = function(opt_callback) { |
2467 var self = this; | 2456 var self = this; |
2468 var reader; | 2457 var reader; |
2469 | 2458 |
2470 function onReadSome(entries) { | 2459 function onReadSome(entries) { |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3081 | 3070 |
3082 if (msg) { | 3071 if (msg) { |
3083 console.log('no no no'); | 3072 console.log('no no no'); |
3084 this.alert.show(msg, onAccept); | 3073 this.alert.show(msg, onAccept); |
3085 return false; | 3074 return false; |
3086 } | 3075 } |
3087 | 3076 |
3088 return true; | 3077 return true; |
3089 }; | 3078 }; |
3090 })(); | 3079 })(); |
OLD | NEW |