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

Side by Side Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 7466046: Some filebrowser bugs and retiring DiskChanged event in filebrowser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months 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 | Annotate | Revision Log
OLDNEW
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 this.initCommands_(); 132 this.initCommands_();
133 this.initDom_(); 133 this.initDom_();
134 this.initDialogType_(); 134 this.initDialogType_();
135 this.initDefaultDirectory_(this.params_.defaultPath); 135 this.initDefaultDirectory_(this.params_.defaultPath);
136 136
137 this.summarizeSelection_(); 137 this.summarizeSelection_();
138 this.updatePreview_(); 138 this.updatePreview_();
139 139
140 chrome.fileBrowserPrivate.onDiskChanged.addListener( 140 chrome.fileBrowserPrivate.onDiskChanged.addListener(
141 this.onDiskChanged_.bind(this)); 141 this.onDiskChanged_.bind(this));
zel 2011/08/09 00:09:45 why don't we remove this if this function is no lo
tbarzic 2011/08/09 00:35:07 I think it would be better that we leave it in ext
142 142
143 this.refocus(); 143 this.refocus();
144 144
145 // Pass all URLs to the metadata reader until we have a correct filter. 145 // Pass all URLs to the metadata reader until we have a correct filter.
146 this.metadataUrlFilter_ = /.*/; 146 this.metadataUrlFilter_ = /.*/;
147 147
148 this.metadataReader_ = new Worker('js/metadata_dispatcher.js'); 148 this.metadataReader_ = new Worker('js/metadata_dispatcher.js');
149 this.metadataReader_.onmessage = this.onMetadataMessage_.bind(this); 149 this.metadataReader_.onmessage = this.onMetadataMessage_.bind(this);
150 this.metadataReader_.postMessage({verb: 'init'}); 150 this.metadataReader_.postMessage({verb: 'init'});
151 // Initialization is not complete until the Worker sends back the 151 // Initialization is not complete until the Worker sends back the
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 var fileName = event.sourceUrl.substr( 1630 var fileName = event.sourceUrl.substr(
1631 event.sourceUrl.lastIndexOf('/') + 1); 1631 event.sourceUrl.lastIndexOf('/') + 1);
1632 self.alert.show(strf('ARCHIVE_MOUNT_FAILED', fileName, 1632 self.alert.show(strf('ARCHIVE_MOUNT_FAILED', fileName,
1633 event.status)); 1633 event.status));
1634 } 1634 }
1635 } 1635 }
1636 return; 1636 return;
1637 } 1637 }
1638 } 1638 }
1639 } 1639 }
1640
1641 if (event.eventType == 'unmount' && event.status == 'success' &&
1642 self.currentDirEntry_ &&
1643 isParentPath(event.mountPath, self.currentDirEntry_.fullPath)) {
1644 self.changeDirectory(getParentPath(event.mountPath));
1645 return;
1646 }
1647
1640 // TODO(dgozman): rescan directory, only if it contains mounted points, 1648 // TODO(dgozman): rescan directory, only if it contains mounted points,
1641 // when mounts location will be decided. 1649 // when mounts location will be decided.
1642 this.rescanDirectory_(); 1650 if (event.status == 'success')
1651 self.rescanDirectory_();
1643 }); 1652 });
1644 }; 1653 };
1645 1654
1646 /** 1655 /**
1647 * Event handler called when some internal task should be executed. 1656 * Event handler called when some internal task should be executed.
1648 */ 1657 */
1649 FileManager.prototype.onFileTaskExecute_ = function(id, details) { 1658 FileManager.prototype.onFileTaskExecute_ = function(id, details) {
1650 var urls = details.entries.map(function(entry) { 1659 var urls = details.entries.map(function(entry) {
1651 return entry.toURL(); 1660 return entry.toURL();
1652 }); 1661 });
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 // is loaded at this point. 2372 // is loaded at this point.
2364 chrome.test.sendMessage('directory-change-complete'); 2373 chrome.test.sendMessage('directory-change-complete');
2365 }); 2374 });
2366 }; 2375 };
2367 2376
2368 /** 2377 /**
2369 * Update the UI when a disk is mounted or unmounted. 2378 * Update the UI when a disk is mounted or unmounted.
2370 * 2379 *
2371 * @param {string} path The path that has been mounted or unmounted. 2380 * @param {string} path The path that has been mounted or unmounted.
2372 */ 2381 */
2373 FileManager.prototype.onDiskChanged_ = function(event) { 2382 FileManager.prototype.onDiskChanged_ = function(event) {
zel 2011/08/09 00:09:45 why don't we remove this?
tbarzic 2011/08/09 00:35:07 Done.
2374 if (event.eventType == 'added') {
2375 this.changeDirectory(event.volumeInfo.mountPath);
2376 } else if (event.eventType == 'removed') {
2377 if (this.currentDirEntry_ &&
2378 isParentPath(event.volumeInfo.mountPath,
2379 this.currentDirEntry_.fullPath)) {
2380 this.changeDirectory(getParentPath(event.volumeInfo.mountPath));
2381 }
2382 }
2383 }; 2383 };
2384 2384
2385 /** 2385 /**
2386 * Rescan the current directory, refreshing the list. 2386 * Rescan the current directory, refreshing the list.
2387 * 2387 *
2388 * @param {function()} opt_callback Optional function to invoke when the 2388 * @param {function()} opt_callback Optional function to invoke when the
2389 * rescan is complete. 2389 * rescan is complete.
2390 */ 2390 */
2391 FileManager.prototype.rescanDirectory_ = function(opt_callback) { 2391 FileManager.prototype.rescanDirectory_ = function(opt_callback) {
2392 var self = this; 2392 var self = this;
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
3006 3006
3007 if (msg) { 3007 if (msg) {
3008 console.log('no no no'); 3008 console.log('no no no');
3009 this.alert.show(msg, onAccept); 3009 this.alert.show(msg, onAccept);
3010 return false; 3010 return false;
3011 } 3011 }
3012 3012
3013 return true; 3013 return true;
3014 }; 3014 };
3015 })(); 3015 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698